Newest Project: Linux Serial Commander

LSCommander on left, Raspberry Pi on right

LSCommander on left, Raspberry Pi on right

Recently I was playing around with the Raspberry Pi and thought of how useful it would be to pair an 16×2 character LCD + buttons with it so that I could control it on the go.  After a few hours of brainstorming, I came up with the Linux Serial Commander, which is an Arduino + LCD + buttons, paired with a Linux system running a python server that I wrote.

Here’s a short video of it in action (recorded using guvcview in Linux):

Linux Serial Commander operation from Dustin Robotics on Vimeo.

Continue reading

Using the Raspberry Pi as My Development Machine

300px-RaspberryPiAs many of my readers know, the Raspberry Pi is a $35 dollar ARM computer with 2 USB ports, and ethernet port, HDMI, and some GPIO pins.  My current plan is to use the Raspberry Pi as my main development machine, flashing all of my ATMEGA328 chips from it.  This will allow me to not only program anywhere, but should my computer crash, my development environment will be perfectly safe (provided that I keep it backed up).  This 700 MHz computer is pretty dinky, when I first ran the GUI several months ago, all I saw was how unreliable it was and that it would be impossible to get anything done on it.

Since then I purchased a high speed SD card from a quality manufacturer, and the performance is better.  I also learned that you can divide the memory between the GPU and the general purpose memory.  For my case, I decided to skip the monitor and keyboard, and SSH into it using KiTTY (an updated PuTTY client). I’m also using Xming to serve as a X11 Server on my windows system, so that I can do X11 forwarding of the Arduino IDE if needed.  I hope to use the command line version, arduino-mk, but currently it doesn’t work as well as the Arduino IDE does.

I also discovered that many of my existing programs no longer work on the latest Arduino IDE v 1.0.1, because the avr-gcc team changed some things around.  Luckily I have a backup of my old development environment, as well as a working VM with it on it, but my current plan is to update my existing code as needed, to work with the new versions, since they are the future.

Here’s a brief rundown of what I needed to setup on the Raspberry Pi to get it to work:

  1. Install the latest Rasbian onto your SD card following these instructions. I followed the Easy Way.
  2. I then connected the Raspberry Pi, SD, Ethernet, and power (from a reliable charger, I’m using a HP Touchpad USB charger).  You’ll need to find the IP of the raspberry pi by checking your router for newly connected devices.  Use KiTTY to SSH into it (using the IP and port 22).  Username / password is pi / raspberry.
  3. Go ahead and update things (sudo apt-get update, sudo apt-get upgrade).  I install vim, tmux, arduino and python-serial as well. I also copy a folder I made a while ago that has all of my vim, screen, and tmux settings.
  4. To get my usb-serial devices working, I need to update to the latest raspberry pi kernel.  To do this, we need to install rpi-update. With that installed, update the kernel.  As of this writing, the latest kernel is “Linux raspberrypi 3.6.11+ #414 PREEMPT”,
  5. Now you should be able to use LScreamer or Arduino to flash your projects!

What’s great about this setup, is that I can SSH into the raspberry pi from anywhere (provided I have opened up the right ports in my router).  Yesterday at my brother’s house I was connected to my Raspberry Pi on my workbench, trying to get an Arduino program to compile. As I work on my latest project, I may implement some improvements to this Raspberry Pi setup, possibly automatically controlling my Oscilloscope and my power supply.

I find taking little steps to big goals gives you small accomplishments that build up, giving you that much more motivation to finish.

Cheap Breadboard Arduino with Wireless Module

I see that there is a good amount of demand in the community for a cheap “Arduino” clone with wireless. Many people, while grateful of the Arduino community and organizers, are frustrated, because everything seems so darn’ expensive! $30 Arduino Board + $20 wireless thing + $15 proto board makes almost $100 just to get you running. If you somehow found JeeNodes, they are $23. A RBBB, which just has the processor, is $13. We can do better than that though!

If you’ve clicked on the caption, you’ll see that it is possible to make a breadboard Arduino for just $7. The problem is that we still need a wireless module. XBee’s retail for $23, which is a pretty robust solution (configurable up to 19200 baud in real world situations, can communicate just with serial, standard footprint so there are lots of cheap adapters for it). But it’s expensive. You can check out the RF Bee, which is a $20 wireless solution, which actually contains an Atmega168 (running Arduino)! It’s tiny form factor is awesome, but it is $20. A RFM12B radio retails for about $6, which is pretty decent. It even has a good library for Arduino to go with it. But we can do better.

How about a $2.50 wireless module, that has a good library to go with it? That would bring our cost to $9.50, excluding shipping. That’s my cup of coffee. The hard part is finding the individual components you need, which I will help you out. Finding the cheapest parts from 20 different places is great, but the shipping will kill you. I’ll attempt to minimize the shipping cost, by ordering from a few places, getting what we need from each.



That brings the total for the required parts to $5.44…  wow.  Shipping would be about $5 from each place (roughly), but it isn’t included in our consideration.  Getting some different colored wire wrapping wire will help you out a lot, as well as getting a wire wrapping tool (which can be very useful).  Adding the $2.50 wireless module would bring you to $8, pretty nice!  This number scales down as you buy more, so if you buy enough parts to build 3 or 5 of them, it will be cheaper. Consider the pricing levels of the ATmega328p chips to figure out how many you should buy (you should always get spare protoboards 😛 )

I’ll do a post sometime soon on my recommended set of parts to have.  A quick update on the Carduino: I still haven’t put it in, I need to get up the motivation to start modifying wires and integrating it into my car.  I know eventually I’ll get to it, but in the mean time, I’m exploring the idea of making my own Watt Meter, with SD logging.  It would be hard to compete with that, but if I’m smart, I can end up with a meter that can work in RV’s, like this one does, using an external Shunt (small value, high wattage, precision resistor).  Till then!

Edit:  If I could make a schematic for this cheap Arduino breadboard, I would take the parts required to make it work, and customize it for each application after it.  The arduino is great as a platform, but for completed projects, typically the soldering connection is constant.    Here is a quick guide on wiring up the nRF24L01+ to a Arduino.  By following the Instructables post, you can get a general idea of how to wire it up.  I got the idea for the voltage regulator + resonator from JeeLabs, so the v5 schematic would be what you use to wire up the rest of it.  I hope this helps!

Carduino! It’s Alive!!!

This slideshow requires JavaScript.

Just a re-cap: This is a little project that will be embedded into my car, that logs the temperature of the engine, transmission, radiator, and interior to an SD card. If something gets too hot, it will show the warning led (decimal point) as well as make an audible notification (cue mario dying song). It can connect to my Controller 2.0 via a BTM-182 module, and if connected, it will display all 5 of the measured temperatures, as well as the voltage, on the controller (without needing any parsing by the controller). This will be my early alert system to warn me if something is getting too hot. In the future I may add sensors to detect the level of radiator coolant, but that is a nice-to-have, rather than need-to-have. The code for this, will be released shortly (Once I have this in my car I imagine).

It’s done! I admit, I did run into some problems. When I first powered up the Carduino main board, there seemed to be a short somewhere. I removed a diode, which of course didn’t help. After poking around, I discovered that the connections for the package of voltage regulator were wrong. After a quick rewire, it produced regulated 3.3v. After fixing a few forgot-to-solder’s, and a ‘soldered but didn’t make connection’, it fully works. I do need to do some tweaking of the software, so that it turns off at 12.3v instead of 14.0v (since I’ll be using a switch to turn it on/off).

Exciting times! Now I just need to get this in the car, and I’ll be set! I’ll need to take care of potential moisture in the temperature cable as well, but I’ll figure that out as needed 🙂

Controller wirelessly controlling servo using BTM 182 BT serial module.

It’s alive! My Arduino controller can control things wirelessly, sending and receiving! It sends Nunchuck ‘packets’, and receives display ‘packets’. I created a basic packet system so that I standardize communication between wireless things. Each packet has a checksum, so if a bad packet is received, it can be discarded. Packets have a ‘type’, which can be things like ‘are you there’, to ‘display this’, or ‘here’s nunchuck data’. The beautiful thing about standards, is that I can use this to quickly roll out wireless things, without having to figure it all out again.

This demo is simple, reading an NTC Thermistor and displaying it on the controllers LCD. The controller sends Nunchuck packets to the ATDservo, and it turns a servo based on the position of the nunchuck joystick. It could easily do anything else, since it received the whole controller output. I also have the code for a PS2 controller, but I have it commented out for now, since the library takes up too much space.

What i plan to do with this, is to make a basic voltage monitoring board to monitor the status of a UPC battery as it discharges. It will save the data to an SD card, maybe making measurements every second. I could do it without anything plugged into it, and with something plugged in. Just a quick little experiment, to show everything working. 🙂

As always, the code is below. I use a simple state machine to process each received packet, and I have another function that handles the different types of packets. And it works 🙂 Someday I may make an PCB based on the Controller, using a singular wireless thing, so that it will be quick and easy to carry the controller with me!

Code for controller

Code for ATDservo

LCD controller functioning, halfway built

This slideshow requires JavaScript.

So I have made some progress! I brainstormed on how my wireless system will work, and I have come up with something that works. I created a packet that contains a checksum, like this (without commas though, and replaced by bytes 0x0A and 0x0D): ,Dest,Sender,type,Num of bytes,,Checksum,. First I got this basic packet working, then, using that packet, I created different types (3 so far).

The end result, is that I can send the equivilant of lcd.setCursor(X,Y); lcd.print(“String here”);, in one single packet! And it looks like this: 0x0A,e,d,0x02,0x06,0x00,0x00,test,0xCA,0x0D. I can send Nunchuck packets too! (containing state of all things), which means that with this basic system, I can already start making a RC Arduino for my Slash RC car. I decided to start actually making the controller though, since it is pretty complete.

For the actual controller, I will have 2 protoboards, LCD, XBee, BT serial, Piezo, SD card, Nunchuck connector, PS2 connector, and buttons. (I also was successful in using the 74LS164N to drive the LCD only using 2 pins). With the added packet processing code, I’m sitting at 24448 bytes, so it is getting tighter.

Another project in the works, is making a portable programmer, that lets you flash different hex files out in the field, away from the computer. It would have a LCD with SD card so that you can choose which one you want to flash. The immediate usages for it is if I want to use the PS2 controller instead of the Nunchuck (since the PS2 code takes more space). Ultimately i will be able to flash anything, just by connecting a cable from my flasher to it. Pretty awesome in my books, and currently, there isn’t anything like it. I should be able to test the concept with the controller I’m making, having already made the modifications to the FTDI port. Stay tuned for updates!

All controller functions functional! Now I need some remote projects!

This slideshow requires JavaScript.

So I have gotten to a point at which everything for the controller works. SD card, Xbee, BT serial, Shift LCD, PS2, and NunChuck. Pretty awesome. But if all of that code is enabled at once, I would have less than 1k bytes to write actual code to interface with things. In the code I have debugging via serial, debugging via LCD (for the controllers). I do like having debugging for LCD, but there is a problem: the PS2 library takes up 5k bytes. So when I actually build the controller, I don’t think I’ll include a PS2 connector, at least initially.

Breakdown of Sizes
with SD enabled
Everything Enabled: 29024 Bytes
Only LCD debug: 27252 Bytes
Only NUN LCD debug, PS2 disabled: 22550
Only PS2 LCD debug, NUN disabled: 25900
Only PS2 & Nun, no debug: 24690
Only PS2, no debug: 24484
No ps2 or Nun: 20972
With SD disabled
Nun and PS2 disabled:13488
BT disabled + SD + NUN PS2
Xbee: 11910
Everything Disabled:
11886 bytes

I think the optimal configuration would be to use the Nunchuck with LCD debugging information, with SD, XBEE and BT, coming at a total of 22550 bytes, giving me about 7.5k to write my code for all of my interfaced devices.

This has led me to the idea, that my interfaced devices should be giving the controller, the menus it should show. I’m thinking of an initial packet that is exchanged between the two, which has a good amount of strings, that are then saved into flash on the controller, and once data starts arriving, those ‘labels’ of the data will make the data make sense. Another idea is to use the SD card to carry firmware for remote projects, and remotely flash them using the controller on the go, so I can update code for my cars without having to take my laptop down there.

Well here it is:

Continue reading

XBee and BTM-182 configured via Arduino

I finally got my Ardunio to successfully configure both the XBee and this BTM-182 bluetooth serial module. Why would you want to do that? Well the XBee has six 10-bit resolution Analog to Digital Converter channels, and about 8 digital IO channels (all ADC channels double as DIO channels, so in total about 8 to play with). Another reason is if you want to only talk to one remote xbee module rather than them all, you could change it on the fly. For the bluetooth module, you can perform scanning of available BT things, and connect to them, all using the ‘Command’ mode.

This is another lesson for KISS I think, since when I first started to tackle this problem, I made these fancy functions to handle it. Well that didn’t work at first, but after some massaging, I got it working. Then I tried to get software serial working, but that didn’t work out. (I thought I configured it correctly, turns out I needed to declare inputs/outputs for the SW serial port)

Ultimately I decided to try the simplest while loop to handle the response, which worked out really well. I found out how to get the SW serial working by looking at this example which had SW serial running (the default examples in Arduino 1.0 IDE didn’t setup the input/output). I’ve attached the code below, it’s not pretty, but sharing is caring 😛

What you see in the picture are two NunChucks that I intend to get setup and running, and once they are running, I can send the joystick response anywhere 😛 Once I get some parts in for the controller, I’ll go ahead and build it up. Then something to interface with (plant waterer). Fun times!!!

Continue reading

Wire wrapping is one tool that should always be in your toolbox

This slideshow requires JavaScript.

I see so many people reaching for the soldering iron to make simple cables, when one of the simplest, and strongest, ways of joining two metal posts, is by wire wrapping.  Wire wrapping is a technique of wrapping the bare conductor of a wire around a metal post and has been in use for over 50 years.  It is used extensively in avionics and the space industry for its superior ability to handle vibrations and stresses.  A simple wire wrapping tool can be picked up at a local Radio Shack, as well as a spool of wire wrapping wire (cheapest place for both that I have found).  Here is an interesting PDF on the history of it, and why you should consider learning more about this easy way of making solderless connections.

That in itself deserves a post, but I’ve discovered what I’ll be working on for the next few weeks: Ultimate Wireless Showdown!  I’ll be putting 6 wireless modules through a gauntlet of tests to try to determine which has the best bang for the buck, when it comes to wireless transmission of data using an Arduino/ATMEGA328.  I’ll be testing the XBee Pro Series 1 60mW, XBee Series 1 1mW, RFM12B, Bluetooth Serial, nRF24L01+, and RF2400P modules.

I have outlined the test setup here, so read up on it if your interested, or on any of the other projects I have in the works.  By actually comparing these modules in real world situations, I’ll be able to see which module I should base my future robotic projects on.  So tomorrow I’ll start to get the two boards assembled, sporting a lovely 3.3V LCD and microSD card, with a few buttons for fun.  Which is why I felt it was necessary to improve my serial cables, as shown in the pictures 🙂  Future, here I come!