Tuesday, 19 August 2014

Stepper Motors

So to move the sweet launcher barrel, I'm using two, 6 wire 12V DC hybrid stepper motors to rotate both horizontally and vertically. These were brought from RS (part no. 191-8299). It gets a bit technical from here, so i wont be upset if you decide to close the web page here :)


I am driving each motor using the unipolar driving method, shown below (pic from motor datasheet).



In order to rotate the stepper motors , each of its windings must be excited in a sequence. To reverse the direction of rotation, I simply reverse the sequence. This is illustrated below (pic also found in the datasheet).



Interfacing motors with the Raspberry Pi

If you are a beginner with the raspberry you will quickly realise that you cant just plug the motors into the PI's GPIO port and hope it to work, this is true for anything that requires more power that the Pi can source.

Switches to switch switches!

Instead, I used the Pi to switch externally powered MOSFET's (instead of the BJT's shown in the unipolar method pic... whos awake?) to drive the motors. I need four externally powered switches for each stepper motor, giving a total of 8, a pic of a single externally powered switch circuit is shown below (please note that the pin labelled "GPIO" is meant to be a single arbitrary GPIO pin, not the entire GPIO port).


So here is how it works.

I first sort to buffer the motor winding from the Pi, to this end i used a simple optocoupler, connected between the Pi's GPIO and the gate of the MOSFET.

When the GPIO pin is high, the LED is off, and the BJT in the optocoupler is also off. The MOSFET gate is the pulled to 12V through R1, turning it on. Current then flows through the motor energizing it.

Conversely,, when the GPIO pin is low, the cathode of the optocoupler LED goes to zero volts, the anode of the LED is at 5V and the LED turns on. This in turn, switched the optocoupler BJT on and its collector is pulled to zero volts, which also pulls the MOSFET gate to zero volts. When this happens the MOSFET is off and no current flows through the motor winding. The shottky diode provides a path for back EMF.

I calculated the value of R1 so that the current that flows through it is the collector emitter current of the optocoupler, which is 50mA. Using our trusty Ohms law and knowing the input voltage is 12V, i calculated a value of 240R

Simply rinse and repeat for the remaining 7 and populate onto vero board.

 Here's one i made earlier.







The Pi was connected to the board with an expansion board (the red T lookin thing in the top left hand corner).

Monday, 21 July 2014

Sweet Beginnings

So here we are, as you have most likely guessed this blog is about about the construction of a sweet launcher, which will rapidly deliver a sugary treat to a hungry individual! 

I am doing this as a summer project over 8 weeks for the university of Bristol Blake bursary with the aim to use it as an interactive demo for open days and introduce engineering concepts, such as programming digital signal processing, real time systems, programming, electronics, mechanical engineering and such. 

So here is the idea...

I am going to develop a  pneumatically driven launcher that will deliver a sweet to a target individual.
Once a person is detected the launcher will automatically adjust its position and then fire a sweet to
that persons location. This system will be based around the Raspberry Pi, which will unitise a video feed input to detect a person and will control a range of actuators, pneumatics to launch the sweet and stepper motors to adjust the position of the launcher barrel. It will also be able to connect a computer via wireless connection for manual control.

So what's been going on?!

Currently im a week in, and while I've been waiting for parts to arrive, I have mostly been busying myself with getting to grips with the raspberry pi... im about as noobish as they come to using Linux based systems, so im experiencing a little bit of a learning curve, however i am picking things up quickly with the help my immensely talented & esteemed colleague, whom is also doing a blake bursary project, i set up an SSH connection from pi to laptop and made some basic programs to control the Pi's GPIO. Check out what he is doing for his project on his blog 8-bit band!

So what's next?

Recently i got some stepper motors and components needed to interface them to the raspberry Pi (WOOO!), but more on that later!