This question already has an answer here:

I am trying to create a PWM signal using a POT from 555 Timer to control speed of a 5V DC motor. I have a development board with a C8051F020 microcontroller, a 100K POT and an LCD display. The requirement is to generate PWM signals externally so that the microcontroller is free to do other things that needs to be done for the project. I need to use the DAC from the microcontroller to drive the 555 Timer.

Scenario: The ADC on the micro reads the value from the POT (present on the Dev board). The DAC converts it to an analog value which can be used by the 555 Timer. I cannot directly connect the pot to the Timer.

My understanding is that the ADC and DAC do not have to be physically connected together on the board. Instead the digital values sampled from the ADC can be used by the DAC through software, am I right? So my question: is it possible to connect the DAC of the microcontroller to the input (pin 7) of a 555 Timer with a level converter from 3.3V (DAC) to 5V (Timer) in between?

EDIT 4th Feb 2014

I am using LM741 OPAMP as a comparator. The Timer is configured in an astable mode. For prototyping purpose, the DAC from the microcontroller is replaced with a 100K potentiometer. Since the DAC is supposed to be the reference voltage to the comparator, I found that the LED would always light up (although very dim) because of the capacitor C1 voltage goes from 1/3*Vcc to 2/3*Vcc which is why the LED was dim because the lowest voltage was 1/3*Vcc = 1/3*5 = 1.67V. So I switched the terminals for the comparator and now the reference voltage is C1 (capacitor voltage) as shown in the schematic below. My questions: 1) Is it alright to replace DAC with a potentiometer to represent DAC voltage as the voltage from the POT? 2). Is it wrong to switch the terminals around? I tested it with inverted terminals and the LED completely switched off and glows bright when the DAC voltage (POT) is turned high up. Also tested with the motor. When the DAC is the reference voltage (pin 3 of LM741) then the motor starts up slow and cannot be stopped although the POT is all the way down. And when connected as shown in the schematic, then the motor is stopped in the beginning.

enter image description here


marked as duplicate by Dave Tweed, Joe Hass, Chetan Bhargava, Kaz, Matt Young Jan 22 '14 at 1:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • \$\begingroup\$ Yes, why not eliminate the 555 and generate pwm with your development board? \$\endgroup\$ – HL-SDK Jan 21 '14 at 19:49
  • \$\begingroup\$ Crap I forgot the mention that, I cannot I need to keep generation of PWM independent of the microcontroller. Thats the requirement \$\endgroup\$ – David Norman Jan 21 '14 at 19:50
  • 1
    \$\begingroup\$ Also I do not think the discharge pin (7) is what you want to be controlling. I could be wrong but you may want to look up the threshold or trigger pins. \$\endgroup\$ – HL-SDK Jan 21 '14 at 19:52
  • \$\begingroup\$ How is checking the ADC and setting the DAC that much less expensive than bit-banging PWM? \$\endgroup\$ – Ignacio Vazquez-Abrams Jan 21 '14 at 19:56
  • \$\begingroup\$ @IgnacioVazquez-Abrams, what do you mean? \$\endgroup\$ – David Norman Jan 21 '14 at 19:57

One way is to use the voltage on pins 6 & 2 when the 555 is in astable mode. It will go from \$0.33 \cdot V_{dd} \$ to \$0.67 \cdot V_{dd} \$ fairly linearly. If you feed that signal into a comparator (with high input impedance so it doesn't load the it too much), inverting input. Feed your DAC input into the converter non-inverting input

The comparator should be powered by supplies that are equal to or greater than the range of the DAC.


simulate this circuit – Schematic created using CircuitLab

The waveform on the capacitor (that goes to the capacitor) looks like the top waveform here:
enter image description here

Whenever the DAC voltage exceeds 2/3 \$V_{cc}\$, the output of the comparator is always high (100% power). When the DAC output is lower than 1/3 \$V_{cc}\$, the comparator is always off. At 1/2 \$V_{cc}\$, the comparator output has a 50% duty cycle at the oscillation frequency of the 555.

Another way is to trigger a 555 with a periodic signal (perhaps from another 555) and feed the DAC output into the control voltage (pin 5) input. In that case, be sure your DAC output does not exceed the supplies of the 555 (high or low).

  • \$\begingroup\$ Thank you for your answer Spehro. Question 1: The DAC would output an analog voltage. The comparator takes two analog voltages to output one digital signal. How would the comparator create pulses when the output of the timer is not connected? Question 2: I believe the comparator will need to very low response time??? \$\endgroup\$ – David Norman Jan 22 '14 at 19:36
  • 1
    \$\begingroup\$ I'll expand on the first question by editing my reply. Response time will depend on your PWM frequency. Most comparators are pretty fast compared to the kind of PWM frequency you'd use for a motor control. \$\endgroup\$ – Spehro Pefhany Jan 22 '14 at 19:54
  • \$\begingroup\$ I get how the comparator output goes high when DAC voltage exceeds 2/3Vcc. But for the comparator to go low the DAC voltage has to be lower than 1/3Vcc and the voltage at the inverting input should be higher than 2/3Vcc right? How do I make sure that the timer output goes high when DAC voltage goes low? \$\endgroup\$ – David Norman Jan 22 '14 at 21:10
  • \$\begingroup\$ You're only using the comparator output. The timer free-runs at whatever frequency depending on the R1-Rt-C. If you feed a constant 0.5*Vcc to the comparator you get 50% duty cycle. Whenever you feed it less than 2/3*Vcc, you get less than 100%, down to 1/3*Vcc, below which you get 0% duty cycle. \$\endgroup\$ – Spehro Pefhany Jan 22 '14 at 21:24
  • 1
    \$\begingroup\$ LM339 is open collector. You need a pullup to +5. \$\endgroup\$ – Spehro Pefhany Feb 4 '14 at 19:50

I cannot I need to keep generation of PWM independent of the microcontroller. Thats the requirement

Why don't you use something like this - it's cheap and reliable and directly takes a 0 to 1V signal and produces PWM at a frequency defined by Rset.

enter image description here

You'll still need a DAC if you are totally sure you are not allowed to put the pot onto the chip above.

  • \$\begingroup\$ This is great but its expensive than a 555 Timer. Looks so much easier to setup I must say \$\endgroup\$ – David Norman Jan 21 '14 at 21:44
  • \$\begingroup\$ @DavidNorman it's a college project - what has expence got to do with anything. Anyway, getting rid of the microcontroller and feeding the pot straight to the chip save how much? Yeah, I know you have to use the micro because it's a college/tuition/learning thing BUT you never mentioned expence was a priority or even a factor in your question. OK when folk say "555" there can be an implication that 555 means cheap OR, maybe, that's all they thought of. My suggestion is an idea for you to consider!! \$\endgroup\$ – Andy aka Jan 21 '14 at 21:51
  • \$\begingroup\$ Its a very good suggestion Andy. I asked my supervisor if I can use an arduino and design everything on my own. He said NO, use the Dev board which would save a little money. Each project has got $20 budget and there are 54 students doing this project. He wants us to use components that we already have sadly \$\endgroup\$ – David Norman Jan 21 '14 at 21:56
  • \$\begingroup\$ @DavidNorman it's be a real shame if they taught you stuff that was 50 years out of date because of shortages. Try asking him what the department's budget really is!!! \$\endgroup\$ – Andy aka Jan 21 '14 at 22:23
  • \$\begingroup\$ One of the guys did because he is a mature student and has industry experience. The supervisor said he has no idea about the 'real' budget. The supervisor is only a PhD student and he's doing what he's told. This is annoying. Please give me tips on how to connect DAC output to drive a 555 TIMER \$\endgroup\$ – David Norman Jan 21 '14 at 22:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.