Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

Output Low Frequency Square wave


  • Please log in to reply
5 replies to this topic

#1 EE Designer

EE Designer
  • Members
  • 11 posts

Posted 11 September 2012 - 03:52 PM

Hi, I would like to know if it's possible to output low (from 1Hz to 30 Hz) square wave using the Labjack U3 and what method, timer, DAC or something else is best suited for the job. Thanks,

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 12 September 2012 - 07:47 AM

You could just toggle a digital output using software timing, but the best solution would be to use a timer in PWM16 mode:

http://labjack.com/s...s-guide/2.9.1.1

http://labjack.com/s...ers-guide/4.3.6

Try it out using the test panel in LJControlPanel. Set #timers=1 and set the mode of Timer0 to PWM16. Set pinoffset=4 and Timer0 will appear on FIO4. Leave the timervalue at 32767 for 50% duty-cycle. Use the timer clock base of 12MHz /Div. Vary the timerclockdivisor from 6 to 183 to get an output frequency of about 30.5Hz to 1Hz respectively.

#3 EE Designer

EE Designer
  • Members
  • 11 posts

Posted 12 September 2012 - 08:34 AM

You could just toggle a digital output using software timing, but the best solution would be to use a timer in PWM16 mode:

http://labjack.com/s...s-guide/2.9.1.1

http://labjack.com/s...ers-guide/4.3.6

Try it out using the test panel in LJControlPanel. Set #timers=1 and set the mode of Timer0 to PWM16. Set pinoffset=4 and Timer0 will appear on FIO4. Leave the timervalue at 32767 for 50% duty-cycle. Use the timer clock base of 12MHz /Div. Vary the timerclockdivisor from 6 to 183 to get an output frequency of about 30.5Hz to 1Hz respectively.



Support,

Thanks it works. I would like to obtain the same thing using the Daqfactory scripting language because i would like to control the number of pulses to send out to a relay between 1Hz to 30Hz.


Thanks,
Vu

#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 12 September 2012 - 09:04 AM

Start with the following:

http://labjack.com/s...ers-guide/4.3.6

http://labjack.com/s...lj-app-guide/10

#5 EE Designer

EE Designer
  • Members
  • 11 posts

Posted 12 September 2012 - 12:41 PM

Support, I got it working. My question is i have two things i would like to accomplish with the Labjack U3 on one program. First, output the low frequency and continuously reading data from a sensor and currently they are on a two separate .ctl files. The way i'm reading the data continuously is using a while(1) loop. Could you recommend a way on how to combine the two things into one .ctl file. I tried but failed. I need something like two threads or something like that so they don't interfere with each other is that possible ? Thanks

#6 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 12 September 2012 - 01:28 PM

So you need a script to start the PWM16 timer output, and need a script to update the timer config whenever you want to change the frequency. What determines when to change frequency? That is, when should the timer update script run?

For your read script, what kind of channel does it read and how fast do you want to read it?

Perhaps post snippets showing the code from your scripts. You might want to do that on AzeoTech's forum rather than here, as they can provide more expertise specific to DAQFactory:

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

... or if you just post here, we will ask AzeoTech to comment here.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users