optocoupler meets air pressure
Interactives
Posts: 83
Ok, so actually this question is just an extension of the "pump contolled airflow" post. I mentioned before that I was going to try to read airflow by putting a DC fan in the path of the air and read the voltage that would result·from ·the spinning of the fan. So I got my self· several DC fans, fired up the compressed air, hooked up the voltometer, and got a reading of nearly zilch. So here's plan B: I took apart the dc fan, and am now just using the fan and the bearings that where hooked to it. I also took apart a trackball, and got from it the IR interupter disk (it's just a metal disk with holes around the outside perimeter) and the optocoupler arrangement, which consists of an optical transistor and emitter pair. I hooked this up to the fan, so that when air is flowing, the fan spins, the interupt disk interupts the transitor signal, and the device out puts from zero, to five volts. usually, when the fan is spinning as fast as it can, the transistor is outputting around two volts- I suppose because the disk is allowing an equal amount of offs and ons to trigger through the disk. What I really need here, is the speed of the fan to result in at least three input states going to the stamp (slow, medium ,& fast, lets call them.) I know I need the analog out put signal here to be converted to digital before it reaches the stamp, but I was wondering if the input signal could be achieved by use of comparators? Here's what I'm thinking: three comparators read the voltage difference between say vdd, and the out put of the optocoupler- if the voltage reaches 1.5V, than the first comparator triggers a signal to pin x, if it reaches 2V, then that comparator sends a signal to pin y, and 5 volts goes to pin z. Could I use this configuration in conjuntion with the PULSIN command to read the speed of the fan? Would I even need the PULSIN command? Is this ridiculously complicated for what I'm trying to do here? I've never used an AD converter before, so I'm fuzzy on the methods I would use to achieve my goal with one.
Comments
Upon further thought, trying to measure the analog value won't work as you expect it would, to illustrate, here are two waveforms of the fan spinning at two different speeds:
As you can see the top waveform corresponds to a fan spinning twice as fast as the bottom waveform, but if you were to compute the average value of each of the two signals (over a long enough averaging window) they would be the same·same since both are at 5V half the time and 0V half the time.
The value obtained through PULSIN has a 1/x relationship with the speed of the fan, since PULSIN is measuring the period of waveform and frequency = 1/period. So the lower the value returned by PULSIN, the faster the fan is spinning with one exception: the value of 0 returned by PULSIN means the fan is not spinning at all (the PULSIN waits until the timeout happens looking for the pulse to change, but this doesn't happen because the fan isn't spinning). You could calculate 1/(PULSIN value) to give a value in frequency, but this inst nessesary because you can just map the value to the appropriate speed range value.
If you desire a 4 state value (High, Medium, Low, Stop), calculate the lowest possible value returned by PULSIN (this occurs when the fan is spinning its fastest). Lets just say 255 is the lowest number produced by pulsin, this means the range of values produced by the system will be 0 or 256-65535, 0 returned means the fan is stopped, if a non-zero number is returned by PULSIN (say x) then the speed value Low=1, Medium = 2, High = 3, perform the following calculation: Integer((65535-x)/(3*255))+1. This subdivides the range of X into three seperate areas: Low = 43775-65535, Medium = 22015-43775, High = 255-22015. The value 3 in the equation is the number of regions, increase it if you want more than 3 regions of speed. The 255 value in the equation is the minimum value returned through PULSIN. Ask for clarification if any of this is unclear.
<EDIT> wait the equation above isn't correct, let me work on it some more </EDIT>
Ok heres the corrected equation:
Speed range = R - Integer((R*(x-MinV)/(MaxV-MinV))
Where R is the number of regions (R=3, for the above example)
X is the value returned by PULSIN
MaxV is the maximum value·returned by PULSIN·(65,535)
MinV is one less than the minimum value returned by PULSIN (254 for our example (255-1))
Integer() is truncation of the value (2.6 becomes 2)
The returned value of 0 by PULSIN is a special case (ie test for it then just output a Stop condition, don't plug 0 into the above equation, it will produce the wrong result)
Post Edited (Paul Baker) : 5/24/2005 9:23:46 PM GMT
I don't see why you wouldn't get some voltage on them if they are spinning up!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://ca.geocities.com/steve.brady@rogers.com/index.html
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
How did your reedswitch/hall effect sensor blocks project turn out?
kelvin
Wouldn't take much electronics wise to make the controls for it, then you wouldn't have to worry about the hassel of brushes.
トヨタは すばらし です!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There are 10 kinds of people....
Those who know binary and those who Don't.