Jump to content
  • 0

How to use a Rotary Encoder with an USB-1808X


Matthew_1

Question

Greetings,

I would like some assistance with how to work with rotary encoders using my 1808X DAQ. I've been using the example file 'CInScan03' as a reference, but I'm still having trouble getting it to work. Note that my encoder only has an A and B wire (no Z wire), and I'm working in Python.

One question is what sort of information comes from the encoder pins (ENCx0 and ENCx1) using the universal library functions? From the 'CInScan03' description it looks like the position (counts) is a standard output, but are other value types like direction and velocity (counts over time) also values I could get from universal library functions, or would I have to write my own functions using position to find them.

Another question is that in the notes of 'CInScan03' it says that it "Scans a counter input in encoder mode...", so does that mean that I would have to connect the A and B wires to the counter pins (CTR0 and CTR1), or that when you set the mode to encoder mode that it reads the counts from the encoder pins (ENCx0 and ENCx1)?

Thanks!

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hello,

There are four counters on the USB-1808X. The first two do not support encoders. Therefore the first encoder channel is number 2. X1 mode increments the count each time it sees a rising edge in phase A. X2 will count rising edges and falling edges in phase A, and X4 will count rising and falling edges in both phases. The data return is simply a number representing the count. There's no conversion to distance or velocity.  

Connect both A & B phases to counter two labeled ENC0A and ENC0B. Here's how to configure it.

      ul.c_config_scan(board_num,
                         2,
                         CounterMode.ENCODER | CounterMode.ENCODER_MODE_X1,
                         CounterDebounceTime.DEBOUNCE_NONE,
                         CounterDebounceMode.TRIGGER_AFTER_STABLE,
                         CounterEdgeDetection.RISING_EDGE,
                         CounterTickSize.TICK20PT83ns,
                         2) 

Best regards,

John

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...