martinw
Posts: 9
Joined: Mon Dec 29, 2014 3:17 pm

Adding on board serial using max232/233 ic

Sun Dec 27, 2015 11:44 am

Hi there :)

I'm going to be adding a serial port/interface to my rpi but I'm not sure about the 3.3v/5v issue that I could possibly get from using a max 233/232 ic.

I don't fully understand electronics and data shifting, buffering, all that, so I'm trying to learn more at the same time as doing stuff. I've used a home made max233 lead to reflash and play around with some different hardware but basically just following tutorials and not fully knowing why I'm doing/using stuff.


For now id like to know if it is possible to make my interface/circuit using a max232/233 ic (I have some of these lying around) instead of using the often recommended max3232.

As I understand it the chips I want to use run with 5v power but connecting that directly to the pi could cause damage as the pi gpios only want stuff at 3.3v.

So in a nutshell my question is would it be possible to use either of my max chips (232 with caps added to circuit or 233 with caps built within the IC already) with some sort of resistor or something between the chip and the pi to prevent problems?

Is it more complicated than that because data could be being sent at 5v and then I might need to convert it down to 3.3 for the pi? Or am I completely confused?


Thanks very much in advance for any help or guidance :)

martinw
Posts: 9
Joined: Mon Dec 29, 2014 3:17 pm

Re: Adding on board serial using max232/233 ic

Sun Dec 27, 2015 2:43 pm

I think this is what I need in between the pi and my max232 cable/circuit that will plug into the devices I need to communicate with
https://learn.sparkfun.com/tutorials/us ... -converter

So I'm still not really sure what I'm doing though lol but I'll be breaking out my breadboard and seeing how it goes later.

I suppose my main question is how important is it to pay attention to the 5v thing when trying to do serial communication?

My devices will all be self powered and so all I will be doing is connecting to the rx/tx/gnd/vcc with wires that go to the maxIC, wires from the ic to the corresponding tx/rx/gnd/vcc pins on pi gpio, but placing the LLC in between that the max circuit and the pi pins.

What would happen if trying to communicate via serial with a 5v device powered by mains, if I don't use the LLC ( I'd normally just try it and see lol but only working with one pi at the moment!)

Thanks

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: Adding on board serial using max232/233 ic

Sun Dec 27, 2015 3:03 pm

There's no need for a fancy level shifter, and it's only the Pi's RX you need to worry about too - the Pi's 3V3 TX logic should drive the MAX232's RX high.

To make a level shifter for the Pi's RX, all you need is a pair of resistors in series to divide the voltage, say 3K3 at the GND end & 2k2 at the MAX232 side, with the Pi's RX connected to the middle.

Alternatively, use a signal diode & resistor as shown in this investigation http://tansi.info/rp/interfacing5v.html. You could even put that circuit on bith TX & RX in case of wiring errors, as it will also provide improved protection for the Pi from the RS232 level signals if you really screw up!

klricks
Posts: 7172
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Adding on board serial using max232/233 ic

Sun Dec 27, 2015 3:24 pm

The best way is to use the max3232 with the vcc connected to 3v3 (not 5v).
If you use the max232 then the rx pin needs a 5 to 3v3 level shifter. A simple voltage divider can be used if the baud rate is not to high.
The tx pin usually can be used directly without level shifter.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

martinw
Posts: 9
Joined: Mon Dec 29, 2014 3:17 pm

Re: Adding on board serial using max232/233 ic

Sun Dec 27, 2015 3:28 pm

Thanks for your reply, it was really helpful and I understand what's going on a slight bit better now :).

Hopefully I'll have time this evening to wire it all up :)

Eventually I want to try using the pi for various multi-programmer tasks, but as I have a lot to learn I thought this would be as good a start as any :)

Thank you again for taking the time to reply :)

martinw
Posts: 9
Joined: Mon Dec 29, 2014 3:17 pm

Re: Adding on board serial using max232/233 ic

Sun Dec 27, 2015 3:34 pm

klricks wrote:The best way is to use the max3232 with the vcc connected to 3v3 (not 5v).
If you use the max232 then the rx pin needs a 5 to 3v3 level shifter. A simple voltage divider can be used if the baud rate is not to high.
The tx pin usually can be used directly without level shifter.
Thanks :)

Because I have a couple of max232 and max233 ic lying around I really want to use one of those :)

Baud rate for devices I'm using currently are 9600 and 115200, as I understand those are not too high so usong the voltage divider should work right?

I don't think I have those handy whereas I certainly have the resistors required for gregerics method.

Thanks for the help, I'll let you know how it goes :)

Return to “Interfacing (DSI, CSI, I2C, etc.)”