Turtle Programming in Real Life

For the 2015 Eugene Mini-Maker Faire, I want to try something a little different and a bit more interactive. I had been toying with the idea of a low-cost, 3D printed robot. Using Python code to create real-world "Turtle-like" graphics sounded like a killer application.

The history of Turtle robots goes back a bit farther than I originally realized. William Grey Walter created a pair of light-sensing robots called "Elmer" and "Elsie" in the 1940s! These were designed to explore artificial intelligence at very simple levels and while not controlled by programmable digital computers, they exhibited some very distinctive life-like behaviors.

Walter's 1948 robot named "Elsie".
MIT's 1970 robot named "Arthur". In the 1960 and 70s, professors at MIT, most notable Seymour Papert, explored using robots and the programming language LOGO to teach computer science. The idea that complex algorithms can be executed using simple instructions is a powerful concept common to a number of fields of study.

Enter the 21st Century. 3D printing is hitting the main-stream. Open Source projects like Python are making programming easier for everyone. And Open Hardware philosophy have us sharing both code and design files freely. Time for another era of Turtle!

I will post more about the robot's construction elsewhere. It suffices to say that it is powered by a Raspberry Pi Model A+ running Linux with code written in Python! The beauty of this is that you can write and test your Python Turtle commands on your computer or in a browser before they even get to the robot.

Lets look at what it takes to create a box in Turtle:

Don't just sit there. Try these out for yourself at www.skulpt.org! With any luck, you will see something like this:
You will have to add a t.shape("turtle") command if you actually want to see the Turtle.
Python powered, 3D-printed, yet to be named Turtle robot.

If I've got you hooked, your next challenge is to figure out how to change the "square" code to create a hexagon. I'll give you a hint.  For the square, 360 degrees divided by four sides equals 90 degrees. Those number should look familiar. Next, how would you create a star pattern? That one took me a bit to figure out, and there is certainly more than one way to do it.

Your next hurdle, if you want to print your name, is to create letters using Turtle commands. Let us look at one way to create a letter "A" in a 2 x 4 grid (that keeps right-angle math simple).

One tidbit that is helpful is that the distance across the corners of a 10cm block is 14.1cm.

Well, there you have a preview of my Maker Faire booth. Hopefully participants will go home with a piece of paper containing their first initial created by a program they wrote and executed by a robot while they watched! And new-found appreciation for programming!

I'll have some pictures of the event posted at www.facebook.com/groups/corvallisareamakers/.

Ken Verses the PrintrBot Z-Stop

  • PrintrBot Simple Metal printers experience  a lot of Z-stop circuitry failures, which can be easily diagnosed and repaired.
  • This only applies to Rev F PrintrBoards which had an inferior transistor. This can cause either the probe to fail, or the transistor to fail, either of which result in the printhead only moving upward when homing.
  • DO NOT reflash your firmware unless you have made hardware changes to board, as it likely came with the correct firmware on it already, and is only behaving in the best interest of your printhead when it doesn't get the correct signals! 
My PrintrBot Simple Metal in Action.

The first big decision when jumping in to 3D printing is choosing the printer.  I decided on PrinterBot Simple Metal based on Make Magizine's review and the fact is was an Open Source / Open Hardware project. The second decision was whether to buy one assembled, or build it from a kit. I went with a kit because I wanted to learn a little about what was going on under the hood and hopefully be able to repair or modify it if needed. Of course, if you really want to dig deep, you can build one from scratch, but I am not that glutton for punishment.

The first big obstacle I had to overcome was the fact that when I tried to print something, the printhead (extruder) would only move up, and not down. As beginners, we always have to struggle with simple concepts that experts seem to take for granted.  This is even more a problem when we haven't seen it working correctly in the first place and so have no experience if what you are seeing it normal or not. I had to struggle with this for a bit before coming to an understanding that the Z-stop probe circuity was not working, and that the printer firmware, in an effort to protect the extruder, would not move down without the right signal.

Googling this problem indicates that it is happening to a lot of people, and that I am not the only one struggling to figure out why. Lets take a look at the circuitry, since understanding that will go a long way toward troubleshooting the problem.

The first concept to understand is that the Z probe inductively detects the build plate, and will emit a 12 volt signal when it is within about 4 mm of ferrous metal. This, combined with the Z offset you determined during your initial calibration, tells the printer where the extruder is in the Z-axis (up and down), and also, by probing three different spots during start up, how to compensate for the level of your bed plate. This is really an awesome feature, and well worth the trouble is has provide me so far.

The second concept that is tricky is that the Printrboard uses the 12 volt signal from the probe control a 5 volt signal by applying the voltage to the base of a transistor. I am more used to using a 5 volt signal being used to control a higher voltage through a transistor, and not the other way around, but hey, it works as long as they have a common ground.

And, if this did not hurt you head thinking about it, there is one more twist. The microcontroller (MCU) is providing the 5 volt signal to the collector of the transistor using an internal pull-up resistors, so that when the probe turns the transistor on, it allows a path to for the 5 volt signal to ground, which the MCU detects as a Z-stop trigger. A bit convoluted and confusing, especially to a beginner.

OK, now that we have a rudimentary understanding of how things should work, lets think about how they can go wrong. If a probe fails, and provide 12 volts at all time, the 5 volt signal drops to ground, causing the MCU to think a Z-stop is triggered regardless of proximity to the build plate, and will only move the probe upward. This is what was happening when I first built my kit, and it is fairly easy to diagnose. If you issue a M119 gcode instruction, it will report "TRIGGERED" when the Z-probe is connected (regardless of proximity to metal), and "OPEN" when the probe is disconnected because the transistor turns off. Printrbot sent me a new probe, and my 3D printing journey was quickly back on track. Seeing how many other folks had experienced the same problem, I bought a backup probe.

Imagine my consternation when the "always moving up" issue surfaced again several months latter right before I was to give a 3D printing seminar at OSU's Beaver Bar Camp! Double that when connecting the new probe failed to solve the issue! Back to the drawing board of understanding. The M119 command would again showed "TRIGGERED" with the probe connected, but also "TRIGGERED" with the probe disconnected. A multi-meter check of the transistor showed that the probe was indeed sending the correct 12 volt signal when metal was present, but that the collector pad, which should have shown 5 volts without the probes signal present, showed 0 volts regardless, indicating the transistor must have failed and grounded out.

Replacing a surface mount transistor is probably not in most beginner's skill bucket, and PrintrBot offered to send me a new board despite my being outside of the one month warranty period for kits. I assume they are sending boards repaired with a better (biased) transistor, and that lots of people have had this issue since the original transistor was unbiased (like I know what that really means). I do know how to read schematics and BOMs (bill of materials), so I ordered the correct transistor for 14 cents (plus about three dollars shipping). I also know from past experience, that surface mount soldering is more art than rocket science, and after snipping away the old transistor and cleaning up the pads, quickly had the new one in place and the printer running again. I also took the time to print an enclosure and relocate the PrintrBoard to the side of the printer since I did not like always having to reach under the build plate to connect the power and USB cables and reach the SD card.

Ain't pretty, but it works!
New Print Enclosure.

So, here are my lessons learned:
  • There is pride in building something, even from a kit.
  • There is pride in fixing something, even when you had to have others help.
  • PrintrBot Simple Metals are still awesome printers, despite having some flaws.
  • PrintrBot as a company is awesome for how it is handling the problems.
  • Open Source / Open Hardware is awesome because even if you don't built it from scratch, you can certainly determine how it should work and diagnose why it isn't.

I also, with some tips from PrintrBot, learned how to print without the functioning probe, and although I scratched my bed several times attempting it, it never hurts to have a backup plan when the workshop is about to start:
  • Shim your build plate so that it is reasonably level. You can do this by finding which corners are the  highest by manually lowing the z-axis and using a piece of paper as a feeler gauge. Shim the low corners using paper or aluminum.
  • Modify your "start" gcode to remove the "G28 X0 Y0 Z0" homing commands, and change the "G29" probing command to the "G90" start from here command.
  • Check your current Z offset using "M501" and write it down for future use if you don't move or replace the Z-probe during repairs (you have to re-calibrate if you do).
  • Remove your Z offset using "M212 Z0" followed by "M500" (the opposite of what you did to calibrate it).
  • Use the software manual control to home X and Y.
  • Use a piece of paper as a shim and rotate the lead screw manually to place the extruder one paper width above the build plate. I do this with the extruder at working temperature.
  • Start your print, being prepared to pull the plug if it the extruder starts to grind into the built plate.

A Good Week for a World-Wide Maker . . .

A man from Australia checked in to share the progress on his model railroad that was inspired by my Dawson Station. He is using my backdrop photos, but has taken it a step further by using Google Earth footage of the mill to help plan the layout.

My "Message in a Chip" Instructable has had more than six thousand viewers in about two weeks. I've helped someone from Finland interface with the chips and sent a couple of them to a school teacher in Canada who wants to use them for a Mother's Day project for his students.

A lady (from Netherlands, presumably), contacted me about the magnification program I wrote for my niece. After trying it, she responded, "this truly is brilliant, really, to me you are a genius! You solved the problem i had been struggling with for the past 15 years." You can see how talented she is in this video:

And finally back on the home front, I made some progress on a soft-circuit prototype that I think will cut the cost of my workshops in half!

It was a very good week . . .

Raspberry Pi Cable Management

The Raspberry Pi is an awesome project, but I've had trouble implementing it into our after-school program, probably because I dread hooking everything up. I think I've solved that problem, and will share the broad strokes with you here.

People are always impressed when you tell them it is a $35 dollar computer, but what that gets you is just the circuit board. You are going to need the following:
  • A HDMI or DVI monitor. Smaller is better for portability. VGA is a no-go since the cable to go from VGA to HDMI is too expensive. Fortunately, you can get suitable monitors at the thrift store for $15 - 25 (make sure it is DVI, not VGA). Onboard speakers is a plus (Sonic Pi!). A suitable new monitor can be had for $100 (example: http://amzn.com/B004N5AH1U).
  • The appropriate video cable. Shorter is better. If you obtained a DVI monitor, you would need a DVI to HDMI cable like http://amzn.com/B000QYZZFK.
  • A USB hub if you have a Model B Pi, which only has two USB ports, and you want to add a WiFi dongle. A plus is if the hub can power the Pi (one less connection). You can see a confusing list of hubs at http://elinux.org/RPi_Powered_USB_Hubs. I've had luck with this Belkin Slim-line: http://amzn.com/B005A0B3FG
  • USB Cables. Shorter is better. Right-angle connectors is a plus. You need:
  • WiFi adapter. If had luck with the Edimax: http://amzn.com/B003MTTJOY
  • A power strip, especially if you are powering more than one Pi, and an extension cord depending on how close to the outlets you are.
  • 4 GB SD Card.
  • Protective case for the Pi. An opening over the GPIO header and camera connector is a plus.  http://amzn.com/B008TCUXLW
  • Oh, and lets not forget a keyboard and mouse.

So, depending on the monitor you obtain, you are closer to the $100 - 200 range by the time you are done. Still a bargain in my book.

I've set four of these up, each with a different monitor and USB hub, so I can't provide detailed instructions. For attaching the Pi Case to the monitor, I removed the monitor back and drilled matching holes in both the case and the back and attached them together with tie-wraps. Depending on the hub, you can use the same tie-wrap method. I've also used two-part epoxy, or double-back tape may do the trick.

Since you have to take the monitor back off to attach the case, you might as well see if there is room to run the USB power and data cables from the hub to the Pi inside. Drill holes large enough for the smaller USB connector and thread them through. 

Even with the shorter 3-foot video cable, you still have about two and a half feet too much. I just loop it around the monitor mount and tie-wrap it together.

The final detail I add is to wrap and tie-wrap the USB hub power cable and the monitor power cable together. Since I had different hubs, I didn't want to have to figure out which cable went with each set up each time.

So there it is. Your mileage may vary. Let me know what you come up with. In the future I'll detail my experience with MineCraft and Python on the Pi!

ChickTech Highschool OSU 2014

Another awesome two-day workshop put on by ChichTech! The girls were super-creative.

The girls had an ice-cream social in the evening, watched the movie Miss-representation, and slept over in the OSU dorms.  At lunch on the second day they got to create "electronic" jewellery using components and some unused circuit boards from previous workshops.

My favorite part was at the close of the second day when the parents and public were invited in for a "Tech Show". There was cake and ice cream and the girls could show off their hard work and see what the other workshops were like.

Hopefully, I've recruited some Teen Makers for the Fall!

Bring Your Child To Work Day 2014

We had an awesome Bring Your Child To Work Day this year. I headed up three different programming activities in the same room with the help of friends from the HP Arduino and Python Groups. We had well over 200 children attend.

Program Your Parent was a paper and pencil exercise for younger children to get a faulty robot (the parent) to retrieve a sample of "candium" from a bucket. The robot could only move forward or turn right, and had to maneuver around a shield.  The activity teaches how literal computers are at following instructions, and how complex tasks can be achieved with sequences of simple commands.

I also had programmable Arduino microcontrollers and my FunShield. The first activity is to get an LED to blink. Then you see how fast you can get it to blink and still see it. This leads to interesting discussion about how the eye works and how fast computers actually are. Participants still interest at that point could continue and learn how to blink a series of LEDs using For loops or play sounds, detect light, or measure temperature. Arduinos are a great way to interface a computer with the physical world.

Finally, we had Raspberry Pi computers running MineCraft. Instead of just playing the game, kids used Python programming to interact with the world. There was a hide and seek game and a maze. They could create a code to place their name or initials using blocks. The idea was to introduce how algorithms can be used to perform repetitive task such as designing a building and then being able to place multiple copies anywhere in world.

Kids got to take home their worksheets which had links to online programming activities like Reeborg.ca where they could continue to learn JavaScript and Python. I also pitched the library's Teen Makers program, which unfortunately is on hiatus for the summer. The activities were not too much different from last year. The big improvement was recruiting volunteers to help at teach of the stations. I've already got some ideas for improvements next year, but first I need to get a paper rocket activity setup for the site picnic in August!

Eugene Mini-Maker Faire 2014

I got invited to bring Dawson Station back to the Eugene Maker Faire. It is one thing to talk your way in to an invitation to an event like this. It is another to get invited back. Not only that, I got asked to give a talk! Well, I may have talked my way into that last part this year.

There were a number of new exhibitors this year. The only one I remember from last year was Fertilab Thinkubator who had the awesome chromatography and spectroscopy projects.

I think a lot of people think making is only about electronics and science, but I think it is much more fundamental than that. I was glad to see groups like the Eugene Weaver's Guild invited to the Maker Faire. They had a spinning wheel, a loom, and some hands on weaving projects for the visitors to try.

I think my favorite exhibit this year, given my recent disassembly activities with the Cub Scouts and Teen Makers, was Next Step Recycling. They brought a number of electronic devices and let the visitors take them apart. I wish I had more time to help them use Arduino to bring the components back to life.

My talk was in the planetarium in front of about thirty people. I gave a rambling account from my first time at trying to build a computer (disaster) up to my recent class on how to build a computer (success). I tried to express that "making" and "sharing" are fundamental human characteristics that have always existed, and that current technology is allowing us to share ideas and projects with more and more people. I closed with some pictures of my decidedly low-tech chicken coop and challenged the audience to find a project they were interested in and make it.

Exhibiting (and speaking) at these events is a lot of work. The Makers exhibit for free. The visitors pay to get in. It is an interesting dynamic that I'm still trying to grasp. At any rate, it does give me a chance to share, learn, and connect, so I feel it is worth it. I've been feeling a bit over-committed lately, but definitely think this event was well worth it. It might, however, be Dawson Station's only public appearance this year.  It is time to follow my own advice and find a new project to learn, make, and share.