# 3.3V -> ~12V square wave generator

#### Fyod

Joined Jun 2, 2019
24
Hi everyone,
I have an old speedometer that is powered by 12V and the needle/speed is driven by a square wave. I have the calculations figured out, 1mph = 2.1622Hz, so ~20Hz to ~300Hz.
I would like to use a microcontroller to create the square wave and will hopefully get good resolution.
However what I don't know is the recommended way to output at the 12V level. The entire circuit would be powered from the 12V (micro would have a regulator).
I believe this could be done with a transistor, but do not know if it would need any special features. I have yet to test what the load is, as these old speedos use large coils.

Has anyone done a similar project and have any advice?

#### BobTPH

Joined Jun 5, 2013
9,137
Simple: + side of meter goes to 12V. - side goes to drain of N-channel logic-level MOSFET, source goes to ground, gate goes to micro output pin.

#### MisterBill2

Joined Jan 23, 2018
18,964
What we do not know is if the input is a 12 volt square wave or not. Is the speedo a one-terminal device? I have seen automotive tachometers that were 12 volt supplied but used a different signal for the RPM input. And I have seen speedos that used a generator driven by the connection to the transmission where a speedo cable would connect. So I am not going to suggest a circuit that might burn up your device untilit is clear that it truely does operate on 12 volt DC pulses.

#### Fyod

Joined Jun 2, 2019
24
@MisterBill2 Yes, the original signal that I want to replicate is a 12V square wave. The pulses come from a sensor in the differential.

#### Ian0

Joined Aug 7, 2020
10,020
If you have a 3.3V or 5V square-wave and you need a 12V squarewave, try an MCP1402.

#### MisterBill2

Joined Jan 23, 2018
18,964
A transistor drive circuit could work, but if it was originally driven by a sensor in the differential, that was probably a magnetic pickup, and it might work better using a small transformer to step up whatever square wave you get from the microcontroller. That would work if the sensor was an inductive pickup coil.

#### MisterBill2

Joined Jan 23, 2018
18,964
One scheme would be to use an opamp IC, if the current required is not excessive. You will need to use an opamp described as Rail to Rail output. and configure it for a gain of about four.

#### BobTPH

Joined Jun 5, 2013
9,137
Why would you need an opamp to produce a square wave, when a single transistor will do, assuming what the OP has said is true.

#### MisterBill2

Joined Jan 23, 2018
18,964
I suggested that because the opamp is less likely to connect the full 12 volts directly to a small signal input if there is a failure to correctly control the transistor.
My concern is protecting the speedo from possible damage by excess input power. THAT is the only motivation.