fun with encoders...


I’ve got two encoders (not the ones attached to the motors) on the back wheels of my robot (I’ve NEVER used these before). As I understand it, the encoder is a digital sensor, as it returns a string of ones and zeros to the microcontroller.

The question is this:

Where should I plug the encoders into my cortex? Thanks in advance for any help.

What programming language do you use? For ROBOTC, plug them into any two consecutive digital ports…


I use easy c, sorry. I was unaware that the language affected the ports.

A string of 1s and 0s is binary; that’s how electronics and computers generally communicate.

A digital sensor is any sensor with only 2 values: 1 and 0.
Digital sensors include bump sensors, limit switches, jumper clips, and pneumatic solenoids (digital-out sensors).

Correct me if I’m wrong, but since an encoder has multiple values, I think it is an analog sensor.

Yes, you are correct in the a digital sensor is a sensor that can only return values of 1 or 0. And that’s exactly what the encoders do. The only thing going back to the microcontroller is a string of 1s and 0s every time the infrared stream is interrupted by the wheel inside the sensor (look at the wiki on how the encoders work). The microcontroller uses this series of 1s and 0s to create an integer value.

^Pages 3 and 4 explain this pretty well…

The encoder is a digital sensor, but the code framework treats them as analog for user-friendliness…

I don’t know if language does or not… :o


The wonderful easy c program (I guess this is why it’s named that way) has just informed me that I should put it in a digital port. I think.

I believe that the encoders are analog. They return values anywhere from 1 to however far you want them to go which can be any value depending on the variable you use. EasyC will let you plug them into any port you want, you just have to select what ports you want to use.

Encoders are actually digital (see RoboDesigners post). EasyC will only let you select the digital ports for the encoders in the program.

They can be plugged into any digital port configured to be an input, one of which will act as an interrupt. You just select the ports you used in the encoder block. It doesn’t matter which one you say is the interrupt, that will just affect your start (whether it is inverted or not) so you will have to test the values you are recieving, I recomend using print to screens.
… by the way are you using cortex or pic?