02-15-2012 02:03 PM
Here is what I tested
02-15-2012 02:26 PM
yet another test the data send at from the PC is slow then the rate of data received.
And also asynchronis, so beginning to think it is not possible (only at slow rates).
02-15-2012 02:48 PM
Changing the last example to timed loop is better, but then would it be possible to synchronize the timed loopt to the termination character or the received data (within a certain range) ?
Why can't I edit my previous post?
02-15-2012 03:10 PM - edited 02-15-2012 03:11 PM
there is a few minute window to allow you to edit, looks like it was about 20 minutes between your posts, which is longer than the window.
You could try looking at the various time outputs of the timed loop and adjust the next loops timing accordingly. When you create a timed loop it has terminals on either side of the inside of the loop. Left clicking on them brings up a drop box with "Select Output" with a "previous interation timing" from which you can tell if the loop went long or not, adjusting the timing on the right hand terminal.

02-15-2012 03:14 PM
Yes have found those block the loop now is within 2ms always. but the send data is not in sync with the dsPIC, what I ment is it possible to trigger timed loop with the serial dat in.
02-15-2012 03:20 PM
Working backwards through your questions....
There is a time limit on how long you can edit a post. After that you need to reply, creating a new post.
You have conflicts in your code: You have termination characters enabled (default). You have the termination character set to a character not in your dataset (line feed - also default). You are using Bytes at Port (conflicts with termination character). And you are running this in a loop much too slow for your data. You have already been told most of these things.
Fixes: 1. Set the termination character to carriage return. Read the detailed help for the Configure Serial Port VI.
2. Get rid of Bytes at Port. The termination character will end each read when a carriage return occurs in the data.
3. Take the Wait functions out of your loop. You cannot set a wait less than 1 millisecond but you need to read about every 65-70 microseconds. The VISA Read will wait until it sees the carrriage return.
Lynn
02-15-2012 03:33 PM
1: I always had this on carriage return, so no problem there. It is indee \lf by default but set it to \r (or 13 decimal)
2: I will try that didn't know that, shall try it.
3: wait function delete when I changed the loop timed loop.
02-15-2012 03:44 PM
The code I now have seems to work on 500Hz. I will test it tomorrow if it realy works.
Thanks for the great support.
02-16-2012 01:12 PM
I changed the code to 500Hz most of the time it works but after a while it sometimes receives incorrect data
See attachment error, and also the VI.
Can I improve the VI so there are no false reads ?
Also the data at serial port says there 951 bytes when it is in fact only 12.
02-16-2012 03:35 PM - edited 02-16-2012 03:37 PM
Are you getting an Error on your VISA read? Hook up an indicator on the error wire. If you aren't getting the correct data, then conversion from string to an integer may be resulting in zeroes, which you are seeing on the graph.
Is the value in the bytes at port growing over time? You may be accumulating data in your buffer. You say "when in fact it is only 12". What make you say that? Because that is what the Received bytes indicator shows? What is that indicator attached to, because it doesn't exist in the VI you attached. You are requesting 20 bytes. Your termination character is enabled and set for the carriage return character. You may have 952 bytes in the buffer, you ask to read 20. You get 12 because that 12th character is the carriage return. Then you write some data.
If your serial port is getting packets of data that each end with a carriage return faster than you read in the loop, you are going accumulate bytes in your serial buffer.