11-19-2020 01:58 PM - edited 11-19-2020 02:00 PM
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
Solved! Go to Solution.
11-19-2020 02:31 PM
11-19-2020 03:08 PM
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
11-20-2020 01:03 AM
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.
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
11-20-2020 01:57 AM
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?
11-20-2020 04:59 AM - edited 11-20-2020 05:02 AM
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
11-20-2020 05:52 AM
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.
11-20-2020 07:25 AM
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
11-20-2020 07:34 AM
@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".
11-20-2020 07:42 AM
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