PWM as analogue input
Is there any way of using PWM as an input, rather than just an output?
We have an IR receiver, and we wish to use it as an analogue sensor, rather than a digital one. We've only found a way to use PWM as an output though.
Any help? :cool:
We have an IR receiver, and we wish to use it as an analogue sensor, rather than a digital one. We've only found a way to use PWM as an output though.
Any help? :cool:
Comments
[COLOR=#000000][FONT=monospace]rct var word ' RCtime value[/FONT][/COLOR] Vx var word ' voltage value calculated ' we want this to = applied voltage Vx Cn1 con 48576 ' first constant, see below Cn2 con 8 ' second constant, ditto ' circuit attached to P0 low 0 loop: RCtime 0,0,rct low 0 Vx=Cn1 / rct + Cn2 debug home,dec? rct,"Vx=",dec Vx/10,".",dec1 Vx pause 500 goto loop
Not sure which pin should be which though. What we've done is replace "rct" with the pin # of one of our IR sensors. Are we at least on the right path, or completely messed up?
Build the circuit shown in the application note and try the program shown. Experiment with different voltages, then maybe try it with your IR sensor and see what happens. Only then should you change the circuit around to fit your project. It's generally a bad idea to change someone's demo circuit / program unless you understand it. You can usually add DEBUG statements to look at temporary or intermediate values (like rct) to help you understand what's happening. You can also use a multimeter or oscilloscope to look at the signals themselves.