Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Setting channel number using a constant


afox18 May 9, 2023 10:53 PM

Hi, I'm trying to write a function that will let me run a Therm109 measurement and process the output, but I've run into a problem where Therm109 only accepts constants as channel inputs.

Here's a very simplified of the program:

Dim My_SEChan(4) = {1, 2, 4, 6}
Dim My_ExChan = 1
Dim i
Public My_T_processed(4)


Function Read_and_Process_Temp(SEChan, ExChan) Dim T, T_processed Therm109(T, 1, SEChan, ExChan, 0, _60Hz, 1.0, 0.0)
T_processed = T^2
Return(T_processed) EndFunction

BeginProg
Scan(1,Sec,0,0)
For i = 1 To 4
My_T_processed(i) = Read_and_Process_Temp(My_SEChan(i), My_ExChan)
Next i
NextScan
EndProg

 This gives me a "variable illegal in parameter: SEChan" error. 

Is there a way to use the values stored in SEChan and ExChan to run the Therm109 function? Or is there something more fundemental to the constant requirement. Will I just have to run Therm109 separately for each SE and Ex channel individually, like so:

Dim My_T(4)
Public My_T_processed(4)

Function Process_Temp(T)
Dim T_processed T_processed = T^2 Return(T_processed) EndFunction BeginProg Scan(1,Sec,0,0)
Therm109(My_T(1), 1, 1, 1, 0, _60Hz, 1.0, 0.0)
Therm109(My_T(2), 1, 2, 1, 0, _60Hz, 1.0, 0.0)
Therm109(My_T(3), 1, 4, 1, 0, _60Hz, 1.0, 0.0)
Therm109(My_T(4), 1, 6, 1, 0, _60Hz, 1.0, 0.0) My_T_processed = Process_Temp(My_T) NextScan EndProg

 ?

Forgive me if there are any additional errors in these programs other than the one I mentioned. I wrote these examples up on my laptop, which doesn't have CRBasic installed.

Thanks


JDavis May 11, 2023 04:02 PM

Measurement channel numbers must be constant. The datalogger configures hardware resources at compile time.

Log in or register to post/reply in the forum.