LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial continuous data with pic18F4580

Hi all,

 

I am using LabVIEW to acquire data (via UART) from pic 18F4580. The idea is Labview send a character which is 'S' to start acquiring data from 8 adc channels from the pic. For the next frame, again charadter 'S' will be send to the pic. The LabVIEW continues to read the data till number of frame is achieved. A frame can be describe to acquire a sample from all channels (ch0-ch7) which in total are 8 samples. If the number of frame selected to 2 then the VI will read 16 samples (8samples x 2frames). I programmed the pic to start send samples from 8 channels when charadter 'S ' is received. The 8 samples will be sent continuously. My problem is the sample data are good for the first 8 samples however when it comes to the next frame it starts to give errors. I verified the pic program and the program can run continuously. Can anyone assists me what is wrong with my VI?

 

Thanks

0 Kudos
Message 1 of 8
(3,978 Views)

And what errors are you getting?  Do you want us to guess?

0 Kudos
Message 2 of 8
(3,955 Views)

Hi,

Sorry about that. The error message is 'VISA Read in queue &dequeue UART 18F4580(a).vi' and the error code is -1073807339. I also verified with hyperterminal and I can observe the samples running continuously. Please help.

 

 

0 Kudos
Message 3 of 8
(3,931 Views)

That is a timeout error.  You are requesting 1000 bytes.  You do have the termination character enabled by default and it is a linefeed by default.  If you don't get 1000 characters within the timeout period (10 sec by default) or get the termination character, then the VISA read returns after 10 secs with what it has and gives you a timeout error.

 

If you are only expecting 8 bytes, then wire in an 8 to the VISA read.

0 Kudos
Message 4 of 8
(3,906 Views)

Hi,

 

Thanks for the reply. I followed the advice and make some changes in the VI. I also changed  input of the byte count and I found when number of frame=1, the byte count value which gives correct value for the sample data is 5. However when it comes the number of frame =2 same problem occurs. The sample hung at sample 9.Smiley Frustrated

 

0 Kudos
Message 5 of 8
(3,892 Views)

Get rid of the Bytes at Port node because you aren't doing anything with it.  There are also some othere nodes in there that are dead and can be eliminated such as 255/255 x 5 goes nowhere.  The VISA Serial configure has inputs to enable/disable the termination character and set it.  Use that rather than dropping in the extra property nodes.  Also, there is no need to flush the buffer since you just opened it.

 

Use block diagram cleanup to straighten up your code.

 

How do you know whether you are getting 1 frame or 2?  If you know, then select how many bytes to read depending on that value.

 

What does your data look like?  From your conversions, it looks like you might be reading ASCII values, i.e.straight up human readable numbers.  If so, get your PIC to send a termination character at the end of every packet.  Then enable termination characters, read a large number of bytes like the 1000 you had before, and now you know you'll get complete messages without errors or timeouts.

0 Kudos
Message 6 of 8
(3,880 Views)

Hi,

 

I attached the sample data (Volts) acquired from all channels using hyperterminal. The code is when I pressed character  's' data from c0 to ch7 are displayed.  The code will displaying samples whenever character 's' is pressed. However in LabVIEW I tried to make it continuously with  'A" as termination character or end of frame (8 samples / frame). The VI runs till reached the number of desired frame. The result is as same as in previous discussion. 

Download All
0 Kudos
Message 7 of 8
(3,811 Views)

Maybe you should set your termination character to be 'A', or 0x41, since that is the end of your frame.  Then you will get all four measurements in a single read.  Also, change the number of bytes to read to be a lot higher, like 50, to ensure you get your whole message.


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