Using rotary encoders with the pulsin command

Butlerluke1

New Member
Hi guys,

I have read that when using a 5VDC power supply to power the picaxe and inputs, that even though the manual states a low state in relation to voltage is = or < 0.8V and a high signal is = or > 2.0V, does this still apply to the pulsin command?

I am using a rotary shaft encoder to measure the speed of a motor but have only just realized that the A pulse output voltage peaks at just 0.193V. If using a pulsin input command would the picaxe recognize the difference between the the high and low state of the encoder or not?

Cheers,
 

AllyCat

Senior Member
Hi,

Welcome to the forum.

The "switching threshold" (i.e. the decision point between a logic '0' and '1') is somewhere between 0.8 and 2.0 volts; typically about half-way (say 1.4 volts) but not guaranteed. It applies to any logic-based command (i.e. including Pulsin), so your 0.193 volts pulse stands no chance of being seen as a '1' and triggering a Pulsin command.

You might be able to write code around a READADC command, or you need either an external amplifier/comparator/Op-Amp, or might use the internal Comparator(s) in almost any PICaxe. Easier with the X2s where they're supported by PICaxe Basic, but also possible with any M2 (there's only one comparator in the 08M2).

Cheers, Alan.
 

Butlerluke1

New Member
Thank you Ally,

I've since looked at using a pull up resistor on the encoder outputs which should allow the Picaxe to read the change in state as the Encoder output is an open collector NPN transistor. I should of mentioned this in my previous message, sorry!

Thanks again,

Luke
 

AllyCat

Senior Member
Hi Luke,

Yes, the 193 mV was "suspiciously" low and I should have picked up on it.

BTW if you ever "forget" to include a pullup resistor on a PCB (or just want to save a component), then often the internal "Weak Pullup" resistors in most PICaxes (particularly M2s) can do the job (see the PULLUP command). They're about 30k, so sometimes larger than ideal, but I have used them even as I2C bus pullups. ;)

Cheers, Alan.
 
Top