8 wire RS232 to microcontroler - Page 1
Forum section: electronics / projects

author: skipper762
author_rank: Contributor
timestamp: April 19, 2016, 01:31:17 am
content: Hi everyone,I'm a bit new to interfacing with micros that aren't not on an dev board (arduino etc).I am trying to interface a GSM modem to an AtMEGA328pThe modem is question is a HUAWEI MG323-B:Datasheet:http://www.farnell.com/datasheets/1696743.pdfThe modem specifies 8 wire RS232 standard (Page 25 of datasheet)How do i interface this to a microcontroller.. do i need an level converter (MAX3232 or similar)?Also can i just forget about the other lines and only focus on RS, TX and ground...?Thanks in advance for your help

author: ChristofferB
author_rank: Frequent Contributor
timestamp: April 19, 2016, 12:43:39 pm
content: Well a lot of those 8 pins are the classic RS232 handshaking lines, which the atmega controllers don't support directly (you could probably write up some code to handle them)-but the datasheet mentions that "...recommended that you use the MAX3232 chip with a 2-wire serial port" - so it looks like it can operate as just RX/TX and GND mode. Might need to handshake loop the device (CTS to RTS, for example).It seems they recommend a max3232 for connecting the device to an RS232 port. You don't need that, of course, because you interface directly to a microcontroller. Only issue is: if it needs a max3232, it's probably a 3-volt thing, so you might need to boost that to 5V.I'm not certain, though. Haven't worked much with either.

author: Jeroen3
author_rank: Super Contributor
timestamp: April 19, 2016, 02:32:06 pm
content: It does not look like they have RS-232 voltage levels. They keep calling it UART1 and say 3.4V as max input.You can use a level shifting buffer (eg: 74LVC4245) if you really want to. But an ATmega running at 3.3V will work just fine.

author: skipper762
author_rank: Contributor
timestamp: April 19, 2016, 10:23:01 pm
content: Thanks for your helpI have the Atmega at 3.3V so i shouldn't have any level problems there.ChristofferB When you mention handshake loop, can you expand on that a little bit?I have only ever user 3 wire serial so all this handshaking/ flow control stuff is a bit perplexing

author: skipper762
author_rank: Contributor
timestamp: April 21, 2016, 09:14:41 am
content: I would like to implement all this pins, but i don't have space on my micro(That i already have)So I have tried to implement handshake looping, this is what i have so far..Does this look right to you experienced folk ?

author: mikerj
author_rank: Super Contributor
timestamp: April 21, 2016, 12:47:03 pm
content: To fully loop back all the handshake lines you can also connect DTR to both DSR and DCD.

author: retrolefty
author_rank: Super Contributor
timestamp: April 21, 2016, 03:28:34 pm
content: Quote from: mikerj on April 21, 2016, 12:47:03 pmThose are all output signals that should never be wired together?

author: Wilksey
author_rank: Super Contributor
timestamp: April 21, 2016, 08:44:24 pm
content: That is one confusing and typo-d datasheet!The UART1 (or URAT!?!) is TTL level, the only thing you might need if interfacing to 5V micro (now or in future) is the TX from the Micro (so RX on the module) to go through a level shifter down to GSM Module VCC (3.3V for ex), if you already have a 3.3V micro then you don't need to worry, the RX on the micro should see 2.85V+ as a logic high in any case (double check!)The only other pin that is useful apart from RX and TX is RING, this can be connected to GPIO direct as it is an output from the GSM module.RTS and CTS, DTR and DSR etc can be looped back or left open and just turn off the appropriate flow control (AT command set unless already turned off).ONE thing to keep in mind, on some of the Cinterion chipsets you need the handshaking lines to upload new firmware to the GSM / 3G module. Just something to bear in mind for future.

author: skipper762
author_rank: Contributor
timestamp: April 21, 2016, 08:49:07 pm
content: Wilksey i fully agree, it's part of the reason i am struggling so much! Can you recomend a good guide on AT commands, most of the guides i have found a very half assed?According to the data sheet:DTR is an inputDSR & DCD are outputs.I will loop these up with jumpers so that i can try running the system without any handshaking, then put the jumpers in if neededEDIT: I should also add that i'm planning on using the GSM modem for outgoing text based coms only, so i shouldn't need the ring line?

author: NivagSwerdna
author_rank: Super Contributor
timestamp: April 21, 2016, 09:28:04 pm
content: Looks like logic levels so put all thoughts of RS232 and MAX chips out of your head.Get something friendly like a Arduino or just a USB to TTL serial adapter and worry only about TX and RX.You need RX to go to TX and vice versa.RTS and DTR are Inputs on the modem chip so pull them highIgnore all other wires and try talking to it.

author: westfw
author_rank: Super Contributor
timestamp: April 22, 2016, 06:09:36 am
content: QuoteThere's some possibility that since this is a MODEM, and a Radio-based (inherently half-duplex) MODEM at that, that you will actually have to pay attention to (and manipulate) the MODEM control signals like RTS/CTS and DSR/DTR, perhaps evenAS ORIGINALLY DEFINEDin the RS232 spec (ie NOT "just" "hardware flow control".)Briefly and approximately:wait for RI to indicate incoming call.Asssert DTR to accept call (or initiate outgoing call)wait for DSR to indicate connection with remote modem.(Accept data in this state.)(if data to send, assert RTS, wait for CTS, send data, de-assert RTS when done. You can think of asserting RTS as turning on the transmitter radio, and CTS indicating that it is on...)(I can't tell from the manual whether any of this is needed. :-( )

author: Wilksey
author_rank: Super Contributor
timestamp: April 22, 2016, 11:15:26 am
content: The RING line can sometimes notify you of incoming SMS (depends on the module, so read the DS), if that particular module doesn't have that feature then no - you don't need it.Jumpers are a good idea for a prototype for the flow control lines.You can download the AT command guide here:http://consumer.huawei.com/en/solutions/m2m-solutions/products/support/user-guides/mg323-b-en.htmIf I were you I would build a prototype with jumpers on the lines as you have suggested you would and play around with some AT commands.

author: macboy
author_rank: Super Contributor
timestamp: April 22, 2016, 04:16:56 pm
content: Quote from: retrolefty on April 21, 2016, 03:28:34 pmComputer asserts DTR when the port is opened. This is commonly looped back to DSR and DCD (inputs at the computer side) to mimic the modem saying both "ready" and "connected".