LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String array Arduino

Este es un trabajo que estoy realizando para la universidad, si podrias ayudarme con mi VI

Tengo el siguiente VI, el cual esta conectado por puerto serial, para recibir un string de datos, este se envia en un periodo de 100ms por parte del arduino, este string tiene una cabecera para identificar el inicio con esta estructura 0xAA (1byte), 0x55(1byte), torque(2bytes), pulsos encoder (2bytes), estado (1byte), cksum(1byte), y que estos se envien cada 100ms (string de ejemplo:  AA55 0000 0000 07F8), pero una vez que se establece la conexión por el puerto serial, este llega en un desorden (0000 0007 F8AA 5500), como puedo hacer para a ordenar este string en el roden que se desea como se marca en la cabecera AA55 para que este sea el byte 0 y luego hasta el final 

0 Kudos
Message 1 of 4
(231 Views)

This might just be a framing error.  If bytes are streaming in, read a dozen or so bytes, search for the start message byte 0xAA, and decode the next message starting there. To be more specific, your code may have started reading part of the end of the previous message and missed initial part of the message

0 Kudos
Message 2 of 4
(206 Views)

You also have serious logical problems, for example unflattening a two byte little endian string to I32 makes very little sense. What is the actual representation for Torque and encoder (U16? I16?)

Most likely you could just unflatten the entire string to a cluster of the various data parts.

 

You seem to receive binary data, but have a termination character enabled, do there is a nonzero chance that your string gets truncated.

 

Your AA55 string is in normal display (4 characters). I can guarantee that the two characters read from the string will never be four characters! Change the diagram constant to hex display and reenter the AAFF value

 

Why is the byte count a control that defaults to zero? Shouldn't that be a diagram constant? Same for the wait.

 

This all seems very fragile.

0 Kudos
Message 3 of 4
(175 Views)

@altenbach wrote:

Most likely you could just unflatten the entire string to a cluster of the various data parts.

 


Here's how that could look like (all other advice still applies, especially regarding the termination characters, etc.)

 

altenbach_0-1722036515734.png

 

0 Kudos
Message 4 of 4
(170 Views)