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

Multiple Pulse U3 in Matlab


  • Please log in to reply
9 replies to this topic

#1 LabJacket

LabJacket
  • Members
  • 5 posts

Posted 13 January 2011 - 09:31 AM

Hi all I'm trying to write a simple Matlab program that will send multiple pulses from different outputs on my LabJack U3 at specific time separations. Are there any functions that would be useful? I'm really new to this. Any help is much appreciated. Thanks

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 13 January 2011 - 09:32 AM

What sort of time separations are you wanting?

#3 LabJacket

LabJacket
  • Members
  • 5 posts

Posted 13 January 2011 - 09:42 AM

We need a second pulse 100ms after the first, both from different outputs. Then from a third out put, 5ms after the second, we need two pulses of separation 0.2ms.

#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 13 January 2011 - 11:17 AM

Your timings of 5 ms plus you could do with simple software timing (set outputs, wait, set outputs, wait, ...), but for timing less than a millisecond you need to do something more hardware based.

Consider using add/go/get blocks with the put_wait iotype:

http://labjack.com/s...rs-guide/4.3.14

The resolution is 128 us, so you could do about 128 or 256 but not exactly 200 us. Is that OK?

The point of an add/go/get block with the put_wait iotype is that you are sending a bunch of commands to the U3 in a single low-level packet. One complication is that there is a limit to how many commands fit in a single packet. There is mention of this towards the end of Section 3.1:

http://labjack.com/s...users-guide/3.1

Actually, looking at that I see that an AIN read with QuickSample=1 and LongSettling=0 takes roughly 100 us, so you might be able to use AIN reads to get a different delay than 128 us.

If you need the 200 us to be more exact, we can get into using a timer output with a stop timer to do that.

#5 LabJacket

LabJacket
  • Members
  • 5 posts

Posted 14 January 2011 - 09:00 AM

Thanks for the help. We've got the pulses up to 5 ms working fine. We're looking at the 200us delay, and i think the method you described would be fine for a rough try-out. However we are going to need to alter that pulse delay up to a resolution of 1us. Is this possible using the stop-timer method? Once again, your help is much appreciated.

#6 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 14 January 2011 - 01:11 PM

So for those 2 quick pulses you need a spacing around 200 us but need to vary it with 1 us resolution? Then you would use a timer in a PWM output mode or Frequency output mode to create those two pulses and use another timer in Stop mode to stop the output timer after 2 pulses.

#7 LabJacket

LabJacket
  • Members
  • 5 posts

Posted 19 January 2011 - 05:49 AM

Hi We're having trouble getting the timer to stop. We think the code below should give 5 pulses at a frequency of ~977Hz. The frequency is correct according to our oscilloscope, but we cant get the timer to stop. Are we making an obvious mistake somewhere? ljud_AddRequest(ljHandle, LJ_ioPUT_CONFIG, LJ_chNUMBER_TIMERS_ENABLED, 2, 0, 0) ljud_AddRequest(ljHandle, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_BASE, LJ_tc1MHZ_DIV, 0, 0); ljud_AddRequest(ljHandle, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_DIVISOR, 4, 0, 0); ljud_AddRequest(ljHandle, LJ_ioPUT_TIMER_MODE, 0, LJ_tmPWM8, 0, 0); ljud_AddRequest(ljHandle, LJ_ioPUT_TIMER_VALUE, 0, 32768, 0, 0); ljud_AddRequest(ljHandle, LJ_ioPUT_TIMER_MODE, 1, LJ_tmTIMERSTOP, 0, 0); ljud_AddRequest(ljHandle, LJ_ioPUT_TIMER_VALUE, 1, 5, 0, 0); Also is it possible to send some of these pulse out of different outputs?

#8 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 19 January 2011 - 10:01 AM

Looks OK to me. Make sure you are getting the result for every add request, and also make sure you have error checking after every add, go, and get. Do you have FIO0 connected to FIO1 so the stop timer is seeing the pulses? Pulses on different outputs: With the non-timer methods you could do whatever you want, but using the timers I don't think it would work very easily. You would have to reconfigure the timers to change which output is doing what, and thus you would lose your small time resolution whenever you do that.

#9 LabJacket

LabJacket
  • Members
  • 5 posts

Posted 19 January 2011 - 12:00 PM

I did indeed FIO0 connected to FIO1. However it looks like I may be able to use a different method to create these two pulses. I am also having a problem with the voltage of my pulses. I expected them to be around 3.3V but I'm only getting 0.3V, any ideas?

#10 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 19 January 2011 - 01:08 PM

Perhaps you have too much load. Try disconnecting your load and the stop timer and see if the voltage goes up to 3.3 volts. That could also explain why the stop timer is not working as it needs to see >2 volts to recognize a high.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users