beautypg.com

A.3.2.1 calendar date battery test – rs-232, A.3.2, A.3.2.1 – Campbell Scientific PS200/CH200 12 V Charging Regulators User Manual

Page 80

background image

Appendix A. Advanced Programming Techniques

A.3.2 Enter Battery Test State RS-232 Programming Example

A.3.2.1 Calendar Date Battery Test – RS-232

'CR1000 Series Datalogger
'Program: RS-232_Calendar_Battery_Load_Test.CR1
'Date: 1.November.2010

'Ver: A
'
'Notes: This program tests the existing battery for problems by

'setting the target voltage down to 11.5VDC forcing the system to run
'strictly on battery power for user settable amount of time.
'Test is based on a time interval in days and test duration in hours.

'
'Use Campbell Scientific RS-232 cable part # 25356.
'

'RS-232 CABLE TO CR1000 WIRING
'-----------------------------

'GREEN: C3 (TX)
'WHITE: C4 (RX)
'BLACK: G

'CLEAR: G
'
'This program uses the RS-232 command "BATT_TEST>" to force the battery target voltage

'down to 11.5vdc.

PipeLineMode

'Constants & Public Variables
'Change this constant if using a different com port on the CR1000.
Const COMPRT = COM2

'Hexadecimal equivalent of a carriage return.
Const CR = CHR(&H0D)

'It is a comma. Used to sort PS/CH200 strings.
Const COMMA = CHR(&H2C)
'I like to use the words "on" and "off" vs. "true" and "false".

Const On = True
Const Off = False

Public PanelTempC 'Datalogger panel temperature: Celsius

'Store the present time information.

Public rTime(9)

'declare as public and dimension rTime to 9

Alias rTime(1) = Year

'assign the alias Year to rTime(1)

Alias rTime(2) = Month

'assign the alias Month to rTime(2)

Alias rTime(3) = DOM

'assign the alias Day to rTime(3)

Alias rTime(4) = Hour

'assign the alias Hour to rTime(4)

Alias rTime(5) = Minute

'assign the alias Minute to rTime(5)

Alias rTime(6) = Second

'assign the alias Second to rTime(6)

Alias rTime(7) = uSecond

'assign the alias uSecond to rTime(7)

Alias rTime(8) = WeekDay

'assign the alias WeekDay to rTime(8)

Alias rTime(9) = Day_of_Year

'assign the alias Day_of_Year to rTime(9)

'Command sent to the PS/CH200 to get status information.
Const CH200STATS_CMD = "RD_STAT>"
'Holds the check sum value of the received PS/CH200 string.

Public Check_sum
'Used to catch clutter from the PS/CH200

Dim xmit_str As String
'Holds the entire status string coming from the PS/CH200.
Dim CH200string As String * 140

'Holds parsed string values.
Dim CH200_M0(9) As String * 20
'Battery voltage: VDC

Public VBatt
'Current going into, or out of, the battery: Amps
Public IBatt
'Current going to the load: Amps

A-18