LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DC Motor control PWM

Hello,

 

I am currently trying to develop a pogram to do motor control. The things I would like my script to accomplish are the following it:

1. generate a PWM signal that can be adjust to see how my motor responds

2. take current and voltage readings using a DAQ 6009 USB card 

3. Be able to continuously acquire data as I adjust the DC of the pwm signal

 

My code is currently incredibly inneficient, if anyone could take a look at my script and offer some tips it would be much appreciated.

 

 

0 Kudos
Message 1 of 4
(5,136 Views)

Hello!

 

What I can see in your code is that you are using standard digital output to generate PWM. Unfortunately these kind of outputs are too slow to generate PWM. You have to use counter output.

 

Fortunately your DAQ card have 1 counter - you can find the spec here: http://www.ni.com/datasheet/pdf/en/ds-218

 

Here you have quite nice instruction how to use counters:
http://www.ni.com/academic/students/learn-daq/digital/

 

Marcin

              

Think Dataflow - blog.mtapp.tech
0 Kudos
Message 2 of 4
(5,120 Views)

Marcin, Mmoon,

 

The counter on the USB-6009 is for event counting only and cannot be used to generate PWM.

 

Comments on the VI:

- You have an architecture which is similar to a state machine. Switching to a state machine may be helpful.

- Also consider the Producer/Consumer architecture.  The user interface stuff and the file I/O would be better in parallel loops rather than in the same loop as the DAQ stuff. 

- The nested loops in case 1 may create issues with responsiveness to the user commands.

- It is usually best to create tasks and do other configuration things outside the loops (or in an initialization state of a state machine) than to repeatedly initialize inside a loop.  Similarly, closing tasks c-should be outside the loop or in a shutdown state.

- Before your close the DO task, write all zeros or some other value which sets the external hardware to a safe condition. You do not wnat the motor to be left running at high speed after the program stops.

 

Lynn

Message 3 of 4
(5,105 Views)

Hello Lynn,

 

Of course you are right, my mistake. I haven't notice that in that DAQ card there is only counter input.

 

In that case I think it is impossible to generate PWM with reasonable frequency using USB-6009...

 

Marcin

              

Think Dataflow - blog.mtapp.tech
0 Kudos
Message 4 of 4
(5,065 Views)