04-03-2015 09:34 AM
help me, please ! i'm connecting labview to MCU by virtual terminal . i use pic 16f887 to transmit data from MCU to labview, MCU transmit 12 datas regarded as 12 channels. but there are still errors. i simulate on proteus , write code on ccs.
04-03-2015 11:52 AM
Why are you using bytes at port? That loop is running as fast as it can and just grabbing whatever bytes happen to be at the port, or even no bytes. You are likely to have incomplete messages.
Does the device send a termination character? Use that. Just read a sufficiently large number of bytes and the VISA read will return the complete message once the termination character arrives.
04-03-2015 08:33 PM
i think that the property bytes at port used to transmit datas which have big size, when i remove the property bytes at port, my code don't active and there is error.
04-03-2015 08:41 PM - edited 04-03-2015 08:55 PM
Is your problem solved? You marked my post as the solution. But then you say "and there is error".
Are you getting an error? If so, give some details like the error number or description.
I'm confused by your last message.
Looking at your text based code, it looks like you aren't sending a termination character. You are sending a literal backslash 'n' backslash 'r'.
You aren't sending a linefeed character (the default terminator for LabVIEW's configure serial port VI), which you send if you were doing a printf of chr$(10) or something like that.
04-03-2015 10:02 PM
sorry, i pressed wrong, I still unsolved, i use printf("\n\r")(\n : new line, \r : carriage return) to create space between 2 datas because labview's program take three of the first number to check channel and next the number ( before excute printf("\n\r") ) is the value to display on waveform chart.
b[] is the array contain channels and a[] is the array contain values.
MCU send the value regarded as channel. (sorry i know a little english)
04-04-2015 10:52 AM
But printf("\n\r") sends 4 characters. The backslash, the letter n, the backslash, finally the letter r. That is not the same thing as a new line feed character and a carriage return.
You should visit a forum that discusses C-based code to learn how to send the line feed and carriage return characters.
04-05-2015 08:29 PM
sorry, i don't understand. i think printf("\n\r") command used to create distance between 2 channel, it don't influence labview's execution
04-05-2015 08:34 PM
You still haven't said what error you are getting.
Yes "\n\r" separates some values, but they ARE NOT the carriage return or line feed termination characters. (If that is what you mean by "create distance".
04-06-2015 03:05 AM
you can see in the picture 2.
for example : the signal 2, MCU always send one value is 2 regarded as the channel 2 but sometime signal is 0. i don't know how to repair that error
04-06-2015 06:40 AM
You will need to debug your own C code.