Using a 555/4060 timer to generate an adjustable PWM with the Bs2?
rwgast_logicdesign
Posts: 1,464
So ive been messing with 555 recently in my quest to become more well rounded in electronis, I also have some 74HC4060s I used in a frequency counter project a while back, not sure how much better than a 55 these acually are.
So if we were working with a Bs2 and lets say wanted to make PWM to drive a motor, depening on how often we need the motor to change speeds and do certain things this could potentially take up alot of the Bs2s resources with something like a propeller this would probably not be an issue unless we were trying to save every scrap of memory we could.
Anyways Ive given this some thought and was wondering if you wanted an adjustable PWM with one of these chips what would be the most effiecent way to do this? My first thought was to manually pulse the comparators in the 555 but you would need the Bs2 to keep continually doing that which doesnt save any overhead it probably makes more. If we wanted good accuracy in our circuit maybe the best way would be to use a 555 with a +-1% tant cap and a digital pot. That way the bs2 would only have to tell the 55 to start or stop and would could adjust the PWM value by adjusting the digital pot? If we used a pot such as a ds1809 with multiple channels we could use the bs2 to control r1 and r2 in order to set duty cycle if we used the commonly seen astable mode with a diode bypass.
Does this sound right? Maybe there is a better way to implement this? My idea above is very easy to create and requires little programming to control, Im wondering why we dont see more circuits like this for PWM, It seems pretty easy compared to writing all the code for a good PWM on something like a propeller. It may not be as fast as using a micro like a Prop or ARM to generate the PWM but in the case of leds and motors im fairly sure this method should be very more than sufficient.
So if we were working with a Bs2 and lets say wanted to make PWM to drive a motor, depening on how often we need the motor to change speeds and do certain things this could potentially take up alot of the Bs2s resources with something like a propeller this would probably not be an issue unless we were trying to save every scrap of memory we could.
Anyways Ive given this some thought and was wondering if you wanted an adjustable PWM with one of these chips what would be the most effiecent way to do this? My first thought was to manually pulse the comparators in the 555 but you would need the Bs2 to keep continually doing that which doesnt save any overhead it probably makes more. If we wanted good accuracy in our circuit maybe the best way would be to use a 555 with a +-1% tant cap and a digital pot. That way the bs2 would only have to tell the 55 to start or stop and would could adjust the PWM value by adjusting the digital pot? If we used a pot such as a ds1809 with multiple channels we could use the bs2 to control r1 and r2 in order to set duty cycle if we used the commonly seen astable mode with a diode bypass.
Does this sound right? Maybe there is a better way to implement this? My idea above is very easy to create and requires little programming to control, Im wondering why we dont see more circuits like this for PWM, It seems pretty easy compared to writing all the code for a good PWM on something like a propeller. It may not be as fast as using a micro like a Prop or ARM to generate the PWM but in the case of leds and motors im fairly sure this method should be very more than sufficient.
Comments
****** from the BS manual *****
Syntax: PWM Pin, Duty, Duration
Function: Convert a digital value to analog output via pulse-width modulation.
Pin is a variable/constant/expression* (0 - 15) that specifies the I/O pin to use. This pin will be set to output mode initially then set to input mode when the command finishes.
Duty is a variable/constant/expression* (0 - 255) that specifies the analog output level (0 to 5V).
Duration is a variable/constant/expression* (0 - 255) that specifies the duration of the PWM output.
****** End Manual Info ******
So depending on how you want to make the changes to motor speed it should be a simple mater of setting the parameters of the PWM command.
Do you know how you want to cause the change in motor speed? Would it happen on each pulse of the 555 timer? If that's the case just feed the 555 output to some pin on tyhe BS2 and have the BS2 poll that pin for changes. When it changes call the PWM command with some new duty value. Make sense?
Good luck and have fun!
this would be the procedure
1 User specifys frequency and duty cycle through a sub routine
2 sub routine does some math based around the fixed cap and then sets the two pots to the correct settings for duty cycle and frequency.
3 bs2 then lets go of 555 reset line and the pwm starts
4 user does what he wants till he needs to change motor speed, led brightness etc, then calls the sub again
They may still be available from some resellers.
#1 this is more of an educational thing ive been trying to learn a little bit more about doing things with discrete logic chips and analog type devices,
#2 I have a homework board not a bs2 so a PWMPAL wont be such a nice form factor with jumper wires everywhere
#3 There is a bigger end result to this education project, Which is to use 3 555 timers, 2 to form an hbridge and one for PWM, I will proably add some kind of current amplification I.E transistors opamps something to boost the 200ma signal from the LM555s im using
#4 when done I could have a board which has adjustable speed and an h-bridge for under 7 bucks in price as most motor sheilds for other micros cost 30 bucks
My biggest issue here is the accuracy of the PWM time, im not sure what my digital pots are rated at but ive read about circuits designed with all 1% resistors and %1 caps and still having a 5% or morore drift.
Id also wondered if maybe there was a better way to go about this
I'm not so keen on building an h bridge out of 555 timers, but that's because the SN754410 is so cheap. But go ahead if you think you'll learn something, and please tell us about your results, we all might learn something new. Frankly I've been avoiding DC motors because of the need to generate PWM signals, I've really got to get over that hump.