20 Hz PWM Scheme
This 20 HZ PWM output scheme uses a closed loop RC signal to generate a 20 HZ PWM output from 70 -90 HZ PWM pulsin values. It does not work as well as desired.
The simple closed loop RC circuit is driven by an on - off output with the resulting quasi triangular signal monitored by a ADC input. If-then statements switch the output on and off depending on the ADC signal level.
PWM output is generated by comparing the pulsin value to the RC signal level with pair of if-then's.
The resulting PWM output resolution is very course with about 5 steps for full range input. It is not known if this is a limitation of the 08M and/or code.
Present code;
main
pulsin 3,4,w1
readadc 1,w0
let w2=w1/2
if w0 < 25 then high 4 endif
if w0 > 211 then low 4 endif
if w2 > w0 then high 0 endif
if w2 < w0 then low 0 endif
goto main
No pauses. pwmout, etc were used to allow the code to cycle rapidly.
I'm not sure if the pulsin stops code operation while measuring the pulse. If it does, that maybe limiting the resolution and response.
The w1/2 was tried to increase the output resolution with out apparent affect.
The second pulse in has not been tried, it may not be nessesay and would not have a proportional fuction.
Any comments and suggestions appreciated. There maybe a better approch or refinement that will obtain more output resolution.
This my first attempt at writing code since a Basic course thirty some years ago. My 66 year old brain has a trouble wrapping its self around this stuff. It has been interesting, and I think the Picaxe system is well done.