LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sine PWM myRIO

 Hello everyone,

I want to use the PWM output of the myRIO 1900 to drive the switches of an inverter. The Sine PWM signal I want to output is created by comparing a 50 Hz Sine wave with a 10k Hz triangle wave. I've gone through the various LabVIEW tutorials, but I'm still pretty new to the program. I also can't find any relevant examples online for this question.

 

 

Anyways, I have these two main questions:

1) How can I generate that Sine PWM signal? I can generate a Sine and Triangle waveform on LabVIEW, but I don't know how to create a wave that is the comparison of them. I have a few ideas, but I'm just not sure what's supposed to be the correct/best way of doing it.

 

2) Even if I can generate the Sine PWM signal, how can I output it through the PWM output on the myRIO? The PWM Express VI just takes in a duty cycle and frequency. It would be ideal if I could just feed it the actual Sine PWM signal.

 

Really, any help is greatly appreciated. I know this is all straight-forward and I'm sure has been done before, I just can't seem to find much on it. Thanks!

 

0 Kudos
Message 1 of 6
(6,270 Views)

I've played around and I think I now can answer my first question. Apparently there's a comparison VI that can work with waveforms. I've attached my (extremely basic) code. The output is a Sine PWM.

 

My only issue at this time is how I can make the myRIO output that signal through its PWM output. Do I need the feed that signal to the Pulse Measurement VI that tells me the Duty cycle and Period (which I can convert to Frequency) and then feed those parameters to the PWM Express VI?

 

I'm just trying to wrap my head around this and making sure this is the right way of going about this. Thanks!

Message 2 of 6
(6,249 Views)

Check out the powerdev forum at ni.com/powerdev. They have many examples for sine-triangle PWM, and I think even have several examples specifically for myRIO. It sounds like you are trying to implement your code in the real-time processor instead of the FPGA. I've never used myRIO, but I'd guess that you can't access the myRIO output pins directly unless you go through the FPGA.

 

Here is the simple FPGA implementation of sine triangle PMW:

 

1) Create a triangle generator (you can find this as one of many VIs in the main power electronics package built by BMac here, it is a big download but it has lots of cool tools).

2) Compare the triangle waveform to a reference signal using a boolean greater than comparison. Route the boolean output to the desired digital output pin on the myRIO.

3) Adjust the triangle frequency to control the period, and adjust the reference signal to control the duty cycle. When the reference signal equals the peak value of the triangle waveform, you will get 100% duty cycle. When the reference signal equals the minimum value of the triangle, you will get 0% duty cycle.

0 Kudos
Message 3 of 6
(6,232 Views)

Hey thanks for the reply!

I went to the link, but it looks like most of their examples make use of their GPIC. I'm not entirely sure why that device is useful, but I don't have one. I also don't think I would need one. This seems like a very basic PWM function no?

 

Anyways, I can create the Sine PWM signal correctly now. I can also generate a simple PWM signal with the PWM pin by using the Express PWM VI. The issue is that I want the PWM output pin to output the exact PWM signal I'm creating.

 

I've gone through various FPGA examples, and I can't anything to help. Everyone who wants to create a PWM seems to simply give desired frequency/duty cycle set-points. Whereas I would like to literally provide the PWM signal, and have the myRIO just output that. Does this make sense?

 

Thanks!

0 Kudos
Message 4 of 6
(6,202 Views)

Most of the examples are for GPIC, but LabVIEW FPGA works on many different platforms including myRIO. I am fairly certain that there is at least one myRIO example project in that download that demonstrates PWM.

 

If you have a PWM signal (a boolean ON/OFF value), go to the project explorer window and find your myRIO. Under myRIO expand the tree and browse to Chassis / FPGA Target / ConnectorX / DIOx (desired DIO pin) and drag it onto your block diagram. Then write click on the I/O node, choose "Change to Write", and wire your PWM signal to it.

 

Here is a quick example I put together in LabVIEW FPGA: myRIO PWM.png

0 Kudos
Message 5 of 6
(6,173 Views)

Hey Shansen1. Thanks for the help. I'm writing this out for future people.

I still could not get things to work this way and I think I understand why. If I'm using a while loop, I can't output things through the Analog Output Express nor PWM VI. Somehow, these VIs just take the first sample and output that. Maybe that's a bit unclear. But if you make a While loop on Labview for a myRIO, and use Simulate Signal and Analog Output Express VIs, it actually won't output anything. Strange.

 

The way to solve this is to use Timed Loops, in conjunction with actual math operators (like the Sine function VI). In fact, after A LOT of searching, I found this thread that has a solution:

https://forums.ni.com/t5/forums/v3_1/forumtopicpage/board-id/10/thread-id/2590/page/2

 

He happens to do exactly what I needed (SPWM) but what matters is how he does it. In the future, if I'm trying to output anything digitally/analog, I know I need to give one sample per loop run instead of just use a function generator and a While loop (which is what I used to do with other DAQ devices, as that's literally what the video tutorials would do).

 

Thanks for the help and I hope this helps others as I think SPWM is fundamental to do on a myRIO without needing other power electronic packages.

 

0 Kudos
Message 6 of 6
(6,125 Views)