Shop OBEX P1 Docs P2 Docs Learn Events
Using a 555/4060 timer to generate an adjustable PWM with the Bs2? — Parallax Forums

Using a 555/4060 timer to generate an adjustable PWM with the Bs2?

rwgast_logicdesignrwgast_logicdesign Posts: 1,464
edited 2012-10-01 09:05 in BASIC Stamp
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.

Comments

  • V-manV-man Posts: 10
    edited 2012-09-30 00:33
    I think you could use the PWM command in the BS2.

    ****** 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!
  • rwgast_logicdesignrwgast_logicdesign Posts: 1,464
    edited 2012-09-30 01:04
    I was thinking more along the lines of using the bs2 to trigger the 555 and then set the two digital pot via the bs2. this way thw PWM wouldnt use the bs2s resources.
  • V-manV-man Posts: 10
    edited 2012-09-30 01:17
    so you mean you would trigger the 555 on some periodic basis (emulating the period portion of a PWM), let the 555 generate the duty cycle portion of the PWM pulse, and after the BS2 triggers the 555 it goes off and sets the digital Pots?
  • rwgast_logicdesignrwgast_logicdesign Posts: 1,464
    edited 2012-09-30 01:40
    Hmmm i dont really understand what your saying

    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
  • V-manV-man Posts: 10
    edited 2012-09-30 02:05
    OK, I see where you're going with this. It sounds feasable but I'd cross my T's and dot my I's. Question: Have you looked into servo controller chips? I believe you can set them with a value and they will continue to PWM at that value until you change it. That might be a simple way to go but they aren't cheap ($20-$40). Good luck and have fun!
  • PublisonPublison Posts: 12,366
    edited 2012-09-30 07:08
    Parallax used to sell the PWMPAL. It sat underneath the BS2. It would take the load off of the BS2 and generate four PWM signals, set and forget.

    They may still be available from some resellers.
  • rwgast_logicdesignrwgast_logicdesign Posts: 1,464
    edited 2012-09-30 14:12
    So that board looks pretty nifty but its not really what i want to accomplish here...

    #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
  • Martin_HMartin_H Posts: 4,051
    edited 2012-10-01 06:49
    Your idea of using a BS2 to control a 555 timer is a good one. Appendix C of this PDF http://www.parallax.com/Portals/0/Downloads/docs/prod/sic/WebIR-%20v1.1.pdf discussed using a 555 to allow a BS2 to generate IR remote control signals. In that case the 555 is locked to a 38 kHz carrier frequency and the Stamp does a pulsout to modulate a signal on top of it. Your novel bit is the use of a digital potentiometer to control the PWM frequency and I think that would work fine.

    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.
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2012-10-01 09:05
    A couple of weeks ago Electronics Design published an idea, LM555 Makes Inexpensive Power Driver.
Sign In or Register to comment.