LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview and arduino

Hi everyone. I want to blink an LED using arduino and labview. the problem is that the labview don't send command on serial monitor in arduino until Highlight Execution botton pressed. can anyone help me 

Capture.JPG

0 Kudos
Message 1 of 9
(787 Views)

Hi mgajh,

 


@mgajh wrote:

the problem is that the labview don't send command on serial monitor in arduino until Highlight Execution botton pressed.


How do you know your VI does not send anything to the serial port? Do you get any errors in your VI?

 

Cleanup your VI:

  • Remove all coercion dots by using proper datatypes.
  • I recommend to use FormatIntoString instead of a big ConcatString node.
  • Enable display mode indicator on ALL string constants!
  • Place a suitable wait inside your loop: do you really want to send a command each µs?

General suggestion: don't use the same serial port with two programs in parallel.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(783 Views)

Since you're since some million commands/sec i'd guess the Duty cycle resets each time causing the LED to never change. 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 9
(741 Views)

@mgajh wrote:

the problem is that the labview don't send command on serial monitor in arduino until Highlight Execution botton pressed. can anyone help me  


If it only works in Highlight Execution, then you have a race condition.  In this case, I fully agree with the others that you just need to add a wait in your loop to limit how quickly you are sending messages to your Arduino.

 

The other option would be to have your Arduino echo whatever it read back to the PC.  This would help the debugging process as you will have a clue that it read what you wanted it to and it will limit the loop rate as VISA waits for the response.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 9
(733 Views)

First of all, I want to thank you for your good and useful explanations. In the beginning you mentioned how you found out that the lip view was not sending the command. I tried the code with arduino serial monitor and it sent the command without any delay or problem. All the connection items such as port and... are correct for LabView. Using format into string, I managed to send the command without Highlight Execution, but there are still two problems:

First: the command is sent with a delay

Second: After a few seconds, the system exits its normal process and returns to the first state

 

Putting a timer with different values didn't help either

0 Kudos
Message 5 of 9
(676 Views)

Thanks for your response. putting timer with different values doesn't help. Can you elaborate on your second suggestion?

0 Kudos
Message 6 of 9
(698 Views)

Hi mgajh,

 


@mgajh wrote:

Can you elaborate on your second suggestion?


All the other suggestions:

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 9
(690 Views)

@mgajh wrote:

Can you elaborate on your second suggestion?


Write your Arduino so that when it receives a message, it sends that exact message back to the PC.  On the LabVIEW side, you do your write and then start to read it back.  When the read succeeds, you know that the Arduino received your message and what the message was.  When your Arduino gets back to trying to read the port, another message will have already come in, but the LabVIEW code will be waiting for that return message.  With this setup, the Arduino is what is limiting the loop rate of everything.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 9
(673 Views)

Hello I'm doing the same thing almost, well want to, but I have 3 LED's connected in arduino and I want to program in the way that through labview the led's would turn by random, let's say if I press one button the first led turns on if I press 2nd button the 2nd led turns on without turning the 1st off, and like 3rd button would turn off only 2nd LED. Where do I start? Maybe someone has a similar thing?

0 Kudos
Message 9 of 9
(592 Views)