Encoder and motor driver

Hello,
I have two questions. First is about the encoder, how to compute the number pulses it generate when it rotate 360°. The parameters are cycles per revolution:100, Quadrature counts per revolution: 400, Frequency: 30kHz. Second, I use raspberry pi to control the motor driver sabertooth in mode 3. When use my own program it works perfectly. But when I use minicom to send data to the motor driver, it does not rotate as expected. On matter what data I send, it seems that only the motor connected to M1 can rotate, and the speed is the same. Could anyone help me?
Thanks and regards

Can you link to the product page?

I have solved the second problem. Here is the link for the encoder: robotshop.com/en/lynxmotion- … coder.html and the parameters in the assemble instruction is different from here. Which parameter should I use?

Regarding the encoder, it provides 100 counts. We suggest resolving the issue with the Sabertooth first. In order to help there, we would need to know a lot more regarding the connections, adapter used, sample code etc.

OK, the connection: from raspberry Pi’s TX to sabertooth’s s1, and the ground of raspberry pi, sabertooth, encoder are connected together. Raspberry Pi and encoder are connected to the +5v of sabertooth. The sample codes:

#include <stdio.h>
#include <wiringPi.h>

#define   PIN_A   8
#define   PIN_B   9

#define   DEBOUNCE   5

static volatile int counter;

void encoder(void)
{
   static unsigned int debounce = 0;

   // If PIN_A is high then ignore it
   //   This may be due to bouncing, or a bug/feature of the edge detect

   if (digitalRead(PIN_A) == HIGH)
	  return;

   // Ignore multiple interrupts inside our debounce time

   if (millis() < debounce)
	  return;

   if (digitalRead(PIN_B) == LOW)   // Anti-clockwise
	  --counter;
   else
	  ++counter;

   debounce = millis() + DEBOUNCE;
}

int main()
{
   int last;

   wiringPiSetup();

   last = counter = 0;

   wiringPiISR(PIN_A, INT_EDGE_FALLING, encoder);

   printf("\nRunning... \n");

   for (;;)
   {
	  if (counter != last)
	  {
		 printf("%5d\n", counter);
		 last = counter;
	  }
	  delay(1);
   }

   return 0;
}

This is an integration issue and is beyond the first level technical support we can provide. However, we encourage the community to take a look and perhaps offer their insights / suggestions. If you would like, we can also give you the contact information for Dimension Engineering to see if they might have some ideas too.

So for the encoder, when it rotate 360°, it will generate 100 pulse of A and 100 pulse of B. Am I right? And I would like to have the contact information to ask them for help to figure out how many “count” in my code I can get with this encoder. It bothered me a lot.
Thanks

So the pulse per revolution is 100? How to compute it? 400/4=100? Thanks

Correct - based on the last datasheet for the Lynxmotion US Digital optical encoder, it should provide 100 counts per revolution. We have attached the datasheet here (it’s model E4P-100).
E4P_datasheet.pdf (653 KB)

To make sure, 1 count means 1 high level +1 low level(just for one output, A or B), so it will generate 100 (1 high level + 1low level). If I detect 1000 such counts in 1 second, then the speed of the wheel should be 1000/1/100/30 (the reduction of the motor is 30:1), right?

Take a look at the guide under “Phase Relationship”. You can use this relationship to also get the direction of rotation.
Every change (for example one of the channels going low) indicates a count.
If you counted 1000 rotations and never changed the direction of rotation of the motor, then the rear shaft of the motor itself has rotated (1000/100) 10 full rotations, which would correspond to 10/30 rotations (using 30:1 gear ratio) of the output shaft.
The speed would be calculated (again, assuming the motor speed has been constant and 1000 counts occurred in 1 second), as 0.33 rotations per second of the output shaft after the gear down. You can then convert this to radians per second to get distance etc.

You said every change indicates a count. Are the changes counted on just 1 channel or both A and B channel. It just for 1 channel, let’s take A channel for example, the “s” of A in the “Phase Relationship”, means 1 count, and the “low level s” means another count. It means that 180° is one count. Am I right? Every 180° for one channel is a count.

Take a look at the section “Phase Relationship”. The square pulse signals represent high (5V) and low (0). You will see when one is high, the other can be high or low. When one or the other changes, that would be a “count”. The “180 degrees” is the phase separation between these two signals.

Thanks you. One more question, how could we get the counts per revolution from the specification of the encoder? The specifications: Cycles per revolution: 100,Quadrature counts per revolution: 400 ,Frequency: 30kHz. The first parameter? 100 cycles per revolution means 100 counts per revolution?
Thanks

If you’re looking for an in-depth understanding of quadrature encoders, we suggest taking a look at the following article:
en.wikipedia.org/wiki/Rotary_encoder
There are many others online as well.

I know how incremental encoder works. What I don’t know is how to know the number of counts I can get per revolution according to the specification of the product. Your specification for your product is cycles per revolution, Quadrature counts per revolution. Only cycles per revolution is 100 which is as you said the number of counts. What does cycles mean here? Number of counts? I am not sure. Sorry that I am not a native English speaker and even with dictionary I can’t find the meaning of cycles is pulses or counts.

The encoder itself does not output “counts” but rather high (5V) and low (0V) values from two channels. It is up to you to program the microcontroller to read these two channels and “count” accordingly.

If we use this output as an example en.wikipedia.org/wiki/Rotary_en … iagram.svg
If this is the output of the encoder. If I set the first phase “2” to the second phase “2” as 1 count(every rising edge of output A). How many counts could I get for one revolution? And how could I know it from the specification of the encoder?
Thanks

The encoder module would have 100 counts and you know this based on what the manufacturer indicates as the specs.