'CR1000X Series Datalogger 'Example datalogger program for Apogee Instruments S2-432-SS Red Far-red sensor 'date: April 8, 2020 'Revised: December 31, 2020 'program author: John Huber 'For more technical information regarding the S2-432-SS operation as well as default settings and register address lists, please consult the sensor's manual, which can be found online: 'https://www.apogeeinstruments.com/product-manuals/ 'Wiring: 'White -> C6 Comm port (RS485 +) 'Blue -> C5 Comm port (RS485-) 'Black -> G port (Ground) 'Green -> G port (Communication mode selector wire. Powered = RS232, Grounded = RS485) 'Red -> 12V port (Input power) 'Clear -> Shield ground 'If using a datalogger model other than the CR1000, some adjustments to commands will be necessary 'Explanation of Constants and Variables Used in Datalogger Program 'BattV = datalogger battery voltage 'PanelT = datalogger panel temperature 'ModbusRead(2) = Output from the modbus sensor 'RED = red light photon flux in umol m-2 s-2 (micromoles per square meter per second) 'FAR = far red light photon flux in umol m-2 s-2 (micromoles per square meter per second) 'REDFAR = ratio of red and far red light 'FRFraction = the fraction of far red light relative to the total red and far red light 'Errorcode = modbus error code value (Check CRBasic help menu for a list of error codes) 'Declare Public Variables Public PTemp, Batt_volt Public ModbusRead(2) Public REDFAR Public FRFraction Public Errorcode 'Declare Aliases for modbus sensor output Alias ModbusRead(1) = RED Alias ModbusRead(2) = FAR 'Define Data Tables. DataTable (Red_Far_red,1,-1) 'Set table size to # of records, or -1 to autoallocate. DataInterval (0,1,Min,10) Minimum (1,Batt_volt,FP2,False,False) Sample (1,PTemp,FP2) Average(1,RED,IEEE4,False) Average(1,FAR,IEEE4,False) Average(1,REDFAR,IEEE4,False) Average(1,FRFraction,IEEE4,False) EndTable 'Main Program BeginProg Scan (1,Sec,0,0) PanelTemp (PTemp,60) Battery (Batt_volt) 'Open modbus serial port in RS232 mode SemaphoreGet(3) SerialOpen(ComC5,19200,2,0,256,3) SerialFlush(ComC5) SemaphoreRelease(3) 'Obtain measurements SemaphoreGet(3) ModbusMaster(Errorcode,ComC5,19200,1,3,ModbusRead(),1,2,2,100,2) SemaphoreRelease(3) 'Calculate Red/far red ratio REDFAR = RED / FAR 'Calculate the Far red fraction FRFraction = FAR / (RED + FAR) CallTable Red_Far_red NextScan EndProg