04-06-2017 09:14 AM - edited 04-06-2017 09:17 AM
Hi,
I send 10 byte data every 4ms from MCU(stm32) to PC(labview).
The MCU does not send zero value, but my labview visa program output zero frequently(not all data).
The uart of MCU is not problem(i check by another serial communication program).
Send data is
0xBE, 0xD7, uint8_t data1, uint8_t data1 data2,uint8_t data3,uint8_t data4, uint8_t data5, uint8_t data6 ,uint8_t data7 ,uint8_t data8
The 0XBE and 0xD7 are STX of protocol.
I attach my labview program.
What is the problem?
Solved! Go to Solution.
04-06-2017 09:38 AM - edited 04-06-2017 09:40 AM
1. You do not need to wire up all of the index inputs on the Index Array. The first will default to index 0 and they just add by 1 from there.
2. No need to put a wait in the loop. The VISA Read will do the waiting for you.
3. Since you are dealing with binary data, turn OFF the termination character on the VISA Configure Serial Port.
4. You can right-click on the case structure and select Radix->Hex to make it a little easier to read.
5. Make sure you have a way to properly stop your VI. DO NOT USE THE ABORT BUTTON IN THE TOOLBAR!!! Add a stop button to your front panel and use that. This way you can properly close down your serial port and file.
6. Since you are just getting 16 bit data, I would use the Unflatten From String with a U16 as the data type. This will extract your 16-bit data and leave the rest of the string for other parsing. So you can just use 4 Unflatten From Strings to get your four channels of data.
7. You can do some really cool things with the Format Into String to make it easier to figure out what is going where just by using the Format String.
04-06-2017 09:43 AM
It sounds like you are sending binary data, and the way you've structured the reading of your bytes seems to match your data packet description.
What I do see is that on you Serial Configure, you have nothing wired into the termination character connections. That means it will default to True (termination character enabled) and Decimal 10, (termination character is line feed. So any time your 8 bytes of data would contain a decimal value of 10 as one of the bytes, that VISA read will end before you've read all 8 bytes.
Wire a False Constant into the "Enable Termination Char (T)" input for the serial configure.