Lego Mindstorms Workshop 88 Class Followup

On Saturday August 25th, I held a NXT-G class at Workshop 88. I had spent several weeks teaching kids at Inzone program at Harper College, but this time I was teaching adults which is a very different experience! We quickly covered the basics of how each block works and how to use wires to pass data values around the program. I then explained how the programming can be applied to a sumo robot, and walked through the logic and the programming part-by-part to show how the settings affected the actions. I even brought up some of the Arduino code which I use with my NXshield to show how each command would look in a text based language in comparison to a graphical one. If my memory serves, we also busted out the NXC code for comparisons as well.
I was hoping that the attendants would have brought some of their own bots so that we could have used them as programming demos. However, most of the attendance just wanted to listen and ask questions which worked out pretty well for the format. After I finished my sermon of robotics, the attendees spent some time talking about starting FLL teams. We are now seeing if we can get a FLL team together.
I have been in involved in varying capacities with FLL for 10 years now! Time flies! I have been a competitor,  Mentor, State Judge, and most recently a Judge at the World Festival. You can see what I have been doing with FIRST, and Lego as a Mindstorms Community Partner(MCP) here in this spreadsheet.
Good Ol’ Teach
Table of Robots
Some of the Crew
More Crew
From left to right: Jay’s Jaysumo and Jaysumo 2. Nicky’s Wedge, Juggernaut

NXT, Linux, NXC

NXC is another cool language. It was made made by John Hansen. One of the really cool features of NXC is that you can build “C” like programs on Linux, OSX, and Windows for the NXT platform.
Here are some instructions to help you get your NXT working with Ubuntu. My best friend, Mike Jones, made this script for me to automate the process. Don’t forget to run the script as root and make sure it is executable. This script installs the nbc compiler and makes the NXT appear to the system correctly. To download something to the brick, all you have to do is whip out a terminal and type  “nbc -d -S=usb programname”. If you’re feeling like a boss, you could do “nbc -d -Z6 -S=usb programname” to do more compiler optimizations. 

At first I started with NBC which is supposed to be an assembly like language that is fed to an interpreter on the NXT brick. Knowing some C, the assembly style was pretty hard for me because it doesn’t have an intuitive form of flow control. In NBC, you can start and stop execution at certain points called labels which leads to some acrobatics. I just couldn’t get the flow right to make my sumo program. I then decided to switch to NXC which stands for Not eXactly C. NXC is also made by Hansen. 

NBC and NXC both use the same compiler. Compiling an NBC or NXC program is as easy as changing the file extension e.g. nbciscool.nbc or nxciscool.nxc. After switching to NXC, I was able to finish my basic sumo program for my sumo robot. I also updated the download for my sumo robot to include the NXC program. 

Since I have some experience with C, making the program do what I want became much easier. However there are still challenges. I really wanted to have different tasks running at the same time to do different things. I wanted a task for getting the sensor values, performing mathematical and logical operations with the stored sensor values, and finally another task to control the motors. I haven’t quite figured out how to do that yet. Sure, making another task is as easy as “task taskname(){};”, but I haven’t figured out how to pass values around between the different tasks even with global variables…yet. After some reading, I know that I need to use some things called “mutex”, “Acquire()”, “Release()” to be able to pass values around. I am still working on that. Until then, please feel free to enjoy the current revision with everything in a single task! 

I have done most of my learning and reading about NXC though Hansen’s online documentation and his book: Lego Mindstorms Power Programming. I have a signed copy which always makes everything that much better 🙂 You can pick up a copy an amazon here.

In summary, NXC was a pretty easy and well documented way to get into some cool C like text based programming on Linux which is faster than NXT-G. I would recommend giving it a shot if you want to take the next step after NXT-G!

NXT, Linux, PBlua

I have been wanting to get into a text based programming language for the NXT for quite some time now. Team Hassenplug as done a lot work with testing and cataloging the different available languages. I want to choose a text based language for the NXT that I can begin to tinker with. I really want the robot to run smoothly which means the software needs to run fast. I also don’t want to purchase a software licence. If I have to purchase software, I want to have full ownership of it; I do not want to pay a subscription fee every year to get updates. It also must run under Linux. This leads me to a great free language called pbLua by Ralph hempel.
From the pbLua site: “In a nutshell, pbLua is replacement firmware for the NXT that allows you to write sophisticated programs for the NXT using any text editor, and to send the programs to the NXT using Hyperterminal, screen, minicom, or any dumb terminal program.

pbLua is operating system and hardware agnostic – which means you can control the NXT from any device that supports either USB and/or Bluetooth as a serial port device. You can use pbLua with Windows, MacOSX, Linux, and pretty much any other OS you can name. There are pbLua users that send programs using their mobile phone.

There is no compiler to install, no IDE to learn. All compilation and execution happens on the NXT itself. There is support for all of the NXT peripherals, I2C and RS485 devices, Bluetooth and USB communications as well as floating point math, arrays, strings and lots of other great features.”

To give you an idea of how much faster pbLua is when compared the software that comes in a NXT kit, The stock firmware and NXT-G was able to squeeze 762 loops out in a minute. In contrast, pbLua was able to deliver 18,000 loops. The loop time was decreased further by taking out the the display commands which yielded 31,000 loops! When we compare 762 loops to 31,000 loops, you begin to see how much extra benefit you are going to get speed wise form the system. That is a 3968.24% change in speed. Robot C is even faster at 103,000 loops. However, you must pay either a yearly licence or a 3.x version licence that works with windows only. As an interesting fact, the person who made pbLua was part of a team of people who helped originally design the NXT. Some of these measurements were taken a while ago; I wonder what the numbers would come to today. I am sure they all might have grown!

I use Linux everyday, specifically Ubuntu. I made the change to Ubuntu to be my main operating system in 2008. I really don’t like using Windows or OSX where it can be avoided. The one downside to this is that you often have to do things the hard way. This can be one of those times. The good news is that you will become much better at using and understanding your computer.

After you flash the new pbLua firmware, it is time to start making some programs. There are some great tutorials on the pbLua Site to help you get started!

Lego CAD systems and Something Different

I have been a big fan of Lego Digital Designer since its early days of being available. LDD allows you to build with Lego in a virtual space. This is very handy for sharing models as well as documenting things that you build. In addition, if you don’t have the space to whip out a hardcore building session, LDD can be a great choice to give you a place to build that does not take up space. 

In general, I like building inside LDD first before I approach the actual plastic. This is because building in LDD has no limits (other than your graphics card and such). You have access to tons of parts of various color, and there is no limit on the number of parts you can place. If you are like me, you have some parts, but maybe not 100 or 1000 of something. In LDD you have all the tools you need to tinker around and find new geometries, and mechanisms. 

The translation between LDD and other Lego CAD systems and the real world isn’t always perfect. You might find that sometimes if you build something in real space first, that you might be able to utilize the flex in a part to make a structure slightly tighter or better somehow. Having some building experience with the plastic will give to you knowledge to know if something is going to be a good idea before you build it.

By far through, the key element for me is the snapping functionality. As we all know, Lego is built off of a grid type system. In general, things in this grid snap together at predictable places, but this isn’t always the case. Packages like MLcad don’t have snapping functionality….yet. This means that you as the user have to place the blocks precisely on a very fine grid. The larger the model, the more off a MLcad model gets as you build out from the origin. This happens because you need to place something precisely where you can’t due to this grid. It is a huge hassle which has kept me from MLcad for years. In contrast, a LDD models stays together significantly better. 

I also like that you can view things in 3D in LDD. In contrast, MLcad gives you a separate isometric view, top view, side view, and bottom(top?) view at the same time. Working with this is pretty intuitive; It is much easier to view what is going on by moving a viewpoint around a 3D space. 

Just to be fair, MLCad and similar systems do have some advantages. One of its major advantages is its parts library. MLCad’s party library, LDraw, has thousands of parts many of which are no longer in production. This allows the Lego community to continuously design models which use parts that Lego no longer makes. It should also be noted that LDD is made by Lego and only has parts that are currently in production. If LDraw were to get a snapping function and a true 3D view of the workspace, I would switch over.

On the MLCad/Ldraw side, you can use this nifty program called LPub to make building instructions. I never used LPub before because I never had the patience to finish something worth recreating in MLCad. However, the instructions that I have seen LPub make of other peoples’ models are gorgeous. LDD’s building instruction generator is not that great. It works sometimes, but don’t be surprised if it asks you to build something in a weird order or is unable to be constructed.

Back when Lego’s Design By Me was still around, they let you build something in LDD and then upload it to their site where you could buy it way overpriced. I am pretty sure the price was so high because of the labor involved with getting the different parts for each individual order. Lego killed off Design By Me and instead introduced Lego Cuusoo which is basically crowdsourced the design portion of the Lego sets; If an uploaded project gets so many supporters, Lego will turn it into a real set that you can buy. This makes much more sense from a business perspective since the marginal cost of making the same set repeatedly is going to be much lower than changing the set design for every order. 

That being said, I indulged myself once with Design By Me when it was active. As a member of Klug, I was going to build a car to compete in a downhill race that took place on a Boy Scout pine wood derby track that someone had around. You could probably tell that I build mostly robots which entails having some Mindstorms and Technic. I have a scarce number of System parts laying around. This means that I was actually unable to build a car that could compete in the race that would conform to the rules with the parts that I had on hand. Enter: Design By Me. I whipped out LDD and completely designed this car without ever touching a physical part. I ordered it, and had it sent to me. Done. I did this a while ago, but I wanted to share how cool being able to go from LDD to real space is! By the way, here is the LDD file for the car 🙂

CAD to Physical
The Car Itself
Rear View

Workshop 88 Lego Mindstorms Class

I am going to be running a Lego Mindstorms class on Saturday August 25th at 11:00am at Workshop 88. The focus of the class will be the Lego NXT-G software and Programming your robots to obey your every command. All ages and skill levels welcome! You will get the most out of the class if you bring your robot already assembled. It will be a bring your own Mindstorms kit class. However, the class itself is free. I will be bringing my sumo ring in case anyone wants to start a sumo match or test their robots on a field. I will have at least one sumo bot that I will use for demonstration. In addition, feel free to just come by to listen and scope out the friendly Workshop 88 atmosphere. Attendees, Please bring a robot, computer with NXT-G, the appropriate USB cable, and spare batteries! If you have any questions, please email me at Don’t forget to register here to let us know you are coming!                                                                                                                                   

Motorola LapDock and Raspberry Pi Part 2

You might recall the first post I made about my Raspberry Pi setup. At the Hackers on a Train Event, I met Drew who is a member at Pumping Station One. His main focus is embedded programming. After talking to drew for a while, I asked him if he had any suggestions to get the Raspberry Pi to display full screen on the LapDock. He suggested that I disable over-scan in raspi-config. I have good news to report that his suggestion works! I now have use of all of my screen. Thanks Drew! The simplest way for you to do it too is to bring up a terminal, and type raspi-config. You will get a set of options. Scroll down to over-scan, and disable it.

Full Screen! Over-scan Disabled.
Not Full Screen. Over-scan Enabled.

Workshop 88 at Mini Maker Faire Evanston, IL

I went to a Mini Maker Faire in Evanston, Il with Workshop 88. This was my first time at one of these types of events. I have been to other events like Brickworld, National Instruments week, and various FIRST events. Those events were more focused on Lego and Mindstorms rather than the art of building things. While there is a crossover, there is a different spirit in the event.  I decided to bring some of my Mindstorms robots to the Faire to see what kind of reaction I would get. I brought my Off Road Crawler, NXShield Sumo Robot, and my Three Motor Sumo Robot. People seemed pretty interested in them. We might have gotten a few people to come to the Lego Mindstorms class on August 25 at 11:00 am at Workshop 88. More on that in the next post ;p
The other project that we had in the booth was a screening process for making custom circuit boards. As you can see, there is a bubbly green tower there which automatically made it more science-y. Don’t quote me on this, but I am pretty sure it was copper-2 chloride that was used to strip away a mask of some sort. If I find a link to his work, I will add it here.
I was pretty impressed walking around the place. There are lots of people there who like the build things…which is the point. Below you can see a picture of our booth with some spectators. In this picture, Andy, the Workshop 88 guy in the white shirt, was talking to the woman in green in the right of the picture about astronomy and astrophysics. It was a humbling conversation to listen in on for anyone not versed in the fields. You never know who is going to drop by the booth…or at the booth already!
The Workshop 88 Table with some interested members of the public
Robotics at Workshop 88
More fun with printing your own circuit boards with Workshop 88!
A Maker Bot

Maker Bots are getting to be pretty popular tools these days. There were three of them lined up here. Pictured is just the one. You can see the curiosities that they had been printing. Blue and green the Yoda’s were printed in. Some of the prints blew me away with their detail and precision. In contrast, Some of the prints were more grainy. I know from reading around that it is a real challenge to optimize the parameters to get everything just right. Some of the models had been perfected while others might have still been in a testing stage. In addition, some models might have been printed faster which would have reduced its resolution as well. There are trade offs with everything.

Some fun prints off a Makerbot
3D Touch Printer

There were some other 3D printers there too. This one here is a 3D Touch. I was extremely impressed with the print it was making. You can see the spiral shape being built in the work envelope. That spiral is completely hollow, and the walls are only one extrusion wide! These start at a cool 3.5 grand and go up from there in the 4 grand region.

They had one. I wanted it really badly. It was not stick though.
A kit built laser cutter for $1500ish!

You can see a really cool laser cutter project here. It is a pretty bare bones cutter, but it works! Our space has been eyeing up something like this for a while now. I wouldn’t be surprised if one of those appeared in the space one day.


These ORD Bots are pretty neat little 3D printers. I am impressed with how absolutely simple and elegant they are. They are supposedly in the $400 dollar region which makes them a steal.

Shapeoko Mini Mill

They had a Shapeoko Mini Mill at the Faire too! I have one myself. I asked the buy at the booth for some tips about how to use it. I am going to get comfy with pycam and GcodeSender and see what happens.
Cool Bug Thing
A vinyl Cutter
The Tech Shop was there laser cutting some balsa wood gliders to hand out.
Ready for Flight!

Arduino Controlled Catapult
Solar Powered “Race Car”
A Book Scanner

I was pretty impressed with this book scanner. You flip the pages and take a picture. Rinse and repeat until book is read. At the end of the process, you can get your new digital book in different formats and such.

An enhanced quad-rotor kit.
A Raspberry Pi
A Raspberry Pi

Are You a Rugged Maniac?

Other than building robots, I also have gotten into the habit of doing mud races. So far, I have completed a Rebel Race, Run for your Lives, and a Rugged Maniac. My next one is going to be a Tough Mudder.I started my commitment to health July 31st, 2010. I weighted 230 pounds with a BMI in the low 30’s. After two years of work, I have managed to get myself to a healthy 160 to 170 pounds with a BMI of around 25. I first started with my diet. I eliminated all of the lousy and unhealty foods. I eat much less now and much healthier. I then enrolled as a student of Krav Maga at Buffalo Grove Martial Arts. For the uninitiated, Krav Maga is an integrated self defense system that the Israeli Defense Forces use. I really like my instructors there. I can attribute much of my weight loss from the training of Steve, Kurt, Brian, and Bert. I also have become significantly more proficient in self defense techniques at the same time. I also have speed skated at Orbit Skate Center along the way, and did some weight training at Roosevelt University’s recreation room.

I started getting into these mud sports when another student at Buffalo Grove Martial Arts invited me to join him in a Rebel Race last year. Being a new experience, I had to at try it out. Today, I did a Rugged Maniac which was 5 Kilometers/3 miles. All of these events are slightly different and have different challenges. I am going to chronicle some of the more amusing parts here for you. The race took me an hour; It was also 95F during the race. I might add some more pictures later when the photographers from the event upload their photos. The pictures here were taken by Jessica.

Before the Race
Being a Rugged Maniac: I am in the same pose at the guy in the Rugged Maniac logo.
Krav Maga Fighting Stance
I always wear my Krav Maga shirt and pants to remind me of how I got there and where I came from.

Stretching in the starting gate before the race. Yea, I can do that. 
Have you ever just come across something you knew was going to really obnoxious?
That was extremely steep and tall.

I should mention here that I am TERRIFIED of heights. I am trying to use these events to help with that somewhat. The best way to tackle this hill challenge is to stay low to the ground and synchronize your arm and leg movement. One of the challenges here is that the ground is slippery from the trouncing of other contestants. This hill was steep and high enough that falling would have caused actual damage to myself and possibly other people. The pictures don’t do justice to just how high and steep this actually is. Failure here pretty much isn’t an option. Things like this are why you sign liability waivers.

Welcome to the really scary part.

I was doing pretty well on this challenge until the end. If someone starts close enough behind you, the rope is pulled to the ground thus ending pretty much any hope you had of holding onto something. It was for this reason why I waited until the person ahead of me had completed his climb. The considerate gentleman in the blue was nice enough to decide to start rather close behind me. This jerked the rope to the ground which made it nearly impossible to hold on to the rope during the ascent. This jerk of the rope forced me down to the ground. It is here that I lost all sort of footing and was supported solely by my arms. I somehow managed to keep going and claw my way to the top with just use of my upper body. I have to give a strong nod to Roosevelt University’s personal trainer Ned. While he was not there in person, his handy work was there in spirit in the form of some very motivated forearms.


One of the obstacles that I really liked were some logs that were sticking out of the ground. The logs were about 6 to 8 inches diameter and facing out of the ground. You had to jump across these logs to the other side. While other people discretely jumped from one to the next and falling, I ran over them in one shot by keeping my momentum. One of the people stationed there said “That was like cheese! I have go to back to school!” after I did that.  
Tactical Jump? Mirror’s Edge anyone?
A much higher wall.
More tactical Mirror’s Edge type stuff. I also punctuated that landing with a forward roll.
Coming in for a water landing!
Letting my inner Ground Hog out.
Like a Boss
Down the Tubes
Across the water with overhead barbed wire.
When someone says they have a project in the pipeline, this is secretly what they mean.

It should be noted here that the inside of the tubes are completely smooth. There is no good way to use your legs to get up the inside of a slimy plastic tube. The tube was also not big enough to really crawl. You had to use the provided rope to pull yourself up.

The last push out of the tube.
The last bit before the finish line.
Cargo net of doom!

This was also ridiculously terrifying. This cargo net was right over a stretch of track right near the starting line. It was elevated by two cargo containers above the ground. I am estimating that it was 25 to 30 feet off of the ground. My fear of heights really kicked in here. I closed my eyes and became an egg roll. Meanwhile the cheers for the competitors below me sounded like people screaming.

Down the other side.

Hackers on a Train come to Workshop 88

Hackers on a Train paid Workshop 88 a visit. They brought a large selection of all sorts of electronic gizmos that they sell along with some really good in-person instruction. One of their amusing projects is called the TV-B-Gone which turn off any TV at the press of a button. You can see other products they sell here. I think a lot of them are pretty cool! They also sell this Arduino clone called the Diavolino. I decided to buy one and put it together at the shop. This board was $20 bucks which is cheaper than the $30ish official Arduino boards.

In my opinion, These are not meant for beginners since it does not have many of the handier connectors that you could use to interface with your computer. I didn’t realize this at first, and I am not sure what to do with it yet. These are meant more for a project where you know that you will not be swapping boards, and you know that you won’t be connecting it to a computer all the time. You also get the options to connect several jumpers which enable different functions. If you need a board that is cheaper for a more permanent setup, this is a good option.

Building things!
Close Up

A Basic NXShield Sumo Robot

I have been working on learning about and how to use the Arduino platform recently. I took both their 101 and 201 classes at Workshop 88. I have taken what I learned there and kept going. Between looking at some of the header files, the official documentation for the NXShield, and my knowledge from the Workshop 88 classes, I have been able to successfully assemble a very basic sumo robot! You can download the code here. Since the program is larger and I want to help other people learn if possible, I spent some effort to comment on just about everything in the code. Reading the comments will help other first time users figure out how to program the NXShield and Arduino. It will also make modifying the code for your purposes really easy.

I built a simple base to put my NXShield on for testing. I wanted the base to be extremely compact so I used Power Functions XL motors instead of the NXT motors. You can see how I used one motor in the front to power the left side, and another motor in the back to power the right side-I squashed everything in there tightly. Since the motors are not geared down, it moves a little too fast. In the future, I will turn the power levels down if I continue on this platform. Eventually, I will have the same setup but with a mechanical platform that is more suited to actual sumo matches. Who knows, maybe it will even be a super sumo robot.
I wanted to replicate the sensor setup that I used on my Other sumo robot. I have a light sensor in the front and back, and I have two ultrasonic sensors which work in tandem in the front. This allows the robot to sense the edge of the sumo ring if it is being pushed backwards, or to sense the line if it is about to move forward and overshoot the ring. The dual ultrasonic sensors allow the robot to turn itself towards the opponent and then attack efficiently. 
The code is setup to be a finite state machine which is a fancy way of saying that the robot has distinct modes. In this case, the robot has 4 modes: forward, reverse, turn left, turn right. The key to the code is to use the sensor inputs to decide which state to use at any given time. It should also be noted that since the motors are facing opposite directions, they must counter rotate to make the robot go forward. This is slightly un-intuitive because the code must move the motors in opposite directions to go forward. Inversely, the robot must move the motors in the same direction to turn. If you want to use the code on your own robot that has the motor directions setup the other way, be sure to make the appropriate changes by changing the states or changing which state is invoked.
Talking in a rough outline, the code gets the values from the sensors and then decides if any of the values are above the trigger point for range or light values. The actions for the ultrasonic sensors are determined first. If both of the sensors see the target, then the robot moves forward. If one of the sensors sees the target, then it rotates towards that direction. If none of the ultrasonic sensors detects and opponent, then the robot just rotates in a search pattern.  The next chunk of code is arguably the most important since the light sensors would indicate if the robot is about to go out of the ring. At this point, the code for the ultrasonic sensors has set an appropriate state. The code for the light sensors will simply overwrite the state if it sees the edge of the ring in either the front or the back. I am not sure if that is the most efficient solution, but it does work. Doing it this way also avoids coding a sizable chunk of logic that I really didn’t want to do.

If you watch the video, you will notice the robot goes out of the ring on more than one occasion. It moves a little to fast for the light sensors to get a good reading sometimes. I could fix this by changing the power levels and lowering the trigger point for the light sensors. The bottom line here is that the code design works, but you will have to fiddle with the exact values to get everything the way you want. My dirty little secret is that the code for my other sumo robot, which is programmed in NXT-G, has the same logical process as this one. 

Overall View
Gear-train and Motors