Advertisement

Showing posts with label Raspberry PI. Show all posts
Showing posts with label Raspberry PI. Show all posts

Friday, October 9, 2015

FBI Exit Problem Fixed

I finished the first prototype for the MMS Photo-inator Xsi a few months back.  It will take a picture when someone presses the button.  Then, it displays the picture on the screen for a few seconds.  Next, it flashes the lights on the green and red buttons and waits for the person to press one.  If the person presses the red button, the program deletes the picture and resets.  If the person presses the green button, the program keeps the picture and resets.



One thing that I need the Photo-inator to do is stop displaying the picture if the person presses either the red or green button.  I have not been able to figure that out, until now.  

I tried sending a keystroke to the session but that did not work.  I also tried killing the process but that did not work.  I tried other software and solutions but could not find one.  I spent the last few months trying to figure this out.  It has been extremely frustrating.  Here is how I finally resolved the problem.

I heard that the uinput module for python will allow me to send keystrokes to a session.  I downloaded the source code from here: https://pypi.python.org/pypi/python-uinput

Before I could install the source code, I had to install a supporting program by typing
sudo apt-get install libudev.so

Next, I installed the source code by running
sudo python setup.py buildsudo python setup.py install
I could not get fbi to work in the python program.  Tried it from the terminal and it will not work either.  I keep getting an error message that says, "ioctl VT_GETSTATE: Inappropriate ioctl for device (not a linux console?)"

Used Ctrl-Alt-F1 to switch to tty1 .  Executing fbi on tty1 works perfectly.

If I have the python program execute this: "fbi -a -T 1 -t 1 BBB.jpeg", fbi will display the image.  The -T 1 tells fbi to display the program on tty1.  I need to specify this on my PC but it apparently did that by default when I ran the program on the Raspberry Pi. 

Next, I wrote a small python program to display a picture with fbi, wait a few seconds, then send a q to the uinput subsystem on Linux to simulate a user pressing the letter q.  This worked perfectly.

The test code looked like this:

#!/usr/bin/python
import subprocessimport psutilimport timeimport uinput

subprocess.call("fbi -a -T 1 -1 /home/ken/Pictures/BBB.jpeg", shell=True)time.sleep(3)
#Uinput testsevents = (    uinput.KEY_Q,    uinput.KEY_H,    uinput.KEY_L,    uinput.KEY_O,    )

device = uinput.Device(events)time.sleep(1)
device.emit_click(uinput.KEY_Q)
Finally, I modified the photo-inator program to use the uinput code.  I need to fire up the whole system to test it out.  I'll do that some other day.

Saturday, June 27, 2015

Building an NPN Transistor Switch Circuit

Introduction
The next step in the MMS Photo-inator project is to design a circuit to switch the light bulbs in the buttons on an off using transistors.  The Raspberry Pi 2 can't provide enough power to make the lights bright enough but it can control electronic switches that allow a higher powered power source to turn the lights on.

Using transistors turned out to be very difficult to me.  The concept of a transistor is pretty simple but actually getting a circuit working is not.  I burned out several transistors trying different things.  I have also read various sources to learn more about transistors but it does not seem to help.  Last weekend, Royce from the Milwaukee Makerspace helped me build a circuit that worked.  I'll try to document what I learned for my own edification.

Learn About Transistors (good luck)
Here are some links to learn more about how to use NPN transistors as a switch:


Transistorized Switching Circuit
The objective is to turn three individual light bulbs on and off from my Raspberry Pi using transistors.  The basic circuit is shown below.  Note that everything, 12v PSU, RPi, and lights share the same ground.  This is important.


Transistors will be used as electronic switches to allow current from the 12v, 1.8A power supply to flow through the light bulbs.  The Pi will send a 3.3v signal to the base pin on the transistor.  This is the signal that tells the transistor to turn on the light bulb.

According to this site, the Raspberry Pi can safely put out a maximum of 16 mA per GPIO pin and a total of 50 mA on all GPIO pins.  So, I have to be careful and limit the current from the Raspberry Pi to the base of the transistor to 16mA per transistor.

Transistor Specifications
The first thing to do was to determine the characteristics of the transistor my project needed.  This site was helpful to determine what transistor to use.

The transistor has to handle the output from the power supply I will use -- 12v and 1.8A (max) -- to power the lights.  Even though the lights only draw 0.25A, the PSU can put out 1.8A.  I think it is possible for the transistor to draw the full current in some circumstances so I need a transistor that can handle the maximum current from the PSU.   The parameter for current is called Ic(max) on the datasheets.  The parameter for voltage is called VCEO (max).  When I look at the datasheet for a transistor, it has to have characteristics that fall within these two specifications.

Finally, the amount of current that the base needs must be <= 16mA.  This parameter is called IB.  To determine the IB parameter, you have to find the formula on the datasheet.  It is usually something like IC = X * IB.  Basically, divide the current for the load by X to find the current to send to the base.  In my case, the load current is 1.8A maximum.  If, for example, a particular transistor has a formula of IC = 100IB, IB would be equal to 1.8A / 100 or 18mA.

Finding a Transistor
Next, I had to find a transistor that meets the specifications.  The Milwaukee Makerspace has several NPN transistors in bulk.  I looked up the specifications for each one on the http://www.datasheets360.com/ website.  Unfortunately, none of the NPN transistors on-hand matched the requirements.  It seemed like I was going to have to buy a MOSFET transistor like this one on SparkFun.  On a hunch, I looked through the hack rack at the 'space for any parts that may have transistors and found a circuit board that had sixteen 2N6045 NPN transistors.  According to the datasheet, these transistors have an I(max) of 10A, and a VCEO (max) of 100V.  Both of these are sufficient for this project.  The IB formula for this transistor is IC/100 or 18mA in my case.  This is just a bit higher than the Pi would like but, the load should not draw that many amperes.  The nominal current that the lights will draw is 0.25A.  This means that the base current needs to be 2.5mA under normal load--well within the Pi's capacity.  Finding the circuit board was an unexpected blessing.  Thanks, Big Guy.

I was able to remove a couple of transistors from the circuit board using a soldering iron.

Resistor for the Base
Its important to prevent the transistor from pulling too much current from the Pi and damaging it.  The Pi can be protected from this by placing a resistor between the Pi and the base pin.  Determining the size resistor that is needed was a bit complicated.

First, we made a circuit with one resistor and one 12v lamp.  A regulated power supply was used to determine the minimum current that would turn on the 2N6045 transistor.  To find the exact current level that the circuit was pulling, I unplugged the positive cable from the PSU, connected the red cable from the multimeter to the positive out on the PSU, then, connected the black lead on the multimeter to the circuit.  The minimum current required to activate the transistor turned out to be 8mA.  Finally, using a multimeter to measure the volts from the base to the emitter while the light bulb was on, showed that the PSU was supplying about 1.4v at this current level.

This means that the voltage from the pin on the Pi needs to be lowered from 3.3v to 1.4v at 10mA (rounded up from 8 just to be safe).  The resistor has to remove 3.3-1.4 or 1.9 volts.  Using Ohm's law to calculate the resistance works like this:

R = V/I or
R = 1.9/0.01A or
R = 190 ohms.

Putting a 190 ohm resistor between the Pi GPIO pins and the base pins of the transistors should keep the Pi safe from pushing out too much current, while providing enough volts to activate the transistor.

I put a 180 ohm resistor (the 'space had a 180 or 220 ohm but no 190) in the circuit and connected the Pi's 3.3v output pin to the base.  The light turned on!

That was a lot of work and very frustrating at times.  I would have never made it this far without Royce.  That is what is so great about the Milwaukee Makerspace.  There is usually someone around who can help you through the rough spots.

Next, I need to remove some more resistors from the board and build a prototype of the complete MMS Photo-inator project.

Friday, May 29, 2015

MMS Photo-inator Xsi -- 22-25 May session

While at the Milwaukee Makerspace for my weekly Maker-time, I continued working on my idea to use a Raspberry Pi 2 Model B to make a device that will take pictures by controlling an SLR camera. This time, I found some software to display an image, made a prototype with hardware, and wrote most of the python code.

Installed Avahi on the pi so I can connect to the Pi over a network.  This allows me to do coding on my Linux laptop and FTP the files to the Pi.  If something happens to the Pi, I won't lose the code.  The instructions to install Avahi are here.  Changed the name of the device to photoinator in both the /etc/hostname and /etc/hosts files.

I kicked around ideas for a human to interact with the photo-inator.  One of my fellow Makers suggested doing everything in web pages.  That would probably make everything easy including printing the picture but it wouldn't make much use of the Perma-Proto Pi Hat from Adafruit.  I'd like to have the user interact with the photo-inate by pressing buttons and seeing flashing lights.

Also, I would like to display a preview of the picture and let the user decide if it is good enough to keep or not.  How do I get the Pi to display a jpg file without using xwindows?

First, I tried an application called feh to display images.  This web page has the instructions for installing feh: http://feh.finalrewind.org/

After messing around with feh, I realized that it only works from within xwindows.  That does not help -- especially since gphoto2 only runs from the command line and will not work in a terminal session running in xwindows.

The application that I needed is called fbi.  I installed the app using sudo apt-get install fbi.  After that, it just worked.  I ran the program in the directory that has the photos in it.  The way to run fbi is fbi image.jpg -a -t 10 -1.  The -a will auto re-size the image to fit the screen.  -t 10 tells fbi to display the image for 10 seconds.  -1 means that fbi should exit after the timeout.

Next, I wrote a quick shell program to take a picture with gphoto2 then display it with fbi.  I pass the filename to save the picture to as a parameter.  The shell file looks like this:

gphoto2 --capture-image-and-download --filename=$1.jpgfbi $1.jpg -a -t 10 -1

The $1 lets me pass in a file name on the command line.

Next, I used a python program that I found on this Instructable and modified it a bit to control a button and an LED on the Adafruit T-cobbler Plus proto board.  It worked.  I was able to press a button to start the process.  The program flashed an LED, took a picture, and displayed it on the screen for 10 seconds.  Nice.

I spent a good part of the day on Sunday (after church of course) writing a much more robust Python program with subroutines and global variables and all of that nerdy goodness.  

Finally, I spent Memorial Day back at the Makerspace to build the prototype and debug the code.  The prototype has three buttons and four LEDs.  One button is to start the picture-taking process.  Another will let the human choose to Keep the picture they just saw.  The third button will tell the Pi to reset everything and start over.  One of the LEDs will light when the picture-inator is ready to take a picture.  The second LED will blink increasingly fast to warn the user that the picture is about to be taken.  The final two LEDs blink alternately next to the Keep and Reset buttons to encourate the human to push one.  This all works fine.  For the final version, I would like to use small light bulbs instead of LEDs to increase the brightness.  I probably need a stronger power source than the PI to light them.  I will also need a more complicated circuit that includes a transistor.  I'll design and build that in the next session.

Another idea I had was to add a toggle switch to designate the mode that the picture-inator is in -- one shot or continuous.  That should be pretty easy to do but I did not get to it this time.

One of the things I struggled with on the coding side was the GPIO.add_event_detect function.  I originally wanted the program to call a subroutine when a button was pressed.  However, I could not get that to work.  The subroutine might get called the first time the button was pressed but not after that.  Sometimes, pressing the button never did anything.  I ended up punting and doing several things to make this work.

First, the main loop uses GPIO.event_detected to see if any of the buttons were pressed.  Anytime a button is pressed or a state changes, the program turns off event detection for all buttons.  Then, it does whatever the function is meant to do, and turns on even detection for any buttons that need to have it.  Doing all of this should allow the program to always catch button presses and never have false-positives or multiple button presses.

One other problem is that I don't know how to interrupt the picture being displayed.  So, if the person pushes the Keep button while the picture is being displayed, nothing will happen.  I don't think I can fix that.  I spent a lot of time researching a way to call an external program in a separate thread but I'm not sure it is possible.

The bug I am currently working on has to do with debug mode.  When the program is running in debug mode everything works.  However, when I run the program with debug mode turned off, it turns on the ready LED but will not do anything when any button is pressed.  I have not been able to figure out why.

Another bug is if the camera is off, gphoto2 returns an error.  The program cannot handle the error.  Need to figure that out.

Here is a picture of the prototype at this point.


MMS Photo-inator Xsi -- 15 May 2015 Session

Even though I am posting this near the end of May, I am describing my efforts from 15 May 2015.

While at the Milwaukee Makerspace for my weekly Maker-time, I continued working on my idea to use a Raspberry Pi 2 Model B to make a device that will take pictures by controlling an SLR camera. 

Another New Camera
After posting my lackluster progress on the Makerspace Google Group, a Makerspace member named Matt
offered to let me use his Canon EOS Rebel Xsi DSLR camera.  Awesome!  It was waiting for me in my locker when I arrived at the 'space.  I tried using gphoto2 with the Canon.  gphoto2 detected the camera but I still had some issues.  I could not take pictures or basically do anything.

Did some searching on the internet.  One site said that the version of gphoto2 that gets installed with apt-get is not the correct version.  apt-get downloads version 2.4.14.  You need the latest version of both libgphoto and gphoto2.

First, I used sudo apt-get purge gphoto2 to remove the gphoto app.

Next, I did apt-get upgrade and update just because.

Next, I installed a bunch of libraries recommended by this website: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=70049

Next, I downloaded the latest versions of libgphoto2 and gphoto2 using wget.  For example, I typed in wget http://sourceforge.net/projects/gphoto/files/libgphoto/2.5.7/libgphoto2-2.5.7.tar.bz2

In order to unpack the files, I typed tar xjvf libgphoto2-2.5.7.tar.bz2.  A web page that talks about this is here: http://askubuntu.com/questions/25961/how-do-i-install-a-tar-gz-or-tar-bz2-file

After unpacking, I cded to the folder.  The INSTALL file has instructions about what to do next.

Step 1: ran ./configure --prefix=/usr/local.  The second time I simply ran ./configure
Step 2: ran make
Step 3: ran sudo make install

Get some error that the install failed.  It could not remove anything in /usr/local.  I rebooted and got messages about stuff not working.  Looks like the OS on the SD card got corrupted.  The pi will no longer boot.  Yar!

I had to start completely over.  Downloaded a program to format the SD card.  Then downloaded the NOOBs files and copied them to the SD card.  The full version of NOOBs would not copy to the card.  I had to copy the lite version to the card.  That version downloads the install files over the internet when the Pi boots up.  That worked.

Did all the setup stuff again.  Downloaded libgphoto again and went through the complete install.  This time, it worked.

Rebooted.

Downloaded the gphoto2 tar file from sourforge using the same wget command.  Used tar to unpack it.  Then, ran ./configure.  It failed saying "Cannot autodetect popt.h" 

This page (http://www.yannock.be/computer/compiling-gphoto2-on-the-raspberry-pi) lists other packages that need to be installed with gphoto2.  Installed all the packages it suggested:

  1. libexif-dev
  2. libpopt-dev
  3. libfuse-dev
  4. mono-devel
  5. monodoc-base
  6. libmono-2.0.1
  7. mono-gmcs
  8. python-pyrex
After installing all of this, I had to re-run ./configure.  This time it worked.  Ran make and make install.  It all worked.

Ran gphoto2.  It worked.  

The gphoto2 auto-detect sees the camera.  Was able to take a picture with gphoto2 and save it to the computer.  You have to specify a filename or it always uses the same one.

That's enough for this week.

MMS Photo-inator Xsi -- 1 May 2015 Session

Even though I am posting this near the end of May, I am describing my efforts from 1 May 2015.

While at the Milwaukee Makerspace for my weekly Maker-time, I started working on my idea to use a Raspberry Pi 2 Model B to make a device that will take pictures by controlling an SLR camera.  I think I will call it the MMS Photo-inator Xsi.

Setting up the Pi
The Pi came with a micro SD card that was already formatted with Raspbian and ready to go.  So I did not have to mess around with that.

First of all, as always, I ran sudo apt-get upgrade and sudo apt-get update to make sure everything was up-to-date.

Changed the password for the pi user to wrenchiron.

The keyboard was setup for British English.  Used raspi-config to change it to US E

nglish.

Camera-controlling Software
The software that will control the camera is called gphoto2.  Installed gphoto2 by typing "sudo apt-get install gphoto2".  <note> It turns out that this was not the correct way to install gphoto2.  I document the correct way to install it in a future post. </note>

Typing gphoto2 --list-ports reveals two USB ports, usb:001,003

Connected a USB cable from the pi to my Canon PowerShot A470.  gphoto2 could not find it.  I tried 3/4 USB ports.  My keyboard was plugged into the fourth USB port.

I had to turn the control knob on the back of the camera to "playback" mode.  Then, gphoto2 could see it on the USB port.

Did gphoto2 --list-cameras.  It does not list the Canon PowerShot A470.  There is a 460 and a 480 but not a 470.

The gphoto2 --auto-detect lists the camera as "Canon PowerShot A740".  That camera is in the list.

Some of the commands I tried returned errors.  For example, 
  • list-config: PTP I/O error
  • capture-image: said "your camera does not support generic capture"
I think I need to find a different camera.

Friday, May 15, 2015

Raspberry Pi Based Photo Booth -- Introduction

The Milwaukee Makerspace got some new Raspberry Pi 2 computers to use in a build night.  We are supposed to make something cool with the Pi and the Adafruit Perma Proto Pi hat.  I'm going to try making a photo booth for new members at the Makerspace.

The main idea for this came from this website: http://www.instructables.com/id/Raspberry-Pi-photo-booth-controller/?ALLSTEPS

The main software for this will be gphoto2.  Here are the steps for how the solution will work.
  1. Press start button.
  2. Turn on camera.  
  3. Display image from the camera on the screen.
  4. If timeout, power down.
  5. Push a button to take the picture.
  6. Display picture and wait for response.
    1. Delete
    2. Continue
    3. Timeout
  7. If delete or timeout, delete picture.
  8. If continue, 
    1. Print picture
    2. Send picture to Makerspace web site
  9. Return to step #3
Components needed
  • Raspberry Pi with power supply
  • Camera with usb interface
  • Start button
  • LED display
  • Monitor
  • Printer
  • Internet connection
Alternatives
Have one big button that starts the process.  Turn on the camera.  Display a countdown.  Take a picture and use it.


Saturday, June 7, 2014

Printed a Raspberry Pi Platform

I was at the Milwaukee Makerspace last night and tried 3D printing a platform for my Raspberry pi.  This is probably the tenth time I have tried to print a platform for the Pi.  In previous attempts, either the filament would not stick to the surface, or the print would curl up, or the filament would get stuck on the roll.  This time, it finally worked.  I printed the platform on the Makerbot Replicator.  It took over three hours but I had no problems at all.  Joe B. was also at the 'space.  He printed the same thingy on the new Lulzbot Taz 3D printer.  I left before that print was done but it also had no problems.

I got the design for the platform off of Thingiverse.  The left side holds the raspberry pi.  The right side would hold a small breadboard.  It would be nice if there was a design that only had the left side for the rapsberry pi.

Below is my raspberry pi in the platform.  It snapped in and will stay in place if the platform is mounted vertically.  I think it will be a nice way to keep the pi from moving while working on projects.



Friday, May 23, 2014

Added Array to HESA Python Code

While at the Milwaukee Makerspace tonight I decided to update the python code for my Home Environmental Sensor Array (HESA).  It gives false readings once a week or so -- telling me there is water in the basement when there is not.  I would like to know what readings it is seeing.  Ideally, I would write the readings to a database but for now, I am going to write the most recent readings to a web page.

The first thing the program changes do is record each of the readings for one cycle.  There are 1,000 readings per cycle.  Each reading is added to a list in python.  Here is the code to add the data to the list.
if GPIO.input(pinIn) == GPIO.HIGH:
  retHighCount += 1
  retTestNbr[circuitTimer] = 1
  if retHighCount > 500: 
    retResult = 1
  else:
    retTestNbr[circuitTimer] = 0

circuitTimer += 1
retTestNbr is the list variable.  A value of 1 means power was found.  A value of 0 means nothing was returned.

Every 10 minutes or whenever electricity is detected, the program will write the current data to the web page.  There are 1,000 readings per cycle.  So, the program will write 20 lines of 50 readings.  The readings should either be a 0 or a 1.  The web page is overwritten if if already exists.  Here is the code to do that.

 with open('/var/www/hesaStatus.htm', 'w') as webPage:
        webPage.write('<HTML>\n')
        webPage.write('<HEAD>\n')
        webPage.write('<TITLE>HESA Status</TITLE>\n')
        webPage.write('</HEAD>\n')
        webPage.write('<BODY>\n')
        webPage.write('<H1>Home Environmental Sensor Array Status</H1>\n')
        webPage.write('<b>Start date and time:</b> ' + strSDT + '<br>\n')
        webPage.write('<b>Current date and time:</b> ' + str(datetime.now()) + '\n')
        webPage.write('<p><b>Last water sensing status:</b> ' + str(wSS) + '.<br>\n')
        webPage.write('<b>High count:</b> ' + str(hc) + '.<br>\n')
        webPage.write('<b>Readings:</b><p>\n')
        rLoop = 0
        while (rLoop < 20):
            cLoop = 0
            while (cLoop < 50):
                webPage.write(str(tn[cLoop + (rLoop * 50)]))
                cLoop += 1

            webPage.write('<br>\n')
            rLoop += 1

        webPage.write('</BODY>\n')
        webPage.write('</HTML>\n')
 Next, I need to install the code on the Raspberry Pi that runs the HESA and see if it works.  Maybe I can narrow down why I am getting false readings.

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

Friday, March 7, 2014

Miscellaneous 3D Printing

While at the Makerspace, I 3D printed a couple of objects (or at least attempted to).  The Makerbot was being very temperamental tonight.  I had to take it apart to remove a piece of filament that was stuck on the filament input from a previous print.  It also kept losing connection to the PC.  I would reboot the PC and it would print for a few minutes and then just stop.  Also, the computer in the 3D printing area would not write to an SD card.  I had to use my trusty Linux laptop to write the gcode for the prints to an SD card.  Finally, I think there was something wrong with the filament.  It just would not extrude consistently.  I did get stuff printed but the pieces were rough.

The first thing I printed is a small piece to hold a 3.5mm hard drive for an Xbox 360 S.  I am hoping to find a cheap or free hard drive that we can install in my son's Xbox.  (If you have one you don't want anymore, let me know.)  This piece would hold the drive in place.  I found the design for the hard drive case on Thingiverse.

The next thing I tried to print was a small case for a Raspberry Pi.  I found this design on Thingiverse as well.  For some reason, it did not turn out at all like it was supposed to.  The picture below shows how the print is supposed to look.



This is what actually printed.  I did not get any errors and the printer says the job finished completely. Not sure what happened.  The actual print did not have any walls.  Oh well.  I'll try a different design next time.


#raspberrypi, #3dprinting, #xbox360, #milwaukeemakerspace, #makerbot

Friday, January 10, 2014

Started Setting up Raspberry Pi for Star

The Raspberry Pi for the Avahi / Bonjour server at Star arrived today.  I started setting it up.

I took everything out of the box and put the RPi in its acrylic case.  I bought an SD card with the RPi that had NOOBS v1.2.1 pre-installed.  After inserting the card and powering up the Pi, the NOOBS software started.  I picked the Raspbian installation and sat back while it did the install.  It took about twenty minutes.

Configuration
When the Pi started, it ran the first-time configuration program.  I did the following:

  • Changed the pi user password
  • Picked the english US locale en_US.UTF-8.  For some dumb reason, you cannot uncheck the UK locale.  You have to use both US and UK.
I did not need to expand the file system because NOOBS did that already.

Next, I ran sudo upgrade and sudo update.  There was nothing to upgrade but it did perform some updates.

Changed the hostname to star-avahi.  I had to edit the /etc/hostname and /etc/hosts file with the hostname.  I found out that you can't use an underscore in the host name.

I asked Bob for what user name and password he thinks should be setup on the Pi.

IP Address
The /etc/network/interfaces file to have a static ip address instead of using DHCP.  I commented out the dhcp line and added these lines.

iface eth0 inet static
address 192.168.96.255
netmask 255.255.254.0
gateway 192.168.96.16

When I get a permanent IP address for the Avahi device, I can change the settings.

Avahi
Finally, I installed the Avahi client for Ubuntu.  Full instructions are here.  I was able to ping the RPi using star-avahi.local.  So, Avahi works.

Next: install the Pi on the Star network.