Measuring the time between port status changes_Campbellsci论坛问答

Hi

I am trying to measure the time it takes for a channel/port to go to HIGH (+5V) on a CR215/216 with in a scan.

Measuring the time between port status changes_Campbellsci论坛问答

This channel is the output from be a basic ultrasonic range sensor that is enabled by a separate port.

Any thoughts would be greatly appreciated.

regards,
HP

新对话如下:

I have been thinking about this, and I haven't come up with much (but it is Friday, so I could be missing something). You could put something in a loop and come up with "Counts" but there is no way to equate Counts to time AFAIK. The CR200 is limited since the any time returned in the program is based off time at the top of the scan and the scan resolution is 1 sec. See below for counts, FWIW.

Dana W.

Public Counter, Port, Flag(1)

DataTable (LoopTab,True,1000)
Sample (1,Counter)
EndTable

BeginProg
Scan (1 ,sec)
Counter=0
If Flag(1) Then
Do
Do Until Port = -1
PortGet (Port,C1)
Counter=Counter+1
CallTable (LoopTab)
Loop
Flag(1) = 0
Loop
EndIf
NextScan

EndProg

新对话如下:

HP,

Take a look at the Ticker250ms instruction. That may give you enough resolution to catch what you are looking for.

Janet

新对话如下:

I am afraid that the resolution needed is in the 1/10 ms range.

The sensor requires that the control port (C1) is maintained at +5V for enough time for a ultrasound pulse to travel forth and back. When the pulse is picked up again the sensor output (SE1) goes to +5V and stays until the control port goes down.

There is a function PeriodAvg which seems to perform microsecond time measurements and would be perfect for the sensor but I have only been able to get a NaN.

HP

新对话如下:

HP,

I know you mentioned that you are using the CR215/216, but the CR800/CR1000/CR3000 (and up) loggers have the functionality and CRBasic instructions to do this.

In CRBasic, take a look at the TimerIO instruction.
"The TimerIO instruction is used to measure the time between edges (state transitions) or frequency on the digital I/O ports of the datalogger."

For example, the following instruction in a CR1000 measures period on C1 and the time between rising and falling edges using C1 and C2. The sensor is connected to both C1 and C2 with a jumper.

Public pwmdat(2)
Alias pwmdat(1)= period
Alias pwmdat(2)= t_on
BeginProg
Scan (1,Sec,0,0)
TimerIO(pwmdat(),00000001,00000031,0,0)
NextScan
EndProg

I could imagine tying your control output to C1 and your sensor output to C2. Then might use something like:
TimerIO(pwmdat(),00000011,00000031,0,0)

This is just one thought.

分享到:

原文链接:,转发请注明来源!
海洋仪器网 仪器使用 Measuring the time between port status changes_Campbellsci论坛问答
「Measuring the time between port status changes_Campbellsci论坛问答」评论列表

发表评论