Code working on Diecimila, but not on Mini Pro

I have been working on combining the Skyetek M1 Mini RFiD module and an Arduino Mini Pro.

To begin with, I have had the components on breadboard and been using an Arduino Diecimila while developing the code. After some trial and error I had a working set up Grin

I then decided it was time to upload the code to the Arduino Mini Pro and check it all worked. Problem is, it doesnt!! The program initialises and returns a Serial.print command showing that it has started. However it does not appear to be talking to the M1 mini, and it defintaly isnt printing the RFiD data to the serial port.

The code I have written is as follows:

// File......RFiD Read - Code for IE5 to talk to Software interface
// Version 1.0
// Author Ian Culverhouse
// Date 13th July 2009
// Purpose - To implement the SkyeTek M1 RFiD Module with the Arduino to read 13.56mhz RFiD IC

// Revision History -

// Imports --------------------------------------------------------------

#include <SoftwareSerial.h> // Initialise Software Serial

// I/O Definitions ------------------------------------------------------

#define txPin 5 // Software serial tx pin
#define rxPin 4 // Software serial rx pin
#define ledPin 13 // LED pin
#define successRead 9 // Indicate successfull read.

// Initialise the Software serial port ----------------------------------

SoftwareSerial mySerial(rxPin, txPin);
#define d_size 64 // create some space for receiving data from tag reader
byte readerData[ d_size]; // Sets up Array for the tag ID to be held in

// Setup the Pins & Ports -----------------------------------------------

void setup() {
// define pin modes for tx, rx, led pins:
pinMode(rxPin, INPUT); // pin mode for the software serial rx pin
pinMode(txPin, OUTPUT); // pin mode for software serial tx pin
pinMode(ledPin, OUTPUT); // pin mode for the ledpin
pinMode(successRead, OUTPUT); // pin mode for successfull read

mySerial.begin(9600); // set the data rate for the serial ports
Serial.begin(9600); // sets data rate for the hardware serial port
Serial.println("Initialised Serial"); //prints the word begin to the hardware serial port as a trace that the system is working
digitalWrite(ledPin, HIGH); // Sets the ledpin to high, indicating the system is active

}

// Program code ----------------------------------------------------------

void loop(){

// first step is to query the reader for a tag. Send a 001400 command to it. If no tag is found then it will lopp back
// and try again. When a tag is found the code will store the entire response from the reader.

int in_count; // defines variable in_count
mySerial.print( 0x0d, BYTE); //send CR
mySerial.print("001400"); // Send read command to M1 mini
mySerial.print( 0x0d, BYTE); //send CR
delay(50);

byte ch = mySerial.read(); // get first byte of answer from reader

// if it was not a LF (0x0a), send read command again if it was,
// store all bytes until ending LF was received
if (ch == 0x0a) // if first byte received is a line feed enter if statement
{
ch = mySerial.read(); // read the first byte into the variable ch
in_count = 0; // set in_count to 0 - used as a counter for the array
while( (ch != 0x0a) && ( in_count < d_size))// while the byte being received is not a line feed and the eeprom is not full enter while loop
{
readerData[in_count] = ch; // the array dta is filled with the value of ch
in_count++; // in_count is increased by 1
ch = mySerial.read(); // the next character from the serial port is read in and ch is assigned the value

}
}

if (readerData[0] != '9') { // check to see if first byte of data is a 9. If it is then
// error code 94 has been sent from reader, indicating that there is no
// in range of reader, go back and try again.

for ( int i = 0; i < in_count; i++) Serial.print( readerData*, BYTE);*

  • digitalWrite(successRead, HIGH); // Sets the successread LED to high*

  • delay(25);*

  • Serial.println();*

  • digitalWrite(successRead, LOW); // Sets the successread LED to high *

}

}
Can anyone offer any suggestions or advice? Have you experienced similar problems when working between arduino hardware?

Which version of the mini do you have?
Have you checked the clock speed?

(Please can you use the "Code" button (#) when posting software?)

Apologises for not using the code button, first time I have really inserted code.

The mini that I am using is the Mini Pro 8mhz 3.3v Atmel 328 version. Will this have an effect on the program?

I'm not sure, but I think the 3.3V one runs at 8MHz, whereas the 5V ones usually run at 16MHz.

However, given that the hardware serial line works, I'm not sure where that puts you.
You could try raising the soft serial bit rate to 19200.

Ok, thanks for the suggestion. I will give it a try and post the result on here as soon as I have given it a shot.

Changing the baud rate to 19200 didnt have any effect on the running of the system. It only scrambled the "Initialised system" message that runs at the beginning to unknown characters.

I am going to order another 8mhz 3.3v Mini and also a 16mhz 5v version in case the Mini I am using is faulty.

It only scrambled the "Initialised system"

No, I said only to change the speed of the soft serial line, not the hardware one.
The hardware serial was obviously working before, and there was no reason to change it.

Sorry,

I also just changed the baud rate of the soft serial but this made no change to the problem. I have put it back to 9600 and ordered a new mini to give that a try.

Thanks for you advice so far. much appreciated

Still no joy even with a different Mini. A thought crossed my mind earlier though, The Diecimila that the code was working on fine has a Atmega 168 16mhz chip, the Pro Mini and the Sparkfun Wee (Secondary board that I tried) are equipped with Atmega 328 8mhz 3.3v, and Atmega 168 8mhz chips respectivly. With these chips being half the power of the one on the Diecimila could this be causing the problems?

I have ordered a Pro Mini, 5v 16mhz board to give it a go.

sounds like the soft serial port is not working properly. you might want to isolate and confirm this by hooking up the RFID module to the hardware serial port, and run a test program that lights up an LED when you've successfully scanned a card.

according to the reference http://arduino.cc/en/Reference/SoftwareSerial the software serial can only go up to 9600 baud.

also, if you changed the hardware serial baud rate to 19200, you shouldn't see a scrambled init message: make sure you have the right baud rate in the serial monitor.

I, too, have a problem with code working on a Diecimilla or a Duemilanove, but not an Arduino mini pro 3.3v. I have an accelerometer wired to the mini pro, and xBee to the serial outs. I was getting garbage out of the xBee/serial, so to remove the accelerometer readings from the mix I loaded a simple sketch (see below). When I run the sketch on the Diecimilla/Duemilanove it runs just fine, communication between xBee and receiver is fine, etc. etc. But running this sketch on the miniPro, instead of seeing "test123" every second in the serial terminal, I get ":...J" once every second.

Checked all kinds of variables--baud rate, channel, PAN ID, etc. etc...I tried different baud rates, too. The only variables I can think of are: the board, the fact that an accelerometer is hard wired to the mini pro. I wonder if maybe there's a power issue or something? I'm running the miniPro and xBee with a 900mAh 3.7v battery, which should be plenty powerful. The LED blinks as in the sketch, so I know it is running. Any ideas?

/* Serial Test code
Sends "test123" over the serial connection once per second
while blinking the LED on pin 13.
*/
#define ledPin 13
byte pinState = 0;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
Serial.println("test123");
// toggle an LED just so you see the thing's alive.
toggle(13);
delay(1000);
}
void toggle(int pinNum) {
// set the LED pin using the pinState variable:
digitalWrite(pinNum, pinState);
// if pinState = 0, set it to 1, and vice versa:
pinState = !pinState;
}