LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending a serial string and waiting for acknowledge

Hi to everyone!
 
I have a little problem and post it here to see if any charity soul could help me!Smiley Surprised
 
The idea is quite simple: I need that LabView send an string of data (selected for the user).
 
The flow of data is the following:
 
1. the user enter a number betwen 30 and 30000
2. the user press an "OK" button
3.labview send an "F" trough the serial port
4.lv wait's until the device responds with "r"
5.if device respond's, lv continues sending data, if not an error message appears
6.lv send the first digit of the string select by the user, non significatives ceroes has to be trasmitted also
7.lv wait's until the device responds with "r"
8.lv send the second digit of the string select by the user, non significatives ceroes has to be trasmitted also
9.lv wait's until the device responds with "r"
10.lv send the third digit of the string select by the user, non significatives ceroes has to be trasmitted also
11.lv wait's until the device responds with "r"
12.lv send the fourth digit of the string select by the user, non significatives ceroes has to be trasmitted also
13.lv wait's until the device responds with "r"
14.lv send the five digit of the string select by the user, non significatives ceroes has to be trasmitted also
15.lv wait's until the device responds with "rf" that means the communication has over.
 
Well sorry for asking help for a so unfinished issue but really I don't have idea in how implement this.
I haven't trouble to receive serial data and split it in several instruments (for a datalogger), but sending and waiting is too far from my knowledge at today.
 
Thank's for your time.
 
 
 
0 Kudos
Message 1 of 6
(3,328 Views)

I guess taht you did look at the visa write,

please post your receive implementation and we give some hints about writing.
This problem is so big, as an advanced architect I need more info to do my homework.

 

greetings from the Netherlands
0 Kudos
Message 2 of 6
(3,300 Views)
I'm not sure what you mean by "non significatives ceroes has to be trasmitted also" when you send each digit. The attached example converts the number to an array of characters, appends the "F", and using an array constant for the expected readings, sends and waits until the expected characters are detected. I also put in a timeout function so that if the expected string is not detected, the whole loop will stop and generate an error.
0 Kudos
Message 3 of 6
(3,298 Views)

One thing I noticed about your post is that it has a very  structured flow to it. Have you considered making a state diagram VI? With defined steps of sending, waiting, moving on, etc... this type of architecture is perfect for your application. To create a simple state diagram VI use a TypeDef Enum with the names (order) of the states, a while loop with a shift register for the states, and a case structure in the loop for the individual states. This should give you the basis for the order of operations, and you simply code each state to do what it needs to. Let me know if you need any help getting it set up. Hope this helps!!

Tyler H.

National Instruments

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

Many thank's Dennis, Tyler and Albert for your contributions.

To Dennis: I would try your solution and comment's the result's here. Transmit non significative ceroes means that the receiver device expects a fixed number of digits after receiving an "F", so if the user want to send "234", the vi has to transmit F00234, to send the five digits expected by the receiver.

To Albert: I attach the current receive vi. They don't have any attemp to send anything.

To Tyler: It would great to know how to start a such state diagram, I'm realy new in Labview.

Again thank's for your time.

Have a nice day!

Diego

 

 

 

 

0 Kudos
Message 5 of 6
(3,266 Views)
Here is a very simple example of a state machine. Look it over and if you have any questions let me know. 🙂
 
Tyler H.
National Instruments
0 Kudos
Message 6 of 6
(3,247 Views)