Difference between revisions of "Blog 17"
From BitWizard WIKI
(→Stepper motor version) |
(→'electric wheels' version) |
||
Line 51: | Line 51: | ||
The full car just went to be a carton box, with everything attached to it with tieraps. | The full car just went to be a carton box, with everything attached to it with tieraps. | ||
− | == ' | + | == 'Electric wheels' version == |
− | Hardware I used: | + | Hardware I used on my Raspberry Pi: |
+ | *One [http://www.bitwizard.nl/shop/raspberry-pi-ui-16x2 RPi_UI board] | ([[User Interface]]) | ||
+ | *One [http://www.bitwizard.nl/shop/motor?search=motor Motor] | ([[Motor]]) | ||
+ | *One [http://www.bitwizard.nl/shop/cables-connectors/4-pin-cable-f-f Cable, 4 Pin (I2C), F-F ] | ||
+ | *Two electric wheels | ||
+ | *Soft cables ( To connect to the motor and the wheels ) | ||
+ | *One dongle | ||
+ | |||
+ | I also used some tieraps to attach the wheels on a board. | ||
+ | |||
+ | Programming: | ||
+ | *Bash | ||
+ | |||
+ | Script: | ||
+ | |||
+ | #!/bin/bash | ||
+ | |||
+ | #Wheel A left forward | ||
+ | #Wheel B Right forward | ||
+ | |||
+ | # X is forwards - Y is backwards | ||
+ | #Wheels at front | ||
+ | #20 A backwards | ||
+ | #21 A forwards | ||
+ | #22 A stop | ||
+ | #30 B backwards | ||
+ | #31 B forwards | ||
+ | #32 B stop | ||
+ | |||
+ | while true; do | ||
+ | BUTTON=`bw_tool -I -D /dev/i2c-1 -a 94 -R 30:b` | ||
+ | |||
+ | if [ $BUTTON = "20" ]; then | ||
+ | #Car going forwards | ||
+ | bw_tool -I -D /dev/i2c-1 -a 90 -W 21:80:b | ||
+ | bw_tool -I -D /dev/i2c-1 -a 90 -W 31:80:b | ||
+ | fi | ||
+ | |||
+ | if [ $BUTTON = "10" ]; then | ||
+ | #Car going backwards | ||
+ | bw_tool -I -D /dev/i2c-1 -a 90 -W 20:80:b | ||
+ | bw_tool -I -D /dev/i2c-1 -a 90 -W 30:80:b | ||
+ | fi | ||
+ | |||
+ | if [ $BUTTON = "08" ]; then | ||
+ | #Car going left | ||
+ | bw_tool -I -D /dev/i2c-1 -a 90 -W 21:30:b | ||
+ | bw_tool -I -D /dev/i2c-1 -a 90 -W 31:80:b | ||
+ | fi | ||
+ | |||
+ | if [ $BUTTON = "04" ]; then | ||
+ | #Car going right | ||
+ | bw_tool -I -D /dev/i2c-1 -a 90 -W 21:80:b | ||
+ | bw_tool -I -D /dev/i2c-1 -a 90 -W 31:30:b | ||
+ | fi | ||
+ | |||
+ | if [ $BUTTON = "02" ]; then | ||
+ | #Car Stops | ||
+ | bw_tool -I -D /dev/i2c-1 -a 90 -W 22:80:b | ||
+ | bw_tool -I -D /dev/i2c-1 -a 90 -W 32:80:b | ||
+ | fi | ||
+ | |||
+ | if [ $BUTTON = "01" ]; then | ||
+ | exit | ||
+ | fi | ||
+ | |||
+ | sleep 1 | ||
+ | done | ||
+ | |||
+ | Other movements: | ||
+ | #Spinning right | ||
+ | bw_tool -I -D /dev/i2c-1 -a 90 -W 20:80:b | ||
+ | bw_tool -I -D /dev/i2c-1 -a 90 -W 31:80:b | ||
+ | |||
+ | #Spinning left | ||
+ | bw_tool -I -D /dev/i2c-1 -a 90 -W 21:80:b | ||
+ | bw_tool -I -D /dev/i2c-1 -a 90 -W 30:80:b | ||
+ | |||
+ | I think the code pretty much explains itself with the extra info I have given it. I used the push buttons as example of how it could be used. | ||
+ | All the protocols can bee found in [[Motor protocol]]. |
Revision as of 14:04, 16 November 2015
Contents
2 Wheel controlled car
I made this on the Raspbery Pi for the stepper motor and for 'electric wheels'.
Stepper motor version
Hardware I used on my Raspberry Pi:
- One RPi_UI board | (User Interface)
- Two 7FETs | (7FETs)
- Two Jumper cables M-F
- Two IDC cable 6 pin
- Two 28BYJ-48 Stepper Motor
Programming:
- Bash
3D printed wheels code
I made the wheels in OpenSCAD and let them be printed out on a 3d printer. The OpenSCAD code:
$fs=0.2; $fa=2; module stepperas(d=5, l=25, t=3) { difference() { cylinder (r=d/2 , h=l); translate ([t/2, -5, -1]) cube([10, 20, l+2]); translate ([-t/2-10, -5, -1]) cube([10, 20, l+2]); } } difference() { union () { difference () { cylinder (r=60/2 ,h=12); translate ([0, 0, 1.5]) cylinder (r=50/2, h=20); } cylinder (r=6,h=6); } translate ([0, 0, -1]) stepperas(5.2, 20, 3.2); }
The full car just went to be a carton box, with everything attached to it with tieraps.
'Electric wheels' version
Hardware I used on my Raspberry Pi:
- One RPi_UI board | (User Interface)
- One Motor | (Motor)
- One Cable, 4 Pin (I2C), F-F
- Two electric wheels
- Soft cables ( To connect to the motor and the wheels )
- One dongle
I also used some tieraps to attach the wheels on a board.
Programming:
- Bash
Script:
#!/bin/bash #Wheel A left forward #Wheel B Right forward # X is forwards - Y is backwards #Wheels at front #20 A backwards #21 A forwards #22 A stop #30 B backwards #31 B forwards #32 B stop while true; do BUTTON=`bw_tool -I -D /dev/i2c-1 -a 94 -R 30:b` if [ $BUTTON = "20" ]; then #Car going forwards bw_tool -I -D /dev/i2c-1 -a 90 -W 21:80:b bw_tool -I -D /dev/i2c-1 -a 90 -W 31:80:b fi if [ $BUTTON = "10" ]; then #Car going backwards bw_tool -I -D /dev/i2c-1 -a 90 -W 20:80:b bw_tool -I -D /dev/i2c-1 -a 90 -W 30:80:b fi if [ $BUTTON = "08" ]; then #Car going left bw_tool -I -D /dev/i2c-1 -a 90 -W 21:30:b bw_tool -I -D /dev/i2c-1 -a 90 -W 31:80:b fi if [ $BUTTON = "04" ]; then #Car going right bw_tool -I -D /dev/i2c-1 -a 90 -W 21:80:b bw_tool -I -D /dev/i2c-1 -a 90 -W 31:30:b fi if [ $BUTTON = "02" ]; then #Car Stops bw_tool -I -D /dev/i2c-1 -a 90 -W 22:80:b bw_tool -I -D /dev/i2c-1 -a 90 -W 32:80:b fi if [ $BUTTON = "01" ]; then exit fi sleep 1 done
Other movements:
#Spinning right bw_tool -I -D /dev/i2c-1 -a 90 -W 20:80:b bw_tool -I -D /dev/i2c-1 -a 90 -W 31:80:b #Spinning left bw_tool -I -D /dev/i2c-1 -a 90 -W 21:80:b bw_tool -I -D /dev/i2c-1 -a 90 -W 30:80:b
I think the code pretty much explains itself with the extra info I have given it. I used the push buttons as example of how it could be used. All the protocols can bee found in Motor protocol.