From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Initialization and COM port set problem

Solved!
Go to solution

Dear Sirs,

I get two problem about controlling the Adruino Uno with Labview 2012. I try to find why but still fail.

1. For init block, the program could work well if I don't mannual assign the VISA resource (I just unwire any thing to this pin). However, if I use a control to choose the corresponding COM port, it works well only for once. While I stop the program and run the program again, the TX led keeps flash and RX is off. Please check the attached file Arduino_01.vi. It does confuse me.

2. pin 6, pin8 are used in my project valued by pointer slider and initially zero. However, while running th Labview program, the pin6/pin8 would ouput some value to make the PWM-driven circuit running. After about 0.5s, pin out is ok and zero. It seems that if I only use Arduino IDE to coding, it would not happen.

I stuck here for several days and really need someone to help me figure it out. Appreciated~

Many Thanks

Jeff

0 Kudos
Message 1 of 9
(5,645 Views)
  1. If you use the abort button (the little stop sign on the tool bar), you will get strange behavior.  Avoid using this button to stop your VI, use the stop button in your code.
  2. I don't see any PWM functionality in your code.

Also, you should consider switching to LINX (LIFA is no longer officially supported):  https://decibel.ni.com/content/thread/21731

Message 2 of 9
(4,156 Views)

Hi Nathan,

Very thanks you to explain the 1st problem. It works well.

And, it seems that the abort "buttom problem" only happens in "LIFA+Labview" and would not cause problem in other VI?

I upload the code with PWM and would try to transfer from LIFA to LINX. Thanks again~

Jeff

0 Kudos
Message 3 of 9
(4,156 Views)

And, it seems that the abort "buttom problem" only happens in "LIFA+Labview" and would not cause problem in other VI?

No, it is not specific to LIFA.  There are many cases where you should avoid using the abort button.  Generally, if you open something that needs closed (like a VISA resourse in the case of LIFA), you should not use the abort button if you don't have to.  If you do use the abort button, you can release the VISA resource by opening Close.vi, selecting the appropriate COM port on the front panel and running the VI.

I upload the code with PWM and would try to transfer from LIFA to LINX. Thanks again~

I don't understand the issue that you are describing.  The only thing that I see wrong with the code is that you need have all of the LIFA VIs, in-line (one after another each using the resource wire from the LIFA VI before it).

Message 4 of 9
(4,156 Views)

Hi  Nathan,

Thanks you again.

Follwing your instruction, I modified the code with blcok in-line rather than parallel.

I run the program with two different inital condition (with pointer scroll bar), and log the PWM output pin-6 data.

a: PWM duty= 100 (0~255)

a.jpg

b: PWM duty= 0

b.jpg

As shown in these two figures,the pin-6 would be "high state" for about 0.5~1 sec, which would trigger a follwed PWM-driven motor-driver.

I would like to elimitate this "high state" just at the beginning of the LabView code running.

Many Thanks

Jeff

0 Kudos
Message 5 of 9
(4,156 Views)

What are you using to measure the signal?  Also, how are you setting the PWM duty cycle?  Are you moving the slide?  This will cause intermediate values to be sent to the Arduino.  I would try to set the value directly to your wanted duty cycle using a regular numeric control or using the digital display on the slide and typing in the number and then hitting enter.

0 Kudos
Message 6 of 9
(4,156 Views)

Hi Nathan,

I use USB6000 (NI DAQ) to measure the signal. For b. case PWM=0, I do not move pointer slide bar.

I use an external LED+R, wired from Pin~6 to GND, and take a video, link-->

https://dl.dropboxusercontent.com/u/22802178/MOV_1494.mp4

First, I show how I wire "LED+R" to Arduino Uno Board. (Pin~6 to GND)

Next, I show that I use input box to replace slide bar. The initial value is 0.

Next, I click on "run" botton.

Then, it shows how on board LEDs and external LED lights.

Many Thanks

Jeff

0 Kudos
Message 7 of 9
(4,156 Views)
Solution
Accepted by topic author jianfengtsai

Have you tried each of the PWM pins?  I've read some people having some issues with certain pins going high when everything boots up.  If it happens regardless, you may need to add in some custom code in the firmware to set up the pin before LIFA even sends/receives commands.

Here is a discussion about pin states being unexpected values.  They said upgrading to LINX fixed the issue (which is what I recommend that you do).

0 Kudos
Message 8 of 9
(4,156 Views)

Hi Nathan,

Upgrade from LIFA to LINX. Everything is solved.

Many Thanks. \o/

Jeff

0 Kudos
Message 9 of 9
(4,156 Views)