# Convert 5v serial data to 12v

#### chrisall

Joined Apr 15, 2008
3
I have a device that sends a string of serial data at 300baud to an ECU. This output is standard async 8N1, inverted so that a 1 is 0v and a 0 is +12v. I wish to emulate this device with a PIC, but this outputs TTL voltages. How can I convert the 5v to 12v?

Note that I'm not trying to convert TTL to RS232 levels, ie MAX232 is not suitable.

Cheers,
Chrisall.

#### Papabravo

Joined Feb 24, 2006
17,539
A single transistor can be used as an inverting level shifter.

#### m.majid

Joined May 28, 2008
53
Hi
I recommend the following circuit.
It works up to 9600 bps,
An advantage of this circuit is isolating +12 from +5
It should work, but I didn't test this circuit practically.
Try it, if not work then tell me to test it practically.

#### Attachments

• 5.5 KB Views: 281
Last edited:

#### lightingman

Joined Apr 19, 2007
374
Hi,

Just use a MAX232.

Daniel.

#### hgmjr

Joined Jan 28, 2005
9,027
I have a device that sends a string of serial data at 300baud to an ECU. This output is standard async 8N1, inverted so that a 1 is 0v and a 0 is +12v. I wish to emulate this device with a PIC, but this outputs TTL voltages. How can I convert the 5v to 12v?

Note that I'm not trying to convert TTL to RS232 levels, ie MAX232 is not suitable.

Cheers,
Chrisall.
I would be interested in learning the reason why you have ruled out the MAX232 right off the bat.

hgmjr

#### m.majid

Joined May 28, 2008
53
MAX232 converts 0, +5v to +12v, -12v

#### chrisall

Joined Apr 15, 2008
3
I would be interested in learning the reason why you have ruled out the MAX232 right off the bat.

hgmjr
Because MAX232 converts TTL into RS232 ie, 0v / 5v into -12v / +12v. The ECU im working with doesn't use RS232 comms, it requires inverted 8N1 async where a logic '0' is represented by 12v and a '1' by 0v.

Cheers,
Chrisall.

Last edited:

#### chrisall

Joined Apr 15, 2008
3
Hi
I recommend the following circuit.
It works up to 9600 bps,
An advantage of this circuit is isolating +12 from +5
It should work, but I didn't test this circuit practically.
Try it, if not work then tell me to test it practically.
Hi, that's pretty much the same as what I've tried already, except I used a 4N25 opto-isolator. I did use a lower value pull-up res and ommited the cap though, so that may be causing problems.

I only need the Tx side btw, all the ECU does externally once it's received the correct code is turn on a lamp!

Cheers,
Chrisall.