08-31-2020 05:14 AM
Hello,
Currently I am controlling my Arduino code via NI Visa from Labview.
The issue is that the Labview will work randomly. I think this problem might be that the delaymicroseconds in Arduino with the milliseconds in Labview. I read some other articles in the community regarding connecting my DAQ. I have the NI USB 6218 which has Timing resolution 50 ns.
My question is what should I read with the DAQ, when I dont need it for any measurements for this VI. Any suggestions?
Regards,
Alexis
08-31-2020 05:17 AM - edited 08-31-2020 05:18 AM
Hi Alexis,
your message misses the most important information: your VI and your Arduino sketch. You also need to explain the goal of all your attempts…
@Alexis_Koul wrote:
My question is what should I read with the DAQ, when I dont need it for any measurements for this VI. Any suggestions?
Simple answer: When you don't need the DAQmx device then you don't need to include it in your VI!
08-31-2020 08:06 AM - edited 08-31-2020 08:08 AM
Dear GerdW,
The VI is very simple.. as I said in my initial message sometimes it will work, and sometimes not. Do you think the issue is with the delaymicroseconds? If yes, then why sometimes is working? The code is from an online video..
Regards,
Alexis
08-31-2020 09:28 AM - edited 08-31-2020 09:29 AM
Hi Alexis,
@Alexis_Koul wrote:
As I said, is a very simple VI which I used from an online tutorial..
What's the point of this sequence frame?
Why don't you use AutoCleanup?
How are you reading the received messages at the Arduino? Why do you only show part of the Arduino sketch? (What kind of answers do you expect when showing only small parts of the code?)
@Alexis_Koul wrote:
Sometimes is working sometimes not. What I mean by that is that sometimes when I click the boolean it will work, sometimes it will not. Is very random.
What does not work?
Does LabVIEW miss to send a message to the serial port?
Does the Arduino miss to receive the message?
Does the Arduino receive other messages (like garbage)?
What did you try to debug your setup? (AFAIK the Arduino IDE allows to monitor the serial port Rx/Tx messages!?)
Did you debug your Arduino sketch?
How fast will the Arduino output that single pulse on "a"? Will there be any pulse at all when you output "LOW" on two DO pins?
How do you monitor those pulses from Arduino?
So many questions, but so little information from your side…
08-31-2020 09:58 AM - edited 08-31-2020 10:03 AM
Hello,
The purpose is when I click the Boolean to give the signal a or x, which means that with a the motor is doing nothing, with x is start rotating in specific speed. If I stop the Vi and start it again, the Boolean activation has no response to the motor. If I stop and re-start the VI few times, it will work again..
Was that clear?
08-31-2020 10:11 AM - edited 08-31-2020 10:13 AM
Hi Alexis,
now it starts getting clearer…
@Alexis_Koul wrote:
The purpose is when I click the Boolean to give the signal a or x, which means that with a the motor is doing nothing, with x is start rotating in specific speed.
Your VI is writing to the serial port AS FAST AS POSSIBLE! (This will stuff the serial buffer in the computer and your ARDUINO quite quickly.)
I guess the serial buffer on your computer might show a buffer overrun problem - but you aren't handling any errors in the loop…
When you just want to send some message to your Arduino "when you click the button" then you should use an event structure!
Again: what have you tried to debug your setup? Did you debug the VI? Did you debug the Arduino code?
08-31-2020 10:25 AM
Hello GerdW,
Thank you for your reply.
Regarding the Arduino code, is debugged because if I dont use the LabView but just Arduino, the motor works perfectly, with no errors or issues.
Same for the Setup. I am sure something is with the VI. The event structure is a good idea and I will try it, but then why sometimes works? This is what I cant understand..
What do you think regarding the delaymicroseconds of Arduino? I am asking because the while loop is in ms.
Again thank you!
Regards,
Alexis
08-31-2020 10:39 AM
Hi Alexis,
@Alexis_Koul wrote:
What do you think regarding the delaymicroseconds of Arduino? I am asking because the while loop is in ms.
The Arduino delay is ok - as long as you don't send command message too often…
On the computer side there is no "while loop in ms" - it iterates AS FAST AS POSSIBLE!
08-31-2020 10:42 AM
Hello GerdW,
Thanks for your message. I will try the event structure, hopefully will help!
Regards,
Alexis
09-01-2020 01:56 AM
Dear GerdW,
Good news. I fixed the problem. What I changed was the Serial.begin and baud rate to 115200 instead of 9600 and apparently is working.
Thanks again,
Alex