LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

can you tell me if this serial communication is okay?

I need the next:

 send and  receive  data. I send  commands to device for  power, play pause or reset. I use a booleans buttons, for example if power is true, I send the number 1 for serial write port, and if is false I send the number 2 for serial write port  and  so with the others( pausa reset and play) each one is assigned one number  in true case o false case. The serial communication is with microcontroller.

Me too need to receive data from the microcontroller in labview, for other application. The data is coming of Microcontroller.

 I made a .VI for to get what I want. I attached VI

My guide was the following document:

http://zone.ni.com/devzone/cda/tut/p/id/7907

 

Is OK??.. Thanks!!.. please, revise my program and tell me if its okay.  And if not well tell me what my mistake

0 Kudos
Message 1 of 3
(2,142 Views)

The problems I see.

 

1.  You have VISA configure and VISA close inside your outer while loop.  You don't want to close the serial port and reconfigure it on every iteration.  Move the configure before the loop and the close after the loop.  Only VISA read and writes belong in the loop.

2.  You have to different VISA communication strings going on.  One is writing and one is reading.  Are they going to be communicating with the same port?  If so, you probably should only have one line of execution for your serial port.

3.  What does the inner while loop do?  The inner while loop has one output.  And that will always be the character "0".  Your output string will only send out a value from the last iteration of the while loop.  That will occur on the 5th iteration where i=4 since that is the condition where you stop the while loop.  When you Index array with an index of 4 on a 4 element while loop, you are getting the 5th element of the array (arrays indices are zero-based) which is the default value of the array, zero.  That zero is getting converted to a string, thus the character "0".

0 Kudos
Message 2 of 3
(2,140 Views)

I would like that you put one image with your suggestions.Thanks.

0 Kudos
Message 3 of 3
(2,137 Views)