Program Doubt

The dataTaker DT80 5 channel general purpose data logger

Program Doubt

Postby mserrao » Fri Mar 02, 2012 3:10 am

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
mserrao
Newbie
 
Posts: 2
Joined: Fri Mar 02, 2012 2:45 am

Re: Program Doubt

Postby Roger » Fri Mar 02, 2012 7:03 am

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
"Don't Panic"
Douglas Adams HHGTTG
Roger
dataTaker Expert
 
Posts: 1000158
Joined: Fri Feb 10, 2012 10:38 am

Re: Program Doubt

Postby mserrao » Sat Mar 03, 2012 4:03 am

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
mserrao
Newbie
 
Posts: 2
Joined: Fri Mar 02, 2012 2:45 am

Re: Program Doubt

Postby KadeM » Mon Mar 05, 2012 9:49 am

Hi Mserrato,

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)

Code: Select all
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
   1*I(120)
   1+I(120)
   2*I(120)
   2+I(120)
RJX 'FTP schedule
   DO{COPYD sched=I dest=ftp://xxx:yyy@IP_ADDRESS}
END
There are 10 types of people, those who understand binary and those who don't...
KadeM
dataTaker Expert
 
Posts: 100015
Joined: Fri Feb 10, 2012 3:35 pm


Return to DT80

Who is online

Users browsing this forum: No registered users and 2 guests

cron