PWM
alnajjar1
Posts: 110
I have been trying to do a simple circuit where I can read the variable value of a photo-resistor and output a proportional voltage 0-12V with a maximum of 2Amps.
My approach, and I got great help from this group, is to use RCTime to read the photo-resistor, then send a PWM to a TIP120 to output the voltage. Both work great. The problem is that the Stamp cannot do anything while it is taking care of RCTime and PWM. Even while completely dedicated to that task, every time it reads the RCTime, the voltage dips slightly.
I have a simple test routine with the attached circuit:
again:
HIGH 0
RCTIME 0, 1, Vx ' measure RC discharge time
PWM 14, Vx, 50 ' PWM at 100/255 duty (~50 ms)
'DEBUG HOME, DEC ? Vx ' display result
GOTO again
Is there an IC that can do the PWM and the BS2 can talk to via IC2 or Serial? I need a smooth and somewhat accurate voltage out but I also need to free up the Stamp to read switches and turn a few other things on and off while it it is getting the voltage out. I thought of dedicating a BS1 to do the PWM and let the BS2 do everything else while outputting values to the BS1 but that seems to be overly complicated.
Any help?
Thanks,
Al
My approach, and I got great help from this group, is to use RCTime to read the photo-resistor, then send a PWM to a TIP120 to output the voltage. Both work great. The problem is that the Stamp cannot do anything while it is taking care of RCTime and PWM. Even while completely dedicated to that task, every time it reads the RCTime, the voltage dips slightly.
I have a simple test routine with the attached circuit:
again:
HIGH 0
RCTIME 0, 1, Vx ' measure RC discharge time
PWM 14, Vx, 50 ' PWM at 100/255 duty (~50 ms)
'DEBUG HOME, DEC ? Vx ' display result
GOTO again
Is there an IC that can do the PWM and the BS2 can talk to via IC2 or Serial? I need a smooth and somewhat accurate voltage out but I also need to free up the Stamp to read switches and turn a few other things on and off while it it is getting the voltage out. I thought of dedicating a BS1 to do the PWM and let the BS2 do everything else while outputting values to the BS1 but that seems to be overly complicated.
Any help?
Thanks,
Al
Comments
(Do a search for a DA-converter)
Alternatively, a Propeller has the resources to do both, and more, at the same time.
The capacitor's charge will hold much longer against the op-amp's high impedance input, giving you the time to take another reading.
-Phil
Al