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.

ConstTable into CR800 Program


SEMN May 25, 2011 02:58 PM

I would like to insert a ConstTable into the following program to allow for constants to be adjusted via the keypad. I have the values defined as constants, and I need to create a "ConstTable". When I do this, I get the following error when compiling:"undeclared variable" for everything in the ConstTable.

Original:

'Declare Constants
Const SRT_EFI = 1000 'ft^3
Const SRTActST = 0.15 'ft
Const SRT_IAdj = 0 'ft
Const SRT_BdHt= 1.96 'ft

'Declare Variables and Units
Public Batt_Volt
Public SRT_in
Public SRT_IStg
Public SRT_Flow
Public SRT_MinV
Public SRT_CFLO
Public SRT_SamN
Public C450_WDS4I(9)

Alias C450_WDS4I(1)=SRT_inPS
Alias C450_WDS4I(2)=SRT_Temp

Units Batt_Volt=Volts
Units SRT_in =feet
Units SRT_IStg =feet
Units SRT_Flow =cfs
Units SRT_MinV =ft^3
Units SRT_CFLO =ft^3
Units SRT_SamN =Count


I changed to:

ConstTable
[SRT_EFI] = [1000]
[SRTActST] = [.15]
[SRT_IAdj] = [0]
[SRT_BdHt] = [1.96]
EndConstTable

'Declare Variables and Units
Public Batt_Volt
Public SRT_in
Public SRT_IStg
Public SRT_Flow
Public SRT_MinV
Public SRT_CFLO
Public SRT_SamN
Public C450_WDS4I(9)

Alias C450_WDS4I(1)=SRT_inPS
Alias C450_WDS4I(2)=SRT_Temp

Units Batt_Volt=Volts
Units SRT_in =feet
Units SRT_IStg =feet
Units SRT_Flow =cfs
Units SRT_MinV =ft^3
Units SRT_CFLO =ft^3
Units SRT_SamN =Count

Again, the variables in the ConstTable show as errors as "undefined variable"

Could anyone tip off what I need to change to make this work?

Thanks


kirving May 25, 2011 03:49 PM

try:

'Declare Constants
ConstTable
Const SRT_EFI = 1000 'ft^3
Const SRTActST = 0.15 'ft
Const SRT_IAdj = 0 'ft
Const SRT_BdHt= 1.96 'ft
EndConstTable


SEMN May 25, 2011 04:19 PM

Thanks. The program compiled. I need to make sure I can still change the values via the keypad with this format within resending the program.

Can anyone confirm that this format will work within a ConstTable?


IslandMan May 27, 2011 01:08 PM

Yes, it will be labeled "Const Table" on your CR1000KD keypad.


Sam Jun 2, 2011 04:09 AM

A few notes regarding ConstTable, and CustomMenu

Constants located within ConstTable/EndConstTable can be edited:

a) Using the CR850 or CR1000KD keypad display and the standard/default logger menu. When a ConstTable is added to a program, you will find a "Constant Table" menu item located at: Configure, Settings -> Constant Table
http://i52.tinypic.com/a4a4av.jpg

b) Using a terminal program such as HyperTerminal or LoggerNet's Terminal Emulator. At the CRXXXx> prompt enter the letter "C" and press ENTER.
http://i51.tinypic.com/28ck80g.jpg

c) Using a combination of ConstTable and CustomMenu instructions.

Dim Recompile As Boolean
ConstTable
Const A = 1
Const B = TRUE
EndConstTable
DisplayMenu ("MENU",-1)
MenuItem ("Numeric",A)
MenuPick (A)
MenuItem ("Boolean",B)
MenuPick (B,FALSE,TRUE)
MenuRecompile ("Recompile?",Recompile)
MenuPick (FALSE,TRUE)
EndMenu
BeginProg
Scan (1,Sec,0,0)
NextScan
EndProg


SEMN Jun 13, 2011 02:25 PM

Thank you. I was able to update the program to allow for easily adjustable constants.

One final question, is there any concern with losing data on the CR800's after a constant is changed and the program is compiled to make the change?


Sam Jun 13, 2011 03:13 PM

Absolutely - for a program that uses Constants to change table definitions or memory allocations. Following are some examples. Remember always test your code. The logger will tell you if the memory has been reinitialized.

----------------------------------------------------
Example - Data Will Not Be Lost By Changing Value of Constants

ConstTable
Const Mult = 1.8
Const Off = 32
EndConstTable

Public PTemp, batt_volt

DataTable (Test,1,1000)
DataInterval (0,15,Sec,10)
Minimum (1,batt_volt,FP2,0,False)
Sample (1,PTemp,FP2)
EndTable

BeginProg
Scan (1,Sec,0,0)
PanelTemp (PTemp,250)
PTemp = PTemp * Mult + Off
Battery (batt_volt)
CallTable Test
NextScan
EndProg

----------------------------------------------------
Example - Data Will Be Lost As Changing The Constant Significantly Changes the Way Memory is Allocated

ConstTable
Const LogTemp = TRUE
EndConstTable

Public PTemp, batt_volt

DataTable (Test,1,1000)
DataInterval (0,15,Sec,10)
Minimum (1,batt_volt,FP2,0,False)
#If LogTemp
Sample (1,PTemp,FP2)
#EndIf
EndTable

BeginProg
Scan (1,Sec,0,0)
PanelTemp (PTemp,250)
Battery (batt_volt)
CallTable Test
NextScan
EndProg

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