Microcontroller - Outputting PWM or Analog - Good Method For Choosing This Via Firmware Config?

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
Hello, I am wanting to output 0-10V PWM signal, or 0-10V analog signal. The microcontroller's GPIOs output 0 to 3.3V, so I will just amplify that up to 10v with an op amp.

My question comes down to, lets say I want this to be a configuration option within the firmware, e.g. setting a flag such as "USE_PWM = True;", "USE_ANALOG = True;", etc.

What would be a good method of wiring these two separate systems up to the same output? For instance one GPIO would be the PWM setup, another separate GPIO would be the Analog setup. If I connect the 2 outputs together I would need to disable/disconnect the other one somehow? Is this doeable with a mosfet somehow? I suppose I could have even a 3rd GPIO controlling a relay and could switch between the two... but would prefer to not use a relay if possible.

Thanks and any help is greatly appreciated.
 

dendad

Joined Feb 20, 2016
4,478
Are you using a processor that has builtin DAC to give you the analog out, or will you be generating the analog out from a PWM signal?

If you have a DAC as well as PWM, and being as you will have to amplify the signal anyway, you may be able to just use a suitable OpAmp. Feed the analog signal to one input, and the PWM to the other. Keep the unused one at 0V. Or for PWM, analog a half volts, and the OpAmp run as a comparator with the PWM signal.
I've not figured out a circuit but something along these lines may be able to work.
 

BobaMosfet

Joined Jul 1, 2009
2,113
Why don't you use a transistor to control digital pwm and one to control analog signal, and one to switch between which one you want to output.
 
Top