Display on TV/VGA monitor

I remember writing as a kid in the mid ’70s to an electronics magazine well-known in Italy, Nuova Elettronica, asking them to publish the project of a device to display music on a TV like on an oscilloscope. They did not reply but eventually they published the project. I’m not sure I’m the one who actually sprung them into designing the circuit but I was nonetheless compelled to build the circuit which of course worked great as expected. In my idea the line would have been horizontal but vertical appeared to be the most natural after reading the article.
The circuit was a clever mixture of triangular wave generators, comparators, monostables and flip-flops plus an RF generator to feed the TV’s antenna input.
Now that circuit is lost and the magazine gone into recycled paper but it remains one of my preferred.

It is now possible to replicate the circuit using a few components. Also, it is now well clear that a regular microcontroller like a PIC or an AVR provide the necessary speed and peripherals to do the job.

The circuit is very simple as this was my main target. I decided I would use one of the smallest AVRs I had, an ATtiny84. Physically small but large in memory : 8k FLASH is way larger than needed as my circuit fits 1/32th of that much. Anyways, just one 20MHz crystal, 5 capacitors, 4 resistors and one VGA connector are sufficient to generate a vertical line on a VGA monitor which swings left to right depending on the voltage at a micro’s input pin. Applying music at the pin the line dances at the music. A little bit kitschy ’70s prop.

This is a picture of the output without any input : a well steady line is displayed, not bad for software timing.

Vertical line without any audio input

I chose to go on a VGA instead of a regular TV because it is a single standard all over the world (no 60Hz vs 50Hz issue) and it is not interlaced (like TVs) which would have added another layer of difficulty.

This is the circuit. It is not mounted on a PCB : read further.

The circuit

The code is entirely in assembler and interrupt driven.

Assembler source code and HEX files are here

Horizontal synchronism is generated by the internal PWM generator at Timer 1. Horizontal Synch is also used as the timebase for Vertical Synchronization. Also, the input voltage coming from the audio input is read by channel 0 of the internal ADC at the beginning of every line, then a new conversion is started over to give the ADC the time of a full Horizontal line to make a new conversion.
Resolution required is low and as few as 7 bits are sufficient to span the monitor horizontally. The overall effect is just fine anyways.

The only tricky part is the interrupt routine called at the start of every horizontal line :
In case it is the last (628th line at 800×600, 60Hz) line, a Vertical sync pulse is started with the aid of a counter. The pulse is stopped after a 4 lines’ duration has passed. This is the Vertical sync pulse wich causes the vertical retrace and during this period no out should be put on the RGB (colour) outputs (the reti instruction).
In case it is not the vertcal sync occurrence, the ADC input value is converted into a delay after that output at the RGB (Red only, actually) is set to VCC for one single instruction cycle. This time is the smallest possible yet a well visible red spot is displayed on the screen.

The schematic is herebelow. Download it in higher resolution clicking on the image to go to Flickr, then select ‘all sizes’.

The input at the ADC must be 0-5Vcc so it is offset at 2.5V with a resistive network. A capacitor cancels the DC component at the input so that audio is converted to an AC offset which adds/subtracts from the 2.5Vcc DC offset.

In case input level is not sufficient I added a simple op-amp preamp suitable for 5V operation. The requirements called for a rail-to-rail op amp that could be powered from as low as 5v and provide an output of 0/5V. Also it had to be powered from one single supply rail. National Semiconductors LMC6462 was my choice. Other components are fine as long as they meet the three requirements above.
The preamp is designed to be driven by an electret microphone of the kind used in cell phones. In case a regular external source like a magnetic microphone or CD player can be connected at the positive lead of C1 and ground. R2 should be removed also.
A filter can be added placing a .1uF to 1uF capacitor in parallel to R5.

I mounted the two circuits on regular perfboard but wanted to add some finesse, so I glued some black and red cardboard on the perfboard (component side, of course!) to hide the holes and just opened the ones I needed with a needle. Next time I’ll print these paper mask adding components references, some logo and legend at the connectors and variable resistor.

This is the circuit completed with the pre amp. Power supply comes from a 5Vcc wall adapter.

Display music on a VGA monitor like on an oscilloscope

Finally a video of the thing in action.

As usual I take the videos with my Olympus camera, probably not the best mean.

The sources I used to understand are endless, probably too many and not always in agreement to each another: probably they all are right as there’s room for tolerance in timing.
I want to mention the most important: Alberto Ricci Bitti whose articles helped to shed some light on VGA with his award winning video projects (www.riccibitti.com), Daniel Ciocea for the same reason (check his VGA monitor tester at http://www.eosystems.ro/deogen/deogen_en.html) and the infinite list of PIC pongs .
Also the reference pages on VGA at http://www.epanorama.net/ was chosen as the standard since same resolutions happen to be given different different parameters on different internet sources.

I developed this infrared remote control decoder for Arduino on my Arduino-compatible STK500 evaluation board for Atmel’s AVRs.

The sketch is pretty much standard C code so porting to non-arduino dev systems is almost immediate.

Remote control receiver / decoder for Arduino

I actually developed the code in C for a smaller ATtiny24 for a specific project underway thenI adapted it for Arduino and made available to anyone whom might need it.

The sketch expects the IR receiver on digital pin 8 and is in the form of a demo where 4 LEDs on digital output 4, 5, 6 and 7 are turned ON on my STK500 (microprocessor’s output connected to LEDs’ cathodes) when keys 1 2 3 and 4 are received from the remote. The power button on the remote turns all LEDs OFF.

The code also ouputs the received code to the serial port to be read on the serial console (9600 Baud-8-N-1) .

Any RC5 Philips TV remote control seems to be fine and the few programmable ones I tried work fine. Feedbacks are welcome.

…yes, one day I`m buying a real Arduino !

The sketch for Arduino is here.

IMPORTANT : should you experience problems with random resets, read Mark Arduino’s comment on Jan 24, 2010 at 1:06 pm.

Enjoy.

Updated 25 April 2009

With this notes I’ll show how I configured an Atmel STK500 as an Arduino-based development system.
I used the STK500 instead of a real Arduino PCB because I already had it and the board carries 8 switches, 8 LEDs and a variable, software programmable AREF voltage as well as a variable power supply. Great things to experiment with on a single board.

What follows applies to the STK500 evb equipped with an ATMega168. Please note I made my best to be as accurate as possible, some errors may be present though. Should you find some, please let me know.
AVR Studio 4.14 build 589 is used in the following; newer versions should be hopefully upward compatible.

Things needed :

One Atmel STK500 Evaluation Board with power supply
One Atmel ATMega168
One 16MHz crystal
One serial cable
One PC with AVR Studio 4 and one serial port
The Arduino software development system and the bootloader file for the ATMega168.

In case the PC doesn’t have a serial port but just USBs, a USB to serial adapter is necessary to interface the STK500 to the PC. I haven’t tried but it should work.

RS232 is needed in first instance to interface the STK500 evaluation board with the PC.

First the STK500 was wired and the jumper set as shown in the picture below.Click the picture for a larger version.

The ATMega168 must be on board, any other CPU must be removed.

The ATMega168 must be placed in the green 28pin socket and the 16MHz crystal into the socket as shown. The PC must be connected to the STK500 serial programmin port, the one labelled “RS232 CTRL” on the PCB. Take note what port of the PC you are using (say COM1 or COM2).

Launch AVR Studio and turn on the STK500.

From AVR Studio select “connect” (the “IC” icon below the menus) and select “STK500″ as platform and “COM1″ or “COM2″ ( the one connected before ) as port.

Press “connect” and the following should come up, the “main” tab :

m

Select ATmega168 for “device and signature bytes” then press the “Read Signature” button and check that the platform recognizes the device (the “Signature matches selected device” label is what you want to see ).

Press the “Erase device” button.

Next, press the “program” tab to display the following:

Check the “Erase device before FLASH programming” and “Verify device after programming”.

Now select the “…” button to the right of the “input HEX file” field and browse to the directory “\arduino-0012\hardware\bootloaders\atmega168″ starting from the place where you exploded the Arduino zip file you downloaded and select the ATmegaBOOT_168_ng.HEX file. Otherwise browse to where you saved the bootloader downloaded from arduino.cc

Press the “Program” button : after a few seconds the bootloader will be FLASHed into the micro and verified automatically. The bottom part of the window shall give some promising “OK !”s

Now click on the “Fuses” tab. Make it look like the following picture: make sure to un-check CKDIV8 and to select the “Ext Crystal Osc. 8.0 – MHz…”.

Changes are reflected in the “EXTENDED”, “HIGH” and “LOW” registers at the bottom: make sure they are the same as below.

Press “Program”.

m

Now, with the “lock bits” tab, the bootloader must be protected from overwriting :

m

The “BLB1″ must be changed to what is above and the “LOCKBIT” register should finally be 0xCF as above, press “Program”.

Now you’re done: you can remove the 6-pin ribbon cable necessary to program the micro and move the serial cable to the other serial port connector of the STK500 (the one marked “RS232 SPARE” on the PCB), make sure you leave connected the PD0 and PD1 to RXD and TXD because these pins make the serial port of Arduino !

Now you have and STK500 running Arduino with the added advantage of pushbuttons and LEDs on board plus variable power supply (useful when working with 3.3V external sensors) and variable Analog Reference (AREF).
The AREF short pin must be inserted when the on-board voltage reference is to be used. Remove the short otherwise. The Analog Reference Voltage can be controlled with the “Connect” dialog box. Target Supply voltage can be controlled there also.
The connections of teh ATMega168 are available at connectors J700 & J701 of the STK500.

The pinout is shown below along with the equivalent name to Arduino’s.

Again, the “spare serial port” of the STK500 is the one used to download sketches on the STK500-Arduino: remember to move the serial cable to this port to connect your PC to your Arduino !

The Reset button on the STK500 is now the reset button of the STK500-Arduino: it must be pressed to download sketches on the board as you would with a regular Arduino.

Connecting PB5 to an LED of the ones on the board gives a visual monitor where the LED blinks right after reset to show it is waiting for the code on the serial port.

Update : there’s a bug in AVR studio 4.16 which prevents bootloader from being written correctly into the micro, see comment below from avirdi.

Have fun and write for questions and comments.

Alessandro

STK500 as Arduino : J700 and J701 pinout Vs Arduino pinout