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.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Novice attempting to get a PWM square wave output from a 9401

Hello,

 

I'm currently attempting a project in which I need to trigger a square wave output through the 9041.

 

The trigger is an "if" statement with-in my coding & dependant on the result this changes the duty cycle so that I can control a motor through PWM.

 

Originally I had intended on creating a digital output through one of the example files on the system ( Example Finder> Hardware Input Output> DAQmx> Digital Output ) & then gaining an understanding of how that one worked & creating my own.

 

However, even using the example "Digital - Continuous Output.vi" I am yet to see any sort of signal on my oscilloscope which I have the 9401 hooked up to.

 

I'm using the file as it stands, setting the lines to "cDAQ1Mod3/port0/line0", setting the clock source to be onboard the cDAQ (/cDAQ1/ai/StartTrigger) & seeing nothing.

 

I'm having some luck using the "Counter - Finite Output.vi" example but this is just giving me rising and falling edges which I assume are to be used as triggers.

 

Any ideas where I can start with this would be much appreciated.

0 Kudos
Message 1 of 5
(5,792 Views)

Hi crumpetnibbler,

 

Am I correct in thinking that you require a PWM output which allows you to change the duty cycle 'on-the-fly'?

 

The following White paper describes methods of outputting PWM signals using DAQmx and also has examples which include the functionality to trigger and alter the PWM duty cycle:

http://www.ni.com/white-paper/2991/en

 

I have tested this with a 9401 and have successfully generated a PWM signal.

Please note that DIO0 does not necessarily relate to ctr0 output. In order to see which pins should be connected, you can right-click the hardware in MAX and select Device Pinouts.

 

Please let me know if I have made any incorrect assumptions of if you have any further questions on this.

Regards,
Chris (CLED, CLA, CTA)
Applications Engineering Specialist
Message 2 of 5
(5,773 Views)

I could kiss you right now.

 

I haven't had a chance to test it because the only chassis I have available to me was in use but if you managed to get it working with a 9401 then I know it's possible & I'll just keep at it until I get it working.

 

I assume I just alter the "Counter(s)" parameter to be the pin output that I need & I can change the duty cycle as the program goes.

 

Thanks again, I'll report back when I get a chance.

0 Kudos
Message 3 of 5
(5,754 Views)

Hi Chris,

 

I've got the PWM program from the White paper working but when I hook it up to an oscilloscope I am not seeing a square wave, instead I'm seeing the following (apologies for the picture quality & unfocused reading on the scope, someone changed the settings while I was away)

 

IMG-20130322-00392.jpg

 

The trailing edge moves when I alter the duty cycle so it works in that sense, I just assumed I'd be looking at a square wave. Is this correct or have I managed to go wrong somewhere?

 

Many thanks for any help,

Josh

0 Kudos
Message 4 of 5
(5,734 Views)

Try settting your scope input for DC coupling. It looks like you have it on AC.

 

Good luck,

 

Dave

0 Kudos
Message 5 of 5
(5,714 Views)