A simple beacon keyer for the ATtiny13

February 18, 2012 | Arduino | By: Mark VandeWettering

Roger, G3XBM built a simple beacon for light communication using a K1EL beacon keyer chip and a handful of other components. I didn’t have any of those chips around, but I did have some Atmel ATtiny13s lying around. I hacked this simple program together to send Morse code in two different ways: on pin PB1 (pin six) there is a simple on/off keying signal. On pin PB0 (pin five) there is the same signal, modulated with an 800 hz signal. Roger used a similar output to send a modulated version of his call. I hardcoded this program to transmit slow Morse with three second dits (QRSS3). I loaded this onto an ATtiny13 tonight, and hooked a small white led the PWM output pin through a current limiting resistor. Using a primitive receiver I built before, a solar cell hooked into a Radio Shack powered speaker, I tested it out, and it seemed to work rather well: the 800hz tone was clear and audible. I’ll be playing with this some more, but for now, here’s the code:

[sourcecode lang=”cpp”]
/*
* beaker.c
*
* A simple beacon beeper for the ATtiny13
*/

// #define F_CPU 1200000UL
#define F_CPU 9600000UL

#include <inttypes.h>
#include <avr/io.h>
#include <avr/sleep.h>
#include <util/delay.h>

#define FREQ (800)
#define DIT_MS (3000)

#define OUTPUT PB0 /* 800 Hz PWM signal, OC0A */
#define KEY PB1 /* Just a keying output */
#define SWITCH PB4 /* a switch between 12 WPM and QRSS3 */

void
dit()
{
/* on */
TCCR0A |= _BV(COM0A0) ; /* enable OC0A */
PORTB |= _BV(KEY) ;
_delay_ms(DIT_MS) ;

/* off */
TCCR0A &= ~_BV(COM0A0) ; /* disable… */
PORTB &= ~_BV(KEY) ;
_delay_ms(DIT_MS) ;
}

void
dah()
{
/* on */
TCCR0A |= _BV(COM0A0) ;
PORTB |= _BV(KEY) ;
_delay_ms(3*DIT_MS) ;

/* off */
TCCR0A &= ~_BV(COM0A0) ;
PORTB &= ~_BV(KEY) ;
_delay_ms(DIT_MS) ;
}

void
space()
{
_delay_ms(2*DIT_MS) ;
}

void
ioinit()
{
DDRB = _BV(KEY) | _BV(OUTPUT) | _BV(SWITCH) ;
PORTB &= ~_BV(OUTPUT) ;

TCCR0A = _BV(COM0A0) | _BV(WGM01) ;
TCCR0B = _BV(CS01) | _BV(CS00) ;
OCR0A = 93 ;
}

int
main(void)
{
ioinit() ;

for (;;) {
dah() ; dit() ; dah() ; space() ;
dah() ; dit() ; dit() ; dit() ; dit() ; space() ;
dit() ; dit() ; dit() ; dit() ; space() ;
dah() ; dit() ; dit() ; dah() ; space() ;
space() ; space() ;
}

return 0 ;
}
[/sourcecode]

Spray-on Antennas? I say “Spray-on Bunkum”

February 17, 2012 | Amateur Radio, electronics, Rants and Raves | By: Mark VandeWettering

Thanks to John, who pointed out that this post was mangled. Fixed now.

I wasn’t going to mention this one, but Dave, Chris and Jeff over at The Amp Hour brought it up on their most recent podcast, but other than Jeff’s somewhat enthusiastic declaration that he thought it was BS, I don’t think they pulled it apart enough.

The topic is a recent video poasted under the auspices of Google’s new Solve for X program. Try watching it:



If you try googling for “spray on antennas”, you’ll find dozens and dozens of links to this video, or what amounts to a copied press release regarding this video. If you dig a little deeper, you’ll find lots of people complaining about how poor the presentation was. What is somewhat harder to find is any kind of a critical evaluation of the information (what little there is) on this antenna scheme. I’ll try to confine my comments to the latter.

It’s begins with a pitch, and not a modest one. We are told to imagine that we can send signals twice as far using no more power. Or the same distance with half the power. Or that we can get rid of cell towers. Or communicate from the depths of the ocean to outer space. And the key is some kind of nanotechnology. that Chamtech has developed for “spray on antennas”.

Following this pitch is a story: a story how “a business partner” who asked him develop a hidden antenna for Special Operations. He was then asked by “the government” to try his antenna technology, which was then tested by “a government team”, who found that this spray on antenna was “an order of magnitude better” than their best antenna.

I’m sorry, but that’s just bunk. Good antennas are efficient. A given antenna has a particular radiation resistance. For instance, a typical dipole antenna such as the antennas that many radio amateurs use might have a radiation resistance of around 70 ohms or so. But, of course, there are other bits of resistance in the antenna too. There is the ohmic resistance of the antenna, so-called “ground losses”, and “coil losses”. The antenna efficiency is just the ratio between the radiation resistance and the total resistance of the antenna.

But here’s the thing: at VHF+ frequencies, it’s just not that hard to make antennas with efficiencies that are 90% or higher. And that means that there is no “head room” to make an antenna which is “an order of magnitude more efficient”. It’s just basic math. You can’t get more energy out of an antenna than you put in, and existing antenna designs are already enormously efficient at radiating what you put in.

Beyond that, the geometry of antennas is important. You can’t generate an efficient one by just stringing a random conductor (or spraying one) higglety piggly all over the place. The length of the various elements change the feedpoint impedance and that must be matched carefully to the transmitter output impedance in order to be efficient. The idea that these nanocapacitors can “hold” electrons and then release them at their “happy place” is enough to make milk shoot out of my nose.

The “test” on the iPhone was comical: inside an Faraday cage (originally he said anechoic chamber, which I thought was an odd mistake for an RF engineer to make) he claimed that their technology improved the output power of the iPhone by “20 dBm”. I’m sorry, but I cry BS on this as well: dBm is the power ratio referenced to a 1mw signal. It doesn’t make any sense to say that there is a 20dBm improvement. An improvement of 20dB is a hundred fold increase in output power. Just where is this power supposed to be coming from? A typical cell phone has an output power of around 27dBm, or around 500mw. A 20dB improvement would raise that to 47dBm, which is about 50 watts. Bunkum.

Honestly Google, I know you have some pretty smart guys who know about RF: why did you let this guy use your forum to sell this complete nonsense? It doesn’t bode well for Solve For X if it can’t distinguish between “radical solutions” and “snake oil”.

More on ATtiny programming…

February 15, 2012 | Arduino, electronics | By: Mark VandeWettering

Last night’s hacking adventure was inspired by a couple of recent posts from Roger, G3XBM having to do with light based communication. The first was his simple beacon design: it’s just a keyer chip, a MOSFET, a voltage regulator, and some (beefy) current limiting resistors. Roger used this beacon to do some non-line-of-sight communications via “cloudbounce”.

It’s inspiring, so I’ve been thinking about trying some similar experiments. As it would happen, I have some reasonably high power LEDs floating around, and rigging up the transmitter really wouldn’t be too hard. I don’t have any of the K1EL chips that he used, but I do have a few of the Atmel ATtiny13s floating around, so I figured I’d go ahead and write up a simple beacon program to send my call via QRSS3 and (if a switch is tossed) 12wpm Morse. After my ATtiny powered Halloween Pumpkin and my ATtiny13 powered Christmas hat, I figured it would be a snap. I fetched an Arduino, programmed it with the AVRISP sketch, and then went to wire up the Arduino to program the code (did I mention I wrote some code?) to an ATtiny13 which I stuck on a breadboard.

And that’s when I realized that I didn’t take very good notes about how I did it last time, and refinding the necessary connections and commands was both difficult and some sources didn’t even have the information correct.

So I’ll remember, here’s the list of connections you need:

  • ATtiny pin 4 goes to ground.
  • ATtiny pin 8 goes to 5V.
  • ATtiny pin 1 goes to Arduino pin 10.
  • ATtiny pin 5 goes to Arduino pin 11.
  • ATtiny pin 6 goes to Arduino pin 12.
  • ATtiny pin 7 goes to Arduino pin 13.
  • Many sources say that for Unos, you must put a 10uF cap between the RESET and GROUND on the Arduino. I had one, so I did it. I’ve used older Arduinos (such as the NG) which have different reset circuits (you must manually reset them to program them) and for those it isn’t necessary. Your mileage may vary.

Lastly, you need the right avrdude command. It took me an embarrassingly long time to come up with the right command, mostly because it appears that I needed to manually set the baud rate to 19200 (what the AVRisp sketch expects). Archived for posterity:


avrdude -v -c avrisp -p t13 -P /dev/tty.usbserial-A800eKtX -b 19200 -U flash:w:beaker.hex

I discovered a couple of things: while the previous versions of the ATtiny I used seemed to have fuses set so that the internal oscillator (nominally 9.6Mhz) would be divided by 8, this one did not. I sorted this out by defining F_CPU appropriately, but it was late and I didn’t get my PWM code (which generates the 800hz sidetone) working properly. Tonight, I’ll dust it off and hook it to the scope and see what’s going on.

When this is done, it should be fairly simple to get the rest of the prototype transmitter together. Roger used a 4″ or so lens as the collimating optic for his transmitter. As it happens, I have a dusty 6″ Newtonian telescope that I purchased for a pittance, whose mirror really isn’t up to the kind of standards I appreciate. I think I can mount a high power LED into a 35mm film can and insert that into the telescope eyepiece, and it should make an excellent collimator (I may need an auxillary lens if the cone from my LED is too broad, I think the telescope is around f/5 or so). Perhaps by this weekend, I’ll have the transmitter setup, and I can start working on the (much harder) receiver.

Hope this article saves someone some time. I know I’ll be referring back to it in the future.

Web-based control of an RGB LED via the Nanode, an Arduino compatible microcontroller

February 12, 2012 | Arduino, electronics | By: Mark VandeWettering

Okay, I finally got some time to record a video about a simple little webserver project I hacked together earlier this week. My wife Carmen got me a Nanode kit from Wicked Device around Christmas. These are Arduino compatible development boards which include a Microchip ENC28J60 Ethernet device to enable web connectivity. One slight drawback is that they are not compatible with the Ethernet shields which are based upon the Wiznet 5100 chipsets, so you’ll need different drivers and different code. I’ve been experimenting with the Jeelabs EtherCard drivers, which seem to work well and are well supported, although they are limited in their TCP implementation (it limits TCP responses to just a single TCP/IP packet). Nevertheless, I implemented a simple webserver to control the I/O pins of the Nanode, based upon the ideas (but not the code) of Jason Gullickson’s RESTduino. I then did a short demo of how you could use it to control a strip of RGB LEDs from a simple jQuery based interface. Watch:



Here’s the sketch. Feel free to swipe it and any ideas for any web enabled projects you need (nothing here is worth copyrighting or licensing at all, consider it public domain).

[sourcecode lang=”cpp”]
#include <EtherCard.h>
#include <NanodeUNIO.h>

//
// remote by Mark VandeWettering
//
// a reimplementation of the "RESTduino" idea, first published at:
// http://jasongullickson.posterous.com/restduino-arduino-hacking-for-the-rest-of-us
//
// I decided to rewrite this application because:
// 1. originally, it was written for the Wiznet based Ethernet Shield, but I have
// mostly Nanodes, based upon the ENC28J60
// 2. It was ported to the Ethershield library by Andrew Lindsay, but Andy has decided
// that he’s decided not to continue development of that library, deferring to the
// EtherCard library being developed by JeeLabs
// 3. I thought there was a lot of cool additions that could be made! Okay, I haven’t
// implemented any at the moment, but I will!
//

#define DEBUG 1
#define BUFFER_SIZE (900)

byte Ethernet::buffer[BUFFER_SIZE] ;
BufferFiller bfill;

char okHeader[] PROGMEM =
"HTTP/1.0 200 OK\r\n"
"Content-Type: text/html\r\n"
"Pragma: no-cache\r\n"
"\r\n" ;

char responseHeader[] PROGMEM =
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html\r\n"
"Access-Control-Allow-Origin: *\r\n"
"\r\n" ;

void
homepage(BufferFiller& buf)
{
buf.emit_p(PSTR(
"$F"
"<html>"
"<head>"
"<title>webserver remote</title>"
"<style type=\"text/css\">"
"body { width: 640px ; }"
"</style>"
"</head>"
"<body>"
"<h1>webserver remote</h1>"
"<p>"
"This webserver is running on a <a href=\"http://nanode.eu\">Nanode</a>, an "
"Arduino-compatible microcontroller with web connectivity. It uses the <a"
"href=\"https://github.com/jcw/ethercard\">EtherCard library</a> written by "
"<a href=\"http://jeelabs.net/projects/cafe/wiki/EtherCard\">JeeLabs</a>. "
"Inspired by Jason Gullickson’s <a href=\"http://www.youtube.com/watch?v=X-s2se-34-g\">RESTduino</a>."
"</p>"
"<hr/>"
"<p style=\"text-align: right;\">Written by Mark VandeWettering</p>"
"</body>"
"</html>"
), okHeader) ;
}

#define CODE_ERROR (-1)
#define CODE_WRITE (0)
#define CODE_READ (1)
#define CODE_ANALOG_WRITE (2)
#define CODE_INDEX (3)

int
cmdparse(const char *cmd, int &pin, int &val)
{
const char *cp = cmd+4 ;

if (*cp++ == ‘/’) {
if (*cp == ‘ ‘) {
return CODE_INDEX ;
} else if (isdigit(*cp)) {
pin = atoi(cp) ;
while (isdigit(*cp)) cp++ ;
if (*cp == ‘ ‘) {
return CODE_READ ;
} else if (*cp == ‘/’) {
cp++ ;
if (isdigit(*cp)) {
val = atoi(cp) ;
while (isdigit(*cp)) cp++ ;
if (*cp == ‘ ‘)
return CODE_ANALOG_WRITE ;
else
return CODE_ERROR ;
} else if (strncmp(cp, "HIGH", 4) == 0) {
cp += 4 ;
if (*cp == ‘ ‘) {
val = 1 ;
return CODE_WRITE ;
} else
return CODE_ERROR ;
} else if (strncmp(cp, "LOW", 3) == 0) {
cp += 3 ;
if (*cp == ‘ ‘) {
val = 0 ;
return CODE_WRITE ;
} else
return CODE_ERROR ;
}
} else
return CODE_ERROR ;
} else {
return CODE_ERROR ;
}
} else {
return CODE_ERROR ;
}
}

void
setup()
{
byte mac[6] ;

Serial.begin(9600) ;
Serial.println("\nbrainwagon remote webserver\n") ;

NanodeUNIO unio(NANODE_MAC_DEVICE) ;
unio.read(mac, NANODE_MAC_ADDRESS, 6) ;

if (ether.begin(sizeof Ethernet::buffer, mac) == 0) {
Serial.println("Failed to access Ethernet controller.") ;
for (;;) ;
}

if (ether.dhcpSetup()) {
ether.printIp("IP: ", ether.myip) ;
ether.printIp("GW: ", ether.gwip) ;
ether.printIp("DNS: ", ether.dnsip) ;
} else {
Serial.println("DHCP failed.\n") ;
for (;;) ;
}
}

void
loop()
{
word len = ether.packetReceive() ;
word pos = ether.packetLoop(len) ;
int pin, val ;

if (pos) {
bfill = ether.tcpOffset() ;
char *data = (char *) Ethernet::buffer + pos ;
Serial.println(data) ;
switch (cmdparse(data, pin, val)) {
case CODE_READ:
pinMode(pin, INPUT) ;
bfill.emit_p(PSTR(
"$F"
"{\"$D\" : \"$S\"}"),
responseHeader,
pin, val ? "HIGH" : "LOW") ;
break ;
case CODE_WRITE:
pinMode(pin, OUTPUT) ;
digitalWrite(pin, val ? HIGH : LOW) ;
bfill.emit_p(PSTR(
"$F"), responseHeader) ;
break ;
case CODE_ANALOG_WRITE:
pinMode(pin, OUTPUT) ;
analogWrite(pin, val) ;
bfill.emit_p(PSTR(
"$F"), responseHeader) ;
break ;
case CODE_INDEX:
homepage(bfill) ;
break ;
case CODE_ERROR:
default:
bfill.emit_p(PSTR(
"HTTP/1.0 404 Not Found\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<html><body><h1>404 Not Found</h1></body></html>")) ;
break ;
}
ether.httpServerReply(bfill.position()) ;
}
}
[/sourcecode]

Boring statistics re: brainwagon

February 6, 2012 | Blogging | By: Mark VandeWettering

Okay, today is February 6, which means that my revolvermap that you can see over in the left margin has been up one entire year. Right now, it’s showing 148,950 visits since it’s inception. I suspect a couple of thousand of those are actually me, but I’m pretty happy that so many people stumble their way to my blog in that time. Over that same time period, Google Analytics reports 126,340 visits, 96,891 unique visitors, and 387,172 page views. The traffic to my blog has been pretty constant: around 300 views per day, with five or six blips caused by links from hackaday or Reddit. About one in four visitors are returning: the rest are new visitors. That seems pretty cool to me: reaching nearly 100K people with something I wrote seems oddly empowering.

But here’s the reality check. My most popular post: Viewing a V4L webcam with mplayer: a little throw away post I did back in 2007, giving the options that allowed me to show video from a V4L webcam using mplayer. It accounts for a little under 2.5% of all the hits to my blog. Two postings on the Fuji Real 3D W1 camera sum to actually a greater percentage (right around 3%). My Downside of Arduino is about 1.41% of all hits, mostly courtesy of a brief mention and flurry of activity from Reddit. My Hellduino project and my Arduino n’ Gameduino Satellite Tracker came in virtually tied at 1.16% and 1.15%, respectively.

What am I to make of all this? Well, I’m not quitting my day job anytime soon. 🙂

Addendum: Tomorrow will be February 7, 2012. This marks the completion of twenty years of work at Pixar Animation Studios. To all those who I’ve worked with over the span of the last two decades, thanks for helping provide one of the most stimulating work environments I could imagine, and for letting me play a small role in the history of animated films.

maniacbug is an Arduino wizard…

February 1, 2012 | Arduino | By: Mark VandeWettering

Ken Boak was nice enough to gift me with a pair of Nanodes when he was out visiting last month. Much to my embarrassment, I haven’t had much time to play with them, so tonight I tried to do a bit more research to figure out how I could use them in some more advanced projects. Previously I had found the Ethercard library which was developed by Jeelabs. It works okay for many things, but has a web server implementation which is too limited for many uses: all web pages must fit in a single TCP/IP packet. I was digging around trying to find a TCP/IP implementation that could handle larger ones. I knew about Adam Dunkel’s uIP stack for microcontrollers which has been ported to many microcontrollers, but the first link I found to an implementation on the Nanode didn’t seem to have any example web server code. But then I ran across this posting on maniacbug’s blog describing a complete webserver using uIP. He’s got his own github repository which seems to have a lot more complete examples fleshed out. I downloaded and tested the code, and it appears to work pretty well. I’ll be digging into it over the next few days, and perhaps making my own webserver application to run on the nanode.

He’s also got a huge number of other rather sophisticated postings on stuff he’s done with the Arduino. Check them all out, I know I will be too.

maniacbug | AVR Microcontroller Projects

Interesting “feature” re: _delay_ms in avr-libc

January 31, 2012 | Arduino, Atmel AVR, Microcontrollers | By: Mark VandeWettering

A couple of my projects have used the tiniest of the Atmel ATtiny chips: the ATtiny13. I have written one or two programs in assembler for these chips, but I prefer to work with avr-gcc whenever possible. What’s amazing is that you actually can use a sophisticated C compiler to generate code for such a tiny chip (only room for 512 instructions).

Yesterday’s project was to implement a small QRSS beacon controller, similar to one’s sold by Hans Summer as part of his QRSS kits. He actually published his code, so I could just use that, but I found it a little bit obscure, and thought I could do something, well, if not better, at least less obscure to me. I wanted to retain the basic interface (Hans’ chip provides a sidetone on one pin, a key on another, and uses three pins as an input to select one of eight speeds). The basic loop fetches a pattern of dots and dashes, looks up the speed from the input switches, and then sends the pattern of dots and dashes. Easy peasy. I’ve written similar Arduino code before. Toggle pin high, delay, toggle pin low, delay, out goes a dot or dash.

But when I tried to use the _delay_ms() macro, I found that the codesize I had used grew enormously. It appeared to be dragging in a bunch of floating point arithmetic routines. I had used this function on my Christmas tree hat project without incident: what was going on?

Well, first of all, it appears that _delay_ms takes a floating point value as an argument. The compiler is smart enough that if the value passed to the function is a constant, it unfolds the code into a simple integer only loop. But if you use a variable as the argument (as I do, since the dit times are varying in length) you end up dragging all the floating point baggage into your code. It seems ridiculous to use floating point in this situation.

I got around this by noting that in my case, all my delays were multiples of 100ms. So, instead of just calling _delay_ms(n*100), I implemented the delays as a simple loop which executes _delay_ms(100) multiple times. Code is small, all is well.

You would think that a small, integer only delay would be possible. Oh well.

ksim 8080 simulator released

January 31, 2012 | Emulation | By: Mark VandeWettering

Fellow hacker Eric Smith has released the code for an 8080 simulator. I spent a few hours hacking my own 8080 emulator a few months ago, and at least got it to run Tiny BASIC, but I was never quite successful in getting it to boot CP/M. Among some of the problems were that I wasn’t quite assured that I implemented all the opcodes properly. There are some programs which act as an “opcode exerciser”, and produce a series of checksums that you can use to detect bugs, but I found that even well known simulators like simh didn’t match the output from real 8080s. It appears that Eric has done the heavy lifting and figured this stuff out, and released the fruits of his labor as a GPL’ed reference implementation, checked against the actual running against an original Sol20. I’ll have to go back sometime and see where my own simulator has gone awry, but until then, thanks Eric!

ksim 8080 simulator released | What's All This Brouhaha?.

A $.33 MAX232CPE, or a $0.01 2N3904?

January 28, 2012 | Arduino, electronics | By: Mark VandeWettering

In response to my previous post, @xek replied:

https://twitter.com/#!/xek/status/163442298456260608

Well, the fact is I had heard of doing that. It’s not really hard to rig something that will convert the RS232 level from the GPS into TTL levels for the Arduino. It just takes a single transistor inverter: you rig an 10K resistor from the RS232 signal to the base, a 1K resistor from 5v to the collector, and then ground the emitter. Tap the transistor on the emitter side, and voila! It works. I rigged this up on the breadboard and checked it on the scope, and sure enough: 5v and 0v. I then coded up a simple sketch which used the SoftwareSerial library: it instantiates a serial port, then copies bytes when available to the normal Serial output device. Once I remembered that my GPS output at 4800 baud, the program worked flawlessly.

After I got this working, I gave the other direction a tiny amount of thought. I couldn’t think of a good, simple way to convert the TTL level to the negative levels without using some kind of charge pump, or a negative supply. But there is a cute trick you can use, that I discovered while surfing for alternative circuits: check it out. The trick is that if you are operating half duplex (only one side of the transmission transmits at the same time), the transmit line will go to the negative state. So, if you need to output a negative value, you simply swipe the voltage from Tx side of the RS232 line. That just takes a PNP transistor. Very cute.

Addendum: the receive circuit looks the same as mine, except they add a diode. Novice that I am, I don’t get why it is necessary or desirable. My circuit seems to work fine without it: can someone with experience tell me why it’s a good idea?

Addendum2: The MAX232s aren’t wasted: I am using it as an opportunity to learn Eagle and design a simple but still useful PCB. I’ll still be working on that.

Tinkering with an old GPS receiver…

January 28, 2012 | Amateur Radio, Arduino | By: Mark VandeWettering

I used to be an electrical engineer like you, then I took an arrow in the knee.

(If you don’t get this, google for “arrow in the knee”, and guess what Xbox game I spent the morning and afternoon playing instead of working on something cool.)

I’ve had a number of projects that could benefit from adding a GPS to an Arduino. I’ve got a few old GPSes lying around: in addition to the normal handheld and car windshield Garmin models, I have an old Garmin 18 and an ADS-GM1 from Argent Data Systems. They are the guys that make the Open Tracker (have one of those kicking around somewhere too). It’s a pretty respectable little GPS, and since I wasn’t using it for anything else, I thought it would be great to hook one up.

Except, well, it doesn’t use TTL signal levels for it’s serial connection. I double checked it by hooking it up to my scope, and have a peek:

Yep, -6v to 6v will not do. So, a few days ago, I ordered some Maxim MAX232CPE drivers from Tayda Electronics (great price, only $.33 each). I also intended to order some PCB mount DB-9 connectors that would mate with these, and do a small PCB that could be plugged into a breadboard, and then the DB-9 on the ADS-GM1 wouldn’t need to be modified. But sadly, I ordered the wrong part, and so that project is a teensy bit on the back burner. But pretty soon, I’ll get that all sorted out and a number of my Arduino projects will be able to benefit from accurate position and time.

AVR-based FM-transmitter

January 26, 2012 | Atmel AVR, Microcontrollers | By: Mark VandeWettering

This is a very cute hack that does something which I thought was impossible: an implementation of an FM transmitter that has exactly two components: a battery and an ATtiny45 microcontroller. It’s brilliantly obtuse and cool:



Sprites mods – AVR-based FM-transmitter – Intro, theory

The basic idea is to trick the internal oscillator of the Atmel to run at 24Mhz. An internal PLL will run at 4x that frequency, which is a 96 Mhz signal (right in the middle of the FM broadcast band). By varying the frequency up and down, you can generate an FM modulated signal. Beyond clever. Very cool.

Unequal Resistor R-2R Ladder Optimizer

January 26, 2012 | electronics | By: Mark VandeWettering

I was reading up on resistor ladder DAC circuits on Wikipedia, and came across the Unequal Resistor R-2R Ladder Optimizer. It’s very neat! You can enter the number of bits you need, and the values of the pile of resistors that you have measured from your bench, and it will produce an optimized design using those values. When you are making an 8 bit DAC, the normal variation in a 5% tolerance (or even a 1% tolerance) can cascade to keep you from being entirely linear, or even monotonic, so doing this optimization seems enormously practical. As a bonus, once you have your DAC simulated using the Falstad Circuit Simulator, which is itself an enormously cool thing: a Java based circuit simulator that can accept new models encoded on the URL! Paul Falstad has a huge number of other cool educational Java applets, check it out!

New 6502 processor at Mouser.com?

January 26, 2012 | electronics | By: Mark VandeWettering

Dave Jones (@eevblog) tweeted:
https://twitter.com/#!/eevblog/status/162530266513014784

And indeed, he’s right! WDC (the Western Design Center) has made a new version of the 6502 available at mouser.com. It’s a 40 pin DIP package, listed at $6.95 in quantity one, and can be clocked up to 14Mhz. It sends my mind racing back to the days of Star Raiders on my Atari 400. Not sure why it would be a good part to use other than nostalgia, but I’m bookmarking for future consideration.

W65C02S6TPG-14 Western Design Center (WDC) Microprocessors (MPU)

Creating source material for Narrow Band TV…

January 24, 2012 | Narrow Band Television | By: Mark VandeWettering

I’ve often thought that creating a replica of an early Baird mechanical television, or televisor would be a fun project. But when starting, you immediately run into the problem of how to generate material for them. The Narrow Band Television Association standard format specifies 32 line format at 12.5 frames per second (400 lines per second). It also specifies an aspect ratio of 2/3, which means that if we are using square pixels, we want to resize to an output resolution of just 32×48 (yes, images are taller than they are wide). I thought about using some old Coronet films like Are You Popular as appropriate source material, and worked to create an ffmpeg command (my goto Swiss Army knife of video conversion) and came up with the following command line to crop the existing video into the 4:3 video into a 2:3 video and resize it to 48×32:


ffmpeg -i AreYouPo1947.mpeg -vf 'scale=640:480,crop=320:480,scale=32:48' -r 12.5 -aspect 2:3 televisor.mp4

You can then play televisor.mp4 and see (in a very small window) what televisor video might look like. But how can we turn this into a sound file like we need to drive a televisor? Well, we need 400 lines per second. A CD’s natural format is 44100 Hz. That’s 110.25 samples per line (bummer, it doesn’t divide evenly). We could round it down to 110 or so (not bad) or we could generate our samples at 48000 hz instead of 44100 and use a high quality downsampler to generate the final audio. Either is acceptable. We can make life easy on ourselves by using ffmpeg to generate individual video frames with the the right number of vertical samples (either 110 for 44100 or 120 for 48000) and generate .pgm files (which are very nearly the raw 8 bit sample values we need):


ffmpeg -i AreYouPo1947.mpeg -vf 'scale=640:480,crop=320:480,scale=32:120' -r 12.5 -aspect 2:3 frame.%06d.pgm

With a little more work, I can transpose the files (so they are in column order as expected by the televisor) and then add the sync pulses we need. I’ll play around some more with this tonight, and then try it and verify my understanding using the NBTV viewer. Then, perhaps on to building a televisor.

High Frequency Precision Sine Wave Synthesis for the Arduino by Adrian Freed

January 23, 2012 | Arduino | By: Mark VandeWettering

While researching something completely different, I found Adrian Freed’s very cool page with code to generate high quality sine waves using PWM on the Arduino. This code could serve as an audio frequency signal generator, or as the basis of a computer music project. It also demonstrates some non-trivial Arduino wizardry in dealing with PWM interrupts and the like. Bookmarked for future reference!

Arduino sketch for high frequency precision sine wave tone sound synthesis | Adrian Freed: arduino, oscillator and open sound control expertise