Maker Pro
Maker Pro

how to connect max 232 to gps to get ttl output

bobdxcool

Mar 9, 2012
98
Joined
Mar 9, 2012
Messages
98
I have a gps board which has a gps module. I need to take ttl outputs from the board. But, the problem is the board already has a max 232 ic and the o/p is given to the rs 232 com port.

SO, i brought a max 232 ic board and will connect the rs 232 pin of max 232 to rs 232 of gps board. I need to take rx and tx output from max 232 now to connect it to arduin uno. How do I identify the tx and rx pins on board.

I am posting pictures below.
 

Attachments

  • 2013-02-05 19.07.44.jpg
    2013-02-05 19.07.44.jpg
    119.2 KB · Views: 188
  • 2013-02-06 02.11.43.jpg
    2013-02-06 02.11.43.jpg
    73.1 KB · Views: 193
  • 2013-02-06 02.12.00.jpg
    2013-02-06 02.12.00.jpg
    102.3 KB · Views: 152
  • 2013-02-05 19.07.13.jpg
    2013-02-05 19.07.13.jpg
    130.5 KB · Views: 167

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
Joined
Jan 21, 2010
Messages
25,505
If the original board has a max232, then you should be able to take the logic levels from the inputs to that chip. Having another max232 board seems like a waste.

If you do go that way, I'd guess the TX an RX pins are the ones labelled TX ad RX.

Failing that, use a multimeter t determine where the TX and RX pins on the DB9 connect to on the MAX232 and locate which pins connect to the board connect to the TTL versions of these.

Do you have the datasheet for the MAX232? Pins 12 amd 11 are the normal choice for TX and RX respectively. (which one is which depends on which way you look at things. Pin 11 in an input to the MAX232 from a uC (T1in) and Pin 12 is an output to the uC (R1out)
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
12,615
Joined
Nov 17, 2011
Messages
12,615
you should be able to take the logic levels from the inputs to that chip
That is the most simple soultion, but you have to remove the MAX232 from the gps board. Other wise the Rx-Output of the gps-board's MAX232 will interfere with the TX-data from the other board.

Otherwise, if you don't want to remove the MX232 from the gps board: Set-up the second MAX232 according to the standard application. Connect Tx-out from one board to Rx-in of the other board and vice versa.
 

bobdxcool

Mar 9, 2012
98
Joined
Mar 9, 2012
Messages
98
That is the most simple soultion, but you have to remove the MAX232 from the gps board. Other wise the Rx-Output of the gps-board's MAX232 will interfere with the TX-data from the other board.

Otherwise, if you don't want to remove the MX232 from the gps board: Set-up the second MAX232 according to the standard application. Connect Tx-out from one board to Rx-in of the other board and vice versa.

I am not understanding what you meant by "you should be able to take the logic levels from the inputs to that chip" .

Could you please explain in detail.

Also, is it possible to connect 2 small wires from rs 232 connector (tx n rx ) and connect it directly to arduino uno. Will it be possible, since it may not be ttl?
 

bobdxcool

Mar 9, 2012
98
Joined
Mar 9, 2012
Messages
98
That is the most simple soultion, but you have to remove the MAX232 from the gps board. Other wise the Rx-Output of the gps-board's MAX232 will interfere with the TX-data from the other board.

Otherwise, if you don't want to remove the MX232 from the gps board: Set-up the second MAX232 according to the standard application. Connect Tx-out from one board to Rx-in of the other board and vice versa.

If the original board has a max232, then you should be able to take the logic levels from the inputs to that chip. Having another max232 board seems like a waste.

If you do go that way, I'd guess the TX an RX pins are the ones labelled TX ad RX.

Failing that, use a multimeter t determine where the TX and RX pins on the DB9 connect to on the MAX232 and locate which pins connect to the board connect to the TTL versions of these.

Do you have the datasheet for the MAX232? Pins 12 amd 11 are the normal choice for TX and RX respectively. (which one is which depends on which way you look at things. Pin 11 in an input to the MAX232 from a uC (T1in) and Pin 12 is an output to the uC (R1out)



Or perhaps I can do the most easiest thing.

I can solder two wires from beneath the board (for rx and tx) of gps module (ttl ) as i know which pin is what from data sheet of gps module and connect to tx and rx of arduino respectively. But i would leave the max ic intact on the board itself and leave the rs 232 port on the board unused , but power the gps module using 12 v adapter provided on board.

What do you think?
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
12,615
Joined
Nov 17, 2011
Messages
12,615
i would leave the max ic intact on the board itself

Nay, as I said, the Rx (TTL-Output) of the MAX232 will interfere with the Tx (TTL-output) from the other board. Renove the MAX232 or use a second one, as you originally meant to do and connnect TX<>Rx and vice versa.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
12,615
Joined
Nov 17, 2011
Messages
12,615
Will it be possible, since it may not be ttl?
It is possible and it will definitely destroy the arduino.
Don't do it. RS232 is way off from TTL. Do not mix these signals.
 

bobdxcool

Mar 9, 2012
98
Joined
Mar 9, 2012
Messages
98
It is possible and it will definitely destroy the arduino.
Don't do it. RS232 is way off from TTL. Do not mix these signals.



Or perhaps I can do the most easiest thing, and not use max 232 at all as i need just the ttl which the gps module directly gives.

I can solder two wires from beneath the board (for rx and tx) of gps module (ttl ) as i know which pin is what (from data sheet of gps module) and connect to tx and rx of arduino respectively. But i would leave the max ic intact on the board itself and leave the rs 232 port on the board unused , but power the gps module using 12 v adapter provided on board.

That is i will bypass that max ic on the board and leave it unused.

What do you think?
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
12,615
Joined
Nov 17, 2011
Messages
12,615
That is i will bypass that max ic on the board and leave it unused.
Re-reaad my answer, I told you explicitely not to do that and also explained why.


If you don't understand this simple explanation, then what you are trying to do is probably not within your league.
 

bobdxcool

Mar 9, 2012
98
Joined
Mar 9, 2012
Messages
98
Re-reaad my answer, I told you explicitely not to do that and also explained why.


If you don't understand this simple explanation, then what you are trying to do is probably not within your league.

If the original board has a max232, then you should be able to take the logic levels from the inputs to that chip. Having another max232 board seems like a waste.

If you do go that way, I'd guess the TX an RX pins are the ones labelled TX ad RX.

Failing that, use a multimeter t determine where the TX and RX pins on the DB9 connect to on the MAX232 and locate which pins connect to the board connect to the TTL versions of these.

Do you have the datasheet for the MAX232? Pins 12 amd 11 are the normal choice for TX and RX respectively. (which one is which depends on which way you look at things. Pin 11 in an input to the MAX232 from a uC (T1in) and Pin 12 is an output to the uC (R1out)


Guys, I tried connecting gsm and gps modules (ttl pins) to tx n rx of arduino. It did not work.

I am totally confused.

This is what I did.

1. I soldered two wires from tx and rx pins of my gps and gsm boards.

2. I connected the tx pin of gsm to rx pin (pin 0) of arduino uno and rx of gsm to tx (pin1) of
arduino. I did this for both gsm and gps modules separately.

3. I just made 2 connections b/w arduino and gsm/gps. No other connections. I powered both the modules using 12v ac/dc adapter connected to the power pin provided on the board. I did not connect the grounds of gsm/gps to arduino or to each other.

GSM module used- sim300
GPS module used- Holux GR-87- baud-4800


The arduino tx and rx pins give 5v, whereas the gps and gsm modules (not boards) rx and tx pins give voltage under 4v (3.3v, 2.9v) .

Is this the problem?

Please help.


This is code for testing gsm-sending message to a number

Code:
#include <NewSoftSerial.h>
NewSoftSerial cell(0,1); 
char mobilenumber[] = "xxxxxxxxx";  // Replace xxxxxxxx with the recipient's mobile number
void setup()
{  //Initialize serial ports for communication.
cell.begin(4800);
delay(3500); // give the GSM module time to initialise, locate network etc.
// this delay time varies. Use example 26.1 sketch to measure the amount
// of time from board reset to SIND: 4, then add five seconds just in case
}
void loop()
{
cell.println("AT+CMGF=1"); // set SMS mode to text
cell.print("AT+CMGS=");  // now send message...
cell.print(34,BYTE); // ASCII equivalent of "
cell.print(mobilenumber);
cell.println(34,BYTE);  // ASCII equivalent of "
delay(500); // give the module some thinking time
cell.print("They call me the count... because I like to count! Ah ha ha ha");   // our message to send
cell.println(26,BYTE);  // ASCII equivalent of Ctrl-Z
delay(15000); // the SMS module needs time to return to OK status
do // You don't want to send out multiple SMSs.... or do you?
{
delay(1);
}
while (1>0);
}

Code for testing gps

Code:
#include <NewSoftSerial.h>

#include <TinyGPS.h>

/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of NewSoftSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 0(rx) and 1(tx).
*/

TinyGPS gps;
NewSoftSerial nss(0, 1);

static void gpsdump(TinyGPS &gps);
static bool feedgps();
static void print_float(float val, float invalid, int len, int prec);
static void print_int(unsigned long val, unsigned long invalid, int len);
static void print_date(TinyGPS &gps);
static void print_str(const char *str, int len);

void setup()
{
  Serial.begin(115200);
  nss.begin(4800);
  
  Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
  Serial.print("Sizeof(gpsobject) = "); Serial.println(sizeof(TinyGPS));
  Serial.println();
  Serial.println("Sats HDOP Latitude Longitude Fix  Date       Time       Date Alt     Course Speed Card  Distance Course Card  Chars Sentences Checksum");
  Serial.println("          (deg)    (deg)     Age                        Age  (m)     --- from GPS ----  ---- to London  ----  RX    RX        Fail");
  Serial.println("--------------------------------------------------------------------------------------------------------------------------------------");
}

void loop()
{
  bool newdata = false;
  unsigned long start = millis();
  
  // Every second we print an update
  while (millis() - start < 1000)
  {
    if (feedgps())
      newdata = true;
  }
  
  gpsdump(gps);
}

static void gpsdump(TinyGPS &gps)
{
  float flat, flon;
  unsigned long age, date, time, chars = 0;
  unsigned short sentences = 0, failed = 0;
  static const float LONDON_LAT = 51.508131, LONDON_LON = -0.128002;
  
  print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 5);
  print_int(gps.hdop(), TinyGPS::GPS_INVALID_HDOP, 5);
  gps.f_get_position(&flat, &flon, &age);
  print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 9, 5);
  print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 10, 5);
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);

  print_date(gps);

  print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 8, 2);
  print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
  print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2);
  print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(gps.f_course()), 6);
  print_int(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0UL : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9);
  print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : TinyGPS::course_to(flat, flon, 51.508131, -0.128002), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
  print_str(flat == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON)), 6);

  gps.stats(&chars, &sentences, &failed);
  print_int(chars, 0xFFFFFFFF, 6);
  print_int(sentences, 0xFFFFFFFF, 10);
  print_int(failed, 0xFFFFFFFF, 9);
  Serial.println();
}

static void print_int(unsigned long val, unsigned long invalid, int len)
{
  char sz[32];
  if (val == invalid)
    strcpy(sz, "*******");
  else
    sprintf(sz, "%ld", val);
  sz[len] = 0;
  for (int i=strlen(sz); i<len; ++i)
    sz[i] = ' ';
  if (len > 0) 
    sz[len-1] = ' ';
  Serial.print(sz);
  feedgps();
}

static void print_float(float val, float invalid, int len, int prec)
{
  char sz[32];
  if (val == invalid)
  {
    strcpy(sz, "*******");
    sz[len] = 0;
        if (len > 0) 
          sz[len-1] = ' ';
    for (int i=7; i<len; ++i)
        sz[i] = ' ';
    Serial.print(sz);
  }
  else
  {
    Serial.print(val, prec);
    int vi = abs((int)val);
    int flen = prec + (val < 0.0 ? 2 : 1);
    flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
    for (int i=flen; i<len; ++i)
      Serial.print(" ");
  }
  feedgps();
}

static void print_date(TinyGPS &gps)
{
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned long age;
  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  if (age == TinyGPS::GPS_INVALID_AGE)
    Serial.print("*******    *******    ");
  else
  {
    char sz[32];
    sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d   ",
        month, day, year, hour, minute, second);
    Serial.print(sz);
  }
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
  feedgps();
}

static void print_str(const char *str, int len)
{
  int slen = strlen(str);
  for (int i=0; i<len; ++i)
    Serial.print(i<slen ? str[i] : ' ');
  feedgps();
}

static bool feedgps()
{
  while (nss.available())
  {
    if (gps.encode(nss.read()))
      return true;
  }
  return false;
}


This code gave number of received characters, but did not show any latitude and longitude.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
Joined
Jan 21, 2010
Messages
25,505
Try swapping TX and RX at one end.

Did you remove the max232 chip on the gps, or are you using the max232 outputs?

try placing a LED and a resistor from pins 1 and 2 to ground so you can see which signal is asserted and when.
 

davenn

Moderator
Sep 5, 2009
14,043
Joined
Sep 5, 2009
Messages
14,043
Guys, I tried connecting gsm and gps modules (ttl pins) to tx n rx of arduino. It did not work.

I am totally confused.

This is what I did.

1. I soldered two wires from tx and rx pins of my gps and gsm boards.

2. I connected the tx pin of gsm to rx pin (pin 0) of arduino uno and rx of gsm to tx (pin1) of
arduino. I did this for both gsm and gps modules separately.

3. I just made 2 connections b/w arduino and gsm/gps. No other connections. I powered both the modules using 12v ac/dc adapter connected to the power pin provided on the board. I did not connect the grounds of gsm/gps to arduino or to each other.

GSM module used- sim300
GPS module used- Holux GR-87- baud-4800


The arduino tx and rx pins give 5v, whereas the gps and gsm modules (not boards) rx and tx pins give voltage under 4v (3.3v, 2.9v) .

Is this the problem?

Please help.

Why are you suprised that it didnt work ?

Its exactly what Harald told you not to do
You cannot mix TTL and RS232 signals

Its really a bit difficult for the guys gere to help you if you just continue to ignore the advice given !!

Dave
 

bobdxcool

Mar 9, 2012
98
Joined
Mar 9, 2012
Messages
98
Why are you suprised that it didnt work ?

Its exactly what Harald told you not to do
You cannot mix TTL and RS232 signals

Its really a bit difficult for the guys gere to help you if you just continue to ignore the advice given !!

Dave

Sir, I have not mixed these signals. I have directly taken the output from the gps module (gr-87) which gives a ttl output, I have not used max 232 on board. I have connected these pins directly to arduino which I believe also has ttl serial tx and rx pins.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
Joined
Jan 21, 2010
Messages
25,505
And you've removed the max232 from the gps board? (or disconnected the connection to the GPS's receive data pin)
 

bobdxcool

Mar 9, 2012
98
Joined
Mar 9, 2012
Messages
98
Try swapping TX and RX at one end.

Did you remove the max232 chip on the gps, or are you using the max232 outputs?

try placing a LED and a resistor from pins 1 and 2 to ground so you can see which signal is asserted and when.

No, sir , I left the IC intact. I did not use the max 232 chip at all. I just soldered two wires, one for tx and one for rx (after identifying the pins on the datasheet) from beneath the pcb.

I am just using the board for providing power supply to gps module.

I have not connected the gnd pin from gps module to arduino gnd.

I think may be this also might be one problem.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
12,615
Joined
Nov 17, 2011
Messages
12,615
I did not connect the grounds of gsm/gps to arduino or to each other.
You need to connect GND. Otherwise there is no reference potential for the chips on both boards.

which I believe also has ttl serial tx and rx pins.
believe it or not. Don't trust your imagination, look up the correct levels and pinouts in the datasheet.

Also, I repeat one last time: Do not connect TTL and RS232 directly. Chances are the TTL-level chips wil be destroyed. If you want to use TTL level, remove the MAX232 chips.
 

bobdxcool

Mar 9, 2012
98
Joined
Mar 9, 2012
Messages
98
And you've removed the max232 from the gps board? (or disconnected the connection to the GPS's receive data pin)

No, sir the max 232 ic is intact on the board, and I have not disconnected the max 232 connection to gps module.
 

bobdxcool

Mar 9, 2012
98
Joined
Mar 9, 2012
Messages
98
You need to connect GND. Otherwise there is no reference potential for the chips on both boards.

believe it or not. Don't trust your imagination, look up the correct levels and pinouts in the datasheet.

Also, I repeat one last time: Do not connect TTL and RS232 directly. Chances are the TTL-level chips wil be destroyed. If you want to use TTL level, remove the MAX232 chips.

Sorry sir I will remove the max ic from the board so that there is no interference.

But I think I need to ensure that there is no open circuit on the gps board, since I have now removed the max 232 ic.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
Joined
Jan 21, 2010
Messages
25,505
The problem (or at least one of them) is that the max232's output (which goes to the receive data pin on the GPS chip) will be solidly pulled to some logic level.

When you try to send data to it from the arduino, it will essentially short it out.

Another issue is that the GPS chip may be 3.3V and your arduino is almost certainly 5V. When it drives the signal high, it may damage the gps unless it has 5V tolerant inputs.

As Harald suggests, getting hold of the datasheets is probably the first thing you need to do before interfacing a pair of chips you've not interfaced before.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
12,615
Joined
Nov 17, 2011
Messages
12,615
Once you have connected Tx and Rx, there will be no open circuit.
 
Top