Advertisement

Saturday, April 26, 2014

Two Weekend Garden Projects

I worked on two garden-related projects last night and today.  First, I built a raised garden box to replace my rotted out box.  I spent $57 on six 2" x 8" x 8 foot boards at Home Depot and took them to the Milwaukee Makerspace for assembly.  I cut two of the boards in half to make the four foot sides.  Then, I connected the boards in pairs, one on top of the other, with 2" x 4" scrap that I found at the 'space.

This morning, the kids and I connected the sides into a 4' x 8' rectangle, and replaced the old rotted out box with the new one.  It was a pretty simple project.

Next, I built two compost bins from wooden pallets.  I got the pallets last fall from a local business that was throwing them away.  Tim and I connected them with smaller pieces of wood and some screws.  The front pallets will be attached to the other pieces with old electrical wire.  That way, they can be easily removed so the compost can be turned.


Overall, it was a good day.



Saturday, April 19, 2014

Tested Motor PCB With RPi and Motor

Earlier this week, we assembled the Raspberry Pi Motor Controller Board (aka RTK RPi MCB) from Ryanteck, Ltd.  Today, I spent a few hours experimenting with controlling motors using the RPi and the RTK MCB.

RTK RPi MCB Basics
The documentation that is provided with the RTK MCB is pretty sparse.  Here are some things that I learned while putzing that I wish was in the documentation.

First, there are two ways that the RTK MCB can be attached to the RPi's pins.  When attached properly to the RPi, the board will mainly hang over the RPi.  See the picture to the right.  If the MCB is attached the wrong way, it will hang over the table.

Second, as the documentation says, the left-hand input on the J1 VCC2 terminal block is for positive power.  The right-hand input is for ground.  The positive input is on the left when you face the terminal block to insert the wires.

Next, the J2 and J3 terminal blocks are to connect to the motors. J3 is for motor one.  J2 is for motor two.  The circuit that connects to the terminal blocks works as follows:

  • GPIO 17 / Pin 11 on the RPi connects to the left-hand input on terminal block J3 
  • GPIO 18 / Pin 12 on the RPi connects to the right-hand input on terminal block J3
  • GPIO 22 / Pin 15 on the RPI connects to the right-hand input on terminal block J2
  • GPIO 23 / Pin 16 on the RPI connects to the left-hand input on terminal block J2
This is a bit confusing.  Say your motor has a red and a black wire.  If you plug the red wire into the left input on terminal J3 and send power out GPIO 17, it will spin the motor in one direction, for example clockwise.  Then, you plug the red wire into the left input on terminal J2 and send power out GPIO 22, it will spin the motor counter-clockwise.  It would make more sense if applying power to GPIOs 17 and 22 made the same motor spin the same way.

In order to power a motor, you have to set one of the pins HIGH and the other pin LOW on a terminal block.  Setting one pin HIGH but not setting the other pin will not work.

Finally, I have no idea what pin headers J4, J5, and J6 are for.  The are labeled 3V3, GND, and I2C respectively.  The documentation does not explain their purpose and they are not needed to run the motors.  It would be nice to have a circuit diagram for the PCB.

Power Supplies
The manual for the MCB says that the board will accept 4.5v to 12v power supplies to power the motor.  I first connected a 9v battery to the MCB.  However, the actual output power was about 4.5 volts.  Not sure why the board does not pass more power through to the motor.

I connected a 12v, 200mA power supply and it worked much better.  More on that below.

Trying to run two motors at the same time seems to make each motor run slower than just powering one motor.  Maybe a PSU that put out more amps would help in this case.

Python Code
I spent a lot of time working on python code to drive the motors.  I had a program from a website that had a circuit driving a motor through a transistor.  I used it as a base and modified it to have the following features:

  • accept inputs for the motor to power (1, 2, or both), the time the motors will run, and the amount of power to send to the motors
  • power one or both of the motors for whatever length of time the user specifies
  • spin the motor first clockwise for one second.  Then, counterclockwise for 1.5 seconds.  Repeat for the allotted time.
  • control how fast the motors spin using pulse width modulation.
Here is a link to the program I used to control the motor.

Testing with the Auger
Now that the MCB is assembled and the python program works, we did some testing with the auger.  The first test was to try to push food through a 2" tube.  The 9v battery was the power source.  Unfortunately, it would not push much food through the tube.  Sometimes, it would not spin at all.

We tried using a smaller, 1" tube.  The motor would not spin the auger at all with food in the tube.  We changed the program so it spun the motor clockwise for 5 seconds instead of 1 second.  That did nothing.

Next, we connected a 12v, 200mA power supply as the motor power source.  The motor had no problem pushing food through the 2" tube with this much power.  We played with the time and power settings.  It looks like the best settings are to run the motor for 10 seconds at 75% power.  This will push the right amount of food into the bowl.

One problem is that the screw that is supposed to keep the motor's shaft in the connector is not tight enough to hold the shaft.  A piece of the allen wrench used to tighten the screw broke off in the screw.  Now, it cannot be removed.  I'm not sure how I will remove it but it needs to be fixed to continue experimenting .

It would also be nice to have something to hold the motor down while testing.  I'll have to build something.

Wednesday, April 16, 2014

Assembled Raspberry Pi Motor Controller Board Kit

Tim and I are building an automated pet feeder.  One thing we need to do is control a motor with the Raspberry Pi.  There are several ways to do this but I chose to use a controller board that was made to control motors.  I ordered the Raspberry Pi Motor Controller Board Kit from Adafruit.  The kit is made by Ryantech Ltd. and costs about $20 plus shipping.  That's a bit more than I was hoping to spend but I'm pretty sure it will do exactly what I need.  Plus, Tim and I can put it together ourselves.


The board can control up to two motors at once (we are only going to control one motor).  We have a 12v power supply that will connect to the board and provide power to the motor.  The board will let the Pi turn the motor in both directions.

I had Tim do the actual soldering work.  He had it done in about thirty minutes and did a great job.  We applied solder flux to the holes on the PCB to make the soldering a bit easier.  Then, we followed the instructions to solder each part to the PCB.  It really was quite easy.

One other hint related to soldering is to place the component upside down on the work surface and put the board on top of the component.  Gravity will keep the work on the component.  We had to add something under the other end of the PCB to support it.

We did not test the PCB with the Raspberry Pi.  That will come next.




Tags: #raspberrypi #petfeeder

Friday, April 4, 2014

Ordered a Motor Control Board for Raspberry Pi

Tonight, I wanted to make some progress on the automated pet food dispenser project.  One of the next things to figure out is how to control the motor using my Raspberry Pi microcontroller.  I did some research.  There are various options.  For example, there are chips like the L293D stepper motor driver or the L293E.  We did not have those drivers at the Makerspace.

There are also several different boards that will drive motors.  I decided to go with the RTK Motor Controller Board Kit from Adafruit.  It's a kit that I can solder together with my son as a mini-project.  Plus, it's relatively inexpensive and it will control a motor from my Pi.  I am sure there are a dozen other ways to control a motor from my Raspberry Pi but this is a good option for me.

Right after I ordered the board from Adafruit, Vishal, another member at the Milwaukee Makerspace talked to me about making my own circuit.  I did find a circuit on the internet that uses an NPN transistor to enable the circuit.  I wired up the circuit on a breadboard and hooked up a 12v power supply.  The motor turned on.  That was strange because I did not have it hooked up to the pi. 

I'll have to do more research.


Tags: #Motor, #RaspberryPi