LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication (read/write)

Solved!
Go to solution


Good evening,

I have a problem with a project about Read/Write data by means of serial communication.
I hope I'm not opening post already discussed.

I'm acquiring by Serial port data (see picture in attachment)
after that I need to write data using same serial. By default data are 0 (see pictures in attachment) and I want to start from value previous read but I don't know how copy that value.
Right now I'm using tab but I'd like to have all in one and decide everything by button.

Can anyone help me for solution?

Thanks in advanced
Antonio

Download All
0 Kudos
Message 1 of 6
(3,163 Views)

Post your code, not a picture of your code, the actual VI's you wrote.

 

If it is a large project with multiple sub-vi's ZIP all the required files and upload the zip file.

========================
=== Engineer Ambiguously ===
========================
Message 2 of 6
(3,157 Views)

I would put all parameters into 1 cluster.

 

Then make a table, listin parameter label, serial command(s), may be index in cluster.

Property "Controls" of the cluster gives you references of all elements.

When you read value from serial - find control and reference to write "Value" property

When you modify element, you find serial command to send.

0 Kudos
Message 3 of 6
(3,119 Views)

Hi,

 

thanks a lot for your suggestion, I'll arrange my code and attach for better way to work.

 

Thanks a lot

Antonio

0 Kudos
Message 4 of 6
(3,062 Views)

Hi,

i'm replying previous question attaching part of my project.

Right now I read by serial communication and after I need to insert value and when button is off I write by serial communication.

By default,the values to write are 0 but after first read I want inside WRITE 1 and WRITE 2 value already read (READ 1 in WRITE 1 - READ 2 in WRITE 2) because in this case there are 2 values but in other project I need to insert 100 values manually and after change just some of them.

 

I hope my question is clear.

thanks in advance 

Regards

Antonio

Download All
0 Kudos
Message 5 of 6
(3,042 Views)
Solution
Accepted by topic author Antonio81

I don't understand what you are trying to do, but I can tell from your VI you've already complicated things.

 

1.  There should be no need for a STOP function in your code.  It effectively aborts your VI at that point.

2.  You have several while loops set to run forever, so the only way to stop it is to abort it.  But the STOP you have as mentioned in #1 will never execute because of your continuous while loop.

3.  You have a lot of sequence structures you don't need.  Some are single frame just enclosing a while loop.  Delete them.  They make your VI harder to follow.

4.  You have the Write message, wait, bytes at port, Read message going on.  That is the wrong thing to do about 99% of the time.  Now it's possible you are in the 1%, but even then there are usually better ways of communicating depending on the protocol.

5.  You talk about going from 2 values to 100 values.  The way you do that is by taking advantage of For Loop, arrays, and auto-indexing.  Which seems to already be occurring in your code.  So I don't know what problem you have at the moment other than adding more elements to the array.

6.  When you auto-index on a For Loop, there is no need to wire the constant 2 to the N terminal of the For Loop.

7.  You are XORing a bunch of U8 values together with an I32 in those For Loops.  (All those coercion dots told me something was wrong).  I doubt you want to do that.  This appears to be a checksum calculation.  That x55 constant probably needs to be a U8 as well.  The Build Array and converting a U8 array to string could probably be simplified then.

Message 6 of 6
(3,013 Views)