PDA

View Full Version : Propeller and Rotary Encoder



xanadu
03-22-2012, 11:49 PM
I got this rotary encoder http://www.sparkfun.com/products/10982 and....

Will this object http://obex.parallax.com/objects/24/ work with the push button function?

Thank you.

Duane Degn
03-23-2012, 12:54 AM
I've used the quadraure encoder object in the Prop Tool's library before with an encoder (http://www.sparkfun.com/products/9117) with a push button.

The button is just treated like a normal button, independent of the encoder.

I'd think the object you linked to would work the same way, but I'm not sure about the "grey code" part of SparkFun's description. I thought grey code was different than just a normal quadrature encoder output (but I'm not sure).

xanadu
03-23-2012, 03:20 AM
Can you tell me what pins the push button uses? I have the encoder working with the object. I didn't think the push button was encoded but I'm stumped on what pin it uses...

jagrifen
03-23-2012, 03:20 AM
JonnyMac wrote an object that I've used with great success. It directly supports the button. Unfortunately I can't find it in the Object Exchange. It was part of a Nuts and Volts Article in May 2010. Try looking here (http://www.nutsvolts.com/index.php?/magazine/downloads//2010).

Duane Degn
03-23-2012, 04:17 AM
JonnyMac wrote an object that I've used with great success. It directly supports the button. Unfortunately I can't find it in the Object Exchange. It was part of a Nuts and Volts Article in May 2010. Try looking here (http://www.nutsvolts.com/index.php?/magazine/downloads//2010).

It's Spin Zone #6.

I based my Mecanum robot's encoder code on JonnyMac's code.

Duane Degn
03-23-2012, 04:24 AM
Can you tell me what pins the push button uses? I have the encoder working with the object. I didn't think the push button was encoded but I'm stumped on what pin it uses...

The push button shorts the common anode of the LEDs to the middle pin of the group of five pins.

Connect the center pin to a Prop IO pin set as an input (with a pull-down resistor on the Prop pin). When the pin reads a high level, the button has been pressed.

These are different than the other encoders with push buttons I've used.

The right angle RGB encoders SF sells use the same sets of pins for the button.

xanadu
03-23-2012, 04:37 AM
Here's what I have so far...


http://youtu.be/7TQxMgffmAE

Thanks for the link to the article. In that article the encoder's push button shows a switch circuit, mine does not. I'm still completely stumped by that part of the datasheet :/

xanadu
03-23-2012, 04:56 AM
The push button shorts the common anode of the LEDs to the middle pin of the group of five pins.

I was wondering what that pin was for haha, it's just not very obvious in the datasheet. Thanks Duane!

Mark_T
03-23-2012, 11:42 AM
I've used the quadraure encoder object in the Prop Tool's library before with an encoder (http://www.sparkfun.com/products/9117) with a push button.

The button is just treated like a normal button, independent of the encoder.

I'd think the object you linked to would work the same way, but I'm not sure about the "grey code" part of SparkFun's description. I thought grey code was different than just a normal quadrature encoder output (but I'm not sure).
Its "Gray code", named after Frank Gray, and a Gray code is one where successive values differ in one symbol position (usually bit position) only. So binary quadrature encoding is the simplest Gray code beyond the trivial one-bit code. Its also a reflected Gray code.

Duane Degn
03-23-2012, 02:36 PM
I was wondering what that pin was for haha, it's just not very obvious in the datasheet. Thanks Duane!

I couldn't make sense of that datasheet. I just tested pins with my mulit-meter until I found a pair that shorted with the button pressed. I wasn't expecting one of the button pins to be shared.

The button can only be used as a normally low button unlike a normal push button that can be used either normally low or normally high.

Besides the pull-down resistor on the IO pin connected to the button, you might need a series resistor between the button and the Prop if you're powering the LEDs with more than 3.3V.



Its "Gray code", named after Frank Gray, and a Gray code is one where successive values differ in one symbol position (usually bit position) only. So binary quadrature encoding is the simplest Gray code beyond the trivial one-bit code. Its also a reflected Gray code.

Thanks Mark.

After a bit more reading, I see a device (http://www.sparkfun.com/products/10064) I had thought produced Gray code doesn't. Apparently one of the key features of Gray code is only one bit position changes at a time, unlike binary which can have changes in many postions as it is increased or decreased by one.