I need to create an analog voltage of 0V-24V for the PLC ( s7-1200) with a microcontroller with operating voltage 5V.


I've been doing this research since yesterday. I'll share the results of my research. I need your feedbacks.

First of all, I was uncertain about this. I decided to drive a 24V DC signal with a mosfet. So I'm gonna raise my signal. In my opinion it wouldn't be right to use pwm to drive this mofets. If I drive a mosfet with 0-5v pwm, I would get a 0-24v pwm signal from the mosfet output. So I decided to produce an analog signal. (also 8 bit, 256 step pwm signal would not be sensitive.) What you think about my approches? Am I right?

I've found a lot of methods to produce an analog signal.

  • Low pass filter. (I read and passed that it has a negative effect on the bandwidth and some things I don't understand.)
  • R2R ladder (After seeing option 3, I didn't look at that much.)
  • mcp4725 I2C DAC, ( I liked it very much. It was good to write the signal you want to eeprom with the I2C. Because my analog signals won't change very fast.I don't need high speeds.) Because of this chip's I2C addresses, only two can be used at a time. So I will multiply I2C channels with TCA9548A. I need 16 analog output. After that, I will raise this analog signal with a mosfet.

Yes, I need your comments and suggestions.

Best regards

  • 1
    \$\begingroup\$ Can you provide a link to the datasheet for the S7-1200 that has a 0 - 24 V analog input? I've never seen a PLC with analog inputs other than 0 - 10 V, 0 - 20 mA, 4 - 20 mA and various thermocouple and RTD sensor analog inputs. \$\endgroup\$
    – Transistor
    Feb 22, 2019 at 17:02
  • \$\begingroup\$ Thanks for the answer. That was wonderful. I am not familiar with PLC. My client just asked me for a circuit like that. I'il tell him that. After I confirm this information, I will update my research. \$\endgroup\$
    – OmerFaruk
    Feb 23, 2019 at 8:47

2 Answers 2


Try this


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ Sorry. I don't expect a complete technical solution. I was just expecting suggestions. Therefore, I did not need to draw schemes. I'm going to add the circuitI mentioned at the first opportunity. \$\endgroup\$
    – OmerFaruk
    Feb 23, 2019 at 9:02

You should use a MOSFET driver but keep in mind that most of them are relatively slow beasts. If you feed a PWM that's faster than the MOSFET can handle, you'll get crap out of it. This of course depending both on PWM frequency and MOSFET toggle characteristics.

So you could place some manner of rectifier between the MCU's PWM pin and the MOSFET, such as an op amp rectifier. Which can also be adapted to be a differential amplifier to get a suitable gate voltage, if this doesn't correspond to the MCU logic levels. There are MOSFETs that are suitable for 5V gate though.

As you can tell, this is all rather vague without a specific frequency and MOSFET in mind.

Keep in mind where you get the 24V from, it should preferably by a clean regulated voltage.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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