LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

combine vi with serial write and read

i need to combine project vi. with basic serial write and read vi so then the data received will be my input

i want to make it likes this..first,as u can see in my project vi..i've a 5 element which is motor current, motor temp and etc..i want to assign each one of them as 8bit hex for example motor current = 0000FFFF, motor temp = 000044FF and so on..so if i received hex 0000FFFF, the 8bit hex after that will be my motor current value and be save in my table under motor current then if i received 000044FF,the 8bit hex after that will be my motor temp value and save to table too and so on for other element

0 Kudos
Message 1 of 10
(3,972 Views)

ouh sorry i forget to attach the vi..here it is

Download All
0 Kudos
Message 2 of 10
(3,965 Views)

Place a visa read in your timeout case of the project.vi and interpret the signal.

What specifically do you have problems with?

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 10
(3,907 Views)

Hello icycool,

 

It looks like it will be fairly straightforward to combine your code as you like.  You can initialize the VISA session before the while loop of project1, and close and handle errors after the while loop.  You can pass the reference between iterations of the while loop to keep using the same session.  You already have an event structure with add, clear, and stop events.  The VISA read and write code fits into that structure with write and read buttons.  You can implement the logic for concatenating and parsing the strings with your data inside of those events.  Case structures with the different codes you are using to identify the information may be useful.

 

Hope this helps,

 

Jen W

Applications Engineer

National Instruments

ni.com/support

0 Kudos
Message 4 of 10
(3,896 Views)

is this one right?i cant test it yet bcause the serial connector is not with me

where do i put the case structure then?

0 Kudos
Message 5 of 10
(3,822 Views)

I don't think this is what you want. Your read will occur before the the while loop and will only happen one time time. You need to place the read/write inside the while loop in another event case. Depending on what you want they may be in a single event case (write a command and read the response), two separate events (one for read and one for write) or some part of it maybe in the timeout event (such as a read with a short timeout (one the VISA read) to process data if it is expected to arrive asynchronously.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 10
(3,805 Views)

i dont really get what u mean..is this one correct?btw i just need my program to read continuous data received from another program

0 Kudos
Message 7 of 10
(3,787 Views)

Do you have plans to do anything with the data you read in from the serial port besides displaying it in the Read String indicator?

 

Also, it will only read data on the first iteration of the loop and whenever your event structure exectues by hitting the Add button which allows the loop iteration to finish and then begin again.

0 Kudos
Message 8 of 10
(3,777 Views)

actually i want my program to work like this

first, i want to send some continuous random 8bit HEX from another program using serial connection to this vi.

then using this vi. i want to assign my motor speed, motor current and others with 8bit HEX

for example 0000FFFF is motor speed and 000044FF is my motor current and so on

then if i received 0000FFFF, the next 8bit HEX after that will be my motor speed value and will be automatically put into my table under motor speed

and so on for others

if possible i want to remove the add button and make it add the value automatically after receive it

 

0 Kudos
Message 9 of 10
(3,760 Views)

icycool,

 

From what you have described, you want a series of events to occur in a given order, depending on what happens previously.  This fits very well with the state machine architecture.  For an example of how it is implemented, look at this simple state machine example.  You would have a case for the initial data you send, then another case to assign your motor speed, and a case to recieve data.  In the case to recieve data, you may need to parse your data into 8bit segments.  Inside the recieve case, you can also keep a case structure inside that has a case for every value you expect to recieve, and then you can write into the appropriate column of your table inside the case.  If you did that, you would not need the add button.

 

Hope this helps

 

Jen W

Applications Engineer

National Instruments

0 Kudos
Message 10 of 10
(3,725 Views)