beautypg.com

A.4.2 zero out qloss rs-232 programming example, A.4.2 – Campbell Scientific PS200/CH200 12 V Charging Regulators User Manual

Page 90

background image

Appendix A. Advanced Programming Techniques

A.4.2 Zero Out QLoss RS-232 Programming Example

'CR1000 Series Datalogger
'Program: RS-232_Clear_QLoss.CR1
'Date: 8.Nov.2010

'Ver: A
'
'Notes: This program sets QLoss back to zero using the RS-232

'command "RESET_QLOSS>" to set QLoss to zero.
'
'Use Campbell Scientific RS-232 cable part # 25356.

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

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

'BLACK: G
'CLEAR: G
'

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. Sort the string from the PS/CH200 using commas.
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

'Variables and constants used to get status information from the PS/CH200
'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
Public ILoad

'Voltage coming into the charger: VDC
Public V_in_chg
'Current coming into the charger: Amps

Public I_in_chg
'Charger temperature: Celsius

Public Chg_TmpC
'Charging state: Cycle, Float, Current Limited, or None
Public ChargeState As String

'Charging source: None, AC, or Solar
Public ChargeSource As String
'Check battery error: 0=normal, 1=check battery

Public Ck_Batt
'Word or phrase equivalent of check battery error.
Public CheckBattery As String


'Array to hold the names of the battery error information.
Dim CheckBatteryArr(2) As String

A-28