Debugging a DIY Segway at the Vancouver Hack Space

Al's Segway device

Al first contacted me by email.  Apparently someone has been telling him that I’m the go-to guy for anything Arduino.  He is not wrong. Sit right here and I’ll tell you about how we went to work on this machine and how far we got in an evening.

Segway PT drives by sensing the way you tilt your body.  The brain of the robot can sense which way is up and which way you lean.  It does this with a gyroscope.  This model also has an Dead Man’s Switch for safety: you have to hold the button down to make it go, meaning it can’t make any escape attempts.  In order to test the parts early on there’s also a knob to make the robot turn and a knob to make the robot go forward and back.  In theory you could drive this model without the robot brain, but that’s not as cool.

Al did what anyone would do.  He carefully assembled the entire machine by following the steps in the manual, copied the code into the Arduino line by line, and when it was ready flipped the switch.  One wheel started to turn right away and the other did nothing – and nobody was holding down the Dead Man’s switch!

To attack this problem efficiently we made a plan: if we know the fundamentals work then we can test higher-up stuff.  First we have to check the mechanical and electrical connections match the diagram.  Second, we have to check that the inputs work and the Arduino can “hear” them.   Third, test that the brain can make the motors go the right way.  Fourth, we know we have an input > brain > motors connection.  The last step then is teaching the brain how to balance.

We disconnected the motors and then Al got out a sharpie and some masking tape.  I gently pulled on a wire at the top of the steering controls and when the other end at the Arduino moved, he put a piece of tape on and labelled it.  We did that through all the wires, which took about 20 minutes.  You can see a ‘T’ (for turn) on a piece of tape next to Al’s index finger.

Al, being very clever, had drawn a schematic of how the wiring should be done.  We took out all the wires from the red breadboard shield, effectively disconnecting all the controls.  The breadboard has the gyroscope chip mounted in the center for easy connecting to the Arduino.  The breadboard and the Arduino click together like a LEGO sandwich.  Then we used the traced Dead Man’s wire and reconnected it to the pin in the schematic and went poking in the code.  About 40 minutes later we had the light on the top of the breadboard turning on when the Dead Man’s Switch was pushed, and turning off when it was released.  This was an excellent sign!  We didn’t stop for high fives, there was a long way to go.

The next step was to get the knobs and the button all working at once.  To do this I wanted to display on a screen the position of the knobs and the on/off of the button all at once.  The best way I know to debug an Arduino is the Serial interface.  In the code we have a value called steeringPot and another called gainPot.  I wanted to be sure that when the steering knob is turned that only analogRead(steeringPot); would return a changing number between 0 and 1023.  I also wanted analogRead(gainPot) to do work the same when the forward/back knob was turned.  I told the Arduino,

Serial.print(analogRead(steeringPot));  Serial.print('\t');
Serial.print(analogRead(gainPot));  Serial.print('\t');
Serial.print(deadManSwitchState);  Serial.print('\n');

…This is where we hit the biggest bug of the night.  We had the code reporting

1023   1023   1

over and over, no matter what we did to the knobs.  We retested everything.  The always resourceful Simon joined in with a multimeter and tested that the electrical signal from the knob potentiometers was rising and falling as the knob was turned.  It’s his hand in the left of the photo when we tried removing the breadboard to see if it was somehow the problem.  Everything seemed to be working, and yet the Arduino was deaf.  For nearly and hours various people took a crack at it.  In the end, it was a function I’d never used before called analogReference(INTERNAL); that was the culprit.  Nobody caught that the AREF wire in the schematic was missing; the one in the board was removed because it wasn’t in the schematic; and the Arduino was waiting for voltages it would never get.  We removed the line and suddenly we were getting numbers that made sense.

By then it was 11pm and time to go home.  Al promised to work on connecting the 6DOF sensor over the week.  If he does we’ll take another crack at it Tuesday night and you can read all about it here Wednesday afternoon.

I should probably mention along the way John cleaned a 1000 watt amplifier and started putting together the Solidworks computer; Miriam got her Makerbot Cupcake 3D printer moving; Jack was laser cutting; and there were at least 9 other people with as many projects going on that I didn’t even get to talk to.  Come on down and check it out sometime, it’s really something.


New Drawbot Assembly Instructions; New Forum.

Get the new Drawbot assembly instructions right here. Please have a read through and let me know if I’ve missed anything.

Try the new Forums!

Tomorrow I’m running Introduction to Arduino at the VHS. Monday I’m working at a local SFX company. Tuesday I’m on a plane to Stanford. Friday I get back. Saturday I’m working on projects for my database clients. Sunday I have Introduction to Soldering at the VHS. Then I’m back to the SFX company and working on the pan and tilt head for Malcolm, followed by the Quarterly GM on Sunday again. Light reading in bed is about how to market my business better. If I get a chance to take a break it’ll probably be spent raking the half ton of leaves that fall on my front yard every day in fall. My TODO list is growing all the time. I need to figure out the best way to use what time I have in my day.

I definitely have troubles staying positive, engergized, and focussed. How do you do it? What’s your secret? I’m taking Vitamin D, getting out in the fresh air every day, and making sure I don’t get dehydrated. Any tips you have would be greatly appreciated. I need to stay efficient and on the ball, not under it.


Skycam features added to improve Drawbot

I’ve replaced the old & busted “load bobbins” with a much more convenient “jog motors”. This way you can test each motor separately. You can even jog it a lot to load your bobbins. It used to be you had to tweak the firmware to load the bobbins or do it by hand. Which was the lesser evil? The question is now moot.

I’ve also added an “invert” checkbox in the jog motor control panel, just in case you decided to do it by hand and got the bobbin loaded backwards. …or maybe you wired the motors in a wierd way and they were running in reverse. Whatever! Both problems are now gone.

Get the master branch from github and run the DrawbotGUI.jar to see the changes. Don’t forget to update your firmware! (You will not lose your GUID.)

I think in the next update I’m going to merge the configuration screens to make setup easier. Something with a picture so it makes more intuitive sense. Can you easily load an image into the background of a dialog box in java? I haven’t even figured out how to make many text inputs the same size.

How would you feel about being able to give your Drawbot a name? “Drawbot #26” sounds so cold.

On the 11th of August I’ll be bringing the Drawbot to the Life Tree fundraiser party in Vancouver where I’ll have some prints ready and I’ll be drawing on-site. I’m also bringing it to the Super Happy Hacker House at the VHS on the 18th of August, and again to the Vancouver New Forms Festival 2012 september 13-16.

I said I’d draw 10 copies of the Burning Man logo in advance and it turns out I’ve only got 9 sheets left. That means between test prints, sales, and personal projects I’ve now drawn 91 giant pictures of steadily improving quality on my Drawbot. That’s over 50km of line!


Skycam frame assembled, Burning Man Life Tree CNC work

I’ve made a cube from 2x4s recycled from a home reno project. On each side I’ve put a drawbot. On the box in the front left corner I put my laptop. The laptop is running custom software that delivers gcode to each drawbot and they’re running modified drawbot code that understands the third dimension. The four strings are connected together at a tool that can be moved with GCODE to almost any point inside the cube. Before I take this project to the New Forms Festival 2012 I’ll be sure to rebuild the cube with some CNC’d corner braces and some property slot-fitted joints that will make it very rigid and aesthetically pleasing.

I built this in my garage while members of the Burning Man 2012 Life Tree project were using my 8×4 BlackToe CNC to cut parts for their burnable art project. Looks like they’ll be in my garage for the next week or so as they cut 100 leaves. Maybe we’ll celebrate at the end with a great big backyard BBQ?

To speed up the manufacturing I’m going to cut one stencil of each of the 4 leaf types. Members will then be able to trace one leaf onto another, drill some pilot holes, and then use jigsaws to cut the rest. Should go much faster than trying to CNC everything.

I’ve got to post to the GVIAS and advertise my skills. It’s great that artists want to make giant wooden sculptures. It sucks that they get an idea stuck in their heads that is hard to build, hard to transport, and hard to setup on-playa. Having worked with a few different groups over the years now I think I’ve developed a bit of experience in this area. By getting involved earlier when the project is being sketched out I could help to build a design plan that meets the artist’s needs and keeps the manufacturing costs to a minimum.

Today’s goal is to get the Life Tree members up & running, finish cutting the templates, and then I’ll be mudding drywall all afternoon.