Can't get my motor encoder circuit to work

dandlion

New Member
I have built a motor encoder using an IR LED and a phototransistor. The circuit seems pretty straightforward to me.
With the output of the LED shining directly into the phototransistor (on the breadbord - in reality the light will reflect off black/white encoding disc) the output as measured by my cheapo multimeter is 5.1 volts (same as the source voltage). Yet, when I route that same output to my PICAXE test board, I can't get it to raise an input pin high. What am I missing?

encodertest.jpg
Here's my code:

main:
if pinc.6 = 1 then
high 4
else
low 4
endif
pause 500
goto main

If I force pinc.6 high then, of course 4 goes high.

I am using a PICAXE 20X2
 

Attachments

Last edited:

g6ejd

Senior Member
Disconnect the PICAXE and activate the phototransistor and measure the voltage at the emitter, as seen by the PIC, does it go to zero when off and +5.1V when on?

Have you set the PICAXE to be an Input on that pin?
 
Last edited:

erco

Senior Member
You want the max possible signal voltage swing at the ptx/resistor junction as the encoder wheen spins, but it will never be zero nor will it be Vcc. If you're getting Vcc, check your connectiobs & ptx polarity. Then adjust your resistors. For a reflective sensor, you need lots of LED current, so a low LED resistor, and a high ptx resistor. 1-4 volts is pretty good signal swing, and the PicAxe's schmidt triggers do a good job of filtering: http://www.youtube.com/watch?v=PfMnl4oGzs8&list=UUXRihcrTP6zOcVfd4WfBMqw&index=23&feature=plcp

But as far as why your PicAxe isn't reading your 5V input signal, must be a bad electrical connection.
 

Jamster

Senior Member
It appears that all the replies (at least on my computer) have appeared in the blogs section of the forum, I assume this shouldn't have happened...
 

Reloadron

Senior Member
I don't understand what you are doing exactly. Your speed pickup is an NPN photo transistor. You are taking the signal off the emitter and have a 100K emitter resistor. If we assume a perfect transistor with no drop the current would be 50 uA? Then you show a pull up on the PIC? Why are you going about it that way?

Since you have a NPN photo transistor I would place a 10 K resistor between V+ and the transistor collector and the emitter to ground and take my pulses off the collector. That or remove the 10K pull up from the PIC and run the emitter signal the way you have it drawn to the PIC. You could likely also reduce that emitter resistor to about 10K.

Personally, I would just configure it with a 10K collector resistor, emitter to ground and lose the resistor on the PIC pin.

Ron
 

Armp

Senior Member
The circuit as shown will only switch between 5v when illiuminated, to 4.5v when dark.
Secondly your output LED has 330K in series - wont be very bright!
 

SAborn

Senior Member
I agree partly with Ron, on the fact i would have the transistor on the ground side and the pullup resistor to 5v.

I dont see if the pullup is removed what will take the picaxe pin high, in Rons last reccomendation.

Also 100K is far to high and needs to be reduced to around 4K7 to 10K max.
 

g6ejd

Senior Member
I would swap Q1 and R2 around, that will solve the problem and remove the need for the pull-up too, although in that arrangement the 100K would be better off being about 10K to ensure enough input current to the PIC.
 
Top