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.

CR1000 digital inputs


CTS Nov 1, 2013 10:28 AM

Hi,
I need to read out a 6 bit gray code from a wind vane. How can this be done the easiest using the CR1000 logger and CRBasinc.

The idea is to connect the 6 bit to the SE inputs 1-6 of the logger and doing a combined readout all at once. Hope its possible.

Your assistance is much appreciated.

Erik


GTProdMgr Nov 1, 2013 03:12 PM

If the levels on the 6 output lines don't exceed 5V, I would use control ports 1-6 (C1,C2, C3...C6) instead of the SE inputs. Then I would use the ReadIO instruction in the CRBasic program.

Use a Mask argument of &B00111111 to ignore ports 7 and 8 for the reading. You will get a number between 0 and 63 for the answer/result. Hopefully your wind vane manual tells you how to scale that result into the desired output (either a multiplier or offset or both would be specified).


From the CRBasic help:
----------
ReadIO is used to read the status of selected digital control ports. There are 8 ports available on the datalogger. The status of these ports is reflected as a binary number where a high port (+5 V) equals 1 and a low port (0 V) equals 0. For example, if ports 1 and 3 are high and the rest low, the binary representation is 00000101, or decimal 5.


aps Nov 1, 2013 03:54 PM

I am not sure which sensor you have but the code below shows and example of reading a 6-bit gray code into the control ports and then decoding it. Note that not all wind sensors use the same gray code scheme.

'Read Vaisala wind vane through control Ports 1-6
'Algorithm relies on the least significant bit being in C1

p=0
'binary-reflected Gray code:
ReadIO(Read_IO,63)
for j = 1 to 6
n = (Read_IO AND 2^(j-1))/2^(j-1)
p = p+n*((2^j)-(2*p)-1)
next

'Using this offset and multiplier matches the integer result to the WAV151 output
WD_Deg = INT((p*5.6244)+0.625)


If you want to measure the signals on analogue inputs you could do this with one VoltSE instruction with 6 reps and then process the result in a loop adding powers of two to the value destined to hold the binary result depending upon whether the voltage is above or below a threshold. As the measurements on each channel will be separated in time there is a small risk a bit could change whilst the voltages are being measured but the use of Gray code is supposed to minimise the errors incurred if this happens.

* Last updated by: aps on 11/1/2013 @ 9:54 AM *

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