ZAXTER.
Click to return home.


http://zaxter.me/siop/©

#!/bin/bash
# This script monitors an input pin "VALUE_A" for a state change and moves
# steppers direction until next state change to switch back.

watch_state() {
VALUE_NEITHER=3
VALUE_A=`cat /home/siop/port1/input/pin12`
VALUE_X=0
if [ $VALUE_A = $VALUE_X -a $VALUE_A != $VALUE_NEITHER ] ; then
clockwise_full_step
VALUE_NEITHER=$VALUE_A
elif [ $VALUE_A != $VALUE_X -a $VALUE_A != $VALUE_NEITHER ] ; then
counterclockwise_half_step
VALUE_NEITHER=$VALUE_A
fi
}

clockwise_full_step() {
# Number for sleep speed1 is set in a file from .00001 - 2 seconds.
speed1=$(for N in /home/user101/speed1 ; do cat $N ; echo -n " " ; done )
echo 1 > /home/siop/port1/output/pin7
sleep $speed1
echo 0 > /home/siop/port1/output/pin6
echo 1 > /home/siop/port1/output/pin8
sleep $speed1
echo 0 > /home/siop/port1/output/pin7
echo 1 > /home/siop/port1/output/pin9
sleep $speed1
echo 0 > /home/siop/port1/output/pin8
echo 1 > /home/siop/port1/output/pin6
sleep $speed1
echo 0 > /home/siop/port1/output/pin9
}

counterclockwise_half_step() {
# Number for sleep speed2 is set in a file from .00001 - 2 seconds.
speed2=$(for N in /home/user101/speed2 ; do cat $N ; echo -n " " ; done )
echo 1 > /home/siop/port1/output/pin9
sleep $speed2
echo 1 > /home/siop/port1/output/pin8
echo 0 > /home/siop/port1/output/pin9
sleep $speed2
echo 1 > /home/siop/port1/output/pin7
echo 0 > /home/siop/port1/output/pin8
sleep $speed2
echo 1 > /home/siop/port1/output/pin6
echo 0 > /home/siop/port1/output/pin7
sleep $speed2
echo 0 > /home/siop/port1/output/pin6
}

while true
do
watch_state
done
http://zaxter.me/siop/proto_typed_icon.png
Why buy SI/OP?