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

Outputting multiple pulse trains


  • Please log in to reply
2 replies to this topic

#1 ponja

ponja
  • Members
  • 12 posts

Posted 19 February 2013 - 05:57 PM

I am trying to output the following: Pulse width: 1 - 50 ms (variable but constant for one sequence) Sequence: 4 pulses 10ms pause 16 pulses Run this 100 times This needs to happen consistently. The pause doesn't have to be super accurate but it needs to be consistent so 5.128ms is fine as long as it is constant. I do the pause with an IO_wait I do the pulse train by setting FREQOUT on timer 0 and operating timer 1 in stop mode. Since timing is important all commands are executed in a single go. Therefore it does not seem to be possible to set the amount of pulses to more than one number (i.e. to do the 4 and 16 pulses). If I try to run the first 4 pulses and then just reinitialize timer 0 and 1 to FREQOUT and timer stop (with 16 pulses now) the result is 2x16 pulses. I assume only the latest setting counts for the timer. Is there a workaround for this? Also it does not seem as though my wait is completely consistent. Basic code: #Initialization: lngError = AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_BASE, LJ_tc1MHZ_DIV, 0, 0) lngError = AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_DIVISOR, 25, 0, 0) lngError = AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chNUMBER_TIMERS_ENABLED, 2, 0, 0) lngError = AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chTIMER_COUNTER_PIN_OFFSET, 0, 0, 0) lngError = GoOne(lngHandle) #Sequences for i = number of sequences lngError = AddRequest(lngHandle, LJ_ioPUT_TIMER_MODE, 0, LJ_tmFREQOUT, 0, 0) lngError = AddRequest(lngHandle, LJ_ioPUT_TIMER_MODE, 1, LJ_tmTIMERSTOP, 0, 0) lngError = AddRequest(lngHandle, LJ_ioPUT_TIMER_VALUE, 0, 100, 0, 0) lngError = AddRequest(lngHandle, LJ_ioPUT_TIMER_VALUE, 1, 4, 0, 0) lngError = AddRequest(lngHandle, LJ_ioPUT_WAIT, 0, lengthOfFirstTrain+5000, 0, 0); lngError = AddRequest(lngHandle, LJ_ioPUT_TIMER_MODE, 0, LJ_tmFREQOUT, 0, 0) lngError = AddRequest(lngHandle, LJ_ioPUT_TIMER_MODE, 1, LJ_tmTIMERSTOP, 0, 0) lngError = AddRequest(lngHandle, LJ_ioPUT_TIMER_VALUE, 0, 100, 0, 0) lngError = AddRequest(lngHandle, LJ_ioPUT_TIMER_VALUE, 1, 16, 0, 0) lngError = GoOne(lngHandle) end End code This gives me a fairly repeatable sequence of 16 + 16 pulses with approximately 5ms delay inbetween. I would prefer 4+16 but I can deal with 16+16. The problem is that the delay is not completely consistent. I suppose that the request buffer might overflow and split into multiple requests. Any suggestions?

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 19 February 2013 - 09:03 PM

Without digging too much, I am not surprised you don't get 4+16, and am somewhat surprised you get pulses-wait-pulses at all. Before spending much time on that, though, I think the fundamental problem might be that the freqout does not start instantaneously. Rather it has to wait for the free-running timer to get to the correct roll point, so since your period is 5ms there could be a 5ms variability in when the freqout starts each time. You have made a noble attempt here, but I don't think this technique of combining a freqout-wait-freqout will get you the consistent timing you want.

I thought about using one of the serial protocols to create your pulse sequence, but they don't use the Feedback packet at the low-level, so you can't do SPI-wait-SPI for example.

You could just do a bunch of toggle-wait-toggle-wait, but each pulse will take 8-12 bytes and you only can fit 57 bytes in a single packet, so can't get all 20 pulses that way.

The UE9 has a Stream-DAC feature that might do what you want:

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

The new T7 is likely (or will likely be) a great option to do this in 2 different ways:

1. The packet size for Ethernet is much bigger, so you could make a big single packet with a bunch of toggle-wait-toggle-wait.

2. You could write a Lua script to do what you want in hardware.

I suspect #1 is something you could do now. #2 is something that perhaps you could try in beta also.

#3 ponja

ponja
  • Members
  • 12 posts

Posted 20 February 2013 - 05:49 AM

Thank you for the response. I'm glad you've developed a new tool capable of performing this task. For now I've reverted to my old setup with setting the digital outs to high/low with IO_wait delays. I found out what was causing me grief, it's the multiple packet breakup and subsequent delay. By identifying where the packet split happens I can reduce the IO_wait to compensate (as long as my period is longer than the split delay). While this is not a perfect solution it is quite consistent and most likely sufficient for my needs.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users