# How to generate a -12V to +12V PWM signal from 0V to 3.3V (or 5V)

I want to build my own Type 2 electric vehicle (EV) charging wallbox. In order to communicate the maximum charging amperage of my wallbox to the EV, I have to generate a -12V to +12V PWM signal of 1 kHz frequency. By setting the on/off ration of the PWM signal I can tell the EV what amperage my wallbox can provide.

I plan to use a Raspberry Pi as central computing unit. Now, how can I easily turn a 0V to 3.3V (or 5V) PWM signal from the Raspberry into -12V to +12V? The +/-12V must be exact since the EV will pull the +12V to 9V (and later to 6V) to indicate connection and charging states. +12V is pulled to 9V when the plug is connected (via a diode + 2k7 resistor to GND) and later to 6V when the EV started charging (via 1k3 resistor to GND) Here is a picture which illustrates the circuit:

I thought about using the MAX232 for this task but it turns out it provides only up to +/- 8V. Also it can only drive really small loads.

• what should the output be when input is 2.5V? what about other intermediate voltages? Commented Aug 22, 2021 at 20:38
• For what purpose would the signal be level shifted? How many amps it should provide? Commented Aug 22, 2021 at 20:40
• one the solution is to generate +/-12v separately and then use an analog 2-1 multiplexer to select between them using rh the input as a select control signal. Commented Aug 22, 2021 at 20:47
• What do you mean by "should be stable"? Add some numbers to your question to show how accurate the voltages must be and how much current will be drawn from the output. Commented Aug 22, 2021 at 22:07
• RS-232 converters like the MAX232 invert the signal, so +5V becomes -8 to -12V. Commented Aug 22, 2021 at 23:03

The +/-12V must be exact since the EV will pull the +12V to 9V (and later to 6V) to indicate connection and charging states.

simulate this circuit – Schematic created using CircuitLab

Figure 1. The actual voltages achieved by the component values shown in your Rev: 2.0 drawing when "Ladung anfordern" is open and closed.

simulate this circuit

Figure 2. An open-collector / open-drain comparator with 1 kΩ pull-up.

How it works:

• V1 and V2 can be generated using any combination of regulators and DC-DC converters.
• R2 and R3 set the threshold for the 3.3 V logic. Adjust to suit. I chose the resistor values for ease of mental arithmetic.
• When Pi is low the output is turned on and pulls CP to -12 V with no source resistance. It will be a "strong" pull down.
• When Pi is high the comparator output goes open-circuit so CP is supplied by V1 via R1 giving you the conditions described in the two options of Figure 1.

Make sure you use an open-collector / open-drain comparator.

I omitted the decoupling capacitors on CMP1. You shouldn't.

• Thank you very much. "The actual voltages achieved by the component values shown in your Rev: 2.0 drawing are a little different ..." that's not correct. The first schematic in your answer is wrong. There is only one 1k resistor and one diode. It actually looks like this. When the switch is open the volt probe shows 9V, when closed 6V. Commented Aug 24, 2021 at 18:08
• I was trying to show both conditions on one diagram but forgot that they'd be in parallel when the switch is closed. Fixed. Commented Aug 24, 2021 at 18:29

To get +/-12 from 5V , you need dual tracking DC-DC converter.

To get +/-10 from 5V, you just need , CMOS, dual charge-pump voltage converters like the MAX680/MAX681 with 4 e-caps.