16-bit, 10 MSPS ADC, dual op amps and 2x10bit 1 MSPS DAC. In case you were wondering MSPS is Million Samples Per Second.

If you're not picking your jaw up off the floor then maybe some comparisons will help.

AVRs have 10-bit, 15 kSPS ADCs. That's kilo-Samples Per Second. Two orders of magnitude difference. The ARM NXP LPC1768 can do 10-bit conversions at 500kSPS. There are Kinetis ARMs that do over 800kSPS. The dsPIC33F has 10-bit, 1.1 MSPS converters which used to be impressive to me.

Oh, and 10 bits is ok, 12 bits is pretty good. But 16 bits is crazy resolution for an MCU. Usually more bits means slower sample rates. And yet...

10 MSPS is a quantum leap. That's some rarefied air in that realm. Usually only specialty ADC chips run in the 10MSPS range. And they have to have parallel interfaces to pump data that fast. Then to throw dual op amps and dual 10bit 1MSPS DACs in the mix?

Microchip Technology Inc. announced a new family of microcontrollers (MCUs) —the PIC24FJ128GC010. This family is an analog system on a chip that integrates a full analog signal chain, including Microchip’s first ever on-chip precision 16-bit ADC and 10 Msps 12-bit ADC, plus a DAC and dual operational amplifiers (op amps), along with extreme Low Power (XLP) technology for extended battery life in portable medical and industrial applications.

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.

Drilled a big ol' hole in the back for a fuse holder

Fuse wiring

But guess what. The lowest frequency setting still doesn't look right despite much tinkering with the device's calibrations. All the other frequencies are usable. I'm not positive but I think it has to do with the automatic gain control circuit. If I find out I'll let you know, ok?

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.

** 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:

The 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.

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.

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.

Things-API Raspberry Pi

On the RPi side of things, well, you'll have to wait for an update to this post because I haven't had a chance to look into how things are set up. I can tell you that when it's all set up, there are REST services on the RPi corresponding to the devices defined on the Arduino. You connect to, for example, http://example.com/alcohol and it returns the value currently read by the Arduino.

JavaFX Front End

I'd not played with JavaFX before, only Swing. What struck me as nice about JavaFX is that you can achieve a higher degree of separation between code and UI using FXML, generated by Scene Builder, a GUI development tool. The FXML drives the creation of the UI in the start() method of your app's Application subclass. Like this:

The controller can then automagically update elements on the UI. We called the bind() method, for example, on the textProperty of a Label. We wrote a monitor class that periodically runs code to call the REST service, and updates its property which is declared as a StringProperty.

This property is made available through a property()method, declared as ReadOnlyStringProperty used by bind(). The StringProperty class implements the Observable interface which appears to be at the heart of the magic that listens for changes to the property, and automatically updates the display. I've got more to learn.

Anyway, that's the gist of our code. We wrote it in a couple of hours by modifying example code. Not bad given that neither of us had played with JavaFX before. Bruno however is a pro Java coder, thankfully. Actually, most of our time was spent properly setting up our IDE environment.

Video Demo

If you want to see the video -- and if you are a minor, please note that I really am only joking about drinking heavily in pursuit of science. All things in moderation, my friends. Trivia: I actually didn't drink at all until I was out of college at aged 23. I've seen what abusing the drink can do and it's not pretty. Make intelligent choices, young ones.

Use the AVR Watchdog Timer as a sleep delay. Put your ATtiny / ATmega to sleep and the Watchdog Timer will wake it up after a specified interval.

oh no, it's the glowing, blinking eyes of a chupacabra!

This is the technique I used for my lost R/C airplane model alarm. I also used it last night for my Halloween glowing, blinky eyes. Here's how.

Two sources of documentation are your friend. Your AVR's datasheet and App Note AVR132 [pdf], "Using the Enhanced Watchdog Timer". Without these documents you will miss the subtle differences between the Watchdog Timers on different devices.

The Watchdog Timer on newer AVR devices can be configured to either reset, fire an interrupt, or both, upon timeout of the Watchdog Timer. We want interrupt mode, only. Let's talk about implementing the specifics of the ATiny13A [datasheet.pdf] since that's what I've used so far.

Overview

You need a sleep function to put the microcontroller to sleep for a specified time period. The Watchdog Timer runs in interrupt mode so it only wakes up the sleeping microcontroller periodically. And an Interrupt Service Routine keeps track of elapsed time.

To enable interrupt mode and disable reset mode, you must:

Disable the WDT Always On fuse on your microcontroller

Within software, define a Watchdog Timer interrupt service routine (ISR)

Code

Please note that, to conserve battery power, I am running the clock at 150kHz scaled down from 9.6MHz. The slow clock will cause problems flashing the chip. In AVR Studio 4, I set the ISP frequency very low so I could continue to flash the chip using my JTAG ICE MkII or AVR Dragon. If you're using avrdude you might be able to use either -B or -i flags. Since originally posting this article I've also added a delay before slowing down the clock which hopefully alleviates the problem but I haven't personally tested it. If you have working solutions please post to the comments.

My WDT initialization is as follows.

Every second after calling this routine, the Watchdog Timer will time out and call the ISR. The ISR counts the number of times the interrupt has fired in the variable sleep_interval.

According to the datasheet for the Tiny13A, the WDTIE bit is cleared after the interrupt fires and the Watchdog Timer goes into reset mode, apparently for increased reliability. To remain in interrupt mode, set WDTIE after the interrupt fires. If you're using the WDT to reset the MCU, then this shouldn't be done in the ISR. I'm not. So I did.

A sleep routine, which takes as an argument, the number of seconds to sleep repeatedly puts the microcontroller to sleep until sleep_interval matches the number of seconds of sleep requested.

The main routine calls init_wdt() then when it needs to sleep it calls sleep(n) where n is the number of seconds. The MCU remains in low power sleep, waking every second until the sleep time has elapsed.

The rand() stuff came out of the candle flicker code I grabbed and adds some psuedo-randomness to the various blinking intervals.

Watchdog on Other AVRs

The register names, interrupt names, and some behavior differs between AVR microcontrollers.

On ATtiny13A, WDTCR is used but it's WDTCSR on ATtiny84A and ATtiny2313 and other devices.

The Watchdog Timer interrupt vector name differs. On ATtiny13, ATtiny85, ATtiny328P it's WDT_vect. On the ATtiny84 family it's WATCHDOG_vect. The ATtiny2313 uses WDT_OVERFLOW_vect.

In terms of behavior, from AVR132, "If the WDTON fuse is unprogrammed on ATtiny13 and ATtiny2313, it is possible to change the WDT timeout period without..." setting WDCE and then setting the WDE bit.

Happy Halloween. After failing to make a bright enough flickering candle on an ATtiny13A, I quickly threw together a "blinking, glowing eyes in the bushes" thing using one of my eeZee Tiny boards with some resistors and LEDs soldered on.

It's possible some of the problems I encountered are fixable. If so, please let me know in the comments.

Details

gerbv is a free, open source package that's part of gEDA's suite of tools. One downfall is that it cannot open zip files, which is usually what I send to the PCB fab. Several display options are possible as with KiCAD. Viewing bottom layers through the top layers is possible in Normal rendering mode. I had to adjust layer colors to be able to see, for example, the bottom silkscreen. Otherwise it displays drills correctly, the UI is quite good, and it has a good set of features. It's one of my go-to Gerber Views on Linux despite the niggling issues.

gerbview comes from KiCad's free, open source suite of free tools. Tip: don't display dcode numbers; they're distracting and slow down zoom. Layers can be shown or hidden as with many Gerber viewers, but they are unnamed (Layer 1, Layer 2). If I want to turn off the bottom copper layer... which one do I hide? The tool only recognized my Excellon file, not my dri file. I also had to select "all files" as it is expecting a .drl extension. Zooming seems haphazard and difficult to control. Centering the design doesn't actually center it. It puts the lower left corner in the center. The UI has some nice display options. It's my second favorite and would be my first if the layers were named descriptively and the zoom/center issues were fixed.

3D Gerber Viewer is a free, online Gerber Viewer that displays your board as a 3D object that you can rotate and zoom. The performance is excellent. It was able to display my Excellon drill file and rendered holes correctly. The downfall is that it requires drag and drop of all your Gerber/drill files at the same time. For me, those files are mixed up with a bunch of board and schematic files. I'd rather click-select files from a dialog. Zip support would be ideal. I'd also love to see improvements in detecting which file corresponds to which layer. But despite these shortcomings, it's a decent tool and I'd recommend it.

gerber-viewer.com is an online version of the EasyLogix GerberLogix tool for Windows. While the Windows tool is wonderful, I found the online tool to be frustrating, particularly the zoom feature which was extremely slow and difficult to use properly. I encountered an issue where every additional file loaded adds to the list of layers. Clicking "clear all" removes all layers. An earlier problem with drill display has been fixed.

Circuit People's web offering is usable but only just so. It reads zips or multiple files which is nice. Unfortunately, it wasn't able to render my Excellon drill file (what I send to OSHPark), and it doesn't display an overlay view of all the layers at once. This latter feature is required if you want to check for alignment and overlap which I do. In short, it's just not useful enough compared to the alternatives.

Note that the review was performed on my 3.4GHz quad core, AMD Phenom II X4 965 on a Gigabyte GA-78LMT-S2P motherboard with built-in GPU. Mint 14 is my installed OS.