Code + doc for Data Through Design 2019
- 4x Stepper Motor
- 4x L293D Driver IC
- 1x Raspberry Pi Model 3B
- 1x Power Supply DC 12V 0.6A
- 1x Power Connector
- 1x MicroSD Card 16GB
- from the pi, run:
wget http://enframed.net/deeds/controller.py
- following this
- download the latest video by running
wget http://enframed.net/deeds/legal_landscape.mp4
orwget http://enframed.net/deeds/legal_portrait.mp4
The diagram for wiring a single motor can be found here.
Things to take into consideration:
- The power source is represented as 2x AA Batteries. It should instead be the 12V power supply, connected to the power connector.
- The wires coming out of the stepper motor are black and red. For clarity, I've connected them to wires that are the same as their actual color (red, green, yellow, blue).
- This means that red and yellow go on one side of the IC, while green and blue should go on the other side.
Here's a shortcut to finding wire pairs for a bipolar (4 wire) motor. Spin your stepper motor with your fingers. Depending on the size / holding torque this could be easy or pretty hard. All you really want from this is to get a feel how the motor spins without any of the wires connected to each other. Now that you know how hard it is to spin with your fingers, connect 2 wires together, any two. Try to spin the motor again. If it feels the same then these are NOT connected to the same coil. Disconnect these wires. Connect one of the other wires to one of the first wire pairs you tried. Try to spin the motors again. This should be much harder. If so, you have found your wire pairs. Each pair goes on one side of the L293D.
In order to set up the raspberry pi, you will need to install it, find it, connect to it and execute the sample program.
- Download the disk image that we will flash on the SD card.
- Download Etcher.
- Insert the SD card in your computer.
- Open Etcher, select the image you just downloaded and the SD card you just inserted, and flash.
- Insert the microSD card in the raspberry pi and connect it to a power source. A microUSB plugged in to a laptop is enough.
- Once the raspberry pi is powered up, you should see a solid blinking LED.
- On your computer, open the Command Prompt and type
ping raspberrypi
. The output should give you the IP address of the raspberry pi. Make sure you are on the same WiFi network as the raspberry Pi. - Install Fing and scan your wifi network to find connected devices.
- Insert the SD Card into your computer. A
boot
disk should appear. Inside the boot partition, create a file calledwpa_supplicant.conf
, this is the file which connects automatically to WiFi networks. The file contents should look like this (make sure it's the correct ssid/pw for your own wifi!). - Plug in the raspberry pi directly to your router. Then open the command prompt and type
arp -a
. Your raspberry pi is the device that starts with the MAC addressb8:27:eb
.
- Download Putty (you probably want the 64bit MSI version).
- Enter the IP address of the raspberry pi in the
Host Name (or IP address)
field, withPort
set to 22 and clickOpen
. - A command prompt should open. When asked to login as, enter
pi
and for password enterraspberry
. - You are now connected to the raspberry pi. To execute the code to make the stepper motor turn, type
python stepper.py
and pressENTER
. Follow the prompts on the screen to select the delays/numbers of rotations.