LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PWM generator w/out hardware

Is there a way to generate a PWM signal in labview with out using external hardware? I wish to create a PWM signal at about 2kHz, where the duty cycle changes in a sinusoidal fashion. The PWM signal will eventually drive a DC motor (and the speed will change in a sinusoid).

Currently I am using a square wave generator to create the pulse. Is there a better way of doing this?
0 Kudos
Message 1 of 14
(4,391 Views)
There most certainly is! Attached is a little piece of code I've used for my own applications. Hope this helps.
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705
0 Kudos
Message 2 of 14
(4,391 Views)
YES! exactly. I was using something similar with the square wave generator

Is there a way to define the frequency of the sine wave? i'm assuming y=sin(wx) where w is the frequency. I want to define w.

I notice you take the 'I' number (iteration number) and divide it by 100. any particular reason?
0 Kudos
Message 3 of 14
(4,391 Views)
Chutla:
Would you happen to know if I could to PWM with parallel port pins? I got it working at 25% duty cycle at a frequency of 15 ms, but I would like to go lower (2~3ms)


thanks,

USCTrojan
0 Kudos
Message 4 of 14
(4,391 Views)
Greetings, Guidoc:

The sine wave frequency is defined by the "wait until" node. I've used a reciprocal in there, so that the control approximates a frequency control. The reason I use the divisor on the iteration terminal is just to prevent 'jerkiness' at lower repetition rates, i.e., the step size is smaller.

I'm sure there's a way of using the prefabricated sine wave node to do this a little more elegantly, but this worked just fine for my particular application.
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705
0 Kudos
Message 5 of 14
(4,391 Views)
Hi there, Trojan,

Funny you should mention parallel ports and Labview. I am just in the throes of creating a programmer for a DDS synthesizer with the parallel port. I ripped the following code scrap off the NI site a while back. I've attached it, just in case it's not still there.

I'm not sure why there 2-3 ms should be any problem even with a SERIAL port, but anyway, this VISA port access does work nicely.

By the way, I'm going to have to charge you extra for this response, since I work for UCLA. Go Bruins!

🙂

chutla
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705
0 Kudos
Message 6 of 14
(4,391 Views)
WOW what a nice Bruin!

I saw the example before, and I have gotten the impression that VISA does not work well with parallel port, especially with Machine that has WIN 2000 as OS.
For the Parallel Port control, I am reading directly from the registers using in/outport VIs (with AccessHW patch to deal with WIN2000�s Kernel Structure). Do you know for a fact that VISA can work faster than in/out port, hence faster than writing directly to the hardware register?
By the way, I tried running your vi, it gave me a timed out error (which has been documented in other discussions in the forum). I hope this was not a Bruin Prank 😃

FightOnSCTrojan
0 Kudos
Message 7 of 14
(4,391 Views)
Hi again!

You're probably right about directly writing to the registers being faster, since Visa is a high level(and hence, probably, slower) environment. If you're comfortable with all that peeking and poking, I'd go for it. There is a good tutorial on general Parallel port stuff on the main NI site. Indeed, win2000 is NOT the preferred platform for this sort of thing....I've had better results with win98, but alas..."progress" marches on.

I don't know why you're having a timeout problem with the PWM circuit. (I've also missed some of the discussios for some reason. I'll check into that)

By the way...I work for HIPAS Observatory here in Fairbanks, Alaska...we're under the UCLA plasma physics department...we do io
nospheric research...poking the Aurora with lots of High power RF...that kind of stuff. Our web site (if it's working) is www.hipas.alaska.edu. We're moving toward converting ALL our remote data acquisition to Labview. (other than a few diehard Matlab grad students...he he 🙂

Chutla
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705
0 Kudos
Message 8 of 14
(4,391 Views)
Trojan:

I wasn't able to get my PWM to fail. I'm sending you a version with some diagnostics. Let me know if you see any error codes. There really isn't very much TO this vi., so it should work.

(A serious, sober design engineer pull a prank???? Perish the thought!)

chutla
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705
0 Kudos
Message 9 of 14
(4,391 Views)
what about the DAQ card? we're sending a 2kHz pwm signal thru that? any forseen problems? (is the DAQ fast enough?)
0 Kudos
Message 10 of 14
(4,111 Views)