Advertisement

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.

No comments:

Post a Comment