Electronics > Beginners
Single 555 Timer with 2 discrete duty cycles? (Not continuously variable)
<< < (3/3)
doublec4:

--- Quote from: not1xor1 on June 27, 2019, 04:57:10 pm ---
--- Quote from: doublec4 on June 26, 2019, 05:39:39 pm ---
--- Quote from: not1xor1 on June 26, 2019, 04:23:39 pm ---imho it would be easier to use a different circuit
start from the 50% duty cycle schematic where the capacitor is charged/discharged by the output and then just change the CV pin voltage value to change the duty cycle accordingly
for instance you can use a microcontroller I/O to connect CV pin via a 10k resistor to 5V or 0V or set the I/O open to leave the duty cycle at 50%

--- End quote ---

Sounds good... however, in my typical astable circuit, I was achieving less than a 50% duty cycle by putting a diode in parallel with R2. It got me down to about %20 by my calculation. Using the voltage controlled option on pin 5 I would still be limited to 50% as my lowest duty cycle, no?

--- End quote ---

Here is the circuit I'm referring to:


here is what you get when you connect a 4.7kΩ resistor between CV and 0V


here is what you get when you connect a 4.7kΩ resistor between CV and V supply


--- End quote ---

Thanks! I'll give it a try on the bread board :)
brucehoult:

--- Quote from: doublec4 on June 26, 2019, 06:20:34 pm ---The other application requires an Arduino to "talk" to a few other devices... so the uC is there to use, however I've read that changing the PWM frequency is more challenging with the Arduino (I need 200Hz... which also seems to be too low to find oscillators on Digikey?).

--- End quote ---

What on Earth have those things got to do with each other?

If you want to output a 200 Hz PWM from an Arduino running at 16 MHz then you program it (whether using software or hardware) to toggle a digital output pin one way and then back again every 80000 clock cycles.

The standard Arduino library "analogWrite()" function uses a 480 Hz frequency on most pins (960 Hz on a couple of them) on all the most common AVR boards including Uno, Mega, Nano, Mini but it you're programming the registers directly you can set any frequency (total cycles) you want.

You could for example use Timer 2, set the prescale to 1024, set OCR2A to 77, and then set OCR2B to a value between 0 and 77 to set your duty cycle. (You need to use the B output in this case).

This would give a 200.32 Hz signal, which is hopefully close enough. You won't do better with a 555 anyway!

See https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM

Don't muck with Timer 0 if you want to use millis() or delay() in your code.
doublec4:

--- Quote from: brucehoult on June 27, 2019, 10:38:09 pm ---
--- Quote from: doublec4 on June 26, 2019, 06:20:34 pm ---The other application requires an Arduino to "talk" to a few other devices... so the uC is there to use, however I've read that changing the PWM frequency is more challenging with the Arduino (I need 200Hz... which also seems to be too low to find oscillators on Digikey?).

--- End quote ---

What on Earth have those things got to do with each other?

If you want to output a 200 Hz PWM from an Arduino running at 16 MHz then you program it (whether using software or hardware) to toggle a digital output pin one way and then back again every 80000 clock cycles.

The standard Arduino library "analogWrite()" function uses a 480 Hz frequency on most pins (960 Hz on a couple of them) on all the most common AVR boards including Uno, Mega, Nano, Mini but it you're  programming the registers directly you can set any frequency (total cycles) you want.

You could for example use Timer 2, set the prescale to 1024, set OCR2A to 77, and then set OCR2B to a value between 0 and 77 to set your duty cycle. (You need to use the B output in this case).

This would give a 200.32 Hz signal, which is hopefully close enough. You won't do better with a 555 anyway!

See https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM

Don't muck with Timer 0 if you want to use millis() or delay() in your code.

--- End quote ---

Thanks! Okay so for the application with the on board Arduino, I've read about changing the registers but have never tried it... I can look into that :)

Regardless, for the purpose of expanding my knowledge I still enjoy learning new ways to tackle this without resorting to using the PWM from Arduino. The advice from Zero999 introduced me to analog switches. Admittedly I didn't even know about their existence prior to this  :palm:
Navigation
Message Index
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod