Setting up wheel encoder on SVP324

Hi,
Santa was nice enough to leave me a new SVP324 controller and a set of wheel encoders and wheels! I am confused over which ports I should connect them to on the 324. The wheel encoder example in the 324 sample lib references calling the init routine with (16,17,18,19) but I don’t know how these map to the I/O ports. I like to be able to use a pin define like PC0 instead of a numeric.

/*
 * PololuWheelEncoders example for the Orangutan LV/SV-xx8.
 *
 * This example measures the outputs of two encoders, one connected to
 * ports PC2 and PC3, and another connected to ports PC4 and PC5.
 *
 * https://www.pololu.com/docs/0J20?section=6.k
 * https://www.pololu.com
 * https://forum.pololu.com
 */

#include <pololu/orangutan.h>
#include <avr/interrupt.h>

int main()
{
  encoders_init(16,17,18,19); // the Arduino numbers for ports PC2 - PC5

I read the library command reference and it made similar references to Pin Port C - PC0 - PC5 but the SVP 324 Reference Diagram and Pin description only has PC0 and PC1 for I/O’s (PC2-PC5 are for the pushbuttons).

Q: what pin ports should/can I use on the 324 for the wheel encoders?

Thanks for any help.
John

John,

You will get better performance if use the SVP’s built-in encoder ports, which are decoded automatically by the auxiliary processor/programmer. See here for documentation.

-Paul

The PololuWheelEncoders section of the library uses the AVR to read the encoder transitions. Instead of using that, I recommend that you read the encoders with the auxiliary processor of the SVP which can do two quadrature encoders at up to 1.25 kHz. You’ll need to connect one of your encoders to pins A and B, and the other to pins C and D, which you can find on the reference diagram. Then you can use the functions getCountsAB/CD, getCountsAndResetAB/CD, and checkErrorAB/CD in the OrangutanSVP section of the library to get the encoder readings from the auxiliary processor. You will also need to put the following line at the beginning of your program to put the auxiliary processor in to encoder mode:

svp_set_mode(SVP_MODE_ENCODERS);

Let me know if you have any trouble with this!

-David

Thank you both for the help. You guys are great. :smiley:

I changed the 328 wheel encoder example to this for the 324:

// Put the aux process in encoder mode.
 svp_set_mode(SVP_MODE_ENCODERS);

 while(1)
  {
    lcd_goto_xy(0,0);
    print_long(svp_get_counts_ab());
    print(" ");

    lcd_goto_xy(4,0);
    print_long(svp_get_counts_cd());
    print(" ");

    if(svp_check_error_ab())
    {
      lcd_goto_xy(0,1);
      print("Error AB");
    }
    if(svp_check_error_cd())
    {
      lcd_goto_xy(0,1);
      print("Error CD");
    }

    delay_ms(50);
  }

I connected my encoders to A/B and C/D and got some success.
I have one encoder that appears to be reading ok and another that doesn’t at all.
I swap the encoders and the working encoder moves. The non-working encoder only show zeros on the display. I also tested this pair of encoders on a 328 and got the same results. I’ve triple checked the power, gnd, and signal connections and they appear to be fine.

Is there some other test I can do on the encoder to see if it is DOA ?
(she’s brand new)

Thanks.

If you have an oscilloscope of some sort (the SLO-scope on the Pololu USB AVR Programmer would work) then you could look at the two output signals from the encoder. They should look like the signals shown on the encoder product page.

-David

You could also put your SVP-324 in to analog mode, and just do analog readings on the four ports your encoders are connected to and print the results on the LCD. This would give you an idea of the range of voltages that your malfunctioning encoder is producing.

-David

Hi again,
I took David’s suggestions. First I did the test using the 324 and reading the encoders as analog lines and printing the values on the LCD.
Here is a snip of the code…
svp_set_mode(SVP_MODE_ANALOG);
set_analog_mode(MODE_10_BIT);

while(1)
{
lcd_goto_xy(0,0);
print("A ");
print_long(analog_read(CHANNEL_A));
:
do same for channels b,c,d…

The good encoder connected to channel A/B and non-working encoder on C/D. The good encoder showed values 0-968 as I rotated the wheel around the encoder. The non-working encoder read constant values of 383 and did not change as a result of moving the wheel.
I switched the encoders around so good was on C/D and non-working encoder on A/B and the results followed with the same values. I also switched my connectors to make sure there wasn’t an issue in the wiring in power or signal.

Next I downloaded the SLO-scope (very cool) and connected good encoder to A/B line - I got up & down activity on the scope as expected when the wheel was rotated. When I put the non-working encoder on the scope all it showed was a flat line and no movement detected from the encoder sensors.

So based on this - I thinking its DOA.
Any other thoughts ?

Thanks as always.
John

Hello,

That doesn’t sound very good. Is it possible you ever connected power backwards to the bad unit? Does it smell like something burned out? When you got the flat readings on both channels, what were the voltages? Did you play with the little potentiometer settings?

- Jan

Hi Jan,
nope, the power was connected correctly and there are no signs or smells of anything toasted. No adjustments made to the pot either. The Slo-scope reads 1.8V for both A & B channels.

-John

I think at this point there’s not much more we can do. You should contact us directly for an RMA number, and you should try to have the order number and name of the person who ordered available.

- Jan