LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview-arduino PWM

Hello All, happy thanksgiving.

 

I am trying to control a small DC motor using arduino uno, labview with L298N H-bridge board.

 

This is the DC motor: (https://www.amazon.com/Topoox-15000-16500RPM-Electric-Science-Experiments/dp/B073Q2Y3RC/ref=asc_df_B...)

 

This is L298N board: https://www.amazon.com/Stepper-Driver-H-bridge-Controller-Arduino/dp/B07SGX6YR7/ref=asc_df_B07SGX6YR...

 

There are alot of tutorials online and I followed their instructions exactly but I think the problem is that I am not getting PWM output (I tried both the Linx VI and Arduino VI). I confirmed that arduino and L298N are powered because of the green led light. also labview is talking to arduino because "RX" led is blinking green. 

 

This is the tutorial I followed: https://www.youtube.com/watch?v=uMkRuFQsd84

 

What I have tried:

1. I jumped the ENA pin on the H-bridge and I was able to get the motor to move, but when I connect ENA pin to one of the PWM pin on arduino, it doesnt work.

2. When I try to measure PWM output pin (#9 in this case) with oscilloscope, (red to the #9, black to arduino ground), I am not getting any signal, just some sine wave noise.

3. I attached the motor to oscilloscope and fed it PWM signals, I can hear the motor whining between above 500 hz at any duty cycle.

4. I have tried multiple L298N. 

 

Please see attached labview VI.  

 

If anyone have any ideas or experienced this as well please let me know!

 

Thank you!

0 Kudos
Message 1 of 7
(2,403 Views)

Hi wew044,

 

I'd suggest the most likely problem with the code you attached is that you're writing the PWM value in a fairly fast loop. It may be that it is being reset each time you write the value.

 

Try moving the PWM Write Pin.vi outside (before) the While loop, and see if that changes the behaviour.

You might also like to read about Event Structures, because it would probably help you create a responsive VI without the need for a "polling" style loop (as you have now).


GCentral
0 Kudos
Message 2 of 7
(2,340 Views)

Hi Sin,

 

Thanks for the suggestion however it didnt help. It is weird, I was observing the arduino uno board as I run the labview program. The RX light flashes green for a few seconds and then it stops.

 

Do you think its a communication error? Although I can run the same set up on arduino IDE...so i suspect there is some sort of labview communication issue with Uno.. but i am not sure how to troubleshoot this.

 

 

 

 

0 Kudos
Message 3 of 7
(2,311 Views)

It's possible that was a response to your other similar post, but I'd just want to check - is the Arduino connected to the ide whilst you're testing with LabVIEW? 

 

If so, the Arduino IDE will hold the COM port and you won't be successful connecting with LabVIEW. 

 

I don't remember if you already commented on this elsewhere, but do any of the VIs/nodes you're using give an error?


GCentral
0 Kudos
Message 4 of 7
(2,306 Views)

Hi cbutcher,

 

I made sure arduino IDE is closed before running on labview. and there was no error in the VIs/nodes.

I did noticed something strange though - when I ran with arduino IDE, there was one time where the motor was still running even when I closed arduino IDE. I unplug/replug the wiring and the motor was still running. I had to unplug my Uno and restart my computer for that to completely stop. Do you think somehow the COM port is still holding up?

0 Kudos
Message 5 of 7
(2,299 Views)

@wew044 wrote:

Hi cbutcher,

 

I made sure arduino IDE is closed before running on labview. and there was no error in the VIs/nodes.

I did noticed something strange though - when I ran with arduino IDE, there was one time where the motor was still running even when I closed arduino IDE. I unplug/replug the wiring and the motor was still running. I had to unplug my Uno and restart my computer for that to completely stop. Do you think somehow the COM port is still holding up?


What is the Arduino running when you're not using LabVIEW? I thought if I remember your example correctly you're using the LIFA toolkit, so that uses a custom Arduino program. Is that being correctly loaded?


GCentral
0 Kudos
Message 6 of 7
(2,253 Views)

The arduino isnt running when I am not running labview. The arduino IDE is closed and RX and TX led is not lit. 

 

I actually loaded LIFA and Linx into labview. and I have tried both VI, none of them was able to communicate with arduino Uno thus far. I followed the directions (see link) to load them. Is there anyway to check if it is loaded correctly? The led lits up when loading them.

 

LIFA: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P8ilSAC&l=en-US

Linx: https://www.instructables.com/id/Getting-Started-with-LINX/

0 Kudos
Message 7 of 7
(2,241 Views)