One of the many uses of an Arduino board is using it as an ISP (In-System Programmer). Which means burning bootloaders or programs without use of a bootloader directly to the ATmega CPU.
Why would somebody need to do that? Here is a real example.
I bought a 9 Degrees of Freedom Razor IMU a while ago. It is an Arduino compatible microcontroller with sensors in reality. Anyway, a small batch of these came with the wrong bootloader and I was lucky to get one of these. So, instead of sending it back and getting a new one I’d chose a simpler way. Burn the proper bootloader. There are ISPs out there that do the job just fine but for me it was an one time gig, thus I decided to go with an Arduino Mega ADK (which I have and I’ll refer to it simply as MegaADK) as an ISP.
A word of caution. This procedure worked for me. You might have a different hardware and it might not work well for you.
- Download ArduinoISP sketch that lives in Examples folder of Arduino IDE (using latest version – 1.0) to MegaADK.
Connect MegaADK and Razor through SPI
. (note: You will need to solder some pins to enable SPI on Razor). Pin 1 on Razor is marked with a white line (here you can find a diagram
for SPI header).
Connect (from MegaADK to Razor) MISO->MISO, MOSI->MOSI, SCK->SCK and SS->RESET. Power for Razor is brought through USB (using 3.3V FTDI Basic Break board
) but you can use other power sources.
Razor with marked pin 1 (blue) and SPI header (yellow)
(original photo taken from Sparkfun
- Using Arduino IDE select Tools/Programmer/Arduino as ISP and a target Tools/Board, which is Arduino Pro or Pro Mini (3.3V, 8Mhz) w/ ATmega328 in my case since ATmega328p is used on Razor.
- If everything worked properly you’d hit Tools/Burn Bootloader. But there is a bug in Arduino libraries that come with version 1.0. For some reason you have to find HardwareSerial.cpp source file (located in [Arduino setup folder]\hardware\arduino\cores\arduino. Edit the 43th line which goes like "#define SERIAL_BUFFER_SIZE 64” to “#define SERIAL_BUFFER_SIZE 128”. If the buffer isn’t set to 64 the burn process will most probably stop when it tries to burn data pages with error like this:
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64
- Hit the Tools/Burn Bootloader and wait for half a minute and there you go, a fresh bootloader is burned to the Razor and it can be programmed using classic Arduino way again.
Photo of my setup:
On the left is Razor, on the centre is Arduino Mega ADK and on the right is a bread board for three LEDs that signal the status of the ISP (green, red and yellow signalling the burning in progress).
Using Arduino BT
I think that it is quite possibly to use the Arduino BT (Bluetooth version). I am mentioning BT version because it has an interesting quirk and a feature.
A program mode LED mentioned above is attached by default to pin 7. The problem is that pin 7 on BT version is used to reset the bluetooth module and shouldn’t be used for anything else. Even if you don’t connect the LED it will reset the bluetooth module and thus drop the connection between Arduino IDE and ArduinoBT once the burn process begins.
The remedy is quite simple. Before downloading ArduinoISP sketch to the ArduinoBT (step 1) you should modify the sources by changing the pin used for signalling the program mode. There are two occurrences:
#define LED_PMODE 7 and the other in void setup() procedure (not sure why the later isn’t using the former). Change number 7 to any other suitable pin and the Bluetooth connection won’t drop anymore.
Serial port speed
Bluetooth communication in ArduinoBT is supposed to run at 119200 bauds, but the ArduinoISP sketch is using 19200 bauds. Simply change the value in void setup() procedure to Serial.begin(119200);
There you go, ArduinoBT is a functioning ISP now.
Hope this article will help somebody.
Today I’ve presented .NET Micro Framework to the students of Nova Gorica. I demonstrated running the C# code on Netduino by taking photos (on demand from client) using C328R camera, sending the JPG bytes over the wireless PAN provided by the two XBee Pros and showing the image within the WPF application running on the desktop. It was my first semi-hardware talk and it went fairly well I assume.
Attached are Power Point slides (in Slovene) and the demo code.
Note about demo: The client code requires PostSharp (if you compile it) for creating and implementing INotifyPropertyChanged. If you don’t have PostSharp then remove the references to it and NotifyPropertyChangedAttribute class. Then implement it manually for MainViewModel class.
mf.rar (13.00 mb)
I always wanted to do play with microcontrollers but I lacked hardware knowledge. Actually the last time I wanted to play with them was at the very early stages of the internet (during my university time that is). So I let it go for the time being because of lack of the available informations and other more important tasks (like going out with friends).
Now, 15 years later, the very same idea kicked in my head again. I was still hardware ignorant - more or less like I was 15 years ago. But this time there was a major factor in my advantage: Internet. So I went surfing for microcontrollers and soon found a priceless site for beginners and advanced users: Society Of Robots. The author has written plenty of tutorials that even a beginner can understand. The tutorials are excellent. There are also tutorials and other content provided by the author and community. But tutorials don't answer every question one can come up with - yes, there is a forum as well. And again, the forum is excellent as tutorials are - many skilled users are ready to answer (even beginner's) questions and many questions are already answered. The author of the site has even created its own MCU (microcontroller unit) Axon (it can be ordered on-line) - an advanced microcontroller worth checking out (I'll buy it, just to support his efforts if not for anything else, but not right now).
Now, armed with new the new knowledge I had to decide which microcontroller I am going to start with. The first choice was Axon, mentioned above, ATmega640 based one with plenty of in/out pins. I went browsing for alternatives. Soon it struck me: [MS] .net microframework might be a perfect choice. The drawbacks? Expensive compared to the Axon. It is much more powerfull in terms of CPU though. The thing is that I wasn't looking for a powerful MCU. Rather I was looking for two features:
- Bluetooth connection with PC - as a beginner I really didn't want to fry my workstation PC by a shortcircuit. That means no physical connection between two entities can exist to be on the safe side. (so far I didn't manage a shortcircuit anyway). Most of the MCUs communicate with PC via USB or RS232 port.
- It should be cheap - because I am a beginner and I don't want to make too much damage from the start.
After a while I've found Arduino - a cheap MCU and again, great site with a great forum and a huge community. Quote form the web site:
"Arduino is an open-source electronics prototyping platform based on
flexible, easy-to-use hardware and software. It's intended for artists,
designers, hobbyists, and anyone interested in creating interactive
objects or environments."
Society of Robots is friendlier to the beginners while this one has definitely a larger community. The base Arudino MCU (based on ATmega168, a chip from the same family as Axon's.) is dirty cheap (Arduino Duemillenova - 22€) and there is even DIY documentation (how to build it from the scratch). There is plenty of Arduino versions and even variations (Roboduino, RainbowDuino, etc.) The bluetooth Arduino BT (built in bluetooth Class I reciever - 100m range) version is cheap as well - 79€ from Smart Projects. Perfect. I went with it. You can buy from various on-line sellers found here.
So Arduino BT for the start it is. Next, for bringing it to live I needed an energy source. While it runs perfectly well on batteries (5.5V max for this particular version) I opted for a power supply instead. I bought a Voltcraft VLP 1602pro from Conrad in Slovenia. It is a dual channel thing with short circuit protection, voltage and current limitator - meaning it is very safe to use and can provide two different voltages at the same time. I'll use batteries when I'll need to move around Arduino.
Voltcraft VLP 1602pro
At that point I was able to power up Arduino and open the communication with PC via bluetooth.
To be continued...