Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Setting baudrate of modem connected to CR1000


Lumox100 Oct 30, 2013 08:10 AM

I am trying to change the baudrate of a Maestro 100 GSM/GPRS modem, connected to a CR1000 via RS232 port, from 115200 to 9600 by sending the command "AT+IPR=9600" in a datalogger program. The reason I want to do this is that we have CR1000 in 3 buoys located 3-5km offshore around the South African coast, which I want to change to use FTP instead of dialing in using LoggerNet. Instead of having to go to each buoy and connecting directly to the datalogger/modem and configuring them, I want to send a program to the datalogger to do this remotely.

I have tried numerous ways but the baudrate refuses to change. On a test setup, connecting directly to the modem and sending the AT+IPR=9600 command works perfectly, but not via the program/datalogger. Is it not possible to send AT commands if the baudrate is 115200?

Here is the program I have created. The various Delay statements were added in case there were timing issues, but still no success.

Const CRLF = CHR(13)+CHR(10)

Public ModemState
Public CR1000State
Public s1 As String * 100
Public s2 As String * 100

DataTable(Modem_Res,True,-1)
Sample(1,ModemState,FP2)
Sample(1,s1,String)
Sample(1,s2,String)
EndTable

Sub CheckModem()
SerialClose(ComRS232)
Delay(1,10,Sec)
SerialOpen(ComRS232,-9600,0,0,1000)
SerialFlush(ComRS232)
SerialOut(ComRS232,"AT+IPR?"+CRLF,"",0,200)
If (SerialInChk(ComRS232) <> -1) Then
Delay(1,10,mSec)
SerialIn(s1,ComRS232,100,-1,100)
EndIf
SerialOut(ComRS232,"AT+CGDCONT?"+CRLF,"",0,200)
If (SerialInChk(ComRS232) <> -1) Then
Delay(1,10,mSec)
SerialIn(s2,ComRS232,100,-1,100)
EndIf
SerialClose(ComRS232)
EndSub

Function ConfigureModem()
Dim Failed
Failed=0
SerialClose(ComRS232)
Delay(1,10,Sec)
'-9600 - will try at 9600 but if unsuccessful, will go into autobaud mode (where it will try different rates
'until successful or until the instruction times out).
SerialOpen(ComRS232,-9600,0,0,1000)
Delay(1,5,Sec)
If (NOT SerialInChk(ComRS232)) Then Failed=-1
SerialOut(ComRS232,"AT+IPR=9600"+CRLF,"",0,200)
Delay(1,300,mSec)
SerialOut(ComRS232,"AT&W"+CRLF,"",0,200)
Delay(1,3,Sec)
SerialClose(ComRS232)
Delay(1,30,Sec)
SerialOpen(ComRS232,9600,0,0,1000)
Delay(1,5,Sec)
If (NOT SerialInChk(ComRS232)) Then Failed=-2
If (Failed=0) Then
SerialOut(ComRS232,"ATV1"+CRLF,"OK",1,200)
SerialOut(ComRS232,"ATE0"+CRLF,"OK",1,200)
SerialOut(ComRS232,"AT+WOPEN=0"+CRLF,"",0,200)
SerialOut(ComRS232,"AT+CGDCONT=1,""IP"",""INTERNET"""+CRLF,"",0,200)
SerialOut(ComRS232,"AT&W"+CRLF,"",0,200)
EndIf
'If ((Failed=0) AND (SerialOut(ComRS232,"ATE0"+CRLF,"OK",1,150) = 0)) Then Failed=1
'If ((Failed=0) AND (SerialOut(ComRS232,"AT+IPR=9600"+CRLF,"OK",1,200) = 0)) Then Failed=2
'If ((Failed=0) AND (SerialOut(ComRS232,"AT+WOPEN=0"+CRLF,"OK",1,200) = 0)) Then Failed=3
'If ((Failed=0) AND (SerialOut(ComRS232,"AT+CGDCONT=1,""IP"",""INTERNET"""+CRLF,"OK",1,200) = 0)) Then Failed=4
'If ((Failed=0) AND (SerialOut(ComRS232,"AT & W"+CRLF,"OK",1,200) = 0)) Then Failed=5
SerialClose(ComRS232)
Return Failed
EndSub

Function ConfigureCR1000()
Dim Success
Success=1
SetStatus("RS232Power",-1) 'set to -1 to check "Always On" option - not sure if is required
Success=2
SetStatus("BaudrateRS232",9600)
Success=3
SetStatus("pppInterface",1) '1=RS232
Success=4
SetStatus("pppDialResponse","0.0.0.0")
Success=5
SetStatus("pppDial","ATV1; AT+CGATT=1; AT+CGQREQ=1,0,0,3,0,0; ATDT*99***1#")
Success=6
SetStatus("pppDialResponse","CONNECT")
Success=7
Return Success
EndSub

SequentialMode
BeginProg
Delay(1,30,sec)
Scan(3,Min,1,0)
CheckModem()
CallTable(Modem_Res)
ModemState=ConfigureModem()
CR1000State=ConfigureCR1000()
NextScan

EndProg


Please can someone advise me as to what is wrong.

* Last updated by: Lumox100 on 10/30/2013 @ 2:16 AM *


aps Oct 30, 2013 03:23 PM

I think the flaw in your program is that you are opening the serial port with the setting of -9600 baud and then sending the baud rate command. If the modem is at 115200 originally you should use 115200 and then issue the IPR command.

To explain further, the autobaud rate options of the logger rely on it receiving a number of repeated characters to allow it to sync to the baud rate. That will not happen if the modem is sitting there in command mode waiting for the logger to send it commands. You need to fix the baud rate to match its initial setup speed.


Lumox100 Oct 31, 2013 07:05 PM

Thanks for the reply. I tried what you suggested with the following code.

Sub CheckModem()
SerialClose(ComRS232)
s1=""
s2=""
Delay(1,10,Sec)
SerialOpen(ComRS232,9600,0,3000,1000)
SerialFlush(ComRS232)
SerialOut(ComRS232,"AT+IPR?"+CRLF,"",0,500)
SerialIn(s1,ComRS232,500,-1,1000)
SerialOut(ComRS232,"AT+CGDCONT?"+CRLF,"",0,500)
SerialIn(s2,ComRS232,500,-1,1000)
SerialClose(ComRS232)
EndSub

Function ConfigureModem()
Dim Failed
Failed=0
SerialClose(ComRS232)
Delay(1,5,Sec)
If (SerialOpen(ComRS232,115200,0,0,1000)) Then
Failed=-1
SerialOut(ComRS232,"AT+IPR=9600"+CRLF,"",3,500)
Delay(1,300,mSec)
SerialOut(ComRS232,"AT&W"+CRLF,"",0,500)
Delay(1,3,Sec)
SerialClose(ComRS232)
EndIf
Delay(1,5,Sec)
If (SerialOpen(ComRS232,9600,0,0,1000) = False) Then Failed=-2
Delay(1,5,Sec)
SerialOut(ComRS232,"AT+WOPEN=0"+CRLF,"",0,500)
Delay(1,300,mSec)
SerialOut(ComRS232,"AT+CGDCONT=1,""IP"",""INTERNET_12"""+CRLF,"",0,500)
Delay(1,300,mSec)
SerialOut(ComRS232,"AT&W"+CRLF,"",0,500)
Delay(1,300,mSec)
SerialClose(ComRS232)
Return Failed
EndSub


Unfortunately, the baudrate still does not change. I let it run for awhile and the following is the output for the "CheckModem" function. It seemed to do something at 12:06, but returned garbage.

"TOA5","Induc_Test","CR1000","39022","CR1000.Std.25","CPU:SetupFTP_Modem_CR1000_v12.CR1","13269","Modem_Res"
"TIMESTAMP","RECORD","ModemState","s1","s2"
"TS","RN","","",""
"","","Smp","Smp","Smp"
"2013-10-31 11:18:00",0,0,"",""
"2013-10-31 11:20:00",1,-2,"",""
"2013-10-31 11:22:00",2,-2,"",""
"2013-10-31 11:24:00",3,-2,"",""
"2013-10-31 11:26:00",4,-2,"",""
"2013-10-31 11:28:00",5,-2,"",""
"2013-10-31 11:30:00",6,-2,"",""
"2013-10-31 11:32:00",7,-2,"",""
"2013-10-31 11:34:00",8,-2,"",""
"2013-10-31 11:36:00",9,-2,"",""
"2013-10-31 11:38:00",10,-2,"",""
"2013-10-31 11:40:00",11,-2,"",""
"2013-10-31 11:42:00",12,-2,"",""
"2013-10-31 11:44:00",13,-2,"",""
"2013-10-31 11:46:00",14,-2,"",""
"2013-10-31 11:48:00",15,-2,"",""
"2013-10-31 11:50:00",16,-2,"",""
"2013-10-31 11:52:00",17,-2,"",""
"2013-10-31 11:54:00",18,-2,"",""
"2013-10-31 11:56:00",19,-2,"",""
"2013-10-31 11:58:00",20,-2,"",""
"2013-10-31 12:00:00",21,-2,"",""
"2013-10-31 12:02:00",22,-2,"",""
"2013-10-31 12:04:00",23,-2,"",""
"2013-10-31 12:06:00",24,-2,"km","[m"
"2013-10-31 12:08:00",25,-2,"o","o"
"2013-10-31 12:10:00",26,-2,"{o","o"
"2013-10-31 12:12:00",27,-2,"ko",""
"2013-10-31 12:14:00",28,-2,"[{o","}ok"
"2013-10-31 12:16:00",29,-2,"[km","[}o"
"2013-10-31 12:18:00",30,-2,"{o","}m"
"2013-10-31 12:20:00",31,-2,"km","k[o"
"2013-10-31 12:22:00",32,-2,"ko","}o"
"2013-10-31 12:24:00",33,-2,"km","[mok"
"2013-10-31 12:26:00",34,-2,"[ko","[mm"
"2013-10-31 12:28:00",35,-2,"{m","m"
"2013-10-31 12:30:00",36,-2,"km","ok"
"2013-10-31 12:32:00",37,-2,"[{o","}m"

I feel it must be some sort of timing issue, but I have been trying for 2 days now with no success.

A sudden thought. Could it possibly be due to the RS232 port option "Always on" (RS232Power) being checked that it is not allowing the baudrate to be changed?

* Last updated by: Lumox100 on 10/31/2013 @ 1:13 PM *


aps Nov 1, 2013 01:11 PM

Having the always on setting may be the cause of the problem as I see your serialopen always seems to be failing after the first attempt. Try turning off that setting as it is rarely needed.

One other thing to try is to send a CRLF before sending the AT+IPR command. This will clear the modem command buffer, just in case it has caught and stored some bad characters at the wrong baud rate which may cause it to reject the AT command.


aps Nov 1, 2013 01:11 PM

Having the always on setting may be the cause of the problem as I see your serialopen always seems to be failing after the first attempt. Try turning off that setting as it is rarely needed.

One other thing to try is to send a CRLF before sending the AT+IPR command. This will clear the modem command buffer, just in case it has caught and stored some bad characters at the wrong baud rate which may cause it to reject the AT command.

Log in or register to post/reply in the forum.