06-25-2018 11:20 AM
Hi,
I have some issue.
I want to restart one counter output. When I turn on the pause switch, the one counter output pauses in the vi.
However, when I turn off the pause switch, the one counter dose not restart in the vi.
When I did not use trigger signal(start digital edge) in the vi, the one counter restarted. However, synchronization of the two output signal did not match. So, I needed trigger signal(start digital edge) in order to match synchronization.
How should I do to restart the counter output?
Here is my VI and the diagram
Thanks.
Solved! Go to Solution.
06-25-2018 04:57 PM
I'll walk through a literal description of your problem. There are different ways to attempt to "solve" it, but I don't know what you really need to accomplish with this stop and restart.
1. You've configured 2 counter output tasks to be triggered off the same signal. They have the same frequency but one has an initial delay. Fine so far.
2. You also generate your own triggering signal and the task sequencing makes sure both counter output tasks are ready for it. Thus, from one run to the next, you get precise relative timing of these two pulse trains. Still fine.
3. You've then introduced a "pause" button that will be used to stop and re-start one of the pulse trains. The nested case structure and polling loop isn't a particularly advisable approach, but the literal problem is that the restarted task is again waiting for a triggering edge on PFI0. Since you don't generate another one, the pulse train never restarts. This is core of the problem.
4. Even if you *did* generate another triggering pulse, you wouldn't re-establish the original timing relationship between the pulse trains because the other counter just keeps running continuously and won't react to further trigger edges.
5. To reestablish the original timing relationship, you'd need to stop and restart both counter tasks, then generate a new triggering pulse to sync them.
-Kevin P
06-26-2018 11:21 AM
I also worried that the I would not be able to re-establish the original time interval relationship between two counter outputs.
I will re-generate the both outputs or will find other ways to sync the signals.
I really appreciate your help.
Thank you.
05-01-2019 08:22 AM
This thread is relevant to what I am trying to do. My project is to write a LV code to generate two pulse trains, one pulse train to turn motor clockwise and the other counter to turn it counter clock wise. There are limit switches that will trigger to logic high when the motor reaches the travel limit. I could use these Digital Input to pause a pulse train. I could also create another Digital Out task to edge trigger a pulse train for opposite direction. My dilemma is what happened to the first pulse train that was paused by the limit switch when it's released. The second pulse train will restart the motor in opposite direction. Upon departure, the first pulse train will loose the pause trigger. Two pulse trains cannot be on at the same time. Is there a latch function for pause? That can be later reset?
05-01-2019 09:20 AM
1. Yes, it sounds like it'd be a good idea to use pause-triggering on the pulse trains to make sure pulses stop when your device trips a limit switch. This helps protect your equipment, but it doesn't automatically notify your software.
2. Thus, you should probably *also* poll the limit switch states with a DI task. When you detect that one of them has tripped, you know it's appropriate to stop the pulse train task that moved the motor into that limit switch. And once you do stop it, you further know that you're now free to start the other one.
-Kevin P
05-01-2019 09:45 AM
Thanks for replying.
My problem is a little more complicated than that.
I need to cycle two pulse trains alternatively for many loops. So, pausing a pulse train when the limit switch is hit and DI logic is high is already implemented and working fine in both CW and CCW directions. My problem occurs when the limit switch is released and the DI log high that paused a pulse train is longer at high, I would like to have the paused state still remain at paused state by latching function if there is. I would like to also restart the pulse train when one cycle is complete without having to configure it again.
05-01-2019 11:17 AM
Any "latching" of a pause trigger signal would have to be done with external circuitry -- no NI DAQ board I'm aware of would support such latching at the hardware level (needed because pause triggering works at the hardware level). I don't think there's much to be gained from such an approach though.
And I don't really understand what you consider to be complicated here. You shouldn't need to reconfigure the pulse train tasks, you would just stop and start them at appropriate times.
You use the passive voice with the phrase "when the limit switch is released", but isn't your software in charge of deciding when to generate the motion that would cause a limit switch to be released? What I'm picturing is that you run the CW pulse task and when you notice the CW limit switch going high, you stop the CW task before starting the CCW task. Then when you notice the CCW limit switch going high, you stop the CCW task before starting the CW task again. Etc.
Am I missing something? Is there a reason your software can't notice when a limit switch trips, stop the pulses driving the motor into the limit switch, then start the ones that drive the motor back out of it?
-Kevin P
05-01-2019 05:09 PM
@Kevin_Price wrote:
2. Thus, you should probably *also* poll the limit switch states with a DI task. When you detect that one of them has tripped, you know it's appropriate to stop the pulse train task that moved the motor into that limit switch. And once you do stop it, you further know that you're now free to start the other one.
Not sure if this is relevant, but rather than polling the DI task, you can set up a Change Detection Event, a read it when it triggers the Event Structure, see below.
mcduff
05-01-2019 05:20 PM
I setup the Digital Input to recognize the limit switch (#1) is triggered and when it is, the CW pulse train is paused. Yes, my SW can recognize the DI is in HIGH state. The SW should immediately stop the CW pulse train and start the CCW pulse train. But, motor didn't respond to it. So, I was looking for similar problems in NI forum and found your answer to this thread. It made a sense to me that when you mentioned that between STOP and START again, task needed to be configured again. Although I could configure every time STOP and START routine is called, it could add extra test time significantly since SW is also doing other measurements in the same loop. I thought that hardware triggering would be a lot faster. I have some other ideas to try now. I will keep you posted later. Thank you for your advice.
05-01-2019 05:30 PM
I agree that the "change detection" approach is better than polling if the DAQ device supports it. It didn't occur to me at first because I earned my DAQ stripes back when change detection was a fairly rare and exotic feature. These days, it's pretty likely that a board with 2 counters will also support change detection for DI. Thanks for the reminder!
-Kevin P