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.

Measuring the time between port status changes


HP Feb 11, 2010 06:23 PM

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.

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


Dana Feb 12, 2010 06:55 PM

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


jra Feb 12, 2010 07:57 PM

HP,

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

Janet


HP Feb 15, 2010 01:23 PM

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


Sam Feb 15, 2010 07:06 PM

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.

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