You are here

Did You Know? Bit-wise AND Digital Inputs in Q Programs

Apr
28
by Bob Loyzim

 All Q programmable drives provide digital inputs that can be used singly or in combination. In programs where only a single input must be examined the TI (Test Input) command is commonly used. The TI command can be used sequentially to test many inputs one right after the other, but it can be cumbersome to create a decision tree in this fashion. A better method may be to bit-wise AND the I/O register. The result is a number that represents the ON & OFF conditions of only the inputs of interest.

Lower-case i is the I/O register that contains the status of both digital inputs and outputs. The exact mapping of this register changes depending on the hardware platform. Refer to the section in the Host Command Reference (document No. 920-0002), Read-Only data registers: a - z

Here’s the representation for a ST-Q drive which will be used in the example below.

Notice the 8 digital inputs X1 thru X8 are represented by bits 0,1…7 and they have weighted values of 1,2…128 respectively.

Here’s the procedure for a system where 4 of the inputs must be in specific states and the other 4 we don’t care about their state.

Here’s the Q program for a 12,000 count move each time the 4 inputs exactly meet the required conditions.

News Tags: