A.1.2, Write/reset remote battery temperature rs-232 – Campbell Scientific PS200/CH200 12 V Charging Regulators User Manual

Page 65

Advertising
background image

Appendix A. Advanced Programming Techniques

A.1.2 Write/Reset Remote Battery Temperature RS-232

Programming Example

'CR1000 Series Datalogger

'Program: RS-232_Set_Batt_Temp.CR1
'Date: 1.November.2010
'Ver: A

'
'Notes: This program sets the battery temperature value.
'Connect the PS200/CH200 to RS-232 port COM2 of the CR1000.

'Use Campbell Scientific RS-232 cable part # 25356.
'
'RS-232 CABLE TO CR1000 WIRING

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

'BLACK: G
'CLEAR: G

'
'TYPE 'T' THERMOCOUPLE USED TO MEASURE
'EXTERNAL BATTERY TEMPERATURE WIRING

'--------------------------------------
'BLUE: 1H
'RED: 1L

'
' This program uses the RS-232 command WR_BT to overwrite the internal CH200 temperature if
' the user sets the variable SetBattTemp = True.

' The external CH200 temperature is used if SetBattTemp = True.

'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)

Public PanelTempC

'Datalogger panel temperature: Celsius

'Battery temperature from an external thermocouple.
Public ExtBatTempC

'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

A-3

Advertising