Hobbyist Toolkit

cancel
Showing results for 
Search instead for 
Did you mean: 

[LabVIEW LINX] - How do I change the frequency of the PWM function?

How do I change the frequency of the PWM function?

 

rodrigo_silva_0-1632417225651.png

 

 

By default it is at 500Hz, I need to change it to 200Hz.

0 Kudos
Message 1 of 9
(3,150 Views)

It does not look like the frequency control has been brought out as an input the the VI.  I found this which explains the interworks of the PWM Set Frequency but I am not sure the exact context.  Maybe this is used inside the PWM Set Duty Cycle VI?  I have not looked at this on a system with LINX installed.  https://www.labviewmakerhub.com/doku.php?id=learn:libraries:linx:spec:pwm_set_frequency

 

What device are you connecting to in which you are using the PWM on?  If is is a Raspberry Pi you may want to check out the LINX Raspberry Pi Addons by MediaMongrels.  It may have the functionality you are looking for.

David Wilt
The New Standard LLC
0 Kudos
Message 2 of 9
(3,117 Views)

I am using arduino UNO.
My application needs 200Hz.
I was using the Serial library, but it is very unstable and communication is dropping all the time.

rodrigo_silva_0-1632482036346.png

 

With LINX it is very stable, but it doesn't have this function.

The NI Library for arduino also does not have this PWM frequency setting.
Here's this tip for NI to apply for this library.

Can we change this frequency (NI library)?

rodrigo_silva_1-1632482201328.png

 

0 Kudos
Message 3 of 9
(3,098 Views)

Hey, Rodrigo (Brasileiro?)
i don't the requirements for your application but i had to "build" an inverter to modulate motor frequency using PWM, however, i used combined the square wave function. which allows you to set desired frequency.

 

So i kind of made a workaround using square wave function to set frequency and PWM to set dutycycle.

jorgemondadori_0-1632742520782.png

 

Since for my application frequency was most important than dutycycle, it worked ok for a MVP.

 

Let us know if this helps

Jorge Augusto Pessatto Mondadori, PhD
Sistema Fiep
CLAD, CLD
0 Kudos
Message 4 of 9
(3,058 Views)

Hi jorgemondadori (sim, Brasileiro),

I had already done the test with this generator, but it didn't work as expected.
In my application I need to vary the duty cycle (5%, 10%, 25%, 50%, 75%, 100%).

 

 

Hi DavidWilt,

https://www.labviewmakerhub.com/doku.php?id=learn:libraries:linx:spec:pwm_set_frequency

 

In this case, how would I change the frequency by changing the bytes?
Could you prepare a step by step?

rodrigo_silva_0-1632743195289.png

0 Kudos
Message 5 of 9
(3,049 Views)

Hey, Rodrigo, just had a look at this topic recently.

 

It sounds like it is a internal AVR timer thing.

https://www.etechnophiles.com/change-frequency-pwm-pins-arduino-uno/

https://anupmarahatta.blogspot.com/2019/05/changing-arduinoatmega328-pwm-frequency.html

When you declare on arduino IDE the pins you can change such configuration. However you won't be able (as far as i understand) to change specifically to 200Hz. I measured the output of a pwm with an oscilloscope, and in fact it is not 500 Hz default, it is 490 Hz. The website i linked explains how to set Timers.

 

If you don`t need to chang you frequency during execution, you can modify the Linx firmware to set those different frequencies and pins.

 

Jorge Augusto Pessatto Mondadori, PhD
Sistema Fiep
CLAD, CLD
0 Kudos
Message 6 of 9
(3,033 Views)

Thanks Jorge for your help, but to apply the PWM I needed I applied the code below.
It worked very well, but I wanted to do this through LINX, as its serial communication is much more stable and robust.
In my LabVIEW code, serial communication with the arduino is blocking communication at all times (I have to close all of LabVIEW, disconnect the arduino and sometimes I needed to restart the PC), so I want to change the frequency to LINX.


How do I change the frequency from PWM to LINX?
How do I change your Byte Frame for this?

 

rodrigo_silva_0-1633000076991.png

 

0 Kudos
Message 7 of 9
(3,027 Views)

Rodrigo, i don't know how to do that since it is not implemented in LINX.

 

even if we could do that, you probably won't be able to achieve 200Hz, only step associated to timers.

with that in mind, it may be the reason why they did not implemented the library, because could impact on other functions.

 

with these in mind, let me ask you something:

 

The code you showed us, is the main funcionality of your application? You could send variable values using LINX by creating a CustomCommand and sending the value of delayMicroseconds.

do you mind explaining what are you trying to do instead of how are you trying to do?

 

this way we could evaluate your requirements and open other possibilities.

Jorge Augusto Pessatto Mondadori, PhD
Sistema Fiep
CLAD, CLD
0 Kudos
Message 8 of 9
(3,022 Views)

Hi Jorge,
My application is simple, I have a Mosfet that I sometimes apply PWM at 75% and at other times 25% at 200Hz.
This mosfet controls a resistive load of 5A or 30A or 50A (depending on my application).
Yes, I could have done the same programming I did in arduino in LINX, applying delays, but as there was a ready-made PWM function I thought I could use it to reduce my code (without needing to create sub VIs).
And another, I was curious why this LINX PWM wouldn't let you change the frequency (everything has a reason), but you clarified this doubt for me.
Thanks!

0 Kudos
Message 9 of 9
(3,006 Views)