Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

switching PWM output by routing

Solved!
Go to solution

Hello

I want to set up a control loop with 2 PWM signals that would be connected to 2 inputs of a H-bridge driving an electric motor. So one PWM would make the motor go clockwise, the other counterclockwise. (similar to a heating/cooling controller)

 

Two independent counters are available (PXI6602).

 

When I want to change the direction, I have to turn off the one PWM signal and turn on the other. However, duty cycle 0.0 is not allowed. I could stop the one /start the other task and vice versa, but this seems very cumbersome.

Is it possible to route the counter output (i.e. PWM signal) through to a digital line? That way, I could keep the 'non-active' PWM running at minimum duty cycle while the 'active' PWM does his job, and just inhibit the respective output line by digital zero-ing it.

 

Thank you for your attention.

Michael

0 Kudos
Message 1 of 6
(5,783 Views)

Hi Michael,

 

is it a possibility for you to use a case structure where you pass the PWM to one input and a falsecontant to the othe? Switching the case will rout the PWM to the other input

 

Kind regards

Carsten

0 Kudos
Message 2 of 6
(5,766 Views)

Hi Carsten

No, I don't think I can. The signal is not present as a waveform that I could pass around through case structures. Instead, it is generated within the hardware via DAQmx-Counter output tasks. So the routing will have to take place within the hardware as well.

 

My current un-solution does more or less what you suggest: I wire both tasks into a case, but I write updated duty cycles only to the active task. However, since H-bridges may misbehave when both inputs are high, I have to stop the inactive counter output. Whenever the motor direction changes (transition = TRUE), this is two steps more than I prefer, considering 20 ms cycle time and 140 Hz PWM base frequency.

 

SetPWM_vi.jpg

 

 

Well it sort of works. And yet.....

Michael

0 Kudos
Message 3 of 6
(5,761 Views)
Solution
Accepted by topic author nimic

Hi Michael,

 

I found an example which is probably meeting your requirements. Here is the link:

 

http://zone.ni.com/devzone/cda/epd/p/id/4422

 

Please let me know if this helps solving your problem

 

Kind regards

Carsten

NI Germany

0 Kudos
Message 4 of 6
(5,758 Views)

Hello, Carsten

Thank you for your reply. Indeed, it answers my question, both in the negative and positive sense: It is possible to do what I want, but it takes different hardware (M-series) than the one I have installed.

 

So I'll stick to my On/Off solution with my E series board.

 

Michael.

0 Kudos
Message 5 of 6
(5,753 Views)
Hello, again I revisited the thread to update the solution: Routing a pulse output not limited to M-Series but it is possible with the 6602 (or other TIO-devices). It works with the PFI lines available for the counter as shown in the MAX-Device connection table. For my 6602 f.i. I can de-route the ctr0 (originally on PFI36) to either PFI 8 or 9. (Which are then, obviously not available for other tasks). When setting the new route via 'Set Channel Property' -> 'CO.Pulse.Connect', other routes are not automatically disabled. As described in Carsten's link above, it must be set to tristate with the appropriate function. Unfortunately, the routing and tristating only works ehen the counter task is stopped. Swapping routes therefore always requires a sequence of 'Stop task' - Tristate old line' - 'Route to new line' - 'Re-Start task'. But it works.
Download All
0 Kudos
Message 6 of 6
(5,363 Views)