From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial write , read and graph help !

Hi All,

 

 

The more I think I got it close, the far it seems to get away from me. So, this is what I should be able to do. ( Feeling a retard )

 

1. WRITE    -----    Write 5 to 200 bytes of hex code including ascii ESC first byte and lascii CR last byte with 2 bytes lsb checksum   ( obtained by adding all the previous byte including 1B ) converted to ascii ( 1B and 0D) .  Example for a 5 byte write command  -    1B 22 33 44 0D  . So, put outgoing data in array and send it out through serial port ?

 

2. READ  ---    Incoming Hex Serial  Data going to array ( whose length to be determined by checking  0x0D  ). 

 

3 .Convert the hex data in arrays to ASCII .

 

4. Graph the hex data .

 

 

Any insights? Any chances of example VI files for reference? 

 

thanks

sasha

0 Kudos
Message 1 of 8
(2,950 Views)

Show us what you've done, where you are "stuck", and we'll provide help.  If we do your homework for you, then you need to provide us your instructor's e-mail address so we can get the appropriate credit for our work.

 

Bob Schor

0 Kudos
Message 2 of 8
(2,939 Views)

There is the Simple Serial Write Read example.  That should get you started with talking over a serial port with VISA.

 

It seems like you have an array of bytes that you need to send.  You just use the Byte Array To String to convert directly into a string and send it.  For reading, there is the String To Byte Array that you can use to start parsing your data.

 

Show us what you have so far.  Be sure to include any sample data you may have and expected results.  Things get really confusing when stating ASCII and Hex since people can interpret that in 10 different ways.


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 3 of 8
(2,937 Views)

As hard  as it is to say - you are right. It is my college work. All I am able to do is follow example, open ports send ascii commands and receive values in arrays. What I cannot do from that example is break that hex stream into bytes starting with SOH and ending with CR and ignore those common ones and save rest to plot data. 

0 Kudos
Message 4 of 8
(2,920 Views)
What exactly are you doing? As mentioned, you would use String to Byte Array and then just use the Index Array to get whatever bytes you do or don't want. With the configure serial port, you enable the termination character and set it to a carriage return. Don't use the bytes at serial port. Just specify some high byte count. Because serial communication is asynchronous, your first read may be incomplete so you would just discard it.
Message 5 of 8
(2,915 Views)

Duplicate Post

 

Please don't start a new thread with the same question.  Especially when you were already getting help in the other thread.

 

Continue in that first thread.

0 Kudos
Message 6 of 8
(2,909 Views)

Yes, I agree. It was stupid to post similar one. Desperateness blindfolds.


@RavensFan wrote:

Duplicate Post

 

Please don't start a new thread with the same question.  Especially when you were already getting help in the other thread.

 

Continue in that first thread.


 

0 Kudos
Message 7 of 8
(2,897 Views)

I recommend changing to an array of bytes and use Array Subset to just get the data.  From there, it is just getting the data that you want.


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
Message 8 of 8
(2,879 Views)