If you have or will have kids in K12 school or you can influnce other parents then you need to know about FIRST Robotics. FIRST is a program with 4 levels of participation, 3 of which involve building and competing with robotics. Ever since discovering FIRST in 2006, the program has become one of the most important thing in my life. Sure I work, and love my work, and have a beautiful wife I love dearly and two girls in late high school and college. FIRST Robotics has made a difference in my kids life in unmeasureable ways. And even more importantly, it touches hundrend of thousand of kids around the world.
FIRST builds interest in Science Technology Engineering and Math (STEM). But it also build character and imporant life skills in its participants. Leadership, confidence, dispute management, problem solving, team work and critical thinking are just a few of the competencies it builds in those that participate.
I could write pages and pages on FIRST. But I won't. If you want to know more, go to their web site FIRST Robotics, search for videos on youtube and ask others what they know about FIRST.
My youngest is on a FIRST Robotics Competition team FRC at Deep Run High School. 1086 Blue Cheese has been around for about twelve years and has about 60 students on the team. They build a 120lb robot in a little more than six weeks and compete at one or two tournaments each year. 1086 promotes STEM around the world. They are involved at the federal and state level lobbying for STEM education and they help others get engaged in STEM and FIRST Robotics activities. They efforts make learning fun for many others. Many of their alumni go on to major in Engineering in college.
Below are some pictures and videos of FIRST team activities I have been involved with over the years. These are FIRST Lego League FLL and FIRST Robotics Competion FRC pictures.
What is a Maker? What is the Maker Movement? Find out in this Science Matters' video filmed at the RVA MakerFest, September 27, 2014.
Now Go and Make Something!
As part of my efforts to learn about motor control and PID conrollers I needed to figure out how to read Quadrature Encoders so that I can measure and adjust motor speed. Using encoders I should be able to measure motor speed with greater precision and accuracy than would be possible from counting each output shaft rotation. And with the right encoders I should be able to measure the motor speed on a regular basis (say every 0.1 second) which makes the PID control simplier and more predictiable.
Rotary encoders are devices that count rotations either of the output shaft or if a geared motor, the primary motor shaft. You will find optical encodes that trigger when a light beam is interupted and magnetic encoders that trigger when a magnet passes close to a hall effect sensor.
With the addition of a third sensor you can also measure the position of the wheel (or whichever part is rotating). Three sensors is a bit advanced and is not part of this blog post.
There are a lot of resources on the web talking about using encoders. For my purpose I just need some sample code that runs in an mbed device. The code below is designed for a mBuino platform. However it also runs on an NXP LPC1768 (with a few minor changes) and should be adaptable to all mbed platforms if they have enough pins available.
When the encoder is attached to the primary motor shaft of a reduction geared motor you can get very high output shaft resoultion from the encoders. Consider the motor I used from pololu which is stated to use a 30:1 reduction gear, with a maximum output shaft speed of 350 RPM. When using both sensors for the qaudrature encoder the motor triggers 64 times for each primary shart rotation.
The quadrature encoder provides a resolution of 64 counts per revolution of the motor shaft when counting both edges of both channels.
This is important because most encoder libraries have a configuration setting for which encoding scheme to use.
This demonstration program used the mbed QEI library provides for X2 and X4 encoding. We need X4 since we are measuring both the rise and fall of the output traces for both sensors. The code sample shows how this all works.
I'm pretty new to using mbed and encoders so I validated the calculated motor speed (output shaft rotations per minute) using a hall effect sensor with a disc with a magnet on the output shaft. The good new is the values are identical. I guess that means I'm doing something right! You can see the setup in the pictures and video at the end of the post.
In this post I will detail the hardware used for the motor PID control expereiments. You should refer to these posts for background information.
Various jumper wires, usb cables, etc.
Actobotics hardware used for the motor test frame.
You can do these experiments with just about any DC brushed motor, a suitable power supply and PWM based motor controller. In later blog post I will include the code for these tests. But for now I'm justing listing and showing the hardware.
I'm lucky to have a great power supply, but a wall wart or battery will work fine as long it supports the current drain of your motor.
You can create your own test framework for these experiments. Measuring RPM can be done several ways in addition to using a photointerrupt circuit. Hall Effect transistors are commonly used as well. You should be able to use many Arduino models, mbed platforms or other microcontrollers. What is important is measuring the speed of the motor (RPM) accurately and having a PWM based motor controller to change the motor speed.
Recently I ordered some breadboards on ebay. The order included 2 YwRobot 545043 Breadkboard Friendly power supplies.
I just love this little Power supply (~$2.49). It can be powered by a 6.5-12V supply and has both 3.3V and 5V outputs. This blog post by Peter Vis has a very detailed review that describes it nicely.
The power supply fits into a 2 ¼ wide breadboard (2 rails). You can power each rail with 5V or 3.3V separately or turn off either rail. With the proliferation of 5V and 3.3V microcontroller boards (Arduinos and mbed devices like the mBuino) having an inexpensive and versatile 5V and 3.3V power supply handy is important.
Just set the jumpers for each rail supply voltage you want and insert it into one end of the breadboard.
I hope you find this useful, if you do please leave a comment.
To provide visual feedback and the ability to iterate quickly through a bunch of manual settings in the software, I wanted the ability to collect data from the microcontroller platform in realtime and chart that data as it happens.
This post serves as a proof-of-concept and focuses on getting fake data from the microcontroller to my Mac OS X system via the USB Serial port and charting the data in Python in realtime.
I've been working with mbed devices and Arduinos lately and decided it would be fun to start with the mBuino mbed controller. It is inexpensive ($10) and has the pinouts needed to meet the requirements outlined above. The code should be easy to port to other platforms like the Arduinos or other mbed devices like my favorite, the NXP LPC1768.
The mBuino data generation program is simple and only generates fake data. It does not measure motor rotation. That way you can focus on just the fundamentals of data transmission, receiving data and charting.
This connects to the same serial port used by the mBuino. Note that your serial port may be different. I use Iterm2 instead of terminal and have a profile set up so I can start up this terminal window, run the screen command all with a simple hot key.
Charting is done using matplotlib version 1.4.2 under Python version 2.7.5 on Mac OS X.
print "Usage: python liveChart.py [mbuino|lpc1768|arduino] dataFileName"
print "       Note: arduino not yet implemented"
print "       program will save all data lines to dataFileName"
print "       python LiveChart.py mbuino data.csv"
print "2 arguments expected", len(sys.argv), "found."
print "Arduino devices not yet implemented"
print "Microcontroller Device", str(sys.argv), "not supported"
print "Setting up matplotlib for chart"
print "#Stop Encountered, ending live chart\nEnter ctrl-C to end program"
print "Saving the chart to \"plot.png\" in the current working directory"
liveChart.py will flush the data to the file you supplied on the command line and will prompt you for saving the final chart to a file. If you respond with "Y" then the plot will be saved in the current working directory.
I focus 99% of my hobby time on MAC OS X and a variety of microcontrollers. It should be possible, and maybe easy, to port this to MS Windows Systems. This article on Reading Arduino Serial using Python refers to the use of Windows. If you get this working on windows please post a comment and let us know about your experiences.
This live charting proof-of-concept gives us a mbed model for writing data to a live charting system and provides sample code in Python for live charting. Now this is working I have the ability to measure motor RPM and control it using a PID controller. My hope is I will be able to learn a lot about PID controllers. So it is time to finish my motor control mbed code and see what I can learn.
I will be using several of these 8 LED NeoPixel Sticks from Adafruit in a Persistence of Vision (POV) project soon. The target POV MicroController I will probably use is based on the ARM mbed platform.
So thought I would test NeoPixel Stick on a NXP LPC1768 and if that goes well then a mBuino platform which is the desired target device for my POV.
I will add a blog pos url here soon.
The project uses this NeoPixel library by Jacob Bramley. This library uses the SPI bus for controlling the timing and the author states that this library should support interrupt driven code (with some limitations). The POV prototypes I will create will be interrupt driven once per rotation so I figured this would be a good library to test.
The NeoPixel Stick have 4 connections 2 GNDs, POWER (+5V) and one for the control signal. The control signal is plugged into P5 on the LPC1768, and we are taking power off of the VU pin (5.0v USB out). I have also tested this powering the stick from an external power supply. Both works nearly flawlessly.
Initially I had a problem with the stick showing colors and lighting LEDs that I did not program in to the code. The stick had long 9 inch leads between the mbed and the stick. If I touched these leads the stick would act erratically. I assume this was due to the high speed communications that the stick depends ons for its control signals. Once I shortened the leads the stick performed great.
// This must be an SPI MOSI pin.
// Create a temporary DigitalIn so we can configure the pull-down resistor.
// An alternative is to connect an external pull-down resistor.
// The pixel array control class.
Please leave comments if you find this useful.
I've been thinking about Persistence of Vision (POV) projects lately. I want to make a rotating cylinder POV device eventually that has a multi-color display.
In preparation for that project I have been watching some videos and reading up on POV. I'm presenting some of these references for your enjoyment as well.
Lets start off with Mr. Wizzard ,Don Herbert, introduction to POV.
Mr. Wizard demonstrates how persistence of vision works. Subscribe now for more science, nature and technology clips from the 1980's Nickelodeon show, Mr. Wizard's World, every week on #WizardWednesdays.
The Wikipedia article is also pretty informative.
The Wikipedia article talks about POV displays constructed of 2D lights that repeat in the same place every couple of milliseconds. So lets start with a 2 millisecond refresh for an LED on a rotating device.
(1000 ms / s) / 2 ms = 500 Hz or 500 rotations per second. Sounds okay right?
Lets turn that into revolutions per minute.
500 Hz (or 500 revolutions / second) * 60 seconds / min = 30,000 RPM. What 30,000 RPM? Something must be wrong here. So lets keep looking for more info. The same article talks about modern film with a refresh rate (frame rate) of 24 Frames / Second and up. I'm not sure that comparing film, where the images is changing constantly and an led display, where we want character display persistence is fair. But lets try anyway.
24 FPS = 24 Hz = 24 Cycles / Second * 60 Seconds / Minute = 2,400 RPM. Now that sounds reasonable. But lets keep checking. Lets look at some videos and related articles if we can find any.
I like this one for the simplicity and that the parts are easy to obtain.
While this design is simple and seems easy to build the density of LEDs could be improved using LEDs based on the WS2812 device. At 5.0 mm per LED these chips can be tightly packed resulting in `2 LEDS / cm or 5 / inch. If you go looking for LEDs based on the WS2812 chip you will find that Adafruit calls their versions of these NeoPixels.
3,800 RPM / 60 Seconds / Minute = 63 Hz.
At 63 Hz the refresh time is 1000 ms / 63 cps = 15.7 ms for the image passing by our eyes in the same place.
Okay so 2,400 RPM to 3,800 RPM might be more reasonable. I don't think we need 30,000 RPM and have plenty of motors lying around that can spin at 3,000 to 4,000 RPM.
This video shows a nifty clock display and they say that they are using a hard disk drive motor (HDD) to spin the lights. Also the board has a nice LED density.
So how fast does a HDD spin? So 7,200 RPM and of course higher.
Now lets go looking for spinning vertical cylinder POVs.
When you watch this video you will see what is possible. To the best I can tell this is a commercial product. Regardless, this shows what a high quality vertical display would look like. If you pause the video at 7 seconds you can get a good look at the whole device from the side. It looks like there are three columns of LEDs in one vertical section. Advancing to 11 seconds you will see there are three vertical sections with three columns of LEDs. The extreme information (pixel) density of this display is a result of 9 total columns of LEDs.
This one looks monochromatic and 5 seconds in you can see how it is constructed. Very simple design from a spinning column standpoint. I wish I knew what the rotational speed is of this device.
The final version of the above POV device can be seen here. At 22 seconds you can see the base controls. Rotor, Motor and Hauptsch which is german for "Current Main". So the builder is using main (house) current to drive the motor of this one. At 2:10 you can see 2 flat ones and a vertical one.
Three models: - horizontal, yellow leds - horizontal, red leds - vertical, yellow leds Connection to PC via Bluetooth.
One more flat one. This one is packaged nicely.
And now a globe. I love the way he can "draw" on the globe.
This is one of our lates projects. For schematics, layouts, and code see our project page: http://www.solderlab.de/index.php/led-projects/rgb-globe Best regards, Pepe PS: There is a small typo at the very beginning of the clip: It should be "2 PCBs" instread of "3".
The maker describes the project details in the Globe project information.
That would br 600 RPM to 1,200 RPM.
So now I can start to work on a design for a flat display (horizontal) so I can work out the electronics and the programming. Then, if time and money permit, maybe I'll do a vertical display.
Now go out and make something.
I've seen these before when deconstructing printers and assumed they were some sort of optointerrupter devices. After some research online and I found a device at Digi-Key that looks similar. The photo of the OPTO SENSOR 5MM DARK-ON TRANS looks similar and the scavanged device acts like the name in the sense that the sensor turns on the logic output when the light can't get to the sensor (e.g., dark).
These devices work by having a infrared LED on one end of the slot and a phototransistor at the other end. There are transistor like devices in the catalogs and there are logic devices as well. Since the current flows when the light is blocked I assumed this was a logic based device and not just a raw optotransistor for the sensor. I am not sure if this is correct, but it doesn't matter since I was able to get it to work.
I played with the device a little and decided I could build something that could measure the reveloutions per minutes (RPM) of some of my hobby DC motors.
The schematic of how I wired this up is shown below. Since I don't know the actual device in use, the schematic of the actual optointeruppter should be asumed to be wrong, but close enough.
I assembled a small jig using Actobotics™ parts from ServoCity and attached a 12-24V hobby motor to the jig. I cut a 70mm disk out of some stiff paper and attached it to the small gear on the motor shaft. The opto device was glued to a piece of hook and loop material that the other half was also glued to the jig.
I've been playing with a ARM based mbed processor lately and figured this would be a great project to try with my NXP LPC1768 (Cortex-M3) mbed microcontroller and mbed application board.
You can see the results on the OLED display shown below. With the hobby motor I was able to get the motor to slow down to ~203 RPM at 2.5 volts before it stalled and up to ~3500 RPM at 27.8 Volts.
I'm very happy with how this worked out. I was hopeful to get some sort of measurement but did not know how responsive the actual opto device was going to be. In a word this was "fantastic".
I was really hopefuly that the rise and fall times for the opto device were fast enough that I could measure 3500 RPM. You can see from the trace below that at 3500 RPM the device has a fall time of about 45us and a rise time of 320us. So lets assume the total dip time (fall + transparent slot time + rise) is about ~500us at this speed. If this holds up (and the slot time will go down) then this device should be able to measure a motor speed of more than 1000Hz or 1000 Cycles / Sec * 60 Sec/Min or 60,000 RPM. I don't think I have any motors faster than maybe 5000 RPM. It would cool to test something in the 10,000 RPM to 20,000 RPM range.
All in all I'm pretty excited by these results. I hope to code up an Ardunio version and test that soon. I will post the results here for those of you that want to do this with an Arduino.
This is the first of several posts about my experiencing building a self balancing robot.
My immediate goal is to build a self balancing robot using off-the-shelf components as a learning exercise. Once I get the robot working I will make a lot of improvements including switching the embedded microprocessor platform from Arduino to mbed. Eventaully I will design my own components as an exercise in skill improvement.
Note that the platform described here is not yet a working robot. Once I get the robot balancing I will write another post about that code and will update this post as well.
If you have questions about any of this please post comments and I will do the best I can to answer them.
Two of the AA battery cases are wired in series to provide 12 volts for the motor shield to power the motors. One AA battery case is used to power the Arduino UNO and 9DOF board.
I wired the battery cases up to the DPDT switch and added the barrel jack plug (Male) to the output of the single case for plugging into the Arduino.
Oh I have so many things I will do different next time. But until I get the robot running it is premature to decide on improving the platform.
In my projects I use a variety of wire colors and guages. I usually have several projects going at one time, so and I needed a portable way to bring the wires to the projects. I took a cheap plastic box from a big box store and cut some holes in the ends. I cut some ¼ inch threaded rod to size, added the wire reels to the rod and bolted the whole thing together.
For one last improvement I used an old solidering iron to melt a hole in the front for each of the 26 guage reels. I threaded the wires through the holes and now I have a simple and effective wire dispenser.
The 26 AWG reels of wire are from Pololu.
Somethings the simplest way is the best way. Now go build someting.