Difference between revisions of "Radio on - off example"

From IARC 207 Wiki
Jump to navigation Jump to search
Line 1: Line 1:
 +
This code can be used with CR Basic compatible Campbell Scientific data loggers to power up & down the radio.  To leave the radio on, in the Connect view, set the variable (user editable in this case) '''radioflag''' to ''true''.  When you are ready to leave the radio in the off state (winter for example) set the '''radioflag''' to ''false''.  Then, to further reduce power consumption you can direct loggernet to turn the radio off after the data retrieval is complete.  To do this using the cora command library on linux:
 +
<pre>
 +
echo "connect localhost; set-variable Radio_Accessible_Site Public commscomplete {} true; quit;" | /opt/CampbellSci/LoggerNet/cora_cmd
 +
</pre>
 +
 +
Or, from windows, put the following into a DOS batch file:
 +
<pre>
 +
"c:\Program Files (x86)\Campbellsci\LoggerNet\cora_cmd.exe" < c:\CampbellSci\cora\radio_off.txt
 +
</pre>
 +
 +
radio_off.txt contains:
 +
<pre>
 +
connect localhost;
 +
set-variable Radio_Acessible_Site Public commscomplete {} true;
 +
quit;
 +
</pre>
 +
 +
 +
What follows is the code for the CR Basic Editor. A further modification would be to make the TimeIntoInterval commands use variables for the on & off times.
 +
 
<pre>
 
<pre>
  
Line 28: Line 48:
 
     ''''''''''''''''''''''''''''''''''''''''''''''''''''
 
     ''''''''''''''''''''''''''''''''''''''''''''''''''''
 
     ''''''''''''''''''''''''''''''''''''''''''''''''''''
 
     ''''''''''''''''''''''''''''''''''''''''''''''''''''
      If radioflag=true Then SW12(1)
+
    If radioflag=true Then SW12(1)
      ' if the battery voltage is high then turn the radio on hourly  
+
 
      If TimeIntoInterval(0,60,min) Then
+
    ' if the battery voltage is high then turn the radio on hourly  
 +
    If TimeIntoInterval(0,60,min) Then
 
         If batt_volt >= 12.4 Then  
 
         If batt_volt >= 12.4 Then  
 
           SW12(1)
 
           SW12(1)
 
         EndIf
 
         EndIf
      EndIf
+
    EndIf
      ' if the battery voltage isn't too low, turn the radio on daily.
+
    ' if the battery voltage isn't too low, turn the radio on daily.
      If TimeIntoInterval(720,1440,min) Then
+
    If TimeIntoInterval(720,1440,min) Then
 
         If batt_volt >= 12.2 Then  
 
         If batt_volt >= 12.2 Then  
 
           SW12(1)
 
           SW12(1)
 
         EndIf
 
         EndIf
      EndIf
+
    EndIf
      ' if the radioflag hasn't been set manually then turn the radio off 10 minutes into the hour.
+
    ' if the radioflag hasn't been set manually then turn the radio off 10 minutes into the hour.
      If TimeIntoInterval(10,60,min) OR commscomplete = true Then
+
    If TimeIntoInterval(10,60,min) OR commscomplete = true Then
 
         If radioflag = false Then  
 
         If radioflag = false Then  
 
           SW12(0)
 
           SW12(0)
 
           commscomplete = false
 
           commscomplete = false
 
         EndIf
 
         EndIf
      EndIf       
+
    EndIf       
      If batt_volt < 12.6 Then radioflag = false
+
    If batt_volt < 12.6 Then radioflag = false
  
 
</pre>
 
</pre>
 
 
A further modification would be to make the TimeIntoInterval commands use variables for the on & off times.
 

Revision as of 14:29, 19 October 2015

This code can be used with CR Basic compatible Campbell Scientific data loggers to power up & down the radio. To leave the radio on, in the Connect view, set the variable (user editable in this case) radioflag to true. When you are ready to leave the radio in the off state (winter for example) set the radioflag to false. Then, to further reduce power consumption you can direct loggernet to turn the radio off after the data retrieval is complete. To do this using the cora command library on linux:

echo "connect localhost; set-variable Radio_Accessible_Site Public commscomplete {} true; quit;" | /opt/CampbellSci/LoggerNet/cora_cmd

Or, from windows, put the following into a DOS batch file:

"c:\Program Files (x86)\Campbellsci\LoggerNet\cora_cmd.exe" < c:\CampbellSci\cora\radio_off.txt

radio_off.txt contains:

connect localhost;
set-variable Radio_Acessible_Site Public commscomplete {} true;
quit;


What follows is the code for the CR Basic Editor. A further modification would be to make the TimeIntoInterval commands use variables for the on & off times.


' Wiring:
' SW12V -- Radio Power

    ''' Diagnostic Variables
    Public batt_volt
    Public Flag(8) As Boolean
    Public radioflag As Boolean  
    Public commscomplete As Boolean

BeginProg

  commscomplete = false
  radioflag=true  
  SW12 (1 )  ' turn on the radio
  Scan(30,Sec, 10, 0)
    '''''''''''''''''''''''''''''''''
    '''''''''''''''''''''''''''''''''
    '' Diagnostic Measurements  '''''
    '''''''''''''''''''''''''''''''''
    '''''''''''''''''''''''''''''''''    
    Battery(batt_volt)
    PanelTemp(Ptemp,_60Hz)
    ''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''
    '' Radio Control  ''''''''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''
    If radioflag=true Then SW12(1)

    ' if the battery voltage is high then turn the radio on hourly 
    If TimeIntoInterval(0,60,min) Then
        If batt_volt >= 12.4 Then 
          SW12(1)
        EndIf
    EndIf
    ' if the battery voltage isn't too low, turn the radio on daily.
    If TimeIntoInterval(720,1440,min) Then
        If batt_volt >= 12.2 Then 
          SW12(1)
        EndIf
    EndIf
    ' if the radioflag hasn't been set manually then turn the radio off 10 minutes into the hour.
    If TimeIntoInterval(10,60,min) OR commscomplete = true Then
        If radioflag = false Then 
          SW12(0)
          commscomplete = false
        EndIf
    EndIf      
    If batt_volt < 12.6 Then radioflag = false