The Zen of Arduino

Well, I shoulda gotten out into the detached garage this weekend and worked DX.. but the weather was nice on Thanksgiving and the day after (when I had to do family stuff thankfully) and freaking cold and windy the rest. (I can heat it but it takes some planning…)

So instead, I decided to catch up on building/hacking projects from the past and ones on a weird tangent to my current construction project the BATC DigiLite.

The past project is rebuilding my ORIGINAL 1998 Dallas Semiconductor “iButton” WS-1 One Wire weather station w/humidity and the tipping rain gauge (it’s been ten years since I had it up and running last– it took me several hours to find it!). I plan on stripping all of the one-wire garbage (sorry, it never worked reliably with any cable length at all) except for the temp sensors out of both units and embedding an AVR and running RS-485 to the units.. and connecting to an Ethernet connected Arduino to report to APRS and/or Weather Underground. My kids are interested and I’m also adding a Real Time Clock and a Barometric Pressure sensor (to the inside unit since my house isn’t pressurized) and having a fairly complete station. No PC will be required and the little 8-bit processors are misers when it comes to power usage!

I want to get my older boys interested in the systems engineering aspect and the coding and the weather station is starting to peak there interest a bit. Keeping my fingers crossed!

This is actually connected to the BATC project in that I want to use the Arduino development system and the extensive library of code instead of taking time I don’t have and writing everything from scratch on a PIC or AVR (non-Arduino). I discovered that except for the bootloader and the sometimes bloated code in some of the libraries (most are very good) that it is not that much less efficient than straight-C on the AVR’s. (The Arduino environment conceals a full open source GCC C++ complier and yup, you can write in C and C++.. you actually are even under the “sketch” environment– but they conceal that well to beginners.) Yes they are small, and slow.. but at $2.50-$6 a pop for DIP IC’s that you can hack together in a hurry.

Here is a picture of some of the AVR based toys I’ve bought and put together over the years. The “real” Arduino shields are recent.. for prototyping your own stuff they suck (since one header isn’t on 0.1″ centers.. DUH!).. but since they are a standard certain modules are cheap (at least the non-Italian “bad labor condition” clones from China) and readily available. You can put together relatively inexpensively and quickly since most of the core code can be borrowed from libraries.

Some AVR based "Arduino" toys-- Arduino 2009 clone with a Nootropic Designs Video Experimenter's Shield, a Sanguino board, an Ethernet module, a Adafruit Proto shield on top of a Clone W5100 Ethernet/SD card shield, a "Boarduino" board with a humidity/temp sensor DHT-22 on it, and a DS1307 Adafruit RTC board attached.. and a homemade video/audio out and a e-bay "DFRobot" LCD Shield 16x2 -- "Unknown" proto card at bottom will be a 5V to 3.3V bidirectional 8-bit I/O board with a 3.3V regulator on it for prototyping.

In relearning the coding, I wrote a lot of odd stuff. Here is an example of a ATMega644 (in an Sanguino PCB) doing a bunch of stuff.. talking to a LCD (via the library in 4-bit mode) and shifting data to a 74HC595 driving the LED’s in a row.. reading from a Dallas (yes, one-wire) Temperature Sensor (those are great units if not parasite powered!) with two debounced switches… doing math for the PLL synth (the numbers in the left bottom corner).. Here is a video:

Sanguino board doing all sorts of stuff

Anyway.. I am going to use the ShiftOut function on the Arduino to program the "Ultram Technologies" PLL board (That I bought preset to 1255 MHz) for the DigiLite LO on the DVB-S modulator. I was going to use that Arduino 2009 / "DFRobot" (clone) LCD Shield to do a GUI. But most of the time the little AVR will be idle. So sad. So I came across the Nootropic Designs Video Experimenters Shield and I thought… really since the BATC project needs the real time MPEG-2 chip in the Hauppage PVR-150 board.. I might as well also do a callsign overlay.

Since the Arduino 2009 has a FTDI chip on it.. it has USB to Serial functionality on it. I can poll the UART at the Vertical Blanking interval and if it receives a PLL tune command, that can be sent to the PLL and displayed (for a short time?!?) on the Video overlay as well. For now, the video overlay shows a callsign message and the system timer in ms for debugging.

Here’s a shot of that too:

Arduino/Nootropic Designs Video Experimenter Shield Overlay Example Video

The video callsign overlay is done with this "sketch":

#include <TVout.h>
#include <fontALL.d>


#define W 136
#define H 104
TVout tv;
char s[32];
unsigned int n = 0;
int index = 0;
int messageLen = 34;
char message[] = "...W0FMS Digital Amateur Television";
char saveChar;
void setup() {
tv.begin(NTSC, W, H);
initOverlay();
tv.select_font(font6x8);
tv.fill(0);
}
// Initialize ATMega registers for video overlay capability.
// Must be called after tv.begin().
void initOverlay() {
TCCR1A = 0;
// Enable timer1. ICES0 is set to 0 for falling edge detection on input capture pin.
TCCR1B = _BV(CS10);

// Enable input capture interrupt
TIMSK1 |= _BV(ICIE1);

// Enable external interrupt INT0 on pin 2 with falling edge.
EIMSK = _BV(INT0);
EICRA = _BV(ISC11);
}


// Required to reset the scan line when the vertical sync occurs
ISR(INT0_vect) {
display.scanLine = 0;
}


void loop() {
saveChar = message[21];
message[21] = '\0';


for(int x=6;x>=0;x--) {
if (x<6) {
tv.delay_frame(3);
}
tv.print(0, 92, " ");
tv.print(x, 92, message);
}
message[21] = saveChar;
saveChar = message[0];
for (int x=0; x<messageLen; x++)
message[x] = message[x+1];


message[messageLen] = saveChar;


sprintf(s, "%dms ", millis());
tv.print(0, 0, s);
}

Assuming that you’ve downloaded the Enhanced TVOut Library into the \arduino\libraries directory.. the code above is how simple something like this can be with Arduino and the libraries. This compiles to less than 10K or 1/3 of the ATMega328P (on the Arduino 2009, or 1/6 of the ATMega644 on the Sanguino).

This is why I like Arduino. It took me less than an hour to build the shield and write the example code. I am not easily impressed and even that isn’t that impressive.. but the Closed Captioning decoder example is impressive. It works really well.. and is so simple really for what it is.

I know that hopefully some day the TV input portion of the BATC project will go from SD analog to SD/HD full digital and a little hack like this won’t be appropriate anymore. But I’ve had a blast with it and I really hope I can leverage it into a learning experience for the kids also.

Pick up a few of these Arduino gadgets (now you can buy them at Radio Shack if you are in a hurry– and want to pay 3x the clone price from e-bay/China) and give it a try– it’s quick fun experimentation and I can now see the ZEN.

73, Fred W0FMS

Fred Spinner, WØFMS, is a regular contributor to AmateurRadio.com and writes from Iowa, USA. Contact him at [email protected].

2 Responses to “The Zen of Arduino”

  • Chad KJ4VYI:

    Enjoyed your arduino write-up I’m waiting on mine to show up and have already have a long list of projects to work on with it!!!

  • W0FMS:

    Arduino a great way to learn programming. From simple to C to C++ classes, the environment is well designed!

    I hope to teach my kids on this first and then move them up to Visual Studio, Java, etc. Learning how to code at low level first is what make a great programmer. Especially with these simple processors that have limitations. Enjoy. Future Arduino posts by me will be at my “technical” ‘blog http://w0fms.blogspot.com.. but I thought this was a good “general interest” example.

    Keep building and enjoy.

    73, Fred W0FMS

Leave a Comment

Subscribe FREE to AmateurRadio.com's
Amateur Radio Newsletter
News, Opinion, Giveaways & More!

E-mail 
Join over 7,000 subscribers!
We never share your e-mail address.



Also available via RSS feed, Twitter, and Facebook.


Subscribe FREE to AmateurRadio.com's
Amateur Radio Newsletter

 
We never share your e-mail address.


Do you like to write?
Interesting project to share?
Helpful tips and ideas for other hams?

Submit an article and we will review it for publication on AmateurRadio.com!

Have a ham radio product or service?
Consider advertising on our site.

Are you a reporter covering ham radio?
Find ham radio experts for your story.

How to Set Up a Ham Radio Blog
Get started in less than 15 minutes!


  • Matt W1MST, Managing Editor




Sign up for our free
Amateur Radio Newsletter

Enter your e-mail address: