NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
mgreytak
Posts: 3
0 Kudos

PWM duty cycle update in DAQmx Base

I am trying to generate a PWM (standard servo, 50 Hz, duty cycle 5-10%) with a USB-6211.  I am on a Linux system so I am using the DAQmx Base C API.  Following the example code supplied with DAQmx Base, I can define the frequency and duty cycle I want and start the task with no problems.  However, I will need to update the duty cycle as the task is running.  I have done this using the DAQmx Write VI on a full LabView Windows system in the past.  However, I don't see the relevant write function in the DAQmx Base API.  Does anyone know the proper function in the API to update the duty cycle of a running PWM generation task?

Member
SunainaK
Posts: 78
0 Kudos

Re: PWM duty cycle update in DAQmx Base

Hi Mgreytak,

 

Have you tried using a channel property node?

 

http://digital.ni.com/public.nsf/allkb/82C9F3C15F62974E86256EBA0058CAF5?OpenDocument

 

 

Sunaina K.
Applications Engineer
National Instruments
Member
mgreytak
Posts: 3
0 Kudos

Re: PWM duty cycle update in DAQmx Base

Hello,

 

I can do that with a VI when running LabView, but I am using DAQmx Base (the C API).  Do you know how to do it in DAQmx Base?  I have tried using the DAQmxBaseSetChanAttribute function to change the DAQmx_CO_Pulse_HighTime attribute of the counter output channel but I get a runtime error "Specified property is not supported by the device, is not applicable to the task, or is not implemented."

 

Thanks,

Matt

Member
SunainaK
Posts: 78
0 Kudos

Re: PWM duty cycle update in DAQmx Base

Hi Mgreytak,

 

I found a document which shows a different approach:

 

http://zone.ni.com/devzone/cda/epd/p/id/5712

 

I believe this will work with DAQmx Base.

 

 

Sunaina K.
Applications Engineer
National Instruments
Active Participant
JoeFriedchicken
Posts: 404
0 Kudos

Re: PWM duty cycle update in DAQmx Base


mgreytak wrote:

 

I am trying to generate a PWM (standard servo, 50 Hz, duty cycle 5-10%) with a USB-6211.  I am on a Linux system so I am using the DAQmx Base C API.  Following the example code supplied with DAQmx Base, I can define the frequency and duty cycle I want and start the task with no problems.  However, I will need to update the duty cycle as the task is running. 

 

<snip>

 

I have tried using the DAQmxBaseSetChanAttribute function to change the DAQmx_CO_Pulse_HighTime attribute of the counter output channel but I get a runtime error "Specified property is not supported by the device, is not applicable to the task, or is not implemented."


Unfortunately, the error text in this case is correct: changing the value for the DAQmx_CO_Pulse_HighTime attribute while a task is running has not been implemented for NI DAQmx Base [1]. Since it appears your application requires on-the-fly updates, as opposed to stop-reconfigure-start updates, please contact your local NI representative and he or she can work with my group to evaluate further options.

 

[1] NI-DAQmx Base 3.5 for Linux "SUPPORTED FUNCTIONALITY" section 

http://download.ni.com/support/softlib//multifunction_daq/nidaqmxbase/3.5/Linux/README.txt

Joe Friedchicken
National Instruments
Software Engineer :: Measurements RLP Group
Applications Engineer :: High Speed Product Group (until Sep 2008)
Get with your fellow OS users :: [ NI's Linux User Group ] [ NI's OS X User Group ]
Get with your fellow developers :: [ NI's DAQmx Base User Group ] [ NI's DDK User Group ]
Member
mgreytak
Posts: 3
0 Kudos

Re: PWM duty cycle update in DAQmx Base

Thanks Joe.  For now a workaround is to generate one pulse at a time; after each one, stop and clear the task then restart it with the new duty cycle.  It takes some time to stop and restart the task so instead of my desired 20 ms period it's more like 45 ms... however, the servo I'm controlling does not seem to mind the longer period as long as the hitime is consistent.  Not ideal, but good enough for now.

 

Thanks again,

Matt

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page