An afterthought>> replace the transistor with a n-channel MOSFET like a 2N7000 and remove the 4.7K, doing this should allow you to keep the 100K resistor as MOSFETs are voltage controlled devices rather than current.
Just connect the source where the emitter is in the above schematic along with drain for the collector & gate for the base.
Turbo, the zener as shown does not really achieve anything. (In fact I expect it will not work at all)
The Zener design is an alternative to using an opto. I gave up using an opto for protection as they needed more protection than the prop itself. The ones I found You need at least reverse polarity protection across the opto.
ie the idea was:
input ----R----------- prop Pin
|
Z
|
gnd
However that turns out to be rubish if you are trying to keep it low power as the zener needs lots of current, so needs a low R. I tried a 1N4728 3.3v zener as input protection, but it needs about 70mA of current.
For the moment I will just increase my series resistance and discard the diodes altogether, and rely on the props built in protection.
If I rebuild I will consider using more traditional protection of 2 (low leakage) diodes, one to gnd and one to the 3.3 rail.
3.3V
|
D
|
input ----R----------- prop Pin
|
D
|
gnd
Ascii schematics... where is the prop font when you need it!
I didn't know what a crankshaft position sensor was until I had to replace mine[noparse]:)[/noparse]
The wavelength will vary with your rpms... so your basic code would be something like
PRI readCrankshaftPS(pin) | period
dira[noparse][[/noparse]pin]~
waitpne(|<pin, |< pin, 0) 'pin high...but may be in middle of pulse
waitpeq(|<pin, |< pin, 0) 'pin low... beginning of low period but not beginning of the signal
Repeat
waitpne(|<pin, |< pin, 0) 'pin high, beginning of high period and beginning of pulse signal
tix:=cnt 'get clock
waitpeq(|<pin, |< pin, 0) 'pin low...end of high pulse
tix2:=cnt
waitpne(|<pin, |< pin, 0) 'pin high end of low period, end of signal wave
fcnt:=cnt
period:=(fcnt-tix)
Comments
Just connect the source where the emitter is in the above schematic along with drain for the collector & gate for the base.
The Zener design is an alternative to using an opto. I gave up using an opto for protection as they needed more protection than the prop itself. The ones I found You need at least reverse polarity protection across the opto.
ie the idea was:
However that turns out to be rubish if you are trying to keep it low power as the zener needs lots of current, so needs a low R. I tried a 1N4728 3.3v zener as input protection, but it needs about 70mA of current.
For the moment I will just increase my series resistance and discard the diodes altogether, and rely on the props built in protection.
If I rebuild I will consider using more traditional protection of 2 (low leakage) diodes, one to gnd and one to the 3.3 rail.
Ascii schematics... where is the prop font when you need it!
Post Edited (matb) : 1/2/2010 6:08:49 AM GMT
Is that (2) 3.3v standard diodes? What value resistor did you use, or are you not sure, so the blank value implies a little experimentation?
[noparse][[/noparse]quote]
3.3V
|
D
|
input ----R
prop Pin
|
D
|
gnd
The wavelength will vary with your rpms... so your basic code would be something like