A better, faster, stronger DAC: An R-2R Ladder!

This is amazing. In this video, he simultaneously explains the concept of making Thevenin equivalent circuits (handy!) and shows the (actually pretty simple) mathematics behind this circuit. This method basically allows you to trade many digital pins and many resistors for a single, excellent analog out. B-E-A-utiful.

Planning on using this on an FPGA for an absolutely stupid-ridiculous resolution analog stream. Why not? I’ve got 36 conductor ribbon cable and 108 matched resistors that would be better served as a 36-bit analog out.

That actually might bring me closer to implementing HDMI…naaahh.

nRF24L01+ Module Documentation



Arduino Library Download
Copy to ‘Libraries’ folder within your main Arduino folder.


MISO -> 12
MOSI -> 11
SCK -> 13


CE -> 8
CSN -> 7


byte cePin
CE Pin controls RX / TX, default 8.

byte csnPin
CSN Pin (Chip select not), default 7.

byte channel
RF Channel 0 – 127 or 0 – 84 in the US, default 0.

byte payload
Size in bytes, default 16, max 32.
Note: channel and payload must be the same for all nodes.


void init(void)
Initialize the module, set the pin modes for the configurable pins and initialize the SPI module.
Mirf.csnPin = 9;
Mirf.cePin = 7;
void setRADDR(byte *addr)
Set the receiving address. Addresses are 5 bytes long.
Mirf.setRADDR((byte *)"addr1");
void setTADDR(byte *addr)
Set the sending address.
Mirf.setTADDR((byte *)"addr1");
void config(void)
Set channel and payload width. Power up in RX mode and flush RX fifo.
Mirf.payload = 32;
Mirf.channel = 2;
bool dataReady(void)
Is there data ready to be received?.
//Get the data to play with.
void getData(byte *data)
Get the received data. 'data' should be an array of bytes Mirf.payload long.
byte data[Mirf.payload]
void send(byte *data)
Send data. 'data' should be Mirf.payload bytes long.
bool isSending(void)
Return true if still trying to send. If the chip is still in transmit mode then this method will return the chip to receive mode.
//Chip is now in receive mode.
NB: Lots more information is available from the status registers regarding acknowledgement or failure status. See Mirf.cpp:218.
bool rxFifoEmpty(void)
Is the RX Fifo Empty.
bool txFifoEmpty(void)
Is the TX Fifo Empty.
byte getStatus(void)
Return the status register.
void powerUpRx(void)
Power up chip and set to receive mode. Also clear sending interrupts.
void powerUpTx(void)
Power up tx mode.


See examples folder in zip file.
Arduino Library Download

MQ3 (or MQ303a) Alcohol Sensor Arduino Guide

This little device is wonderful, for parties at least. Accuracy wise, it’s not much more than a toy (without some opamps for signal amplification and filtering) but I digress. Just plugged right straight into an Arduino will be plenty of fun, assuming you read the datasheet.

To wire this properly, check out this diagram, which will get further explanation after the break.
Continue reading

Adafruit /Sparkfun Waterproof RGB LED Strip (60/m)

This this is beyond amazing. Only in real life can you appreciate it’s vibrancy and power to invoke emotion. It shall fulfill you. That money spent on electronics, that time burned grepping Ohm’s and Kirchoff’s laws; time well spent. Once you gaze upon the 16.7 MILLION colors available, as this relic leisurely strolls through them at whatever speed your Arduino/various MCU desires.

View at Sparkfun
View at Adafruit

Color Gallery and ‘How to set it up’ section after…
Continue reading

Programming a breadboard Arduino with Sparkfun’s FTDI Adapter

I required a programmer to program bare AVRs (ATtiny85s and ATtiny84s,) so, In my infinite spendthriftyness, I bought this FTDI breakout from Sparkfun. What is this? Well, I assumed it was an AVR programmer. I was incorrect. It can reprogram AVRs, however it cannot burn bootloaders or change fuse settings as is (the version from ladyada can, and with precious little modifications.) Being the same price, I made the wrong choice.

Anywho, here’s how you get it to work. I also ordered (fortunately) a ATmega328p from Sparkfun with the Optiboot Bootloader. So, essentially, it’s like they yanked the chip out of a new Arduino Uno. Not bad for $5.50. So we take this, plink it down on a breadboard like shown below, then get to wiring it up.

Don't worry, this will all be explained after the break.

One hell of a ratsnest. Don't worry, this will all be explained after the break.

Continue reading

IR remote control reverse engineering

If you’re anything like me, or the vast majority of Americans, you are surrounded by IR devices at home, at work, and pretty much everywhere you go. A great number of these devices (round 90%, its kind of the standard) use the 38 kHz SonyIR protocol, but knowing just that doesn’t help much. Especially if you lack a proper oscilloscope, like me. Plus, hell, your remote might be in that mysterious 10 percent. In order to figure out the actual encoding, you need to be able to plot the signals while you fiddle with the remote, and then make a chart relating the independent variable (the fiddling) to the depedent variable, the bursts of 0s and 1s that inevitably ensue.

IR pulses for various button presses on someone else's oscilloscope :-\ man browser up

Trandi has done precisely that, in his reverse engineering a remote controller from a toy chinook to operate his land based Rover and has devised an excellent technique for visualizing the data transmissions from the remote with just an attiny and a IR photodetector IC from radio$hack. Now if you, like me, find your local radio$hack overpriced and understocked, over on the arduino forums its been discovered the same resolution can be had with a plain IR phototransistor and optionally a cheap opamp like the lm741 (or also I hypothesize with a TL082 dual biFET (perhaps wired as a fourth order Butterworth high-pass?) and a IRled. Likely it’d work best reverse biased, reducing the slow response time typical of using an led as a photodiode, at the expense of increased noise. What’s the point? Never had one. And that just burns you up inside!) provided you modify your timings a bit.

A remote much like this one was harmed. Severely.
Continue reading

Arduino on the attiny in 15 minutes

It’s actually fairly easy, you must do precisely this. First, you will need to download the one of the files listed below, depending on which model attiny you’d like to use (I’d suggest installing them all, so it will be easy to change between microprocessors as the situation warrants.) For the example case, I will be using the attiny85, so, I will refer to the attiny45_85.zip file.

First, make sure the Arduino program is *not* currently running, if so, shut it down. Open your arduino folder (arduino_022, or whatever you’ve named it) and create a folder inside your sketchbook folder called hardware (if it does not already exist.) Extract the zip file, and copy the folder within to your newly created hardware folder. The arduino IDE is now prepared to program your attiny. If you have a stand alone ISP, skip down to the ‘my first ardutiny program’ below. Otherwise, you need to configure your arduino (or compatable) to program your bare attiny.

Fortunately, the arduino IDE comes with a sketch built in to handle this task. Connect your arduino, start up the IDE, and select the ‘Arduino ISP’ sketch from the examples menu. Upload the sketch to the arduino, and now were ready to wire this bad boy up.


The picture above shows my setup. Basically, you need to connect the attiny to power and ground, connect three of its pins (5, 6, and 7) to three of your arduino’s pins (11, 12, and 13) respectively. Connect the attiny pin 1 to the arduino’s pin 10; this will allow your attiny to be automatically reset as you program the microcontroller. *If you’re using a teensy or other ‘arduino-compatable’ your pins will be different. If you can’t work it out, feel free to contact me in the comments.*

ardutiny programming
Now, were ready to program. Select ‘attiny85 (w/ Arduino as ISP)’, open up the blink sketch from the examples, and hit program (likely some errors will pop up, ignore these, and carry on). Take a LED, and connect it as shown above, and watch it light up!

This allows the attiny to support the best arduino functions such as digitalWrite(), digitalRead(), analogRead(), analogWrite() this is our PWM! More on this in tomorrow’s article. It also is hip with the time based functionality, such as millis() and pulseIn() another very useful function to be covered this week!

Give your thanks to these folks, if they’re still listening, MIT HLT Lab, and Alessandro Saporretti. Questions, comments and hopefully plenty of b**ching in the comments below, por favor.

the avr motherlode

FM RF Data Link


In preparation for testing for my technicians class radio license, I’ve been designing a data modem for my avr chips. The current plan is to use a tuned FM transmitter, driven by an op-amp square wave generator, modulated by a microcontroller. This is an improvement (in both power and computational resources) over the original idea of summing sinewaves on the Tx side and Fast Fournier Transform on the Rx side. Seems pretty wasteful, now doesnt it?

Attiny85 Parallel Programmer (AVR compatible)

Here it is, works like a dream. Get out your soldering iron, and build this up. Spread the knowledge.

The Atmega32 Programmer. In the wake of this final year project presentation on 22nd January, we sort of started things up with the project. The first thing was the brain of our sensor nodes – the micro-controller – which needed to be get done with. We chose Atmel’s Atmega32 uC for following “good” reasons: 1. Atmega32 puts up a lot of features right on the uC itself. Things like ADC, Internal Oscillator (1 MHz), 32 KB flash memory etc. are built on the chip and thus sav … Read More

via Paths

Blog at WordPress.com.

%d bloggers like this: