PWM at 10KHz | LabJack
 

PWM at 10KHz

12 posts / 0 new
Last post
Nmistry82
Nmistry82's picture
PWM at 10KHz

Hello, I am trying to set up A specific timer mode using the attached PWM out example, https://labjack.com/support/ud/df-lj-app-guide/10.5 However, I want to set it up to 10KHz rather than 1 MHz Would I just need to set the divisor to 4800 rather than 48 and also change the resulting timer clock to 10 KHz rather than 1 MHz? I currently keep getting an error every time I try and change to duty cycle: The duty cycle does change, but the following error also appears: ''Error occurred on io type: 1000, channel type: 1002, code: 10: Invalid parameter'' Please can you help? Kind Regards, Neil Mistry

LabJack Support
labjack support's picture
The range you can get from 8

The range you can get from 8-bit PWM on the U3 is 15 Hz to 187500 Hz:

https://labjack.com/support/datasheets/u3/hardware-description/timers-co...

The formula for frequency is:

Frequency = TimerClockBase / (TimerClockDivisor / 256)

Start by closing DAQFactory and instead using the test panel in LJControlPanel. Set TimerClockBase and TimerClockDivisor to get the desired frequency. Once you see the settings you want in the test panel, you can try them in DAQFactory.

Nmistry82
Nmistry82's picture
Hello,

Hello,

Thankyou for your reply, I have set the desired frequency via the LJControl panel using the above formula. (48000000/10000)/256 = 18.75 so have set the clock base as 48MHz/Divisor and the Timer Clock Divisor to 19. Have i done this correct for a 10KHz frequency? I have added an attachement showing the configuration i have used along with the resultant graph i am getting. Have i made an error along the way?

Regards,

Neil

LabJack Support
labjack support's picture
Yes, your math looks good. 

Yes, your math looks good.  Your frequency will be about 10kHz.

I'm not sure if it is a problem, but your DF script has 2 lines setting the clock base.  I suggest you comment out line 6.

As for the graph, it appears that DF is streaming the signal that has been fed back into an analog input.  I'm not sure about the details there, but keep in mind that if the signal is a 10kHz square wave you are going to want to stream it at 50 kHz to get any sort of visualization of it, and even then you will just barely be able to see it.  You really need an oscilloscope to look at it.

Nmistry82
Nmistry82's picture
Hello,

Hello,

Thanks again for your reply.

Is there a way of using the 'TimerDuty' example to confirm that what i assume is 10KHz actually is? or is there any way of doing such a thing, if i am unable to get visualisation via the graph? Just so i am sure it is doing what i think it should be doing. The TimerDuty example i have, unfortunately does not seem to work either.

I Keep getting an error saying 'timer sharing error'  

Kind Regards,

Neil

LabJack Support
labjack support's picture
An easy way to check the

An easy way to check the frequency would be with a counter.  Enable a counter input along with your timer:

https://labjack.com/support/datasheets/u3/high-level-driver/example-pseu...

Jumper your PWM signal to the counter input, and if you read the counter input once per second it should increment by about 10k ticks every second.

Did you get your TimerDuty example from the following, as your screenshot looks different than what I have?

https://labjack.com/support/software/examples/ud/daqfactory

Nmistry82
Nmistry82's picture
Thank you,

Thank you,

The exapmle from the link yousent is working.

Now that i am able to see the duty cycle and frequency of this one screen, i need to be able to control/monitor a further 3. I am looking to monitor 4 heater mat zones with different duty cycles (all at the same frequency though) i am looking to have some sorrt of set up where i have 4 of the graphs (each one representing each of the 4 heating zones) but each set to different duty cycles. how would i create this please?

Kind Regards,

Neil

LabJack Support
labjack support's picture
I don’t understand.  Do you

I don't understand.  Do you want 4 PWM outputs, 4 PWM inputs, or some of both?

The U3 only has 2 timers, so you can just do 2 PWM inputs or outputs with it:

https://labjack.com/support/datasheets/u3/hardware-description/timers-co...

Nmistry82
Nmistry82's picture
I need 4 PWM outputs, so i

I need 4 PWM outputs, so i will require 2 labjacks? but both of these labjacks will be able to monitored by the DAQfactory software right? 

Kind Regards,

Neil

LabJack Support
labjack support's picture
You will need 2 U3s or 1 U6.

You will need 2 U3s or 1 U6.

DAQFactory can control the PWM outputs on multiple devices.  You will be controlling the outputs, not monitoring them.

Nmistry82
Nmistry82's picture
Hello,

Hello,

I now have 2 labjack U3's, would i need to create 4 seperate sequences for the 4 PWM's i will want to control? My thinking so far is to create a variable value component text on page 0 for each PWM and set the 'action' in  properties tab to toggle between 0 and whatever the duty cycle is as all 4 PWM's will have differant duty cycles. Where i am coming stuck, is with the script. Please culd you help me to set up the 2 labjack set-up aswell as having the 4 PWM's set up. Does what i am trying to do make sense?

Kind Regards,

Neil

LabJack Support
labjack support's picture
I would post a snippet

I would post a snippet showing your attempted script so we can comment on it and help you with it.  If it is just a script doing calls to the UD driver we can certainly help here, but if your questions get into DAQFactory things that are beyond our DF expertise you might be better continuing with a post on AzeoTech's forum:

http://www.azeotech.com/board/