Discussion:
Implement a watchdog with counter output using DAQmx
(too old to reply)
FTI Newton
2008-03-20 00:10:06 UTC
Permalink
I'd like to implement a watchdog timer with a counter using a USB 6016.
Basically, configure the counter to output a pulse, but reprogram it before it gets a chance to toggle.
I have done this before with older Eseries cards, so I know the general method, but I have been totally unsuccessful in configuring DAQmx to do the same thing.
The main problems I've run into are
  1) Restarting the task returns errors
  2) updating the pulse specs is not possible while the task is active
 

I tried retriggering the start before pulse is complete but that doesn't seem to interrupt it either.
I can't imagine that it's not possible in the "new and improved" driver architecture :smileymad:
 
Any help appreciated!
mallorim
2008-03-21 16:10:08 UTC
Permalink
Hi FTI Newton,

I am afraid I am a bit unclear as to your application. What did you mean by ?reprogram the counter before it gets a chance to toggle?? As I understand your issue, you want to have a counter that waits a set amount of time before generating a pulse. However, after the count has started, you want to be able to change how long it waits before the timer has reached its set limit? Is this understanding correct?

I would really like to see your Traditional DAQ Legacy code where you had implemented this watchdog timer, if you could post back with it attached. What E-series card had you used?

Last, can I ask what is the length of the delay you want to see in the timer? Would you consider implementing this in software timing? Regards, Mallori M.
FTI Newton
2008-03-21 19:10:07 UTC
Permalink
You described it exactly right. I want to reset the counter before it gets to the high portion of the pulse. That means I basically must reprogra it while the task is running.. Timewise, I'd like to do this on the order of 100's of milliseconds.
 
As far as legacy code, I don't have it - that was several years ago, and definitely on an Eseries card.
 
No matter, there are already online examples of the method in the Developer Zone, but none using DAQmx.
 
FTI Newton
2008-03-24 21:40:07 UTC
Permalink
The application is a watchdog timer . The software periodically resets the counter in a pulse generation task, preventing it from toggling the output. If it cannot keep up . LabVIEW crashes, Windows hangs, a process takes too long... the counter continues and toggles out, shutting down power to critical parts of the system.
 
1)  I want to reset the counter at any time, programmatically.
2)  I do not want to wait for the task to complete the current loaded pulse spec.
3)  I want the ability to reset it before it gets the to active state for the pulse: high or low is irrelevant.
4) The timing does not matter - if my software cannot reset the counter in time, I want the counter to continue and toggle out. That's entirely the point of a watchdog.
5) I have to do it in DAQmx because of the hardware. You can do exactly this thing using DAQ traditional. All I need is the DAQmx equivalent of programming or resetting the counter... WITHOUT stopping the task.
 
FTI Newton
2008-03-25 16:40:09 UTC
Permalink
Are you suggesting that the watchdog VIs support a USB 6016? :smileyindifferent:
 
 I can't find what I need in DAQmx to even give you a screenshot -  The DAQ traditional version that works? You have that already.
 
Nevermind the watchdog timer - it's only an application that requires this particular feature; forget I ever mentioned it. Here's the more fundamental issue:
 
Generally speaking, I want to be a able to asynchronously reprogram the counter, at any time. (It doesn't matter what I need the hammer for, I just need to know where the hammer is.) :smileywink:
 
PALETTE: Data Acquisition (NIDAQ traditional) >> Counter >>  Advanced Counter >> "Counter Control.vi"
 
Make the Control Code input = 'program'.
 
 
QUESTION: What is the equivalent in DAQMX?
 
 
 Message Edited by FTI Newton on 03-25-2008 11:24 AM
NI-Bongo
2008-03-27 13:10:08 UTC
Permalink
Hello FTI Newton,



I did not think Watchdog Tasks were supported by that device and was
not successful getting them to work here with the 6016, but I thought
perhaps you knew something I didn't and found a way to implement it. 



Unfortunately, there is Control Counter.vi in DAQmx.  The analog with DAQmx is to stop and restart the task:



How do I Programmatically Reset a Counter with NI-DAQmx?

http://digital.ni.com/public.nsf/allkb/65E3DBC715998C3286256E900075B7F8?OpenDocument



From your previous posts I've gathered you are having trouble with
this or don't want to do this for some reason.  What error messages are you receiving?  Again, a screenshot of
the code that throws this error would help us diagnose the problem.

You may have to do things differently than you did with Traditional
NI-DAQ because the drivers are built on different foundations.   This
is why I'm asking about what you want, as there is not always a  1-to-1
relationship between the drivers.Transition From Traditional NI-DAQ to NI-DAQmx in LabVIEWhttp://zone.ni.com/devzone/cda/tut/p/id/4342Answers to Frequently Asked Questions about NI-DAQmx and Traditional NI-DAQ (Legacy)http://zone.ni.com/devzone/cda/tut/p/id/3021
Kevin Price
2008-03-27 21:10:08 UTC
Permalink
Two comments:
 
1. Search the site and the DAQmx Help for info on the "Task State Model."  You can noticeably reduce the overhead associated with a DAQmx Stop followed immediately by a DAQmx Start.   The basic idea is that when you do a Stop, the task transitions back to the state it was in prior to your Start.   If you intentionally make use of the function calls to "reserve" or "commit" the resources for the task before starting it, then a subsequent Stop and Start will execute quicker because it has less work to do.
 
2. Because you've got an M-series board that supports encoders, there's another kinda goofy way to approach this in hardware.  Here's a streamlined outline:
- configure for position measurement with a "two-pulse" encoder

- wire the counter's "A" input (source) to digital ground
- programmatically assign the "B" input to be an internal timebase such as 100 kHz.- enable Z-indexing with a specific non-zero Z-index value (see below).  Set Z-index polarity to A Low - B High.  
- configure the counter to "pulse on terminal count".  This is the watchdog pulse that shuts down your world if the counter ever reaches its terminal count of 0.  I *think* it lasts only 50 nanosec (1 cycle of 20 MHz timebase) and I don't know of a way to change that.
- the Z-index value *and* the counter's initial value should be the same.  Your "position" counter is going to always decrement at 100 kHz starting from that value.  So if you need a 0.5 second watchdog timeout period, you'd use a value of 50k.
- You reset the watchdog by creating a "Z-index pulse" using either the board's other counter or by double-toggling a digital output bit.  While that Z-index pulse is high, whenever the A,B inputs are Low,High respectively the counter will reset to the Z-index value.  A is always Low because you wired to ground.  So you just need to make sure that your pulse stays High long enough to see a high state on the 100 kHz clock.  6 microsec should be enough.
 
-Kevin P.
FTI Newton
2008-03-27 23:40:06 UTC
Permalink
Kevin:
I had already tried the DAQmx task control options.
 
I'll definitely try the encoder implementation - very nice. Thank you!
Loading...