Hello Forum (warning - long post),
We are converting CR10x programs to CR1000 and would like to ask the experts for some programming advice.
We need to do the following:
A. If the orifice temp is below 4C then set Control Port 8 high.
B. If the orifice temp is greater than or equal to 4C set Control Port 8 low.
C. If the RUN_TIME is greater than or equal to 900 seconds set Control Port 8 low.
Here is the existing CR10x code: (con_temp is a user entered value (4 deg c in this case)
;
;PUMP CONTROL
15: If Flag/Port (P91)
1: 21 Do if Flag 1 is Low
2: 30 Then Do
16: If Flag/Port (P91)
1: 58 Do if Port 8 is Low
2: 30 Then Do
17: IF (X<=>Y) (P88)
1: 2 X Loc [ OR_TEMP ]
2: 4 <
3: 22 Y Loc [ CON_TEMP ]
4: 30 Then Do
18: Timer (P26)
1: 0 Reset Timer
19: Do (P86)
1: 48 Set Port 8 High
20: End (P95)
21: Else (P94)
22: IF (X<=>Y) (P88)
1: 2 X Loc [ OR_TEMP ]
2: 3 >=
3: 22 Y Loc [ CON_TEMP ]
4: 30 Then Do
23: Do (P86)
1: 58 Set Port 8 Low
24: Else (P94)
25: Timer (P26)
1: 23 Loc [ RUN_TIME ]
26: IF (X<=>F) (P89)
1: 23 X Loc [ RUN_TIME ]
2: 3 >=
3: 900 F
4: 30 Then Do
27: Do (P86)
1: 11 Set Flag 1 High
28: Do (P86)
1: 58 Set Port 8 Low
29: End (P95)
30: End (P95)
31: End (P95)
32: End (P95)
;
Here is the Transformer.exe converted code:
'Pump Control
If Flag(1) = False then
If CheckPort(8) = False then
If (OR_TEMP < CON_TEMP) Then
Timer(0,uSec,2)
PortSet(8, 1)
EndIf
Else
If (OR_TEMP >= CON_TEMP) Then
PortSet(8, 0)
Else
RUN_TIME=Timer(0,uSec,4)
If (RUN_TIME >= 900) Then
Flag(1) = true
PortSet(8, 0)
EndIf
EndIf
EndIf
EndIf
Here is a modified CR1000 snippet from a related post on the CSI forum:
'http://campbellsci.com/forum/messages.cfm?threadid=D676CA27-E83A-B343-EFE483A8DD971E96
If OR_TEMP < 4 Then PortSet (8 ,1 )
If OR_TEMP >= 4 Then PortSet (8 ,0 )
Question 1: Is the modified snipped doing the same thing as the original code?
Question 2: Is there an eloquent way to set port 8 to low if the RUN_TIME is greater than or equal to 900 seconds (ie. the TIMER portion of the original code)?
Thanks in advance for the guidance,
AMK
The timer instruction as shown in your CR1000 program is the most reliable way to handle elapsed time.
is it possible to make some program and change pump/s interval in RTMC Pro ?
is it possible to make some program and change pump/s interval in RTMC Pro ?
It is very possible to do this in RTMC Pro. It appears from this code:
If (RUN_TIME >= 900) Then
Flag(1) = true
PortSet(8, 0)
EndIf
that your pump is turning off after 900 uSec of runtime. (seems really short for a pump runtime). If this is the case, you can just make the number 900 into a public variable and then include that public variable at a "Set Point" in RTMC pro. Then you can adjust the run time on the fly from RTMC.
If that does not answer your question, then please give more details about your project and we can find a way to make it work.