Amir Lazarovich

Project Remote Control

Soldering can be soooooo hard!!! I spent so much time this week on soldering - it's not fun after couple of hours trust me!

How to get hello_radio to work

Follow this tutorial. Make sure you set the parameters in the modela right. Also if you're not going to use the Arduino IDE then you don't need to download the .hex files. If you are using it, download only the one that correspond with your processor clock speed. 16mhz is built-in in the Arduino IDE.

The first step after milling the board is frustrating - solder all the parts. If you don't have a microscope it's not going to be an easy task. If you're a ML student go to Changing Places' group and use their awesome microscope. This task is really annoying due to two things: really small traces and microscopic parts. The former can be solved if you modify the board - which you should!
One more note, make sure you check all the traces before/after soldering. Short circuits suck big time.

Are you using a 20mhz resonator?
Yes, edit the makefile and replace the line F_CPU = 16000000 with this: F_CPU = 20000000.
No, :)

Good, now lets flash the fuse bits and upload the program. To do that, simply write make. This will run the default target all.
If the process completed successfully, you're running now on 9600 baud rate and should see the following in the serial terminal:
*** hello_radio.c - Hello Radio v0.2 [date] [time] ***
The easiest way I found to work with a terminal is to open the one that comes with the arduino IDE.
* make sure you put the makefile file in the same directory from which you run that code.

Test your code by clicking on the button - you should see R^*|B1 when you press on the button and R^*|B0 when you release.

What can possibly go wrong?

1. The initialization code didn't finish and was stuck while trying to read the MISO bit since it was never HIGH. That was because I had bad soldering and that pin wasn't really connected. Make sure you solder all the parts and double check before running the software - it will help you keep your sanity.

2. Not all the bytes are received or some of them are corrupted. When I tried to fix the first issue I added lots of printf. Some were placed in the middle of a packet transmission. Don't do that! any delay between the starting time and ending time of a transmission will cause problems.

How to get your hello_radio talk to your board

There are many ways and I chose to use SPI.
See my example code for reference. I use normal SPI when the radio is in master mode and interrupts when it's in slave mode.

What can possibly go wrong?

I've just spend two hours trying to figure out what's wrong with my code, almost rewriting it from scratch and then finally saw my problem! I accidentally used SPSR for data instead of SPDR. God damn it...

Setup and use of the SPI
Radio - with SPI-master hardware enabled
Radio - with SPI-slave hardware enabled using interrupts
SPI master|slave simple implementation
SPI master|slave with interrupts
Eagle design for the remote controller
Arduino code for the remote controller

Network | Communication | Radio