Older blog entries for shimniok (starting at number 43)

Hacking a dual rail supply for HP204 oscillator


I built a custom power supply for my HP204 oscillator and cleanly modded screwed up, hacked things together, and eventually shoehorned it into the case.

Now why would I go and do all that? Read on...

I hacked my HP204D, similar to the HP204C, because the waveform sucked at low frequency settings. Mine was battery operated but the batteries were missing. The power supply circuit was designed to charge those long-gone batteries and, without them, it doesn't supply the correct +13V and -13V voltages.

I originally planned to make use of the original diode bridge rectifier and be all clever. I was going to cleanly replace the original transformer with a new, center-tapped one that I'd been saving for just such an occasion. Pretty much none of this worked out.

The transformer output a rather high voltage requiring large, high cost capacitors that wouldn't fit in the case. I discovered this after I cut holes for the big transformer. Oops. I bought a lower voltage transformer and selected cheaper, smaller, shorter input ripple filtering capacitors.

The new transformer was a bit smaller than the old so the hole I'd already cut into the circuit board was too big. The install wasn't quite as clean as I'd originally intended. It's good enough, though. The transformer is affixed to a single, existing mounting standoff affixed to the PCB by the factory.

Smaller transformer, back panel, prototyping regulator
As for the original bridge rectifier, I goofed up and blew out one of the diodes, then trying to repair that, I damaged the traces, lifting them off the PCB. It was time to give up on that plan.

Some day I may build adjustable positive and negative power supplies with LM317/337 ICs but as an interim fix, I went with +12V/-12V design using 7812 and 7912 regulators.

Simple home-etched +12V/-12V supply
After breadboard prototyping, I designed the circuit and layout, etched the board, removed all the original regulator components and tapped into existing +V and -V traces so I didn't have to change the green card edge connector, too.

Regulator with soft start resistors
Then I shoehorned the supply into place on the internal frame out of the way of other components. The transformer is wired from the mains socket through a switch for 120V/220V compatibility. I don't know why I retained that feature since I have no intentions of taking this device overseas. Whatever.

Regulator tucked in on the internal frame.
The custom board features a compact, 400V bridge rectifier, 1000uF ripple capacitors, 1.5A 7812/7912 regulators, and 100uF output capacitors. As a final step, I installed a fuse on the AC hot side.

Sparkfun AVC 2014 Announced

Sparkfun has announced the date and venue for the 2014 Autonomous Vehicle Competition. June 21st at the Boulder Reservoir. Details here.


Syndicated 2013-11-18 16:49:00 (Updated 2013-11-18 16:49:08) from Michael Shimniok

ATtiny Software Serial

ATtiny software serial transmit and receive, based the Arduino SoftwareSerial library, and around 1K compiled. That's what I've been working on. Why?

Spy photo :) of ultra compact eeZeeISP AVR programmer
I'm designing a low cost, really small AVR Programmer, that's why. It's based on an ATtiny84A and requires SPI which claims the USI peripheral, leaving no hardware serial.

Here are the details on TinySoftSerial.

Overview

The current Arduino
SoftwareSerial library is based on the NewSoftSerial library by Mikal Hart. A few years ago, NewSoftSerial was a dramatic improvement over then-incumbent SoftwareSerial, which is why the new code is part of the Arduino 1.0.x distribution.

Multiple serial listeners are supported at baud rates from 300 to 115200 though errors above 38400 at 16MHz may be too high and lower rates too slow. Overall, it's a really neat library for typical communications of 9600 - 38400.

So you may see why, when I needed serial receive (the hard part), I didn't really feel like reinventing the wheel. I need the library for other projects, too. But I needed something small and with only one software serial instance.

What I Did

  • Converted to C
  • Removed multiple instance capability
  • Converted to native PORTx/PINx/DDRx register references
  • Hardcoded to use PA0 for RX and PA1 for TX
  • Shaved a few bytes here and there,
    • e.g., using a mask instead of modulo for circular buffer**
  • Adapted interrupt register references to ATTiny84A: GIMSK, PCMSK0
  • Hardcoded 16MHz timings (for now; I may restore the other frequencies later)
  • Fixed "Error: register r24, r26, r28 or r30 required" - details
  • A few other things I can't remember
The result is pretty small. The following is for the library with a simple main() that echoes characters you type:

  avr-size --format=berkeley -t TinySoftSerial.elf
   text    data     bss     dec     hex filename
   1008       2     204    1214     4be TinySoftSerial.elf
   1008       2     204    1214     4be (TOTALS)
Finished building: sizedummy

** If you're curious about using a mask instead of modulo. Let's say you have a buffer of 64 bytes (or any number 2n), aka 0x40 or 26. Indexes range from 0x00 to 0x3f or 000000 to 111111. After you increment your index, simply AND it with 0x3f (2n-1). Suppose the index is 0x3f, the maximum and you increment it to 0x40. Now AND with 0x3f and you get 0x00  (%01000000 & 111111) . This is faster and uses fewer assembly instructions to implement than modulo or an if statement. Here's what it looks like in C:

#define MAXBUF 64
#define BUFMASK (MAXBUF-1)
...
char buf[MAXBUF];
...
i = (i+1) & BUFMASK;

The Code

I bet you just want the code. Ok, here it is.

Source Code

Porting to ATtiny85, Etc.

It shouldn't be too hard to port this to ATtiny85. You could port to ATtiny2313 although it has hardware serial separate from the USI. The library is too big for ATtiny13 to do anything useful. I don't use any other ATtinys but basically anything that has 2K flash or higher should be a go.

Saleae Logic Analyzer: STK500 V2 protocol

Syndicated 2013-11-14 17:00:00 (Updated 2013-11-14 19:42:47) from Michael Shimniok

9 Nov 2013 (updated 9 Nov 2013 at 20:12 UTC) »

Robot Art


My best friend is an artist. His latest blog post features some of the robot head art he's been working on. His prices are reasonable so if you want one, let me know and I'll put you in touch.





Syndicated 2013-11-09 16:46:00 (Updated 2013-11-09 17:42:12) from Michael Shimniok

JavaOne: Raspberry Pi Embedded Challenge


After a couple late night hours at JavaOne Java Embedded Challenge, Bruno and I had written a field sobriety tester on a Raspberry Pi using JavaFX and Java Embedded Suite. It's an example of how easy it is to build embedded solutions when all the hard work is already done for you :) Here's what we put together...

A few weeks ago I was fortunate enough to attend the JavaOne conference. I was there for purposes other than blog fodder but by happy coincidence, I stumbled across the Raspberry Pi Embedded Challenge in one of the first presentations of the event.

In the evenings, on personal time, a handful of us committed to hacking up some code on Raspberry Pi using Java Embedded Suite, Arduino, a big board of sensors, and a slick RPi-Arduino interface API (
things-api) written by Vinicius Senger.

Bruno P. and I teamed to create a Field Sobriety Tester that incorporates an alcohol sensor and a "drunk swaying" sensor, that is, a Ping))) distance sensor. The distance sensor is graphed and value displayed, the alcohol monitor value is also displayed.

That's me talking about the JavaFX display
Our source code is posted on github.

Overview

The basic architecture begins with a JavaFX client running on our laptops. The client could just as easily run on the Raspberry Pi. In fact, JavaFX can directly write to the RPi's frame buffer hardware, bypassing X.


The Raspberry Pi is running Oracle Java Embedded Suite, basically like a lightweight, embedded J2EE.

The Embedded Suite is running things-api code, exposing Arduino sensors as REST web services. The RPi's things-api web services talk to Arduino's things-api code over serial. The Arduino in turn interfaces with sensors in the standard fashion.

Things-API Arduino

On the Arduino side, defining sensors is beautifully simple. Declar a Device object, then add things to it, defining the pin type and pin number, e.g., Analog pin 2. Then just loop calling loop functions.