avrBridge
- Introduction
- Hardware
- Firmware
- Host-Driver
- Use-Cases
- Demo Applications
- openAMI
- Documentation
- Downloads
- Source-Code
Introduction
the avrBridge bridges an avr microcontroller’s hardware registers to a host pc, so the host can access them just like they were part of itself or in other words, it adds a set of general purpose I/O pins as well as ADCs and DACs to your PC, Notebook, Server or Router and makes them accessible via an easy to use API.
To demonstrate what this actually means, here’s a quick example, that would flash a led at PORTB, PIN0.
// configure PORTB, PIN0 as an output pin
setPortPinDir(PORTB,PIN0,OUT);while(1) {
// set led on
setPortPin(PORTB,PIN0,HIGH);
// sleep a while
sleep(500);
// set led off
setPortPin(PORTB,PIN0,LOW);
// sleep again
sleep(500);
}
this code uses the avrBridgeC API and could be written in c as well as in java.
Hardware
the hardware requirements are minimal, usb is done in software using obde’s V-USB and since that, all you actually need is an atmel atmega8, a usb-port, 4resistors and a resonator, you can find schematics for simple dev-board here , at metalab.at or at obdev.at .Currently there is only one supported mcu, the atmel atmega8.
Firmware
The firmware is based on obdev’s V-USB, which implements USB completely in software.
Right now only usb control-messages are transferred, to improve performance bulk messages will be used in a future release.
Host-Driver
to access the hardware from the host side, there are several possibilities, currently there is:
- avrBridgeC – a c-library which relies on libusb
- avrBridgeJNA – a java-wrapper for the c-library
- avrBridgeKMOD – a x86-linux- kernel 2.6 driver
- avrBridgeC_openWRT – the c-library for use with openWRT-based embedded systems
- avrBridgeKMOD_openWRT – linux- kernel 2.4/2.6 driver for use with openWRT-based embedded-systems
following features are currently supported:
- read/write all PORTs and PINs
- read from ADC on all channels
- write to DAC on all PWM channels
following features will be supported:
- configure timers
- use i2c, usart and spi bus
Use cases
here are some potential use cases for the avrBridge:
- rapid prototyping: because the software runs on the host, no firmware flashing is required anymore.
- debugging: the fact that common registers can be read, displayed and analyzed from the host at any time, makes debugging more comfortable
- Human Interface Devices: because of the usb connection, and the easy to use host side API, the weirdest hid devices can be implemented in no time!
- Datalogging: collecting and analyzing live sensor-data is as simple as the led example above.
- Hardware Hacks:Hacking new features into Toys and Consumer Electronics can be done with minimal programming efforts.
- Extending Embedded Devices:
the avrBridge now supports OpenWRT embedded devices running Linux Kernel 2.4 and 2.6
Demo Applications
Datalogging
- zero-signal detector
a little tool I built for a radio-station I work for, its basically the dev-board from above with two audio-jacks connected to two adcs.The host software polls the adcs and decides what to do in case there is so signal going out of the station.
HID
- footswitch
I’ve simply placed two piezos on the floor beneath my desk so I can use them as footswitches to trigger shortcuts or mouse-events.
Hardware Hacks
- Remote Remote Power Switch
I’ve managed to connect a cheap hx2262-based remote controled power outlet to an openWRT-based router using the avrBridge.

News:
openAMI
The avrBridge is now part of the openAMI project. All sources and schematics are available via google code, see below.
https://code.google.com/p/openami/
Demo
This is a short preview showing the openAMI AJAX-Remote, Light control and sensing is done by using an avrBridge connected to a ASUS wl500 gp V2 wireless router.
Source Code
hg clone https://avrbridge.openami.googlecode.com/hg/ openami-avrbridge
Downloads
In addition to the source-code repository, schematics and sources are also available for download here.
Documentation
The Documentation isn’t nearly complete, but build instructions and some samples can already be found here.










I’m trying to compile the firmware to atmega48 and I get this errors:
====================================
main.c: In function ‘timer2_init’:
main.c:104: error: ‘TCCR2’ undeclared (first use in this function)
main.c:104: error: (Each undeclared identifier is reported only once
main.c:104: error: for each function it appears in.)
main.c:105: error: ‘COM21’ undeclared (first use in this function)
main.c:105: error: ‘COM20’ undeclared (first use in this function)
main.c:107: error: ‘OCR2’ undeclared (first use in this function)
main.c: In function ‘setDac’:
main.c:156: error: ‘OCR2’ undeclared (first use in this function)
main.c: In function ‘main’:
main.c:349: error: ‘TCCR0’ undeclared (first use in this function)
main.c:354: error: ‘TIFR’ undeclared (first use in this function)
make: *** [main.o] Error 1
=================================
Anybody can help me?
Thank you.
hey vraptor,
i’ve never used the m48, but i’ve just looked up the datasheet, the registers that refer to the timer configurations are different from the m8 i’m using.
I’d suggest you just adept them to your mcu. For a quick and dirty fix, you could comment out the timer related code segments, but this would also break DAC on the pwn pins.
Let me know if it worked, would be great to see some more devices support the avrBridge.