cancelar
Mostrando los resultados de 
Buscar en lugar de 
Quiere decir: 

Read Array from Serial

I am able to write to elements in an array but am having an issue reading. Can anyone take a look at my attached .vi and give me some feedback?

 

Thanks,

Nathan

0 kudos
Mensaje 1 de 13
4.545 Vistas

Hi najossmith,

 

I am able to write to elements in an array but am having an issue reading. Can anyone take a look at my attached .vi and give me some feedback?

There are a lot of issues, not just the array reading…

Why do all your controls miss their label? NEVER delete the label!

Why do you insert to an existing array all the time?

Why do you need a second loop to send that string again and again to your device?

Why do you typecast your array to string? Why do you typecast the received string back to an array?

Does the formatting of the sent and received string correspond to the requirement of the device connected to your serial port?

See this:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 kudos
Mensaje 2 de 13
4.537 Vistas

What exactly is your issue?  What is not happening that should be?  What is happening that shouldn't be?

 

I do see an issue with your code in that most of your controls don't have any labels.  Every control and indicator should have a label to give it a name.  You can choose to hide the label on the front panel if you want to, but they should be named.  That is why your local variable has a question mark.

 

Also, why are you using individual scalar controls to write to an array that is a control?  Because your array control is empty, the Replace Array Element has nothing to replace and you are left with an empty array.

0 kudos
Mensaje 3 de 13
4.534 Vistas

Correct, the formatting has to do with the device on the other end. 

 

I attempted to build what you posted, but I am still not getting that values I am writing to show up in the read array. I have it attached if you could take a took.

 

Thanks,

Nathan

0 kudos
Mensaje 4 de 13
4.513 Vistas

Should happen: I write into the array attached to the Write and it then shows up in the array connected to the Read.

 

What is happening that shouldn't: The read array stays grayed out.

 

Adding labels didn't fix my problem and your last issue is resolved by populating the array right after I start the program.

 

Thoughts on how to get the Read to pickup the write?

 

Thanks,

Nathan 

0 kudos
Mensaje 5 de 13
4.511 Vistas

Hi Nathan,

 

Correct, the formatting has to do with the device on the other end. 

So what is that device? Manufacturer? Type/model?

Any relevant documentation? Did you read it's manual?

Can you describe the string format expected by that device?

 

I attempted to build what you posted, but I am still not getting that values I am writing to show up in the read array. I have it attached if you could take a took.

So you attached your VI from your first post again.

Without any of our suggestions taken.

Still no labels, still that nonsens ReplaceArrayElement, still that nonsense loop…

 

Thoughts on how to get the Read to pickup the write?

Read the manual of your external device.

Which string format does it expect?

Which string format is used for the answer of that device?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 kudos
Mensaje 6 de 13
4.509 Vistas

I attached the wrong .vi, sorry about that, here is the corrected one.

 

The other end will just be an Arduino, I can set it up to read/write anything so I'm less worried about that part. I just need to prove to myself that I can write an array on LabVIEW and then read it over the serial port.

 

Example End goal:

LabVIEW writes array (255,3.3, 0, 0) over serial

Arduino reads array and executes the command.

Arduino updates array to (255, 3.3, 24.12, 1.4)

LabVIEW reads updated array

(loops continuously)

0 kudos
Mensaje 7 de 13
4.503 Vistas

So does this latest VI work or not?

 

I don't have a serial port to funnel the data through at the moment.  Or a serial loop back adapter.  But  the array to string and string to array functions seem to work like they should.

0 kudos
Mensaje 8 de 13
4.493 Vistas

It doesn't, but I am told that I can't read and write the same array all within LV without an external device setup in between? If that's the case, I need to setup my Arduino to send out an array first.

0 kudos
Mensaje 9 de 13
4.489 Vistas

You are sending an array out of the serial port, you are trying to read the array in from the serial port.

 

What do you have in between right now to turn the array back around from the transmit pins to the receive pins?  What is connected to your serial port?

0 kudos
Mensaje 10 de 13
4.487 Vistas