Go Down

Topic: Serial Communication Syntax (Read 528 times) previous topic - next topic

Debsl

Hi, Hopefully someone can help me.

I am using an Arduino Mega to interface with a device which requires several parameters set up over serial for correct operation.  The documentation for the device specifies that the serial string sent to it should be in the format

s<value><return>

with 's' being the parameter i am trying to set up, <value> being a value between 0 and 1 to four decimal places, and <return> denoting a carriage return.

I would have thought that the below would work.

Serial.println("s0.2500");

However the device seems to just ignor this command.

I know the serial comms are working as they should as I am able to communicate with it successfully to change other parameters - The problem appears to be just when sending numeric values.

Can anybody see what I am doing wrong, or any suggestions for different methods would be appreciated.

Thanks in advance

majenko

I believe that Serial.println terminates with both a CR and an LF.  I'm not sure whether they mean CR by <return> or LF.

Try the following:

Code: [Select]

Serial.print("s0.2500\n");


And:

Code: [Select]

Serial.print("s0.2500\r");


to find out which works.
Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Debsl

Hi Majenko,

Thank you for your quick reply.

Unfortunately both of those have the same result as println - the device just seems to ignor it  =(

majenko

Do you have a link to the documentation of the device?
Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

PaulS

Quote
the device just seems to ignor it

Then maybe it's time for you to tell us what this mysterious device is, and how you KNOW it is ignoring the data.

Nick Gammon

And post all your code. What baud rate? Do you do Serial.begin()? Is it wired up correctly?
http://www.gammon.com.au/electronics

Go Up