4
$\begingroup$

I'm starting out with robotics, got my first DC gear motor with quadrature encoder (https://www.pololu.com/product/2824):

enter image description here

I ultimately plan to hook it up to a motor driver connected to a Tiva Launchpad. However, since I'm a noob, and curious, I am starting by just playing with it with my breadboard, oscilloscope, and voltage source. E.g., when I plug in the motor power lines into my (variable) voltage source the axis spins nicely as expected between 1 and 12 V.

The problems start when I try to check how the encoder works. To do this, first I plug a a 5V source into the encoder GND/Vcc, and then try to monitor the encoder output.

While the motor is running, I check the Yellow (encoder A output) cable (referencing it to the green (encoder GND) cable). I made a video that shows a representative output from one of the lines (no USB on my old oscilloscope so I took a video of it using my phone).

As you would see at the video, the output doesn't look anything like the beautiful square waves you typically see in the documentation. Instead, it is an extremely degraded noisy sin wave (at the correct frequency for the encoder). The amplitude of the sin is not constant, but changes drastically over time. Strangely, sometimes it "locks in" and looks like the ideal square wave, for about a second or two, but then it gets all wonky again.

Both of the lines (encoder A and B output) act this way, and they act this way at the same time (e.g., they will both lock in and square up at the same time, for those brief glorious moments of clarity). Both of my motors are the same, so I don't think it's that I have a bad motor.

I have also checked using Vcc=12V, but it made no difference other than changing the amplitude of the output.

Note I already posted this question at reddit: https://www.reddit.com/r/robotics/comments/502vjt/roboredditors_my_quadrature_encoder_output_is/

$\endgroup$
  • 1
    $\begingroup$ Are you just connecting the "Encoder A Output" (for example) directly to the Oscilloscope input? If so I would suggest also adding a pull-up resistor (maybe 5k or 10k ohms) from each output to "Encoder Vcc". This might be necessary to get the proper output from the encoders, if they are Hall-effect types. $\endgroup$ – Andy Aug 30 '16 at 6:24
  • 2
    $\begingroup$ If you look at the encoder board on the motor, you will see it already has pull up resistors and even some filtering caps. I would suggest fiddling a little with a sensor. Try to bend it towards the magnet and see if it helps. $\endgroup$ – mactro Aug 30 '16 at 8:50
  • 1
    $\begingroup$ Oh crap I reversed Encoder Vcc/Encoder Ground last night when I "fiddled with it". And that's when it stopped working. Seems to be close now. Oh, and one of my connections was fubar in my breadboard so I was only getting ~50 mV through from 5V. Not sure how that is possible...but I checked and there it was. Dear lord I am such a noob (if you can't tell...programmer here, not hardware guy). $\endgroup$ – neuronet Aug 30 '16 at 13:29
  • 2
    $\begingroup$ Umm, while I hate to admit this, I have to do it. I haven't done electronics in a few years, and never did it much. I forgot the top/bottom power rails on a breadboard are separate. There was no bad connection on my breadboard. I was a freaking idiot (Napolean Dynamite voice). $\endgroup$ – neuronet Aug 30 '16 at 13:46
  • 2
    $\begingroup$ Thank you for updating - it's always good for the rest of us to know where the missing link was! $\endgroup$ – Andy Aug 30 '16 at 14:04
5
$\begingroup$

Conceptually everything was set up correctly, but a number of basic mistakes affected the signal. Here is the set-up which should be used to record the signal from one of the encoder outputs:

connecting a scope to an encoder via encoder ground and encoder output

A set up like this should result in a a clean signal if your motor/encoder is not broken. Once it's up and running, seeing the signal is simple. It's as easy as checking the square wave coming off of any common function generator: fiddle with your oscilloscope until it looks good (or just hit autoset and any good oscilloscope will do it for you, or read the excellent answer by Chuck for more help on that).

The underlying problems seem to stem from an accumulation of rust when it comes to dealing with real, wire and breadboard, electronics projects:

  1. The top/bottom breadboard power rails are typically separated, so you cannot assume continuity between them. Always keep a multimeter handy and do simple continuity tests before doing deeper troubleshooting. When stuff's busted, never assume continuity. Test for continuity.
  2. Be careful not to confuse motor ground with encoder ground, motor ground is likely to be electrically very noisy,m which will corrupt your encoder signal.
$\endgroup$
  • 1
    $\begingroup$ I'll add to your comment about testing for continuity - whenever you get a printed circuit board (PCB) that you ordered, BEFORE you solder anything to it, check continuity between power and ground, power and signal buses, ground and signal buses, and the individual lines in all the signal buses. Some manufacturers, cheap ones especially, may not etch the board correctly and this will bridge two buses together. Similarly, if your power, ground, or signal buses are very long (service a large number of components), spot check between the "source" and each device to check. $\endgroup$ – Chuck Aug 31 '16 at 18:32
  • 1
    $\begingroup$ Once you solder devices onto the board, the impedances of those devices (filter capacitor, etc.) makes it really hard to determine if there's really a short between V+ and GND or similar. I would have saved weeks of my life if this had been my practice from the start. $\endgroup$ – Chuck Aug 31 '16 at 18:34
  • 1
    $\begingroup$ Thanks for your answer neuronet. I've edited it to be a little nicer, since we expect people to be as nice to themselves as we expect them to be to others. *8') $\endgroup$ – Mark Booth Jan 8 at 12:04
2
$\begingroup$

I followed the link to your Reddit post and, after checking the datasheet for your motor, I agree with what some people are saying there, but I'll expand their answers and hopefully give you some insight into what I think is happening.

/u/zevryn said,

I hope this doesn't come off as mean since I'm not trying to be, but how good are you with the oscilloscope? I could see if the scope is configured wrong, it will not be displaying properly. If you have it set to trigger on one of the rising edges and have the sample frequency high enough to get multiple samples per square wave, they should all overlap and look nice and stable.

(Emphasis added)

/u/Ttimoffi said

I think u have to read it at a frequency specified on the encoder data sheet.

I think what is happening, that the others are commenting on, is that you are not sampling the output at a high enough frequency. You haven't commented as to what the motor speed is when you monitor the encoder output, but let's assume it's the full unloaded output speed of 200rpm.

The encoder is setup to output 3,200 counts per revolution of the output shaft. At 200rpm, that means you're getting $(200*3200) = 640,000 \mbox{ counts/min}$ which is equivalent to $10.6 \mbox{ kHz}$.

As explained in this video on aliasing, when you under-sample a signal you get false signals - signals that, as far as your instruments are concerned, are real but don't actually exist. They "appear" because of instrument inadequacies.

Finally, as explained in this video on oscilloscope sampling rates, the person says,

Note by the way also the trigger is not working. This is maybe your first clue if you're playing with your scope and you can't get it to trigger right, "What's going on here, why isn't it triggering correctly?" It's triggering on the aliased signal.

Your video is very blurry, so it's very hard to read what anything is set to on your scope, but it kinda looks like, at the bottom, it says, "<10Hz". Also, at the top, it looks like it says, "M Pos: 270.0ms". This all makes it seem like your scope is set way too slow to be able to see the signal correctly.

At 10.6 kHz, the signal period is (1/10666) = 0.000094 seconds, or 94$\mu$s. An oscilloscope setting of 100$\mu$s per division should get the actual signal when the motor is at full speed.

tl;dr - Set the scope to 100$\mu$s per division. You're reading an aliased signal, not the real signal, which is why it keeps jumping around like that.

$\endgroup$
  • $\begingroup$ Unfortunately, my errors were way more basic than this (see comments above), but this is a good answer so I'll upvote it, and won't delete my question because this is useful. The engineer where I work also went right to this as a problem. The problem was so basic I literally wasn't getting the right signals, and once I did I got the osc settings right pretty quickly (despite my incompetence with wires, I can do oscilloscope settings). $\endgroup$ – neuronet Aug 30 '16 at 13:43
  • $\begingroup$ Frankly I was about to delete my question, because it was based on such basic stupid mistakes, but then your answer popped up, so now here we are. A monument to my amateurishness with basic breadboard electronics. $\endgroup$ – neuronet Aug 30 '16 at 13:52
  • 3
    $\begingroup$ @neuronet - Glad you figured it out! If you leave the question open, it gets put in a "question purgatory" where it gets bumped occasionally and never marked as resolved. If you could, please post an answer (you can answer your own question) and, after the time limit expires you can accept it as the answer. I think it's maybe a day or two until you can accept it. This will mark the question as resolved (and help future visitors find the correct answer quickly!) $\endgroup$ – Chuck Aug 30 '16 at 13:53
  • 1
    $\begingroup$ Thanks, will do. Must run to work but will post when I get a chance. Will try to actually post something useful for people who want to monitor their quad encoders on their tabletops like I did, so at least there will be a little tutorial on that. Dear lord I'm so embarrassed. $\endgroup$ – neuronet Aug 30 '16 at 14:03
  • 1
    $\begingroup$ @neuronet - Eh I wouldn't worry about it too much. Hopefully you didn't spend too much time on it. I've done terrible, terrible simple things like this before, too - wondering why a value isn't changing when I'm not actually referencing that value, wondering why a file looks so strange when I loaded the wrong file, wondering where my glasses are when I'm holding them, etc. Mistakes happen! :-P $\endgroup$ – Chuck Aug 30 '16 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.