Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

COM-port terminal on Labview

Solved!
Go to solution

Hello everyone!

I'm trying to connect my controller (atmega2560) with Labview via Com-port. 

The task is to send the commant to the controller and receive the answer. Command and answer should be hexadecimal type. 

For my task, I use standart example "Serial Write and read on two Ports". The only one changing is selecting of hexadecimal display style to the "Read string" and "Write string".

 

Well, I send to my controller this one:

0x01 00 00 01

 

For this message, controller have to anser: 

0x 0d 00 00 0d

 

But I have: 

0x 00 02 00 02 - this is the message of error, what means that controller does not get the command right (0x01000001).

 

As I can understand, changing the display style for "Write string" is not enough.

What I also have to do, to send the hexadecimal constant to my controller?

 

Sorry for my English:)

 

 

0 Kudos
Message 1 of 6
(1,341 Views)
Solution
Accepted by topic author iaz5

What all settings did you use?  And why are you using the 2 port example?  That example was designed to be used between 2 ports on the same machine with a NULL Modem cable between them.

 

My current thought is that you need to turn off the End Write On Termination Character and the End Read On Termination Character.

 

But do you have any documentation on the message protocol?  Based on your description, it is a very poor protocol.  Hex/Binary/Raw communication schemes need structure around the message data to make sure you are properly aligned (ie: you are interpreting the correct bytes).  This typically includes a start character (I often see 0x2), a message id or message length byte(s), the data, and finally a checksum or CRC (to error check the data, extra step to make sure you are aligned to the message frame).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 6
(1,305 Views)

Baudrate 9600. 

I use 2 port example just because it is close fo my task- send and receive the essage from my device. Maybe, in the library of labview examples have another good variant. 

 

I'm sorry, could you, please explain how I can "turn off the End Write On Termination Character and the End Read On Termination Character"? This is my first time of using labview. Quite possibe, my question is very stupid 😄

 

I use "some kind of MODBUS protocol". The principle of work is similar, but the commands are different. Consequently, you are totaly right: it includes message id, command and CRC.

0 Kudos
Message 3 of 6
(1,284 Views)

All setting for ports:

BAUD 9600

number of bits: 8

Stop bits: 1 

parity: no

control: no

This is all settings from the terminal. And I  repite this in labview. 

0 Kudos
Message 4 of 6
(1,282 Views)

I turned off the "End Write" and "End Read" and now it works!

I received:

0x 0d 00 00 0d

 

But I also have the error: Timeout expired before operation completed.  By the way, it works!

Thanks! 

0 Kudos
Message 5 of 6
(1,278 Views)

@iaz5 wrote:

I use "some kind of MODBUS protocol". The principle of work is similar, but the commands are different. Consequently, you are totaly right: it includes message id, command and CRC.


Without knowing the details, I can give a very simple example here.  In a real system, I would use a more complicated setup where I read a single byte until the start byte is read, then read the ID, read the data, read the CRC and verify the CRC.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 6
(1,248 Views)