Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Interfacing / Re: Serial Comms Problems on: May 13, 2010, 06:09:44 am
Nothing. It's designed as a 485 protocol really. why, is that what i need to do to make it work? I thought just Rx and Tx was enough
2  Forum 2005-2010 (read only) / Interfacing / Re: Serial Comms Problems on: May 12, 2010, 10:34:21 am
You are quite welcome to look at my code...
It received a message, validates it's checksum, and once it has a valid message, it sends a valid message back.

Also, There is nothing wrong with the LabVIEW code I am using, as I was the one who wrote it and have been using it sucsesfully for over a year.

int inByte = 0;         // incoming serial byte
int x = 0;
int potentialCheck = 0;
int actualCheck = 0;

int DCPstart, DCPflag0, DCPflag1, DCPkey, DCPseq, DCPid, DCPlen, DCPdst, DCPsrc;
int DCPhdrChk1, DCPhdrChk2;
int DCPIncomingMessage[23];
int newCheckSum;

boolean DCPreading, stopReadingDCP, messageAwaitingProcessing;
int DCPbyteReadCount = 0;

void setup()
  // start serial port at 9600 bps:
  establishContact();  // send a byte to establish contact until receiver responds
  DCPreading = false;

void loop()
  // if we get a valid byte, read analog ins:
  if (Serial.available() > 0) {
    // get incoming byte:
    inByte =;
    if (DCPreading == true)                             // Are we still reading the message?
      DCPIncomingMessage[DCPbyteReadCount] = inByte;    // Add next byte to array
      DCPbyteReadCount = DCPbyteReadCount + 1;          // Keeps check of how many bytes we have read
      if (DCPbyteReadCount >= 12)
        validateChecksum();                 // is it a complete message?
      if (stopReadingDCP == true)                       // have we reached the end of the message?
        DCPreading = false;                             // stop next time around
        messageAwaitingProcessing = true;
      if (inByte == 83)                                 // Is this the start of a DCP message
        DCPIncomingMessage[0] = inByte;                 // place the first byte into the beginning of the array
        DCPreading = true;                              // let us know that we are part way through reading a message
        DCPbyteReadCount = 1;                           // reset the byte count
    if (messageAwaitingProcessing == true)

      DCPstart = DCPIncomingMessage[0];
      DCPflag0 = DCPIncomingMessage[1];
      DCPflag1 = DCPIncomingMessage[2];
      DCPseq = DCPIncomingMessage[3];
      DCPid = DCPIncomingMessage[4]*100+DCPIncomingMessage[5];
      DCPdst = (DCPIncomingMessage[6]*1000000)+(DCPIncomingMessage[7]*10000)+(DCPIncomingMessage[8]*100)+(DCPIncomingMessage[9]);

      newCheckSum = DCPstart ^ DCPflag0 ^ DCPflag1 ^ DCPseq ^ DCPid ^ DCPdst;
      //Serial.print("I'M SOMTHING NEW!",BYTE);
      messageAwaitingProcessing = false;

void establishContact() {
  while (Serial.available() <= 0) {
    delay(300);    // Wait until device is communicated with

void validateChecksum() {
  // if the checksum is valid

  x = 0;
  potentialCheck = DCPIncomingMessage[0];                                    // Add first Value into check
    x = x + 1;                                                                // Ensure the first value is XORed by the second
    potentialCheck = potentialCheck ^ DCPIncomingMessage[DCPbyteReadCount];  // XOR each value
  while (x < DCPbyteReadCount - 2);

  actualCheck = DCPIncomingMessage[DCPbyteReadCount - 1];              // Add First Value
  actualCheck = actualCheck *100;                                      // Shift up 2
  actualCheck = actualCheck + DCPIncomingMessage[DCPbyteReadCount];    // Add Second Value
  if (actualCheck == potentialCheck)
    stopReadingDCP = true;                                            // This flag is only set if a valid checksum is identified
3  Forum 2005-2010 (read only) / Interfacing / Re: Serial Comms Problems on: May 12, 2010, 10:27:33 am
Are you all sure. I have noticed when I open the arduino serial monitor it always opens a comms session on the same port. When as the dll I am using seems to just pick any port. Are you sure that it is not the operating system that runs in the arduino not letting me?

For example, what happens if I just happend to send the right sequence of characters down the serial port that would place the Arduino into "Program" mode. Is this not catered for by the operating ssytem/enviroment?
4  Forum 2005-2010 (read only) / Interfacing / Re: Serial Comms Problems on: May 11, 2010, 11:45:26 am
A LabVIEW controlled winAPI bespoke protocol
(I knew you didn't really want to know) smiley-wink
5  Forum 2005-2010 (read only) / Interfacing / Serial Comms Problems on: May 11, 2010, 11:03:01 am
   I am trying to write an application for the arduino that will communicate with my PC via USB. This works fine while using the "Serial Monitor" within Arduino. But when I try and use some seperate software, the arduino seems not to respond, and even the LED on pin 13 illumiates slightly (i assume to let me know that there is an error) does anyone have and ideas what this means or what the error is?

Many thanks, Alec
6  Forum 2005-2010 (read only) / Development / Veroboard Layout Software on: May 10, 2010, 07:55:34 am
   Does anyone know of any good free/shareware software (for PC) that allows you to play the layout of a circuit to be built on veroboard?
Cheers, Alec
7  Forum 2005-2010 (read only) / Interfacing / Re: TTL to LVTTL on: May 06, 2010, 12:25:11 pm
1631692. if you could grab me 10 it should be 67p. your a legend man!
the module is a LS-40EB-5V. (I'm hoping to stick it all in a high altitude balloon when i'm done!) smiley-grin
8  Forum 2005-2010 (read only) / Interfacing / TTL to LVTTL on: May 06, 2010, 08:09:41 am
   I have a LVTTL GPS device(Rx & Tx lines) I am trying to convert the TTL from the arduino into LVTTL. Do I need to? Can I plug these straight into each other?
   The only place I can find a part to do it is Farnell, and they have a minimum order of £20 and a £15 P&P charge... The actual part is 7p!!!

Do i need to bother? or will I blow my GPS?
9  Forum 2005-2010 (read only) / Interfacing / SD card with homemade Sheild and uFAT on: April 29, 2010, 10:42:49 am
Hi All. I'm really struggling. I have build an SD card holder sheild following the schematics below...

I have loaded the uFAT code into my arduino (found here - The code has compled ok, runs ok and I can communicate with the applciation down the serial port. The problem is when I issue the "L" command (List file Details) I receive a "[hola.txt] - ..error!"

This library works on the prinicpal that the SD card is formatted FAT16 and there is an existing file on the card called "hola.txt". My current system has all of these things but I can't for the life of me get it working...

I am using Arduino_018. Does anyone else have any experience of getting SD card reading and writing going using a homemade shield?

Many thanks, Alec

PS (there are conditions that the hola.txt file contain some info. a template for this file is includedd with the library. this is the file currently on my SD card)
10  Forum 2005-2010 (read only) / Exhibition / Re: SD card read/write with Arduino on: April 21, 2010, 01:43:15 pm
   as soon as I try and run this example I receive the following error:
My Documents\arduino-0018\libraries\SDcard\arduino sd card example.cpp:161: error: 'DEC' was not declared in this scope

This makes no sense to me as "DEC" seems to be used in the correct way throughout the example. Can anyone help?

Many thanks!

NOTE: I'm using Arduino_0018 and the "libraries" folder is not within the "hardware" folder, does this matter?
Pages: [1]