optic encoder and 16f628A. Help.

Status
Not open for further replies.

MathGeek

New Member
I have a bunch of opto interrupter. For those of you who are interested, an opto interrupter has a IR LED and a phototransistor side-by-side. In between them, a plastic wheel with "slots" go through. A signal lead changes voltage from High (Vdd) to Low (~0) when a slot passes by.

So as previously discussed in my other threads, I will use opto interrupter (aka photomicrosensor, optic encoder, etc) for the positioning of my robot leg, which is controlled by a motor. I don't need to know the speed of rotation, but I do need to know the position.


I just need to get started. Where in Midrange manual should I look for this thing?


BTW, I just succeeded controlling a mini RC car from my computer using Visual Studio 2005 and PIC16F628A. Yey!
 

You can't get the absolute position from it, only the relative position, nor can you tell which direction it's moved in - with a single opto interrupter you can only tell it's moved so many pulses in 'some' direction, but you have no idea which way (except by the way you told it to move), nor where it started from.

Servos generally use poteniometers for good reason, they provide absolute positioning, so you know where it is at all times.
 
Nigel Goodwin said:
Servos generally use poteniometers for good reason, they provide absolute positioning, so you know where it is at all times.

How long will a pot last? Optos have an advantage of no wear, perhaps 3 optos could work... 2 for position, 1 for reference (drill another hole in the disk) Just a thought.

Always wondered how the 360 degree modified servo pots work...
 
Nigel First of all, you are right. opto only gives relative positioning. But if I know the first position, I can keep tract of all subsequent positions. Also, with different slot size (say, progressively larger slots) approximate positioning is also possible even without knowing the first position. Direction--don't worry about it, microcontroller controlls the motor, so I know the direction.

So, guys, help me out with interfacing opto interrupter with 16F628A.
 
William At MyBlueRoom said:
Always wondered how the 360 degree modified servo pots work...

Easy! - it's NOT a servo anymore, you break the connection to the pot so it doesn't move, and just use it as a motor and gearbox, with a built-in H-bridge.
 
Anyone?

By the way, what does CCP (Capture/Compare/PWM) do?

I get the PWM part, but what does it "Capture"?
 
It captures the value of the a free running timer on eiter a rising or falling edge. Subtract the timer values of two successive captures and you have elapsed time or pulse width.
 
The answer to your question comes in two parts: hardware and software.

On the hardware side, light the LED (+5-resistor-led-gnd). pull up the collector of the phototransistor to +5 (10K would be good), emitter to ground and take the output from collector into a PIC input. High means interruptor tab is present in the slot. You might want to use a schmitt trigger between the PT and the PIC since your interrupting tab will be fairly slow moving (noise could cause multiple transitions). A 74HC14 is cheap though it inverts so you'll need to invert the sense in your software.

On the software side you can use either interrupts or polling. You get 5 interrupt pins on the 628A. Look at the external int section (RB.0) or interrupt on change (RB.4..7). For polling, you can have more inputs. run a timer to generate periodic interrupts which check the pins in the ISR.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…