Search This Blog

Showing posts with label ROB-09571. Show all posts
Showing posts with label ROB-09571. Show all posts

Saturday, 5 February 2011

FEZ Domino

A few months ago now I was drawn to the relatively new Arduino semi-compatible boards capable of running .Net MicroFramework managed code. With a rich feature list I opted for the FEZ Domino and grabbed one from a local supplier. Curious to see how an ARM core would handle the CLR and managed code.

The design of the Domino is very nice. There are key differences between it and an Arduino, particularly on the IO lines. So you need to be wary when using Arduino shields with the Domino.

As for key features, here is a list from the FEZ Tutorial PDF;
  1. Lowest cost at available features!
  2. Runs Microsoft's .NET Micro Framework 4.0.
  3. Uses Free Visual C# 2008 express.
  4. Run time debugging over USB or serial.
  5. Program in modern managed language.
  6. 32-bit ARM processor, running at 72Mhz.
  7. FAT file system for storage on SD cards and USB memory devices.
  8. Easy upgrades to high end systems like ChipworkX or Embedded Master.
  9. The FEZ core, USBizi, is widely used in commercial applications around the world.
  10. RunTime Loadable Procedures
After using Microsoft Visual Studio products for over a decade. One beautiful feature is the use of the free Express Edition as an IDE, and single-step debugger! As well as a feature rich class library in the Microsoft .Net MF framework.

My first task was to develop the interface between the SparkFun ROB-09571 Motor Controller and the FEZ Domino. This turned out to be incredibly easy thanks to the breakout of a second UART to the Domino's EXT edge connector. Three female to female connecting wires hooked up TX, RX, and Gnd. The Domino's System.IO.Ports.SerialPort class can then be used to setup and communicate with the Motor Controller. I also hooked up digital pin 10 (FEZ_Pin.Digital.Di10) to the reset line on the Motor Controller. The MotorTest Visual C# solution can be found here (revision r62).

Modified firmware for the Sparkfun ROB-09571

The Sparkfun Serial Controlled Motor Driver contains adequate firmware code for most purposes, but is begging to be tweaked.

The latest version in my GoogleCode SVN repository can be found here (revision r59).

Changes in this firmware are;

  • CURRENT_THRESHOLD has been increased from 150 to 300
  • Motor current monitoring interrupt code now changes the Sense LEDs based on the ADC
  • The command buffer has been modified to accept 'b' as a command (Used to start both motors at a specified speed and direction)
  • The speed command is now 16 bits. It is decoded into the OCR1 register directly.
  • The UART reply from a command now passes back both Sense current readings from the ADC.

Saturday, 16 October 2010

Re-programming the ROB-09571 (Serial Controlled Motor Driver)

Sparkfun's Serial Controlled Motor Driver is a lovely board. It has been working great in Project: Burt. One thing I've been meaning to do though is to change the firmware it is supplied with. Various comments suggests that this is possible with an Arduino, so I spent the morning having a look into this.

The first thing is to get the firmware re-compiled. For that we need to download and unzip the firmware supplied by Sparkfun. Inside the zip file are three files; main.c, main.h, and a Makefile. The Makefile points to using WinAVR to rebuild this code. A quick trip via the WinAVR website, takes us to the download location on SourceForge. I used the latest installer file called WinAVR-20100110-install.exe Choosing the default install options, and making sure that the PATH environment variable was updated.

Opening up a cmd prompt and navigating to the unzipped firmware, it was then a simple case of using 'make clean' to verify that WinAVR was installed ok. Then 'make all' to rebuild the firmware. From the resulting files we only need the main.hex and main.eep files. These contain the hex dump ready for uploading to flash memory, and the EPROM (eep) file ready to burn into the ROB-09571.

So far so good. The next step was working out how to turn an Arduino into an AVR ISP programmer.

Looking at the Deumilanove and the ROB-09571, they both have ICSP headers breaking out the SPI lines.


On the Duemilanove the 6-pin header is clearly labelled. On the ROB-09571 you need to solder on a header (in my case, design of Project: Burt restricted me to a two row right angle header). On both boards pin 1 is conveniently labelled (top left of each header). A quick look at the Deumilanove schematic and ROB-09571 schematic shows that all the neccesary ICSP lines are connected to the 328p ICs. So it should be a simple case of connected pin 1 to pin 1, pin 2 to pin 2, etc. That sounds far too easy, and it is :)

Next is what code do we need to upload to the Arduino. I'm currently using version 018 of the Arduino SDK Included is a sketch called ArduinoISP. Looking at this code, it recommends adding three LEDs (and current limiting resistors) to three of the Arduino digital pins. A tutorial describing how to connect the LEDs to an Arduino can be found over at LadyAda. Below is my initial wiring setup.

BEWARE: This wiring setup will never work! Read on for why it doesn't work.



All three LEDs use 470 ohm resistors to limit current, connected with a common ground (blue wire). The green LED is connected to D9 (green wire), the red LED connects to D8 (red wire), and the yellow LED connects to D7 (white wire). These LEDs are used by the ArduinoISP sketch to inform you of progress and/or errors. The six green wires connect the two ICSP headers.

Uploading the ArduinoISP sketch to the Duemilanove we are now ready to try reflashing the ROB-09571. But WAIT!! One vital wire is in the wrong place!!

Looking at the Duemilanove schematic it clearly shows that pin 5 of the ICSP header is connected to the 328p RESET pin! This is fine to reset all boards connected via ICSP, but the ArduinoISP sketch requires a seperate slave reset. A quick fix is to disconnect the green wire to pin 5 of the ICSP header, and connect D10 from the Arduino to pin 5 ICSP header on the ROB-09571. This now agrees with the expected wiring connections in the ArduinoISP sketch. An alternative is not to use the ICSP header, and connect to D10, D11, D12, and D13 on the Arduino.

At last. A correct wiring setup! Now it's time to flash that hex file.



We now need to use a program supplied with WinAVR called AVRDude. This communicates with the ArduinoISP sketch, and uploads the hex file to the ROB-09571.

The first thing we need to do is test that the Arduino, plus ArduinoISP sketch, and the wiring is working ok. Use the following cmd prompt line (changing com21 to the port you have your Arduino connected);
avrdude -p m328p -P com21 -b 19200 -c avrisp -v
You should eventually see;
avrdude: AVR device initialized and ready to accept instructions
If you receive any form of errors (protocol, sync, etc.), check your wiring.

We are now ready to upload our new ROB-09571 firmware. We can simply use the following commands;
avrdude -p m328p -P com21 -b 19200 -c avrisp -v -U flash:w:main.hex
avrdude -p m328p -P com21 -b 19200 -c avrisp -v -U eeprom:w:main.eep
AVRDude prints out some nice progress text. And the yellow LED should flash rapidly when the programming occurs.

When AVRDude has finished succesfully, you then have completed uploading new firmware to the ROB-09571 :)