Author Topic: Single 555 Timer with 2 discrete duty cycles? (Not continuously variable)  (Read 1943 times)

0 Members and 1 Guest are viewing this topic.

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
Hi all,

I am using the typical 555 timer circuit to produce a PWM signal (see attached circuit). I would like two discrete duty cycles as determined by different R1,R2 combinations with a common C1.

I would like to switch between the duty cycles electronically (no mechanical switches but rather with a digital I/O from microcontroller). Originally I thought about creating a type of SPDT circuit using complementary MOSFETs (between R1 and Vcc) to switch between different R1,R2 combinations in the circuit, but I don't think it will work as the different values for R2 would still be in parallel and it would mess up the duty cycle.

Any ideas how I could achieve this switching between duty cycles? I have seen the circuits with continuously variable duty cycles using potentiometer but this is not what I am looking to do.

Any help would be great! Thank you so much!
 

Offline GerryR

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: us
A single miniature DPDT relay (5V, 12V ??) would do it.  No current to speak of and in excess of 10 6 cycles.  Connect the junction of R1a and R2a to the NO of one set of contacts and the other side of R2a to the NO of the other set of contacts.  Junction of R1b and R2b to the NC set of the contacts that the R1a and R2a set are connected to, with wiper to pin7 on the 555.  Other side of R2b to the NC set that the other side of Ra is going to, with the wiper to the top of the Cap going to pins 2 and 6 of the 555.
Still learning; good judgment comes from experience, which comes from bad judgment!!
 
The following users thanked this post: doublec4

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
A single miniature DPDT relay (5V, 12V ??) would do it.  No current to speak of and in excess of 10 6 cycles.  Connect the junction of R1a and R2a to the NO of one set of contacts and the other side of R2a to the NO of the other set of contacts.  Junction of R1b and R2b to the NC set of the contacts that the R1a and R2a set are connected to, with wiper to pin7 on the 555.  Other side of R2b to the NC set that the other side of Ra is going to, with the wiper to the top of the Cap going to pins 2 and 6 of the 555.

Interesting, thanks! Makes sense and I can drive the coil with my I/O and transistor if the required voltage or current exceeds the capability of the I/O directly driving it. I tried looking up solid state DPDT relays on Digikey but it seems there are none.

If anyone else has any other method of achieving this with mosfets or transistors or something I am definitely still interested in multiple solutions! Thank you
 

Offline not1xor1

  • Frequent Contributor
  • **
  • Posts: 716
  • Country: it
A single miniature DPDT relay (5V, 12V ??) would do it.  No current to speak of and in excess of 10 6 cycles.  Connect the junction of R1a and R2a to the NO of one set of contacts and the other side of R2a to the NO of the other set of contacts.  Junction of R1b and R2b to the NC set of the contacts that the R1a and R2a set are connected to, with wiper to pin7 on the 555.  Other side of R2b to the NC set that the other side of Ra is going to, with the wiper to the top of the Cap going to pins 2 and 6 of the 555.

Interesting, thanks! Makes sense and I can drive the coil with my I/O and transistor if the required voltage or current exceeds the capability of the I/O directly driving it. I tried looking up solid state DPDT relays on Digikey but it seems there are none.

If anyone else has any other method of achieving this with mosfets or transistors or something I am definitely still interested in multiple solutions! Thank you

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%
 
The following users thanked this post: doublec4

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
A single miniature DPDT relay (5V, 12V ??) would do it.  No current to speak of and in excess of 10 6 cycles.  Connect the junction of R1a and R2a to the NO of one set of contacts and the other side of R2a to the NO of the other set of contacts.  Junction of R1b and R2b to the NC set of the contacts that the R1a and R2a set are connected to, with wiper to pin7 on the 555.  Other side of R2b to the NC set that the other side of Ra is going to, with the wiper to the top of the Cap going to pins 2 and 6 of the 555.

Interesting, thanks! Makes sense and I can drive the coil with my I/O and transistor if the required voltage or current exceeds the capability of the I/O directly driving it. I tried looking up solid state DPDT relays on Digikey but it seems there are none.

If anyone else has any other method of achieving this with mosfets or transistors or something I am definitely still interested in multiple solutions! Thank you

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%

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?
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 20360
  • Country: gb
  • 0999
No, the voltage controlled option will work at lower duty cycles than 50%. I've used it before to get from close to 0 to 100% so 5% to 95% is reasonable.

Another option is to use an analogue switch such as 74HC4066 to switch the diode an resistor element in to the circuit.
https://assets.nexperia.com/documents/data-sheet/74HC_HCT4066.pdf

Just one question: why not use the microcontroller to generate the PWM and do away with the 555 circuit altogether?
 
The following users thanked this post: doublec4

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
No, the voltage controlled option will work at lower duty cycles than 50%. I've used it before to get from close to 0 to 100% so 5% to 95% is reasonable.

Another option is to use an analogue switch such as 74HC4066 to switch the diode an resistor element in to the circuit.
https://assets.nexperia.com/documents/data-sheet/74HC_HCT4066.pdf

Just one question: why not use the microcontroller to generate the PWM and do away with the 555 circuit altogether?

I actually have two applications where in one of them is just a simple flashing light system and I had figured the extra step of programming the chip was going to be a pain... I was hoping to have a system where I could order the PCB and someone else could assemble the light system.

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?). So in the end I figured it would be easy to just use the circuit from the first application and use a digital I/O to control the duty cycle of the 555 timer instead of a mechanical switch.
 

Offline GerryR

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: us

.... I tried looking up solid state DPDT relays on Digikey but it seems there are none.

If anyone else has any other method of achieving this with mosfets or transistors or something I am definitely still interested in multiple solutions! Thank you

The relays are miniature mechanical relays; NAIS  DS2E-M-DC5V is one with 5 volt coil, also available in 12 volt, 24 volt.  Magnecraft and Hamlin make them in DIP packages.  Try Newark Element 14, Allied or Mouser as a source.  Many instruments use them internally for range changes, etc.  Have a great day.  :)
Still learning; good judgment comes from experience, which comes from bad judgment!!
 
The following users thanked this post: doublec4

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca

.... I tried looking up solid state DPDT relays on Digikey but it seems there are none.

If anyone else has any other method of achieving this with mosfets or transistors or something I am definitely still interested in multiple solutions! Thank you

The relays are miniature mechanical relays; NAIS  DS2E-M-DC5V is one with 5 volt coil, also available in 12 volt, 24 volt.  Magnecraft and Hamlin make them in DIP packages.  Try Newark Element 14, Allied or Mouser as a source.  Many instruments use them internally for range changes, etc.  Have a great day.  :)

Yep! Should have been more clear, it was kind of an off tangent thought when I mentioned the solid state device. I found many mechanical relays :)
 

Offline not1xor1

  • Frequent Contributor
  • **
  • Posts: 716
  • Country: it
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%

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?

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

 
The following users thanked this post: doublec4

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
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%

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?

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


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

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4767
  • Country: nz
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?).

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.
 
The following users thanked this post: doublec4

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
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?).

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.

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:
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf