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.

controlling power supply of fastrack gprs modem


graywacke Jul 17, 2013 04:21 AM

I tried using the program to control the power supply of fastrack modem from the Appendix B of CS-GSM transceiver kits but the compiling was not successful. The prompt says that the WriteIO (&B00000001, 1) already in use.

Is there any way that i can sort this out? or any simple program that can power on the fastrack model every 6 hours just to send data to an FTP server and power down after 5 minutes when the communication was done?


aps Jul 17, 2013 11:57 AM

I have just extracted the program from the last published version of the CS-GSM manual and after editing errors caused by the cut and paste process it compiled OK. Maybe you have added other code in the main body of your program that conflicted with that code, or perhaps have a different version of that manual.

Anyway just to go over the principles you either need to connect the power of the modem via a separate power switch (PSW12 is the Euro part) which is controlled by a logger control port or connect it to the SW12 output of the logger, if this is free.

I have taken the slowsequence code out of the manual and added some extra code to control the GPRS connection and included an FTPClient which you can tailor to your needs.

I cannot check this works but it should be close to what you need.

Andrew


'-------------------------------------------------------------------
'Modem control slow sequence - can be cut and pasted as self-contained
'Set this constant to match the port the modem is connected to
Const Modemport=COMRS232
Const Modembaud = 115200 'Change to match modem baud rate
Public timetogooff As Boolean, ftpdone
SlowSequence
'Run once a minute so can have one minute resolution of timing
Scan (1,Min,3,0)
'Every 6 hours, in this example, turn on the modem
If TimeIntoInterval (0,360,Min) Then
'Assumes the power is controlled via power switch on C1
'Change to the SW12 instruction is using the SW12 output otherwise
'Set port 1 to 1 (ON) (use writeio so works in pipelinemode in a slowsequence)
WriteIO (&B00000001,1)
Delay(1,2,sec) 'Allow 2 seconds for the modem to power on
SerialOpen (Modemport,Modembaud,0,0,100)
'Send the command to allow low power shutdown
'between calls (Wavecom specific)
SerialOut (Modemport,"AT+W32K=1"+CHR(13),"0"+CHR(13),1,100)
SerialClose(Modemport)
PPPOpen
EndIf

'An example of calling the FTPClient instruction, one minute after power up
'(to allow for connection etc). More intelligence could be added here to check the PPP state
If TimeIntoInterval (1,360,Min) Then
ftpdone =FTPClient ("IPAddress","UserName","Password","USR:Filename","Path/Filename",2,10,0,Sec,9)
EndIf

'5 minutes later turn the modem off if it is not online
'First set a variable to indicate the 5 min time has passed
If TimeIntoInterval (5,360,Min) Then timetogooff=true
'If time to go off also check we are offline OR that 15 mins has not passed
'i.e. shutdown at 15 mins anyway
'NOTE: edit the commactive variable to match the serial port being used for the modem
If (timetogooff AND ftpdone<>0) OR TimeIntoInterval(15,60,min) Then
PPPClose 'For GPRS comms
SerialOpen (Modemport,Modembaud,0,0,100)
'Send the command to log off the network and shutdown cleanly, wait up to 3 sec.
'First send the +++ sequence to get the modem in command mode - in case online
SerialOut (Modemport,"+++","0"+CHR(13),1,150)
SerialOut (Modemport,"AT+CFUN=0"+CHR(13),"0"+CHR(13),1,300)
'Delay To allow deregistration
Delay (1,2,sec)
SerialClose(Modemport)
'Set port 1 to 0 (LOW)
WriteIO (&B00000001,0)
timetogooff=false
EndIf
'--------------------------------------------------------------------
NextScan


graywacke Jul 20, 2013 05:02 AM

Sir Aps,

Thanks for the code. I incorporated the code yesterday but when it was compiled by the logger, I got two line error:

Line 328 Control port: C1 already in use or unavailable cannot be use in WriteIO
Line 357 Control port: C1 already in use or unavailable cannot be use in WriteIO

All those line have the code WriteIO (&B00000001, 0).

What do you think is the problem with it?


aps Jul 22, 2013 08:01 AM

I cannot say without seeing the rest of your program which may be using the control ports in another way.

If it is not critical to run your program in Pipleline mode you can change the writeio instructions to PortSet which just specifies a single port (if the control line to the power switch is connected to a control port) or SW12 if you are controlling the power via the SW12 line on the wiring panel.

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