CS-GSM/GPRS Digital Transceiver Kits (including the COM110 modem)
B-2
B1.1 CRBasic Program Example of Power Control
This example can be used on the CR800 series, CR1000 and CR3000 dataloggers.
It uses the standard CRBasic serialopen, serialout and serialclose commands to
send out configuration commands to the modem. The example shows using a slow
sequence to turn on and then turn off the modem after 5 minutes. When it comes
to turn off the modem it sets a flag. If communications are still active the modem
is not turned off unless a full 15 minutes have expired since it was turned on.
This example also shows how to log off the network before power is turned off
(using AT+CFUN=0).
'CR1000 Series Datalogger
'Example program showing how to turn on/off a GSM modem
'This example only turns on the modem for 5 minutes, but extends the time on for up
'to 15 minutes if the com port is active when it is time to shutdown.
'Also includes the correct sequence to shutdown the modem cleanly before turning
'off the power.
'The modem control is done in a slow sequence to avoid interference with measurements
'Declare Public Variables
'Example:
Public PTemp, batt_volt
'Main Program
BeginProg
'Normal measurements in the main scan here
Scan (1,Sec,0,0)
PanelTemp (PTemp,250)
Battery (Batt_volt)
'......etc
NextScan
'-------------------------------------------------------------------
'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
SlowSequence
'Run once a minute so can have one minute resolution of timing
Scan (1,Min,3,0)
'Every hour, in this example, turn on the modem
If TimeIntoInterval (0,60,Min) Then
'Set port 1 to 1 (ON) (use writeio as in slowsequence)
WriteIO (&B00000001,1)
Delay(1,2,sec) 'Allow 2 seconds for the modem to power on
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,60,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 (NOT status.commactiveRS232)) OR TimeIntoInterval(15,60,min)
Then
SerialOpen (Modemport,Modembaud,0,0,100)
'Send the command to log off the network and shutdown cleanly, wait up to 3 sec.