BACK to START

FINAL PROJECT / WEEK 1 / COMPUTER AIDED DESIGN / COMPUTER-CONTROLLED-CUTTING / ELECTRONICS PRODUCTION / 3D SCANNING & PRINTING / ELECTRONICS DESIGN / COMPUTER-CONTROLLED MACHINING / EMBEDDED PROGRAMMING / MECHANICAL DESIGN / MACHINE DESIGN / INPUT DEVICES / 3D MOLDING AND CASTING / OUTPUT DEVICES / COMPOSITES / EMBEDDED NETWORKING & COMMUNICATIONS / INTERFACE AND APPLICATION PROGRAMMING / APPLICATIONS AND IMPLICATIONS / INVENTION, INTELLECTUAL PROPERTY, AND BUSINESS MODELS / PROJECT DEVELOPMENT

Week 10 - MACHINE DESIGN

April 6 - April 13

Lecture, Video

*Weeks Assignment*

This week was a group project.

* automate your machine
* document the group project and your individual contribution

To automate our primograph we decided to use a raspberry pi and a motor controller board. The video of the working machine you find on the group page and on the pages of Norma and Elissa you can find the documentation about how they made the hardware like the box and the gears. Here you can find my part of the project which was electronics and software and a little introduction using the pi and the explorer hat.

Bill of Materials

Design

The idea is to hit a button and in the middle of our Primograph and be able to change the speed of the motors which moves then the Primograph and draws patterns on a sheet of paper.

Electronics

I connected the two motors two the explorer hat board and then the button to pin 9 (MISO) and the led in the button to pin 10 (MOSI). I made this software with Fritzing. Its free to use. Download it here and think about a little donation to help the guys out.

Code

The Explorer HAT uses an output driver chip called the ULN2003A, which contains a set of transistor pairs called a Darlington Array. It transforms the small logic signal of the Pi into something capable of driving much bigger loads, such as motors, steppers, lights and more.

After a couple of hours wondering why my output does not work I found this:

The 4 outputs on Explorer can sink 5V, but not source. This means you need to connect your load to one of the 5V pins, and then to the output. When you turn the output on it will connect your circuit to ground, allowing current to flow and your load to turn on. This is the opposite of using a bare Pi GPIO pin, where you might connect to the pin and then to ground; keep this in mind!

In the meantime I have already connected the Button and the Led of the Button to MISO (pin9) and MOSI (pin10).

The complete code you find here and under Project Files. What it does is when you hit the button you start the motor and when pressing it again you make the motor go faster until its maximum speed and then you turn in off again.

import explorerhat
from gpiozero import Button, LED, Motor, Robot, Buzzer
from time import sleep


button = Button(9)
led1 = LED(10)
#buzzer = Buzzer(17)

#motor1 = Motor(forward=19 , backward=20) #gpio zero motor1
#motor2 = Motor(forward=21 , backward=26) #gpio zero motor2

#robot = Robot(left=(19, 20), right=(21, 26))



#the explorer hat has already some motor functions build in
#invert() - Reverses the direction of forwards for this motor
#forwards( speed ) - Turns the motor "forwards" at speed ( default 100% )
#backwards( speed ) - Turns the motor "backwards" at speed ( default 100% )
#speed(-100 to 100) - Moves the motor at speed, from full backwards to full forwards

#speed_levels = [0, 25, 50, 75, 100]
speed_levels = [0, 0.25, 0.5, 0.75]

active_speed = 0



def button_pressed():
        print("Button pressed")
        led1.on()
        explorerhat.light.toggle()

        global active_speed
        active_speed = (active_speed + 1) % len(speed_levels)
        explorerhat.motor.forwards(speed_levels[active_speed]) #with explorerhat
        #motor1.forward(speed_levels[active_speed]))   #with gpio zero Motor
        #motor2.forward(speed_levels[active_speed]))
        #robot.forward = (active_speed + 1) % len(speed_levels)

button.when_pressed = button_pressed

while True:
       sleep(5)

Control the Motor

Also I looked at the Data Sheet of the Motor Driver with is a Dual H-Bridge Current Control Driver DRV8833PWP and I realized that I could not only control DC Motors but also Stepper Motors and I am also able to control my speed with PWM.

These are the commands for the Motor I can use.

invert() - Reverses the direction of forwards for this motor
forwards( speed ) - Turns the motor "forwards" at speed ( default 100% )
backwards( speed ) - Turns the motor "backwards" at speed ( default 100% )
speed(-100 to 100) - Moves the motor at speed, from full backwards to full forwards

Make everything boot on startup

Because I wanted to make the pi battery powered and make the machine portable I made the program start on startup.

For that you just need to type the following in the terminal in your pi:

sudo crontab -e

insert code with ...

i
@reboot python /home/primogrogaph/motortest4.py

Team Primograph - Eva, Me and Elissa at Valldaura after just finishing the machine.

We were just happy to have something working. When I was visiting the Fablab Turin is saw another primograph version at Casa Jasmina. They just made the gears much smaller (so you dont have so much wobbling around) and they put the motors on the side of the box and made the gears out of plastic and the pencil holder out of aluminum.

Project Files

primograph.py

primograph_schematic.fzz (fritzing file)

Learnings

Feedback

Twitter me or email me at andreasrkopp at gmail dot com.

Or chat with me on gitter.

Gitter

previous week <-----------BACK to TOP-----------> next week