Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA - Queueing

Hi,

I having a problem to read data from ADC transmitted from pic18F4580 via UART. The data transmitted reads from 8 ADCs plus with 0 (originally is *END* which is marked for end of iteration).To complete 1 frame data requires 12 iterations. Therefore for each iteration there will be 9 measurements data. I build a VI using VISA and queue/ dequeue functions to make sure all measurements are available for the next process. When I run the VI, no data are displayed on the front panel. Any advice or what did I missed here?

Regards

Ledang

 

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

Hi,

I suppose there are lack of informations about the problem. I tried to read data which in the following formats:

1.233\r\n

1.333\r\n

.

.

.

*END*\r\n

 

The problem comes form the multiple termination characters (\r\n) for each data received. I searched and found a tutorial which similar to the problem. However I could not I find the function (in the black circle) as attached in the VI palette. Which palette does it located? Another problem is what does the " %[^,],TDS%d " mean? 

 

Regards

Ledang

0 Kudos
Message 2 of 10
(3,526 Views)

You haven't really spelled out what the problem is, just that you aren't seeing data on the front panel.  I imagine you mean in the array indicator.  So have you run the code in highlight execution mode?  Have you then used probes to see what's read and what gets added to the queses?   Have you tested the read in a simple case rather than with queues?  (i.e. is the problem with your architecture or with your communications?)  Is that file data what you are actually reading?  I'd also expand the VISA read characters to say 50, since you are using termination characters anyway it doesn't hurt to add extras in case you are occasionally getting longer strings.

 

VISA supports \r\n as a return character.  See the string palette for the primitive.  You would use the VISA serial config to setup the right return character or the property node like in your picture.  The primitive in the picture you show is the type cast primitive, which is found in the sub-paletter "Data Manipulation" from the Numeric palette.

 

As a note, always better to attach your code than pictures of it if you want help!

Craig

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

Hi,

Thank you Craig for the advice. It's my bad for not putting the code and for not fully understanding the problem. Sorry for that.. Back to the problem...I make  a simple queue/ dequeue using array string with \r\n to replicate the data received from the serial port (COM3) and found out the error remains. I make some changes based from earlier forum discussion about multiple termination characters and the updated Vi is as attached. I tried running the VI with received data from ADC (dspic30F6014) via UART  and it works much better that the previous VI. It counts and stops at required no.of frame. However I found some problem when run button clicked  for the first time. The VI will error and message " An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @. So what I did, I refresh and select COM3 and VI runs again with no error till it stops. Is the VI reads remaining data from the previous execution? From my understanding it should not happened as VI flushed the remaining received buffer before VI close the VISA session in previous execution.

Another thing is when \n is set as termination character should at the READ BUFFER indicator the \n has been removed from the data? It \n still remain. However I still get the correct data and perform calculations with it.

 

Regards

Ledang

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

Sorry I forget to attached the VI

 

Ledang

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

Hi

Not sure that it a solution but you are comparing two floating point numbers in your consumer loop. Make sure that this really works. This means that every bit, also the non visible bits of the float should be equal!

Maybe easier to compare on Greater Than then on Equal.

 

greetings from the Netherlands
Message 6 of 10
(3,484 Views)

I agree with Albert, it doesn't look like your consumer loop logic is working.  Comparing floating point numbers as equal is not a good idea.  If "9.999" is somehow a special value, compare the incoming string in string format before conversion to float.

 

To test your VI's consumer logic more easily replace the serial input with a case structure, like attached.  Make the cases match the data pattern you showed and then check the logic using highlight execution.  (I just inserted random values and 9.999 to see if it works and it seems too.) 

 

If your goal is feedback of what you are collecting, you might want to build the arrays inside the consumer.  Right now nothing will appear in your array indicator until the consumer loop stops running.  

 

Craig

Download All
0 Kudos
Message 7 of 10
(3,477 Views)

Hi Craig,

Thanks for the advice. However I could not open the files given as I am using Labview 2013. I  requested for file conversion but still no response.Can snapshot the VI?

 

Regards

Ledang

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

Should have just asked here earlier, its easy to save for previous versions.

 

Note that I'm still not 100% clear on what problem you are trying to solve, so I took out the serial comunications and added the case structure with fake data and a shift register and delays to show you how data is being consumed.  Verify the logic then try it again with the serial data.

 

Craig

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

Hi,
I modified the VI as advised. The VI should read 144 measurement values + 1 end marker which is '9888'. The baud rate is set at 9600. However I found several problems with the VI as listed below and request if someone can assists me :
a) Whenever I start the VI (the microcontroller has started earlier) an error message "VISA Read in 144 Measurement Data with queue-dequeue.vi" error code -1073807252 and "Get Queue Status in 144 Measurement Data with queue-dequeue.vi" error code 1. I need to start several times before it can run without error.
b) When in runs, in consumer loop: Update & display image in 4x4 map, the displayed images are not display continuously. Several times the 4x4 map is blank without any values. I'm expecting the 4x4 map update continuously. When the VI is running the number in queue is 0. I checked the number of frames the VI executes in the consumer loop, it executes accordingly. 
c) The VI runs with specified number of frames. Producer loop will stop when the number of frames has achieved. However when the VI stops an error message "an input parameter is invalid...". How to remove the error?
From the given problem what I overlooked here?

Regards

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