Jump to content


Photo

Timer/Counter Control


5 replies to this topic

#1 Mark

Mark
  • Members
  • 8 posts

Posted 19 July 2006 - 07:33 AM

Please can you confirm whether it is possible to start and stop the onboard Timers and Counters in software? I have a digital pulse train typ. 15 but up to 30Hz seperated by 100-1500mS gaps. I am hoping to use the Timers and Counters on the U3 for the following: 1) Start/Stop Counter 0 in software to count the total number of pulses received over a fixed period typ. 20 minutes. 2) Stop/Read and Start Counter 1 during each 100-1500mS gaps. Presumably the counter can be interogated continously to detect when the pulse train has stopped in each gap and can then be read and re-triggered? 3) Start/Stop/Read Timer 0 in software during each of the gaps (see 2) to determine how long each period of Timer 1 measurment has been? With no pulses the digital signal sits at 3V. I would really appreciate any help and advice you can give. Development for this project is Microsoft VB6.

#2 LabJack Support

LabJack Support
  • Admin
  • 8312 posts

Posted 19 July 2006 - 07:52 AM

In general you can use software to stop/start/reset/read counters and timers whenever you want. Usually, though, you do not want to disable (stop) the timers or counters during your experiment, and there is usually no reason to do so anyway. 1) Straightfoward. Just enable Counter0 and read it whenever you want. 2) Sounds reasonable. Enable Counter1, read it every 5 ms perhaps, and if it has not changed for 67 ms (your maximum period) you know you are in a gap and you reset Counter1. No need to ever stop/disable the counter. 3) I don't understand this one. Sounds like once you reach a gap between a burst of pulses, you want to look at the previous burst and find the time between the initial falling edge and the final rising edge. You mentinoa Timer0 and Timer1. What is Timer1 doing? Do all pulses within each burst have the same period?

#3 Mark

Mark
  • Members
  • 8 posts

Posted 21 July 2006 - 03:35 AM

Many thanks for such a prompt response. I have now purchased a U3 device and have started to do some testing which has prompted some more questions: 1) Is it possible to use a call back function or some type of event interrupt to stream timer and counter values from the device? At the moment I am relying upon a fast VB timer to poll the device but obviously have some latency issues with the Bus/Operating System etc, etc. Do you have some pseudo or sample vb code of streaming data? 2) Can a timer or counter be enabled/disabled/reset with an ePut request? 3) Can a Configuration Reset be done with an ePut request? Thanks again for any help and advice you can give.

#4 LabJack Support

LabJack Support
  • Admin
  • 8312 posts

Posted 21 July 2006 - 10:27 AM

1. The U3 does not support streaming at this time, but based on your previous description of your application that is probably not what you want anyway. I would just remove any timer or delay from your loop and interate as fast as you can. That will give you the best real-time response. Section 3.1 of the U3 User's Guide gives you an idea of how long each iteration will take. For the best times, you don't want other processes interrupting your program. Avoiding running other programs at the same time, and perhaps use Windows Task Manager to increase the priority of your process. 2. Yes, but it can lead to confusing. I recommend doing all enabling/configuration within a single add/go/get block at the beginning of your program. That is how it is done in the "Simple" VB6 example. Then for your reads/resets you can use eGet, but for better performance you should again group all reads/resets into a single add/go/get block such that a single low-level command can handle them all. 3. Yes. I see that is missing from the VB6 examples. All the examples should have the following after the open function: 'Start by using the pin_configuration_reset IOType so that all 'pin assignments are in the factory default condition. lngError = ePut(lngHandle, LJ_ioPIN_CONFIGURATION_RESET, 0, 0, 0) If lngError <> 0 Then Err.Raise lngError

#5 Mark

Mark
  • Members
  • 8 posts

Posted 24 July 2006 - 02:15 AM

1) Do you have any schedule for the U3 streaming functionality? 2) Can you confirm the best type of high speed USB connection. The manual talks about connecting the device to a high speed host via a hub despite the U3 not being a high speed (USB 2.0?) device, is that correct? Should I be connecting the U3 to my USB 2.0 laptop ports via a USB 2.0 Hub to get the fastest data rate? 3) Contrary to my earlier messages it appears my timings were not quite right. I need to read Counter 0 as fast as possible so that I can read it sometimes before it has incremented to enable the software to react in the correct way. Please can you confirm which functions are best to call in order to obtain the faster counter read rate? The eGet or using the GetResult method? Many thanks and I look forward to your reponse.

#6 LabJack Support

LabJack Support
  • Admin
  • 8312 posts

Posted 24 July 2006 - 09:31 AM

1) See the following:

http://www.labjack.c...?showtopic=1388

Because of the various buffering that goes on, streaming is often not the best solution for applicaitons requiring fast real-time response. One way streaming might work well for you, though, is if you just collect all the input data and store it to disk, then post-process to determine the timing information that you need.


2) Yes, for the best speed you want to use a High-Speed host and put a High-Speed hub between the host and the U3. Should take less than 1 ms each time you read and reset both counters.

USB 2.0 refers to the specification that introduced High-Speed, in addition to Full-Speed and Low-Speed which were the 2 choices from USB 1.1, so there are now 3 possible speeds. When a device says it is USB 2.0, that does not mean it supports High-Speed, but from what I have seen all hosts and hubs that say they are USB 2.0 do have High-Speed support.


3) If you call eGet twice to read the two counters, each call will make a low-level command to get the desired data. If you instead do a add/add/go/get/get to read the two counters, the two reads will be done in a single low-level command and your total time will be about half.



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users