Off-board quadralature decoding

144 views
Skip to first unread message

ColinC

unread,
Oct 11, 2015, 7:15:48 AM10/11/15
to diyrovers
If you're interested in off-board quadralature decoding, this chip might be useful. Even comes in DIP.

http://phi-education.com/store/index.php?route=product/download/download&did=32

Cheers,
Colin

Jon Watte

unread,
Oct 12, 2015, 12:01:41 AM10/12/15
to diyrovers
There are lots of counter chips.
The one you linked to is LS7366 -- I suppose you prefer that because it has SPI support as opposed to the more common parallel/8-bit bus?
The trick is finding someone who actually has it in stock! It's not a common need anymore (as most MCUs have some kind of counter built-in.)
Then again, I've used a ATTiny84 as a quadrature decoder to SPI chip before. Software doesn't weigh anything once the chip is on the board :-)

What are you using it for, and where are you buying it in small quantities?

Sincerely,

jw





Sincerely,

Jon Watte


--
"I find that the harder I work, the more luck I seem to have." -- Thomas Jefferson


--
You received this message because you are subscribed to the Google Groups "diyrovers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diyrovers+...@googlegroups.com.
To post to this group, send email to diyr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/diyrovers/1ccd88c6-4441-413a-b8c4-3fcd9c8b1232%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jon Russell

unread,
Oct 12, 2015, 6:58:51 AM10/12/15
to diyrovers
I've used those. They are very easy to use, and they do come in DIP.

They are quite expensive though.


Jon.

ColinC

unread,
Oct 12, 2015, 5:25:02 PM10/12/15
to diyrovers
I'm not using the device; I just noticed it when looking at this motor controller:

http://phi-education.com/store/cheetah
(which I'm also not using :-)

Cheers,
Colin

Michael Shimniok

unread,
Oct 13, 2015, 9:19:13 PM10/13/15
to diyr...@googlegroups.com

Cool. That chip or one like it might come in handy. It seems like all the ARM microcontrollers I run across just have a single quadrature channel (2 inputs). I like having two channels, one per rear tire.

--
You received this message because you are subscribed to the Google Groups "diyrovers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diyrovers+...@googlegroups.com.
To post to this group, send email to diyr...@googlegroups.com.

Thomas Roell

unread,
Oct 14, 2015, 2:54:29 PM10/14/15
to diyrovers
TM4C123GH6PM (yes, I can write that without looking at the datasheet ;-)) has 2 QEI. That's the one on the TM4C123G Launchpad from TI. Both of them are accessible directly from this board.

- Thomas

ColinC

unread,
Oct 15, 2015, 5:41:32 AM10/15/15
to diyrovers
For the STM32F series, I think you have to use the first 2 channels of the timer, but you can use multiple timers. Here's an example:

http://www.micromouseonline.com/2013/02/16/quadrature-encoders-with-the-stm32f4/

Cheers,
Colin

Thomas Roell

unread,
Oct 15, 2015, 8:23:53 AM10/15/15
to diyrovers
Colin,

thanx for sharing. Looks like TIM2/TIM3/TIM4/TIM5 are all QEI capable even on the very lowend parts. They did hide that rather well in the documentation.

- Thomas

Michael Shimniok

unread,
Oct 15, 2015, 10:22:27 AM10/15/15
to diyr...@googlegroups.com

Nice to know about those and the Ti part. Thanks. I have been contemplating building a rover brain around an STM32. I have loads left from the OpenMV cam prototypes. Hmmm...

--
You received this message because you are subscribed to the Google Groups "diyrovers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diyrovers+...@googlegroups.com.
To post to this group, send email to diyr...@googlegroups.com.

Thomas Roell

unread,
Oct 15, 2015, 10:55:06 AM10/15/15
to diyrovers
Perhaps it's time we get together and design a proper rover brain ;-)

- Thomas

John Tilghman

unread,
Mar 30, 2016, 12:33:52 AM3/30/16
to diyrovers
The LS7184 is in stock here and they ship quick..


I got 4 and could have got a 100 if needed.

Ted Meyers

unread,
Mar 30, 2016, 12:48:46 AM3/30/16
to diyr...@googlegroups.com
Eh, I don't get this chip, how is it supposed to be used?  When I think of a quadrature decoder, I think of something that does the counting for you and outputs a count (number).  This chip outputs up/down pulses -- not of much use, unless I'm missing something.

--
You received this message because you are subscribed to the Google Groups "diyrovers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diyrovers+...@googlegroups.com.
To post to this group, send email to diyr...@googlegroups.com.

John Tilghman

unread,
Mar 30, 2016, 1:02:41 AM3/30/16
to diyr...@googlegroups.com
The way it works is that it gives ticks from the encoders, and a direction.

So now you can count ticks, and know the direction.


Wayne Holder

unread,
Mar 30, 2016, 2:11:39 AM3/30/16
to diyr...@googlegroups.com
Here's an open source design that uses an ATTiny45 to implement a quadrature decoder/counter that can be read via I2C:


more details can be found, here:


It appears to use a 16 bit counter (based on examining the code) and one user claims to have tested it at up to a 2 kHz count rate which reading from I2C at 100 Hz.  Not spectacular, but perhaps useable for many situations.

Wayne

On Sun, Oct 11, 2015 at 4:15 AM, ColinC <colinj...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "diyrovers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diyrovers+...@googlegroups.com.
To post to this group, send email to diyr...@googlegroups.com.

Jon Watte

unread,
Mar 30, 2016, 3:48:29 PM3/30/16
to diyrovers
The encoder output is already up/down.

Specifically, when moving one direction, A will be high each time B rises; when moving the other direction, A will be low each time B rises.
So, "direction" plus "trigger" counters don't need any adapter at all.

If you want a different pin pulse for "up" versus "down," you can probably run any 8-bit Tiny MCU at 8 MHz to count at 100 kHz to 1 MHz rates.
It probably costs a few more cents per circuit, but if the problem is "availability" not "cents of cost" then that's unlikely to be the problem :-)
 
Sincerely.

jw






Sincerely,

Jon Watte


--
"I find that the harder I work, the more luck I seem to have." -- Thomas Jefferson

Jon Watte

unread,
Mar 30, 2016, 3:54:05 PM3/30/16
to diyrovers
Belay that. Tinys are a buck in singles; that chip is $3.20!

The chip does megahertz clocking though, whereas the Tiny probably tops out at 500 kHz or so when running on internal RC oscillator.
The chip also uses slightly less current.
What do you have that spins so fast that you need this? Sounds interesting!

Sincerely,

jw





Sincerely,

Jon Watte


--
"I find that the harder I work, the more luck I seem to have." -- Thomas Jefferson

Wayne (gmail)

unread,
Mar 30, 2016, 4:49:03 PM3/30/16
to diyr...@googlegroups.com
The attiny internal Osc is typically 8 MHz.

Wayne 

Ted Meyers

unread,
Mar 30, 2016, 6:13:01 PM3/30/16
to diyr...@googlegroups.com
Yeah but even if this encoder chip can read ticks at MHz freqs, you still need some other chip that can read the ticks that this chip puts out at MHz freqs (obviously NOT a Tiny).  At some point in this chain of chips you need one that puts out data at a frequency low enough that a normal microcontroller can process it.

Jon Watte

unread,
Mar 30, 2016, 9:36:43 PM3/30/16
to diyrovers
My point is that, 99.9% of the time, it seems like an 8-pin Tiny or 14-pin 2313 would be a much better AND cheaper option to count encoders.
The drawback being that you need to write a little bit of code once, and program each chip once.
The MCU could also integrate the "decode quadrature" AND "count pulses" into a single circuit, as opposed to a separate counter. (You linked an I2C version of that approach; slightly different choices could easily create an SPI-based 32-bit dual counter.)

The original asker, John Tilghman, is probably also an engineer, and might have an interesting reason for why he'd not go that option, so I'm kind-of curious to hear what that is! Maybe my estimate of 99.9% goes down to 99.8% :-)

Sincerely,

jw





Sincerely,

Jon Watte


--
"I find that the harder I work, the more luck I seem to have." -- Thomas Jefferson

Thomas Roell

unread,
Apr 11, 2016, 7:38:46 AM4/11/16
to diyrovers
A couple of quick questions:

It seems one needs 2 QEI inputs. Counter only, or counter + timestamp (i.e. timestamp the last count event) ?

Why would you ever want to use something like the LS7183 ? It seems to me that mostly you are just shifting the problem from QEI to a hardware up/down counter in the MCU (I would not know how to do that on any of the STM32 MCUs with a single timer to begin with).

Software QEI. In reality you need 2 timer channels that trigger interrupts on each edge change. Say you use that for wheel encoders, then your RPM will be perhaps 500 rpm, which means 2000 interrupts per second. That would be in the noise level for a modern ARM CPU.

Anyway, what  do not quite understand is the need for an offchip solution. If you use a direct QEI interface, you need 2 signal lines. If you use an offchip solution, you need at least 2 for I2C, and 3 for SPI (if you use halfduplex). So you have one extra IC, and probably more signal lines.

- Thomas

Matthew Mucker

unread,
Apr 11, 2016, 9:14:46 AM4/11/16
to diyrovers
The STM32 has timer modules that support quadrature decoding in hardware. If you're already using an STM32, there's absolutely no reason to use an off-chip solution for quadrature decoding.
 

Thomas Roell

unread,
Apr 11, 2016, 10:41:40 AM4/11/16
to diyrovers
I am just curious why you ever want to do that (assuming now that you use a Cortex-M3/M4 class CPU to begin with). While the idea to distribute functionality seems to be interesting to begin with, using QEI with edge sensitive GPIO lines has lower overhead probably than trying to read the data via I2C ...

Regarding STM32, there are a couple of reasons why you may not want to use hardware QEI. They are tied to CH1/CH2 of a timer block, and using QEI will essentially hog the whole timer block. Even worse, because the encoder mode essentially drives the clock of the timer, you lose the ability to time-stamp events. Hence you needed to use another timer in tandem with the encoder timer to get the "when" of a pulse, which obviously you need to derive the veclocity. So in short, you might simply run out of hardware resources (i.e. timers) to do this properly.

- Thomas

Jon Watte

unread,
Apr 11, 2016, 1:52:18 PM4/11/16
to diyrovers
Some reasons to use off-chip solutions:

- Not everyone uses chips with built-in quadrature decoders.
- Some people want to drive more motors than there are decoders.
- Some people maintain legacy designs.
- You're out of pins.

Offloading to a serial-bus chip may cost you zero or one pins, if you're already using the bus. If you're using I2C already, it's zero pins. If you're using SPI already, it's one pin (for the chip bus enable signal.)

That being said, I still don't understand why anyone would use a quadrature pulse conditioner chip like the LS7184, instead of a bus-interface chip like LS7366 or a plain MCU. Maybe John Tilghman can share the reasons he's using it?

Sincerely,

jw







Sincerely,

Jon Watte


--
"I find that the harder I work, the more luck I seem to have." -- Thomas Jefferson

--
You received this message because you are subscribed to the Google Groups "diyrovers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diyrovers+...@googlegroups.com.
To post to this group, send email to diyr...@googlegroups.com.

John Tilghman

unread,
Apr 11, 2016, 2:36:50 PM4/11/16
to diyr...@googlegroups.com
Well, where do I start.. lol

The platform I am building my robot on robot-platforms and following this site http://ekpyroticfrood.net/ for quite a bit of the build and design/code, uses this MCU parallax for its low level interfacing with sensors and motor control along the quad encoders.

Problem is that the ONLY code the is available for the MCU doesn't the quads it just treats them and 1 encoder per wheel.

I have found myself in a situation where having been out of coding for quite sometime as well as hardware, that I have picked up of the hardware side of things MUCH quicker than the software side.

That being said, I started researching ways to use the quads properly and quite a few people (The internet..) talk about the LS7184 as the go to chip for using quads and making the coding side much easier.

As for the cost of the chips, lol.......

When I have $300 invested in just motors for my robot, $6 worth of chips to possibly solve a problem isn't really anything.

I could go thru the whole story of where this all started and the time/effort and dollars that have gone in to it, but I am not sure I want to revisit my past. I am here now and going forward.. lol

Anyway, I don't know if this really answered your questions or not but if I had to do over again I am sure I would still get these chips and offload the counting to them so my micro can respond in real time to the other sensors and not fall down the steps because it was too busy counting ticks to figure it out it need to STOP a few hundred ticks back and it now tumbling down the stairs in to many costly parts to replace.

This being my 1st real robot and the fact that I am learning as I go, this just seemed like a possible good solution to a problem. Which by the way I have yet to implement.

If you have any other questions, please feel free to ask. I am  pretty sure you will enjoy the trials and tribulations of a 1st time bot builder who bit off more then he ever knew, but is slogging thru it anyway.

Thanks,
JT
 

Jon Watte

unread,
Apr 12, 2016, 12:01:23 PM4/12/16
to diyrovers
Sounds reasonable. You actually hit two of the four reasons:

- Not everyone uses chips with built-in quadrature decoders.
- Some people maintain legacy designs.

Please post pictures when your robot starts getting somewhere :-)

Sincerely,

jw





Sincerely,

Jon Watte


--
"I find that the harder I work, the more luck I seem to have." -- Thomas Jefferson

Ted Meyers

unread,
Apr 12, 2016, 10:41:39 PM4/12/16
to diyrovers
John, that looks like a very nice robotics platform (if a bit pricey, but what isn't in this hobby)!  How well is it able to drive around the house?  I'm assuming that it is built for indoor use?  Does it do well on carpet and smooth floors?  What is the top speed?

Ted 

John Tilghman

unread,
Apr 12, 2016, 11:21:44 PM4/12/16
to diyr...@googlegroups.com
To be honest, it seems like a great platform the way the wheels and casters are set it doesn't seem to get hung up on much.

My house has a mix of tile, carpet and area rugs.

Only problem it has is when crossing the from tile to area rug, and the stairs of course.

I am just now getting him mobile, using a Parallax Propeller Activity Board for to drive the main sensors, motors and encoders. And for now Raspberry PI-2 for the brains running ROS on Ubuntu.

He is FAST, I am not even sure his speed but flat out he is dangerous which is what I want. What fun is a slow robot, of course ROS limits his speed and ramps him up/down as needed.

He is an indoor robot, but sturdy enough to be used outside as long as you keep him clean. The Motor Mount & Wheel Kit I have will support up to 60 lbs on this chassis and with the 2 SLA Batteries I have on him now, he clocks in right about 25 lbs.

Once I get the 2D/3D digital/analog video processing hardware and radios on him, he should be pretty cool.

If anyone is in Tampa, feel free to say Hi.

JT



On Tue, Apr 12, 2016 at 10:41 PM, Ted Meyers <ted.m...@gmail.com> wrote:
John, that looks like a very nice robotics platform (if a bit pricey, but what isn't in this hobby)!  How well is it able to drive around the house?  I'm assuming that it is built for indoor use?  Does it do well on carpet and smooth floors?  What is the top speed?

Ted 

--
You received this message because you are subscribed to the Google Groups "diyrovers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diyrovers+...@googlegroups.com.
To post to this group, send email to diyr...@googlegroups.com.

Matthew Mucker

unread,
Apr 13, 2016, 9:44:26 AM4/13/16
to diyrovers
John, there's a lot to be said for a solution that works. :)

Having said that, I encourage you to investigate doing the quadrature decoding on board. If your microcontroller supports an interrupt on pin change, like Thomas alluded to, try setting up an interrupt on one of the two pins to fire when the pin goes from low to high. In the interrupt, look at the state of the other pin. If the other pin is low, subtract one from the count. If that other pin is high, add one to the count. It should be a fairly easy interrupt to write, and could even be less coding than writing an interface to an outboard decoder/counter. It'll probably be faster, too.

Again, I readily agree that an inefficient solution that works is better than elegant code that doesn't. And if you don't have the available pins on your microcontroller, you don't have the pins. But if you do have the pins available, I encourage you to spend a few hours with this idea to see if you can get it working. Best case, you learn something and get it working without an outboard chip. Worst case, you don't get it working, you lose a couple of hours of your time, but you likely learn something that way as well.

Minuteman

unread,
Apr 14, 2016, 1:57:48 PM4/14/16
to diyrovers
If you like the arudino environment, the teensy 3.1 has 2 hardware QEI's and there is a provisional library for using them: https://forum.pjrc.com/threads/26803-Hardware-Quadrature-Code-for-Teensy-3-x

Nathan

ColinC

unread,
Apr 19, 2016, 4:55:14 AM4/19/16
to diyrovers
For motor control I'm using a $10 board with an STM32F103RCT6. So 4 of the timers are used for hardware QE decoding and the Systick timer determines the interval. Another timer puts out 4 hardware-generated PWM signals.
Reply all
Reply to author
Forward
0 new messages