Support Forums
Program Doubt

Hi all,

First of all I'm a beginner in DT program and I'm from telecom area (just helping a structural monitoring small company).

We have a remote DT with this program:

;BEGIN"A"
;RA1H
;1RELAY=1
;DELAY=3000
;1I(120)
;1+I(120)
;2
I(120)
;2+I(120)
;DELAY=3000
;1RELAY=0
;RB12H
;DELAY=8000
;1RELAY=1
;DELAY=600000
;DO{COPYD job=A sched=A dest=ftp://xxx:yyy@IP_ADDRESS}
;DELAY=300000
;1RELAY=0
;LOGON
;END
;G

The main idea of this program is in 1 hour interval collect sensors data (RA1H) and within 12 hour interval transfer collect data to a external FTP server (RB12H)

All goes well with it but the FTP part (COPYD) only execute at the end of the program. In the this case the COPYD will never ocurr because the power is off (with the 1RELAY=0).
Can you help me?

Thx in advance and with best regards
/mserrao

Hi all, First of all I'm a beginner in DT program and I'm from telecom area (just helping a structural monitoring small company). We have a remote DT with this program: ;BEGIN"A" ;RA1H ;1RELAY=1 ;DELAY=3000 ;1*I(120) ;1+I(120) ;2*I(120) ;2+I(120) ;DELAY=3000 ;1RELAY=0 ;RB12H ;DELAY=8000 ;1RELAY=1 ;DELAY=600000 ;DO{COPYD job=A sched=A dest=ftp://xxx:yyy@IP_ADDRESS} ;DELAY=300000 ;1RELAY=0 ;LOGON ;END ;G The main idea of this program is in 1 hour interval collect sensors data (RA1H) and within 12 hour interval transfer collect data to a external FTP server (RB12H) All goes well with it but the FTP part (COPYD) only execute at the end of the program. In the this case the COPYD will never ocurr because the power is off (with the 1RELAY=0). Can you help me? Thx in advance and with best regards /mserrao

Good morning mserrao,

I've had a quick look at your code and need to ask some questions about your application.

1/ What power are you tuning on/ off with the relay?
2/ What are the delays for?
3/ What type of sensors are you reading?

Cheers,
Roger

Good morning mserrao, I've had a quick look at your code and need to ask some questions about your application. 1/ What power are you tuning on/ off with the relay? 2/ What are the delays for? 3/ What type of sensors are you reading? Cheers, Roger

Hi Roger

Please find below my replies:

1/ What power are you tuning on/ off with the relay?
The power of the sonars (Current sensors) on RA1H and the power of the 3G Router (obviously important for the FTP) with RB12H

2/ What are the delays for?
Some delays are only wait some little time after bring or turn power off. The other ones (600s and 300s) are to turn up the 3G connection and for have some time to check (using icmp and/or http) the status of the remote (both 3G Router and DT80) site.

3/ What type of sensors are you reading?
The sensors are sonars (we are reading Current)

Thx in advance
/mserrao

Hi Roger Please find below my replies: 1/ What power are you tuning on/ off with the relay? The power of the sonars (Current sensors) on RA1H and the power of the 3G Router (obviously important for the FTP) with RB12H 2/ What are the delays for? Some delays are only wait some little time after bring or turn power off. The other ones (600s and 300s) are to turn up the 3G connection and for have some time to check (using icmp and/or http) the status of the remote (both 3G Router and DT80) site. 3/ What type of sensors are you reading? The sensors are sonars (we are reading Current) Thx in advance /mserrao

Hi Mserrao,

The issue with your code is that the DELAY commands essentially halt all operation of the logger for a period of time, which means nothing else can occur during this time.

What I choose to do instead is run a schedule as a timer and have it control everything else. This is what I call a state machine.

Excuse me for re-writing your program, but it was a few minutes work to put into a format that should work well and have no delays. Given that there are no other state machine examples on the forum yet I thought I would use yours as an example.

The below code uses G schedule to control all of the timed events, including the relay, measurements and FTP transfers. The G schedule timer is re-started every hour by the A schedule. On the 12 hour events, an additional flag is set so the relay stays closed, keeping the modem awake and proceeding with the FTP transfer.

Give this a go and read the comments in the program (after the apostrophe's)

BEGIN"A"
LOGON
RA1H
DO{1CV=0;GG} 'reset timer and start the state machine
RB12H
DO{2CV=1} 'timer already started by A, so only need to enable the FTP flag (2CV=1)
RG1S HG 'state machine (1CV = time elapsed)
IF(1CV>0){1RELAY=1} 'turn on modem and sensors
IF(1CV==3){XI} 'run I schedule when counter gets to 3 seconds
IF(1CV==6)AND IF(2CV<1){1RELAY=0} 'dont turn off if 12H schedule running
IF(1CV>7)AND IF(2CV<1){HG} 'halt counter if no FTP required
IF(1CV==608){XJ} 'run J schedule when counter gets to 608 seconds
IF(1CV==908){1RELAY=0} 'turn off modem at 908 seconds
IF(1CV>909){2CV=0;HG} 'reset the FTP flag and halt the counter
1CV("TIMER",W)=1CV+1
RIX 'measurement schedule
1I(120)
1+I(120)
2
I(120)
2+I(120)
RJX 'FTP schedule
DO{COPYD sched=I dest=ftp://xxx:yyy@IP_ADDRESS}
END

KadeM

Hi Mserrao, The issue with your code is that the DELAY commands essentially halt all operation of the logger for a period of time, which means nothing else can occur during this time. What I choose to do instead is run a schedule as a timer and have it control everything else. This is what I call a state machine. Excuse me for re-writing your program, but it was a few minutes work to put into a format that should work well and have no delays. Given that there are no other state machine examples on the forum yet I thought I would use yours as an example. The below code uses G schedule to control all of the timed events, including the relay, measurements and FTP transfers. The G schedule timer is re-started every hour by the A schedule. On the 12 hour events, an additional flag is set so the relay stays closed, keeping the modem awake and proceeding with the FTP transfer. Give this a go and read the comments in the program (after the apostrophe&#039;s) BEGIN&quot;A&quot; LOGON RA1H DO{1CV=0;GG} &#039;reset timer and start the state machine RB12H DO{2CV=1} &#039;timer already started by A, so only need to enable the FTP flag (2CV=1) RG1S HG &#039;state machine (1CV = time elapsed) IF(1CV&gt;0){1RELAY=1} &#039;turn on modem and sensors IF(1CV==3){XI} &#039;run I schedule when counter gets to 3 seconds IF(1CV==6)AND IF(2CV&lt;1){1RELAY=0} &#039;dont turn off if 12H schedule running IF(1CV&gt;7)AND IF(2CV&lt;1){HG} &#039;halt counter if no FTP required IF(1CV==608){XJ} &#039;run J schedule when counter gets to 608 seconds IF(1CV==908){1RELAY=0} &#039;turn off modem at 908 seconds IF(1CV&gt;909){2CV=0;HG} &#039;reset the FTP flag and halt the counter 1CV(&quot;TIMER&quot;,W)=1CV+1 RIX &#039;measurement schedule 1*I(120) 1+I(120) 2*I(120) 2+I(120) RJX &#039;FTP schedule DO{COPYD sched=I dest=ftp://xxx:yyy@IP_ADDRESS} END KadeM
27
3
3
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft