As part of my learning about CygNet, SCADA, and the exciting world of Real World Data, I decided to build a SCADA-enabled device from scratch.
I wanted something that could be reconfigured to support any sort of sensor, was very small, and that didn’t require soldering. A little bit of research (and by research I mean shopping) turned up the venerable BasicStamp: http://www.parallax.com/Default.aspx?tabid=295
It’s just about the simplest embedded system possible. A processor with a built-in Basic (the language) interpreter, 16 I/O lines, a serial port, and a small breadboard for components.
For $80, you can pick up a version at Radio Shack that includes a complete training program. (http://www.radioshack.com/product/index.jsp?productId=2117994&cp=&sr=1&origkw=parallax&kw=parallax&parentPage=search), or you can buy just the boards for anywhere from $10-$40 on eBay or the Parallax store.
I spent a little over a week going through the training and ended up with a photocell-based light meter that output readings on the serial port, and stored a small number of recent readings in its onboard EEPROM. I hadn’t read a circuit diagram in about 30 years, so that was fun.
Useful tidbit: the web has lots of resistor value calculators
Doug had already created a serial-device EIE for the Davis Vantage weather station, so it was a matter of hours for him to add a new “general” message that would allow communications with arbitrary devices
The protocol is blindingly simple. Send a number (really a single byte with the ASCII code for a numeral) from 0-n, and the device sends back data and/or takes some action. The current command set:
- 0 (48/0x30) – reset the device. Clear the ring buffer and all counters and restart the program
- 1 (49/0x31) – return the most recent reading
- 2 (50/0x32) – return all readings
- 3 (51/0x33) – sleep (turn off power to the device for N seconds, where N is currently hardcoded)
- 4 (52/0x34 – return a known diagnostic string (“deadbeef”). Why that word? It’s the default register & memory settings for the RS/6000 plus it’s all in hex. I didn’t say the commands made sense.
- 254 – used in early testing
Example: Send “1” -> Receive “NNNNN” where N is a numeral
There is no way I could have gotten this running without help from everyone, but especially Doug, Pete, Sheri, and Derek.