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.

Faster scan


Martin Jun 30, 2011 11:39 AM

Hello everybody

We use a CR1000 for doing research on a railway track. One point is measuring the movement of the track during a train is passing. Even the train isn't very fast ( 40km/h ), we need a fast scan rate for doing that.

In the following program, the scan rate is 40mSec. Is there a possibility to achieve 20mSec?


Public PTemp, batt_volt,DMS,Dehnung,PT100SCH,TempSCH
Public PT100LUF,TempLuft,TRH(2),Radar,Dummy,TempCase
Public potimp(15),RefTemp
Public save As Boolean

Alias TRH(1)=TempLuft2
Alias TRH(2)=RH

Units TempLuft=Deg C
Units TempLuft2=Deg C
Units RH=%

Const KFaktor = 2.03
Const BrZero = 0.32

DataTable (Messwert,1,20000)
DataInterval (0,1,min,10)
CardOut (1,200000)
FillStop
Average (15,potimp(),IEEE4,0)
Average (1,Dehnung,IEEE4,0)
Average (1,DMS,IEEE4,0)
Average (1,TempSCH,FP2,0)
Average (1,TempLuft,FP2,0)
Average (1,TempLuft2,FP2,0)
Average (1,TempCase,FP2,0)
Average (1,RH,FP2,0)
Average (1,Radar,IEEE4,0)
EndTable

DataTable (Distanz,1,-1)
DataInterval (0,40,mSec,1000)
FillStop
CardOut (1,-1)
Sample (15,potimp(),IEEE4)
EndTable

BeginProg
Scan (40,mSec,1000,0)
PortGet (Radar,1)
If Radar>0 Then
AM25T (potimp(),15,mV2500,1,6,- 1,RefTemp,7,8,0,0,0,250,0.05,-20)
CallTable Distanz
EndIf
NextScan
SlowSequence
Scan (2,sec,10,0)
PortGet (Radar,1)
If Radar=0 Then
AM25T (potimp(),15,mV2500,1,6,-1,RefTemp,7,8,0,1,0,_50Hz,0.05,-20)
AM25T (potimp(2),1,mV2500,2,6,-1,RefTemp,7,8,0,1,0,_50Hz,0.02,0)
BrHalf4W (PT100SCH,1,mV25,mV25,7,Vx3,1,2000,True ,True ,0,_50Hz,1,0)
PRT (TempSCH,1,PT100SCH,1,0)
BrHalf4W (PT100LUF,1,mV25,mV25,3,Vx1,1,2000,True ,True ,0,_50Hz,1,0)
PRT (TempLuft,1,PT100LUF,1,0)
SDI12Recorder(TRH(),3,"0","C!",1.0,0)
PanelTemp (TempCase,_50Hz)
BrFull (DMS,1,mV7_5,5,Vx2,1,2500,True ,True ,0,_50Hz,1.0,0)
StrainCalc (Dehnung,1,DMS,BrZero,-1,KFaktor,0)
PortGet (Radar,1)
CallTable Messwert
EndIf
NextScan
EndProg


The next step was using the pipeline mode. But here is the problem, that when I jump from the slow scan to the fast scan, there is a inconstant delay from one to five seconds. But fast scan shouldn't start after more than one second after Port1 gehts an input.


Public PTemp, batt_volt,DMS,Dehnung,PT100SCH,TempSCH
Public PT100LUF,TempLuft,TRH(2),Radar,Dummy,TempCase
Public potimp(15),RefTemp
Public save As Boolean

Alias TRH(1)=TempLuft2
Alias TRH(2)=RH

Units TempLuft=Deg C
Units TempLuft2=Deg C
Units RH=%

Const KFaktor = 2.03
Const BrZero = 0.32

DataTable (Messwert,1,20000)
DataInterval (0,10,sec,10)
CardOut (1,200000)
FillStop
Average (15,potimp(),IEEE4,0)
Average (1,Dehnung,IEEE4,0)
Average (1,DMS,IEEE4,0)
Average (1,TempSCH,FP2,0)
Average (1,TempLuft,FP2,0)
Average (1,TempLuft2,FP2,0)
Average (1,TempCase,FP2,0)
Average (1,RH,FP2,0)
Average (1,Radar,IEEE4,0)
EndTable

DataTable (Distanz,1,-1)
DataInterval (0,20,mSec,1000)
FillStop
CardOut (1,-1)
Sample (15,potimp(),IEEE4)
EndTable

PipeLineMode

BeginProg
Do While TRUE
Scan (2,Sec,100,0)
PortGet (Radar,1)
If Radar>0 Then ExitScan
AM25T (potimp(),15,mV2500,1,6,-1,RefTemp,7,8,0,1,0,_50Hz,0.05,-20)
AM25T (potimp(2),1,mV2500,2,6,-1,RefTemp,7,8,0,1,0,_50Hz,0.02,0)
BrHalf4W (PT100SCH,1,mV25,mV25,7,Vx3,1,2000,True ,True ,0,_50Hz,1,0)
PRT (TempSCH,1,PT100SCH,1,0)
BrHalf4W (PT100LUF,1,mV25,mV25,3,Vx1,1,2000,True ,True ,0,_50Hz,1,0)
PRT (TempLuft,1,PT100LUF,1,0)
PanelTemp (TempCase,_50Hz)
BrFull (DMS,1,mV7_5,5,Vx2,1,2500,True ,True ,0,_50Hz,1.0,0)
StrainCalc (Dehnung,1,DMS,BrZero,-1,KFaktor,0)
PortGet (Radar,1)
If Radar>0 Then ExitScan
SDI12Recorder(TRH(),3,"0","C!",1.0,0)
CallTable Messwert
PortGet (Radar,1)
If Radar>0 Then ExitScan
NextScan

Scan (20,mSec,10,0)
AM25T (potimp(),15,mV2500,1,6,-1,RefTemp,7,8,0,0,0,250,0.05,-20)
CallTable Distanz
PortGet (Radar,1)
If Radar=0 Then ExitScan
NextScan
Loop
EndProg


Does anybody has a good idea?

Thank you for your help in advance!

Martin


aps Jun 30, 2011 04:30 PM

Some tips:

1) the first program will not work (looked at the skipped scan counter in the status table to see it isn't running as you expect) this is because you have a lot of measurements and most with 50 Hz rejection specified. With these loggers an integration technique is used for noise rejection so 50 Hz rej = a delay of >20 ms per measurement. In addition you have an SDI-12 sensor measurement that will take up to one second

2)the second program is closer to working, but because of all those 50 Hz measurements the entire scan may be taking 2-3 s to run which is why it is taking time to drop out to the fast scan.

What you need to do is investigate use of slowsequences that run in parallel, but with lower priority than the main scan. Put the SDI-12 measurement by itself in a slow sequence as that will then not hold up anything.

You can try putting all the other slower measurements in a slow sequence but you will still need to cut out the 50 Hz rej with this approach as the logger will not be able to time slice these measurements in between the fast ones if it tries to do both at once. I suspect you will still run out of time though and get some skipped scans.

This is the closest I can get to a running program, but it really needs 30 ms and further tweaking. Your measurements in the fast scan take 16-17 ms so there is little time for anything else.

There are lots of IF Radar =0 statements in the slow sequence so if that sequence is active when the radar is triggered it stops doing anything as quickly as possible.

Good luck - this is pushing the limit for the CR1000:

Public PTemp, batt_volt,DMS,Dehnung,PT100SCH,TempSCH
Public PT100LUF,TempLuft,TRH(2),Radar,Dummy,TempCase
Public potimp(15),RefTemp
Public save As Boolean
Public timearray(100)as long
InstructionTimes (timearray())


Alias TRH(1)=TempLuft2
Alias TRH(2)=RH

Units TempLuft=Deg C
Units TempLuft2=Deg C
Units RH=%

Const KFaktor = 2.03
Const BrZero = 0.32

DataTable (Messwert,1,20000)
DataInterval (0,10,sec,10)
CardOut (1,200000)
FillStop
Average (15,potimp(),IEEE4,(Radar=1))
Average (1,Dehnung,IEEE4,(Radar=1))
Average (1,DMS,IEEE4,(Radar=1))
Average (1,TempSCH,FP2,(Radar=1))
Average (1,TempLuft,FP2,(Radar=1))
Average (1,TempLuft2,FP2,(Radar=1))
Average (1,TempCase,FP2,(Radar=1))
Average (1,RH,FP2,(Radar=1))
Average (1,Radar,IEEE4,(Radar=1))
EndTable

DataTable (Distanz,1,-1)
DataInterval (0,30,mSec,1000)
FillStop
CardOut (1,-1)
Sample (15,potimp(),IEEE4)
EndTable


'Main Program
BeginProg
Do
WaitDigTrig (1 ,0)
Scan (30,mSec,10,0)
PortGet (Radar,1)
If Radar=0 Then ExitScan
AM25T (potimp(),15,mV2500,1,6,-1,RefTemp,7,8,0,0,0,250,0.05,-20)
CallTable Distanz
NextScan
Loop

SlowSequence
Scan (2,Sec,100,0)
If Radar=0 Then
If Radar=0 Then AM25T (potimp(),15,mV2500,1,6,-1,RefTemp,7,8,0,1,0,_50Hz,0.05,-20)
If Radar=0 Then AM25T (potimp(2),1,mV2500,2,6,-1,RefTemp,7,8,0,1,0,_50Hz,0.02,0)
If Radar=0 Then BrHalf4W (PT100SCH,1,mV25,mV25,7,Vx3,1,2000,True ,True ,0,_50Hz,1,0)
If Radar=0 Then PRT (TempSCH,1,PT100SCH,1,0)
If Radar=0 Then BrHalf4W (PT100LUF,1,mV25,mV25,3,Vx1,1,2000,True ,True ,0,_50Hz,1,0)
If Radar=0 Then PRT (TempLuft,1,PT100LUF,1,0)
If Radar=0 Then PanelTemp (TempCase,_50Hz)
If Radar=0 Then BrFull (DMS,1,mV7_5,5,Vx2,1,2500,True ,True ,0,_50Hz,1.0,0)
If Radar=0 Then StrainCalc (Dehnung,1,DMS,BrZero,-1,KFaktor,0)
ENDIF
CallTable Messwert
NextScan

SlowSequence
Scan (10,Sec,3,0)
If Radar=0 Then SDI12Recorder(TRH(),3,"0","C!",1.0,0)
NextScan


EndProg


aps Jul 1, 2011 12:28 PM

I thought about this a little more and came up with another variant which is a hybrid of your second attempt and my program above. This runs in pipeline mode so is most effecient and will give good timing of the fast scan.

The SDI-12 sensor is moved out of the way into a slow sequence.

All of the slower measurements are preceeded by a test of the radar, so the maximum time you will need to wait for the logger to drop out of the first scan is about 1 sec or so (worst case, it could be in the middle of one of the measurements or waiting for the scan to start again).

You could reduce the latter a bit by getting rid of some of the 50Hz rejections and running the first loop a bit quicker.

As it stands the fast loop runs without skipping at 20 ms interval (without a card in my logger though)

Hope this helps.

Andrew

------------------------

Public PTemp, batt_volt,DMS,Dehnung,PT100SCH,TempSCH
Public PT100LUF,TempLuft,TRH(2),Radar,Dummy,TempCase
Public potimp(15),RefTemp
Public save As Boolean
Public timearray(100)as long
InstructionTimes (timearray())


Alias TRH(1)=TempLuft2
Alias TRH(2)=RH

Units TempLuft=Deg C
Units TempLuft2=Deg C
Units RH=%

Const KFaktor = 2.03
Const BrZero = 0.32

DataTable (Messwert,1,20000)
DataInterval (0,10,sec,10)
CardOut (1,200000)
FillStop
Average (15,potimp(),IEEE4,(Radar=1))
Average (1,Dehnung,IEEE4,(Radar=1))
Average (1,DMS,IEEE4,(Radar=1))
Average (1,TempSCH,FP2,(Radar=1))
Average (1,TempLuft,FP2,(Radar=1))
Average (1,TempLuft2,FP2,(Radar=1))
Average (1,TempCase,FP2,(Radar=1))
Average (1,RH,FP2,(Radar=1))
Average (1,Radar,IEEE4,(Radar=1))
EndTable

DataTable (Distanz,1,-1)
DataInterval (0,20,mSec,1000)
FillStop
CardOut (1,-1)
Sample (15,potimp(),IEEE4)
EndTable


'Main Program
BeginProg
Do
Scan (2,Sec,5,0)
PortGet (Radar,1): If Radar=1 Then ExitScan
AM25T (potimp(),15,mV2500,1,6,-1,RefTemp,7,8,0,1,0,_50Hz,0.05,-20)
PortGet (Radar,1): If Radar=1 Then ExitScan
AM25T (potimp(2),1,mV2500,2,6,-1,RefTemp,7,8,0,1,0,_50Hz,0.02,0)
PortGet (Radar,1): If Radar=1 Then ExitScan
BrHalf4W (PT100SCH,1,mV25,mV25,7,Vx3,1,2000,True ,True ,0,_50Hz,1,0)
PortGet (Radar,1): If Radar=1 Then ExitScan
PRT (TempSCH,1,PT100SCH,1,0)
PortGet (Radar,1): If Radar=1 Then ExitScan
BrHalf4W (PT100LUF,1,mV25,mV25,3,Vx1,1,2000,True ,True ,0,_50Hz,1,0)
PortGet (Radar,1): If Radar=1 Then ExitScan
PRT (TempLuft,1,PT100LUF,1,0)
PortGet (Radar,1): If Radar=1 Then ExitScan
PanelTemp (TempCase,_50Hz)
PortGet (Radar,1): If Radar=1 Then ExitScan
BrFull (DMS,1,mV7_5,5,Vx2,1,2500,True ,True ,0,_50Hz,1.0,0)
PortGet (Radar,1): If Radar=1 Then ExitScan
StrainCalc (Dehnung,1,DMS,BrZero,-1,KFaktor,0)
CallTable Messwert
NextScan


Scan (20,mSec,100,0)
PortGet (Radar,1): If Radar=0 Then ExitScan
AM25T (potimp(),15,mV2500,1,6,-1,RefTemp,7,8,0,0,0,250,0.05,-20)
CallTable Distanz
NextScan
Loop


SlowSequence
Scan (10,Sec,3,0)
If Radar=0 Then SDI12Recorder(TRH(),3,"0","C!",1.0,0)
NextScan


EndProg

* Last updated by: aps on 7/1/2011 @ 10:44 AM *


Martin Jul 5, 2011 06:43 AM

Dear Andrew

Thank you very much for your help. You're doing really a great job.

Unfortunately, your second program wasn't running first. That's because I copied the program out of the email I got from the forum. There were some errors.

For example:
PortGet (Radar,1): If Radar=0 Then ExitScan: ExitScan AM25T (potimp(),15,mV2500,1,6,-1,RefTemp,7,8,0,0,0,250,0.05,-20)

Probably caused by Microsoft Outlook. After copying the program direct from the forum, everything is fine. :-)

We're now measuring the time for switching from the slow to the fast scan. I'll coming back to you with results.

Even with card installed, there were no skipped records.

Again, thank you very much for the program.

Greetings from Switzerland

Martin


aps Jul 5, 2011 08:23 AM

The spurious error you got was my fault. I had used a find and replace function to change the program and it changed one thing it should not have done. I spotted the error a little while after the first post and then went back in and edited the post to correct it. That explains why cut and pasting it from the forum worked. Sorry.

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