|
Re: Limit Switches help
we have limit switches wire to the digital in/outs. The motor turns untill a certian pattern of switches open/clsed is reached, To make an integer from 4 digital i/os do this:
word = dig_in01<<3
word+= dig_in02<<2
word+= dig_in03<<1
word+= dig_in04
Say dig_01 & dig_03 were closed, making "0", the 4 bit word would be 0110 or 6.
Remember, inside the digital_in/outs are tied high, they read 1, you need to ground it to read 0.
Turn the motor until the number is the lift state you want. Think "state machine".
|