Pages: [1]   Go Down
Author Topic: Serial Communication Syntax  (Read 495 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

UK
Offline Offline
Faraday Member
**
Karma: 100
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Serial.print("s0.2500\n");

And:

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

to find out which works.
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-cry
Logged

UK
Offline Offline
Faraday Member
**
Karma: 100
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have a link to the documentation of the device?
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 638
Posts: 50307
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 502
Posts: 19080
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

And post all your code. What baud rate? Do you do Serial.begin()? Is it wired up correctly?
Logged


Pages: [1]   Go Up
Jump to: