Hello,
I need to use the CR6 to measure the high time and the low time of a fast digital signal (1uS resolution).
I thought TimerInput would work for this but I looked closer at its documentation and now I'm not sure if it will work. The description for function 3 is below:
calculate the time from an edge on the previous channel (1 number lower) to an edge on the specified channel (in microseconds)
With this approach I can measure the time between a high and low pulse, or the time between a low and a high pulse. But I can't get the continuous measurement of high to low to high to low, etc. that I need.
Does anyone know how I can continuously measure the high time and low time of the signal?
Thanks
The following program will give the High time in Period(1) and the low time in Period(2). You must feed the same signal into all four C ports C1..C4.
When you say a fast digital signal, keep in mind the limitation for input frequency to TimerInput is around 2.2KHz, but the resolution of the timing is 520nS.
Public Period(2)
BeginProg
Scan (1,Sec,0,0)
TimerInput(Period,C1,1001,3030,0,0)
NextScan
EndProg
Hi DAM
Thanks for your reply, I kind of had that approach in mind and it is a relief to hear you confirm that it should work.
In terms of timing I did some calculations to make sure the error wouldn't affect my data too much. The algorithm from going from my t on and t off to the data of my sensor (which is angular position divided into 2^12 steps) is:
x = ((t on * 4098) / (t on+ t off)) -1
If there is 520nS of error on the start and end of both the t on and t off measurements there will still only be a max of +/- 1 bit of error in the data I get, which corresponds to 0.088 degrees. This is an acceptable amount of error for our application.
The one thing I still don't get is how I'm going to store the data. My high level approach is to store it in an array then offload it to the microSD card when the array gets full which should be about 4MB according to the spec for SRAM of the CR6. For the array, it will be 2D with 1 column for t on, the other column for t off, then each successive row is the next measurement, like so
t on 1 | t off 1
t on 2 | t off 2
... 4MB is filled ...
t on last | t off last
My problem is that I don't know the syntax for timerInput to write to an array like that. I get how to write to the two columns (like you showed above) but not how to write to each successive row for a new measurement, and I can't find it in the documentation. Do you know how to do that?
Thanks for your help,
Tom
You can use the DataTable .. EndTable to store the data automatically (no need for the array filling). It will store a timestamp and both values in the array each time you use the CallTable. The code below will do it. You can use LoggerNet or the DevConfig utility to connect to the CR6 and retrieve the stored values. With a newer CR6, this will give ~ 72Mb of storage (the 4M of RAM you referred to plus ~70Mb of internal flash memory). You could also go directly to a uSD card up to 2Gb per file by adding a CardOut instruction within the table. refer to the help for more of an explanation on the CardOut operation. You don't need to handle the array manipulation or writing to the file. This is all done in the canned up instructions.
Public Period(2)
DataTable(HighLow,True,-1)
DataInterval(0,1,Sec,10)
Sample(2,Period,IEEE4)
EndTable
BeginProg
Scan (1,Sec,0,0)
TimerInput(Period,C1,1001,3030,0,0)
CallTable(HighLow)
NextScan
EndProg