LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa port speed

Solved!
Go to solution
Highlighted

Dear friends

 

Continue working in the project

 

https://forums.ni.com/t5/LabVIEW/Visa-port-string-and-substring/m-p/4085976#M1176008

 

I have a few questions and important for me understanding serial communications

 

1- I am creating a labview program to read a string from arduino.

I have some dificults to adjust the loop time with loop time from arduino, and if labview is lower than arduino, data starts to be stucked in serial port and becomes with a delay.

If labview is too fast, some times string is empty and the data in graphs goes to zero.

 

 

2- The first versions the loop times were around 1s, and it works good for receiving data and for sending some commands (letters) to arm some relays.

After changing the loop time from arduino to 100ms and labview too, the sending process starts not working good, some commands take some time (about 10s) to arm relays. Strange...

 

Best

cpalka

 

0 Kudos
Message 1 of 28
(231 Views)
Highlighted

Hi cpalka,

 

use TermChars for your communication, so LabVIEW automatically adjusts its loop speed to incoming messages...

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 28
(209 Views)
Highlighted

Hi Gerd

 

Thanks for the reply

 

I ear something about it, but I really know only a litle bit about it.

 

Can You help me to implement it in my code?

I read about it and about /n Terminal Character.

How can I make it? 

I have some print commands in arduino, what is the TermChars tha I should print in arduino that labview recognises and how can make a change in labview to adjust its loop time?

 

I will appreciate your help

 

Do you want tosee my code?

 

best 

cpalka

 

0 Kudos
Message 3 of 28
(202 Views)
Highlighted

Hi Gerd

 

I remove BytesAtPort, replace for a constant (big number) to give number of bytes in serial read.

Remove the loop time in labview, and works! The labview refreshs each time it has a reading.

 

cpalka_0-1605855492499.png

 

Now the problem is to write, I use a case structures, but when I turn for true some cases it sends a "letter" to activate a relay. I can see that the letter was sent but arduino only arms relay after a few secounds

 

 

 

 

 

best regards

cpalka

0 Kudos
Message 4 of 28
(160 Views)
Highlighted

We can't debug your code, since you sent an image and not the actual vi. Nor we can know how the Arduino is programmed.

However, since Arduino reacts to the command, it seems that the problem is in the Arduino software.

You can be confident that the output string is sent immediately, and not after some seconds. Are you sure you are not missing part of the protocol?

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 5 of 28
(152 Views)
Highlighted

Hi

 

Sorry for that.

In the communication window from arduino soft I can send the commands and it reacts to the commands. From Labview with 100ms in arduino, no.

 

best regards

cpalka

 

 

Download All
0 Kudos
Message 6 of 28
(143 Views)
Highlighted

I notice that in the LabVIEW program you are sending more than one command in a very short time. Maybe the Arduino firmware does not like it.

Try first to send only one command for each iteration and see what happens. If this works, you can try inserting delays between commands or interleaving different commands.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 7 of 28
(135 Views)
Highlighted

Hi Friend

 

I did tryed it, I delete all letters in cases and I let only one write block with a text box, I write each letter and send but does not works. Maybe I need to delete all structure cases and let only one.

Other thing is with 1000ms and 500ms loop time, labview works, for 100ms no.

 

The arduino code is strange and was made by another person, for changing the loop time has 2 places to change...

 

The strange is by the arduino window I send each command and it accepts well.

 

best regards

cpalka

 

0 Kudos
Message 8 of 28
(119 Views)
Highlighted

@cpalka  ha scritto:

The strange is by the arduino window I send each command and it accepts well.

 


I don't think you can send commands every 100 ms with the "Arduino window".

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 9 of 28
(112 Views)
Highlighted

Sorry

 

I did not explain well

 

I change the loop time and print time in arduino for 100ms

In the display window from arduino soft, I see the strings came too fast.

In the box to send commands, I write a letter for relay 1 for example, and relay 1 arms

I send another letter and the relay turns off

I dont want to send commands at this speed, I only need data from arduino a this speed, but for sending, I need to send 3 or 4 commands

0 Kudos
Message 10 of 28
(109 Views)