Blog 16
Working with 2 7FETs Stepper motors
Talking to the second 7FETs ( stepper motor )
Raspberry Pi version:
How to find the second 7FETs( on spi1 ). The other 7FETS also of course has 88 as address. ( On the 2 dots there has to be a hexadecimal number. ) But when you also send
bw_tool -s 50000 -a 88 -W 42:..:i
nothing will happen, only the other stepper motor will rotate.
The second spi (spi1) is named spidec0.1.
bw_tool -S -D /dev/spidev0.1
( If you are sending commands on I2C you have to use -I instead of -S (SPI) )
Result:
88: spi_7fets 1.1
To try it out:
bw_tool -S -D /dev/spidev0.1 -a 88 -W 42:0x200:i
This should make the stepper motor rotate 90 degrees.
Arduino version:
2 7FETs rotating plateaus
Now I want to show how you can make it possible to let with the previous script let 2 7FETs rotate and stop a special amount of seconds.
#!/bin/bash Address="bw_tool -s 50000 -a 88" Address2="bw_tool -S -D /dev/spidev0.1 -a 88" Rot=-400 Target=`$Address -R 41:i` #Speed=200 #$Address -W 43:$Speed:b` #$Address2 -W 43:$Speed:b` Current="" while true; do $Address -W 42:$Rot:i $Address2 -W 42:$Rot:i Target=`$Address -R 41:i` while [ "$Current" != "$Target" ] ; do sleep 0.2 Current=`$Address -R 40:i` done sleep 10 done
What I did with the code I add a second address that leads to the second 7FETs. I made is possible to also change the speed from the second stepper motor. You of course have to make them both as fast otherwise one of them will keep spinning around. I also make it that they both run the command of rotating 90 degrees after the while do loop had ended.
2 7FETs stepper motors controlled by pushbuttons
Now lets control the 2 7FETs with the pushbuttons.
#!/bin/bash Address="bw_tool -s 50000 -a 88" Address2="bw_tool -S -D /dev/spidev0.1 -a 88" AddressI="bw_tool -I -D /dev/i2c-1 -a 94" #SpeedX=0x25 #bw_tool -s 50000 -a 88 -W 43:$SpeedX:b #SpeedY=0x25 #$Address2 -W 43:$SpeedY:b $AddressI -W 10:00:b $AddressI -W 11:00:b $AddressI -t "1=1+ 2=1- 3=12+" $AddressI -W 11:20:b $AddressI -t "4=12- 5=2+ 6=2-" Rot=0x200 #Rot2=0x400 #Rot3=0x100 while true; do Button=`$AddressI -R 30:b` if [ $Button = "20" ]; then $Address -W 42:$Rot:i fi if [ $Button = "10" ]; then $Address -W 42:-$Rot:i fi if [ $Button = "08" ]; then $Address -W 42:$Rot:i $Address2 -W 42:$Rot:i fi if [ $Button = "04" ]; then $Address -W 42:-$Rot:i $Address2 -W 42:-$Rot:i fi if [ $Button = "02" ]; then $Address2 -W 42:$Rot:i fi if [ $Button = "01" ]; then $Address2 -W 42:-$Rot:i fi sleep 1 done