LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa Uart communication problem

Hello i am doing a project that includes data data acquisition, i am using ICM20948 sensor for gyroscope, accelerometer and magnetometer it works perfectly fine and i sent the data from my microcontroler stm32 to labview with UART connection the data is good before i send it so i think there is a problem in reading data in labview if anyone can point out my mistake i would be thankful. 

 

I attached PNG of my data charts where you can see sometimes the read is wrong and i get random peaks to -400000 for example 

 

also here are my UART settings i used for microcontroller 

 

huart2.Instance = USART2;
huart2.Init.BaudRate = 115200;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

Download All
0 Kudos
Message 1 of 3
(525 Views)

Hi Adweqweq,

 


@Adweqweq wrote:

if anyone can point out my mistake i would be thankful. 


Using BytesAtPort is a big mistake!

Initializing the port in each iteration is a big mistake!

Please watch this video

 

You just need to read 99 bytes from your port, VISARead will handle all the rest as it also recognizes the CR/LF chars in your messages…

 

Also your string parsing is way too complicated: why not use SpreadsheetStringToArray with a comma as separator?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(513 Views)

Thank you for your insights i am knew to this and this was very helpful

0 Kudos
Message 3 of 3
(496 Views)