picture home | pixelblog | qt_tools

omino code blog

We need code. Lots of code.
entries for category "wbl weird blinking lights"
David Van Brink // Wed 2008.09.24 23:02 // {wbl weird blinking lights}

XBee Untethered

The XBee module has an odd connector. It’s 20 pins in two widely-space rows, with 2mm spacing. Nice and efficient, but doesn’t fit into my gridlike 10th inch world view.

I mean, it’s fine, if you’re spinning a board…

But if you’re just dinking around, it’s nice to have it fit into that 10th inch protoboard world.

Thankfully, Sparkfun Electronics sells little adapter boards and the exotic 2mm-spacing female headers. A breakout board and all the connectors runs about $5.50 from them. (From Digikey, just the 2mm female headers are, like, $4.00 each. Sometimes their pricing confuses me.)

Here’s an XBee module connected to 3v, and a resistor, and an LED, and nothing else. Boots into receive-mode, and the led blinks in response to a button on a second module.

Also, bonus points to Sparkfun for shipping my whole order in a single heatsealed baggie in a very small cardboard box by US mail. Valuable service!

oh, i dont know. what do you think?


David Van Brink // Mon 2008.09.15 19:16 // {wbl weird blinking lights}

Fun With XBee

About a year ago, I was vaguely wondering if there were any low cost 802.11-ish WiFi modules, to easily add a net-presence to my dinky electronics doodles. There wasn’t; WiFi modules seem to run around $150 or more. (Which is the same price as a WiFi Kodak picture frame, but that’s parts for ya.) But I came across these $19 “XBee” modules and was intrigued…

XBee modules, from www.digi.com (not digikey), implement an RF protocol called ZigBee, 802.15.4. It can run at various power levels, up to about a mile. At 1mW, you get a few rooms coverage. An XBee transmitting at 1mW consumes around 50mA when either receiving or transmitting.

Just recently, on a whim, I got their starter kit which includes two modules mounted on boards, $99.

I have to say, it gave great Out Of Box experience! Just plug one into the USB port, and plug a serial loopback into the other, and fire up their little terminal program, and they’re talking!

So here’s what their $19 module can do:

  • Automatically form a repeater mesh
  • Default mode is a transparent 9600 baud serial party line
  • Can enter “command mode” by sending +++ onto the serial port
  • Can configure the module into different modes with AT-commands (snicker)
  • Can configure a module’s address, take it off the “party line”, and such
  • Has a half-dozen available I/O pins, which can be AT-configured to act as “virtual wires” between modules
  • Use ATWR to save the configuration… powers up identically next time.
  • Requires 3 volts.

Interlude

The starter kit comes with two boards. The first uses USB for the serial comm port and for power. The second uses a DB-9 with official RS-232 on it, and a 12v adapter. The general purpose I/O lines are just sitting there, without even a header.

Some necessary modifications were in order. I added headers to access the I/O lines. (Pesky wave-solder on the PC board filled in all the holes; clearing them out with a soldering iron, melt-and-slam, works except for the pesky GND, I guess the four layer board’s ground plane is sucking away all my heat.) I contrived a 9v battery to power the remote board. I added some female headers to an LED and a microswitch.

Look, new toys! Some Panavise holders to replace the stupid “Helping Hands Magnifier” from Radio Shack. Sheesh I remember when that looked sooo useful. Also a new soldering iron, with digital readout. ($90 on eBay, search for “tmc soldering iron”, came with two irons and 6 tips, happy with it so far.)

Back To Work

I configured the two boards with a variation of the example in the datasheet:

Module with button:
ATDL 1234 their address
ATMY 5678 my address
ATD0 3 i/o 0 is an input
ATIR 14 sample rate
ATIT 5
ATWR save
Module with LED:
ATDL 5678 their address
ATMY 1234 my address
ATD0 4 i/o 0 is an output
ATIU 1 i/o enabled
ATIA 5678 receive i/o commands from
ATWR save

And ho ho! They can talk.

Good clean fun.

oh, i dont know. what do you think?


David Van Brink // Sun 2008.09.7 22:01 // {wbl weird blinking lights}

In Memory Of an early WBL

Specimen: a Lazer Tag target, circa 1987, manufactured by Worlds of Wonder, an early commercial WBL if ever there was one.

I’m doing a bit of dejunking and shedding, but wanted to give a moment’s silence for this one. LEDs and speaker and a tiny cpu, delicious. The LEDs would blink back and forth, a little faster each time you hit the target with the IR gun, until it blipped out, dead. Five or six hits, I think.

Some parts I see: LM567, the internets say it’s a tone decoder, probably for IR sensing. The two big black rectangles in the middle are the IR sensors. And I’m guessing the CPU is the TI MP1826N2; no idea what it is.

Me, I’m gutting it for the cool red dome and small speaker.


(From Wikipedia, WoW founder Don Kingsborough with gun and target)

oh, i dont know. what do you think?


David Van Brink // Wed 2008.08.13 19:24 // {wbl weird blinking lights}

The Old Parts

Getting on towards deep self indulgence, here …
++more

oh, i dont know. what do you think?


David Van Brink // Tue 2008.08.12 22:16 // {wbl weird blinking lights}

12f509 cheat sheet

Back in the 80’s, I thought it was the coolest thing that you could call up someone in San Jose, tell them you were interested in such and so category of parts, and they’d send you a great box of literature. I obsessively read the app notes and features of the 8051 and 8048 “single chip microcomputers”, among the 20 pounds of Intel phonebooks. Apart from their undeniable literary value (the signs and signifiers were never closer, and the narrator… such a cypher) they were occasionally of practical value. One day at the local landfill, I came upon a stash of 8748’s (reprogrammable and UV-erasable!) and, guided by the incantations of these tomes, heroically brought those chips to life. But that’s for another post.

Those endless summers of bound and printed datasheets weren’t so endless… Now you have to print your own. On the other hand, you can obtain them any time of the day or night. Progress!

The “data sheet” for one of Microchip’s smallest parts, and my favorite, the 12f509, is still 97 pages long. I have it printed out, of course. But the majority of my inquiries where answered by just a few particular pages. So here are what I found to be the most important bits, extracted into the “Pic 12f509 Single Page Cheat Sheet.”

2 comments
Raymond // Wed 2008.12.10 09:479:47 am

The most frustrating part about the widely used 12F508/509 is the general lack of published software examples. I want an assembler template and a .inc file for programing. Along with the 12F675 it looks like a usable chip set.

David Van Brink // Thu 2008.12.11 08:428:42 am

Hi Raymond — I haven’t used the ‘675 yet. I do love these tiny 8-pinners though.

It’s not comprehensive, but most of my PIC code is viewable at http://omino.com/src/pic/

Look for asm files, like
http://omino.com/src/pic/wbl05bDemocracity/generalBlinker.asm .

Hope that might help, a little. I found the chip pretty straightforward to use, overall.

oh, i dont know. what do you think?


David Van Brink // Sat 2008.08.9 21:58 // {applet wbl weird blinking lights}

Nightlight Algorithm

For our Trylon and Perisphere installation, it seemed like it’d be more dramatic if the lights only came on at night. Some of these lights are Cool Neon, and others are Pic-controlled LEDs. To do this required three problems to be solved: 1) sense light, 2) switch circuits of various voltages on and off, 3) make the switching robust against shadows, twilight, and flashlight-weilders.

Sensing Light

I went to Radio Shack with some vague idea of getting a phototransistor, but all they had was a $2 pack of “Assorted Photocells (Cadmium Sulphide)”. I measured one at 1M ohms inside my travel-coffee mug (lid closed), 10k ohm lid open, and 150 ohms for under a desk lamp, in my optics lab. Conveniently, merely hooking it to the Pic 12f509’s GP3 input, with Weak Pullup Enabled, seemed to work great. It pulls the input low in moderate room light.

For the outdoor installation, I’ll move the sensor into our out of a tube or something, to adjust its sensitivity.

Controlling Circuitry

I got a handful of “Aromat TF2E 4.5 Volt Relays” on e-bay, for a couple bucks. These relays need (as you might surmise) 4.5 volts to activate, and, amazingly, only 24mA. A Pic chip can sink that much on an output pin. I’ve heard that coils are hazardous to chips, but so far it seems fine. It may have a built-in diode protection; I noticed that the voltage must be applied in the correct direction for it to click and activate.

Robustness

If you just put a threshold on the light sensor, it runs the risk of frequently flickering, at twilight. Also, the whole installation would fire up in the daytime if someone cast a shadow for a moment, and shut down at night if one shined a flashlight on it.

<Wikipedia-says> that streetlights use a photocell to modulate a heater which bends a bimetal contact, which stabilizes the sensitivity a bit.

A streetlight has a different materials and power budget profile than mine. </Wikipedia-says>

I came up with a simple, simple algorithm (about 30 pic instructions) that prevents all that, with just time delays. One could do more with an analog-input for the light, I suppose.

As briefly as possible: A counter migrates UP for darkness, and DOWN for light. The installation activates at the halfway point, by merely tracking bit 7 of the counter. Whenever the light changes, bit 7 is replicated across the counter.

But that’s a mind twister. Here’s the algorithm interactively for your ready apprehension.

More to come.

2 comments
Douglas Jones // Sun 2008.08.10 08:158:15 am

Another approach… I pulled apart a light-controlled outlet with the hope that a simple reversal of the logic would make it turn on duringthe day instead of at night. Inside it wasn’t so simple; they had one sensor feeding two inputs with different resistor values so that one would change level before the other and based on that you know from the timing if it’s a quick shadow or someone messing with it.

I suppose I should try just inverting both inputs to see how it goes. I think pulling a chip off and finding a way to reprogram it is too much effort for what I want.

David Van Brink // Sun 2008.08.10 15:023:02 pm

hmm! Interesting. They could be using those inputs in all sorts of ways, like expecting a gradual darkening… or it might just be a sort of “self calibration” because photoresistors are so imprecise.

Pull it apart and run the experiments!

oh, i dont know. what do you think?


David Van Brink // Fri 2008.08.8 22:42 // {wbl weird blinking lights}

wbl05b

A Future City

Our project for Burning Man this year is a minuscule reproduction of the Trylon and Perisphere from the 1939 World’s Fair. Google it, it’s worth reading a little, seeing a few photos…

Ours will be 16″ in diameter, with a tiny miniature city inside (as opposed to the giant miniature city within the original).

Kitchen Table Prototypeneighbors

Naturally, we’ll need to light this up, both magically on the inside and dramatically on the outside. This is a job for WBLs.

wbl05b

This board is an update from the wbl05a:

Improvements include:

  • Several unallocated power and ground points (good for stabilizing caps, and such)
  • Can be populated for LEDs, or to activate transistors for heavier loads, like speakers or bigger lamps
  • Two power planes, one for the pic, and one for the transistor-driven loads
  • Can take a 7805, for driving (for example) 12v LED clusters and powering the pic at 5v
  • Connection for In Circuit Serial Programming (icsp), which can shorten the code/debug/test cycle significantly.

ICSP and the Pic 12F509

How I do love the 12F509! It costs less than a dollar, and makes lights blink any way you want! And it has the most lovable quirky asymmetric nonorthogonal memory map and feature set you could ever want. It’s like building a ship in a bottle which I’ve never done but I bet it’s kinda like this. Except anyone can see how cool a ship in a bottle is, and only you, dear reader, will know how nifty programming this stupid Pic chip is. I mean, if you give it a go sometime.

Anyway, it’s easy enough to hook up to ICSP, but there are some issues, noted below.

I’m here using the Microchip ICD2, but their PicKit 2 or other programmers should work the same. The rj12 phone jack is from Home Depot, intended to go in a wall, with push-down wires out of some cat-5e.

Some things to keep in mind are:

  • Keep the leads short! I had wires too long, and got comletely sporadic results. Checksum errors, partial programming, all zeroes, nonsense like that. Keeping the wires short (like in the picture> fixed it right up.
  • Only 3 pins left. This makes it a little bit pointless. Two of the outputs, and GP3 (the dedicated input) can’t be used while the ICSP is connected. They probably can if you’re smart enough, but I’m not. Actually, even missing some pins, getting to see the code run right after compiling is quite helpful.
  • There are various contradictory reports in forums and such about using the 12F509’s internal oscillator and dedicated reset pin in various combinations. They all work fine. This is a fact. There are no forbidden combinations of config bits and ICSP. The ICSP “activates” the chip by pulling pin 4, MCLR’, higher than Vcc, so it can’t be locked out.

That’s enough for now! Back to the bottle go I.

oh, i dont know. what do you think?


David Van Brink // Mon 2008.05.26 22:41 // {wbl weird blinking lights}

Retro USB MIDI Device VIII

SEND MORE BOARDS

Noodling around with more boards. Nothing too insightful here, but I do love to post glamor shots of LED’s and such. I’ll call out the actual technical tidbits in an attempt to be useful.

Useful Technical Tidbit 1: How to Solder Surface Mount Parts

So I got these cute little surface mount boards and TQFP 44-pin 18F4550’s, from Sure Electronics.

I consulted Aaron for advice on soldering. It’s pretty easy.

  • Use a good tiny-pointed soldering iron. (I’m lucky, my employer had one.)
  • Melt some tiny-solder onto one of the board pads.
  • Hold the package exactly in place on the board with your finger, and touch the soldering iron to the pin on the soldered pad. (If the registration is wrong, hold it upside down and touch the pin again, freeing the chip.)
  • Solder another pad. If the registration is still good, solder the rest!
  • I went around the board with a Fluke set to “beep” mode, checking adjacent pins for solder bridges. Corrected a couple by the usual means of “Heat joint while upside down, impact on tabletop, avoid splatters.”

Useful Technical Tidbit 2: Quick and Easy ICD for the PIC 18F4550

For programming and debugging from the MPLAB ICD 2, it was easy to add an RJ-12 jack. This matches the cable that comes with the programmer. I had some jacks left over from installing phone lines in my home. Home Depot carries them, made by Leviton. The connections are:

Connections for ICD/ICSP between PIC 18F4550 and RJ-12 jack:

RJ-12            PURPOSE       18F4550 TQFP-44
1 green-stripe   reset mclr    18
2 orange-stripe  +5            7
3 blue-solid     ground        6
4 blue-stripe    rb7/icd data  17
5 orange-solid   rb6/icd clk   16
6 green-solid    unused

Two LED's with 200 ohm resistors

                 ra0      19
                 ra1      20

Setup code

    TRISA = 0;    // all outputs
    PORTA = 0x01; // one on, one off.

Here it is attached to the programmer. Note that the programmer *must* be connected to an external power supply. In MPLAB, in the connection settings, you can then have it power the target board. Convenient!

But you know, that board is just for dinking around. I wanted to make some LED sculptures, and this has lots of I/O. Can’t run USB off the internal oscillator…

The CUI Platform

Google led me to Dan Overholt’s CUI project, which is a lovely little PIC 18F4550 board that’s all set for what I needed! It turns out it that there are USB HID drivers for this board, but no USB MIDI. HID works with all the hip academic software like MAX and Supercollider via OSC. But MIDI drivers are handy too, for more traditional software like Reason. Dan was kind enough to send me a board for experimentation.

It’s very nicely designed. See how all the pins are clearly labeled? See how the analog inputs are each next to a +5 and gnd, so you can just plug in a potentiometer? Perfect!

As much as I’d love an excuse to spin a board and all that, when something like this arrives on the workbench, you just have to accept that that problem is solved, and you have to just move forward to the next.

oh, i dont know. what do you think?


David Van Brink // Tue 2008.05.13 21:26 // {wbl weird blinking lights}

Retro USB MIDI Device VII

Hardware Prototype

I built a few switches and the PICDEM FS USB demo board onto a… um board. A wooden board. Here’s a little demonstration of its use.

It plugs in and is immediately available to all MIDI apps on the Mac. Here, it’s controlling a patch in Propellerhead’s Reaason.

1 comments
mattvb // Wed 2008.05.21 06:226:22 am

This is as lovable as a furry kitten. Yay

oh, i dont know. what do you think?


David Van Brink // Sun 2008.03.23 20:54 // {c code wbl weird blinking lights}

Retro USB MIDI Device VI

First Working Code

After much tinkering and poring over data dumps and specs, I have flashed the PICDEM FS USB board such that, when plugged into the Mac, it shows up as a usable MIDI input. (Doesn’t yet show up properly on Windows XP, though.) This, using a Pic 18F4550.

From reading and googling the subject, it seems that most USB developers start by creating the descriptors, and committing them to ROM.

I took a different approach. I wanted to have a flexible and repeatable way to create new MIDI devices as needed. Who knows, I might do more than one. And this way others might benefit from it too, potentially. As part of main, I call a setup method which dynamically creates the all the descriptors, strings, & so on. I donated 256 bytes of RAM (out of 2k) to hold the descriptors. And the code to poke it all in chews up a K or so of program space. But, for now at least, the freewheeling flexibility is worth it.

    UsbMidiSetup(0x0832,0x401c,5,5,
        "omino.com products",
        "omino 8038 controller"
        );

The above C call creates in memory the device and configuration descriptors for a Streaming Audio (MIDI) USB device with Vendor ID 0832, Product ID 401C, five MIDI input cables, five MIDI output cables, for a company named “omino.com products”. It shows up in the MIDI patchbay as an “omino 8038 controller”.

Below the cut, some trivia about the Pic 18F4550, the PICDEM FS USB demo board, and their development tools.

++more

oh, i dont know. what do you think?



(c) 2003-2011 omino.com / contact poly@omino.com