Author Topic: 8 wire RS232 to microcontroler  (Read 4108 times)

0 Members and 1 Guest are viewing this topic.

Offline skipper762Topic starter

  • Contributor
  • Posts: 11
  • Country: nz
8 wire RS232 to microcontroler
« on: April 19, 2016, 01:31:17 am »
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 AtMEGA328p

The modem is question is a HUAWEI MG323-B:
Datasheet: http://www.farnell.com/datasheets/1696743.pdf

The 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 :)

 

Offline ChristofferB

  • Frequent Contributor
  • **
  • Posts: 929
  • Country: dk
  • Chemistry phd student!
    • My channel:
Re: 8 wire RS232 to microcontroler
« Reply #1 on: April 19, 2016, 12:43:39 pm »
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.

 
--Christoffer //IG:Chromatogiraffery
Check out my scientific instruments diy (GC, HPLC, NMR, etc) Channel: https://www.youtube.com/channel/UCZ8l6SdZuRuoSdze1dIpzAQ
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4193
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: 8 wire RS232 to microcontroler
« Reply #2 on: April 19, 2016, 02:32:06 pm »
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.
 

Offline skipper762Topic starter

  • Contributor
  • Posts: 11
  • Country: nz
Re: 8 wire RS232 to microcontroler
« Reply #3 on: April 19, 2016, 10:23:01 pm »
Thanks for your help
I 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
 

Offline skipper762Topic starter

  • Contributor
  • Posts: 11
  • Country: nz
Re: 8 wire RS232 to microcontroler
« Reply #4 on: April 21, 2016, 09:14:41 am »
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 ?
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3327
  • Country: gb
Re: 8 wire RS232 to microcontroler
« Reply #5 on: April 21, 2016, 12:47:03 pm »
To fully loop back all the handshake lines you can also connect DTR to both DSR and DCD.
 

Offline retrolefty

  • Super Contributor
  • ***
  • Posts: 1648
  • Country: us
  • measurement changes behavior
Re: 8 wire RS232 to microcontroler
« Reply #6 on: April 21, 2016, 03:28:34 pm »
To fully loop back all the handshake lines you can also connect DTR to both DSR and DCD.

 Those are all output signals that should never be wired together?

 

Offline Wilksey

  • Super Contributor
  • ***
  • Posts: 1329
Re: 8 wire RS232 to microcontroler
« Reply #7 on: April 21, 2016, 08:44:24 pm »
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.
 

Offline skipper762Topic starter

  • Contributor
  • Posts: 11
  • Country: nz
Re: 8 wire RS232 to microcontroler
« Reply #8 on: April 21, 2016, 08:49:07 pm »
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 input
DSR & 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 needed

EDIT: 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?
« Last Edit: April 21, 2016, 09:03:07 pm by skipper762 »
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2507
  • Country: gb
Re: 8 wire RS232 to microcontroler
« Reply #9 on: April 21, 2016, 09:28:04 pm »
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 high

Ignore all other wires and try talking to it.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4311
  • Country: us
Re: 8 wire RS232 to microcontroler
« Reply #10 on: April 22, 2016, 06:09:36 am »
Quote
I am trying to interface a GSM modem
There'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 even AS ORIGINALLY DEFINED in 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. :-( )
 

Offline Wilksey

  • Super Contributor
  • ***
  • Posts: 1329
Re: 8 wire RS232 to microcontroler
« Reply #11 on: April 22, 2016, 11:15:26 am »
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.htm

If 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.
 

Offline macboy

  • Super Contributor
  • ***
  • Posts: 2288
  • Country: ca
Re: 8 wire RS232 to microcontroler
« Reply #12 on: April 22, 2016, 04:16:56 pm »
To fully loop back all the handshake lines you can also connect DTR to both DSR and DCD.

 Those are all output signals that should never be wired together?
Computer 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".
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf