LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 200290 when running a pulse count and pwm program together.

Yes my daq does have a counter output,how do i go about doing this to create the pwm for the motor.

 

Regards Anthony

0 Kudos
Message 11 of 33
(2,504 Views)

@Anthony_Bracken wrote:

Yes my daq does have a counter output,how do i go about doing this to create the pwm for the motor.


Look in the example finder for pulse generation or PWM, or search this forum. I don't believe the DAQ Assistant can configure a counter to generate a PWM output with a variable duty, but maybe it can - I use the DAQmx functions directly, not the DAQ Assistant.

0 Kudos
Message 12 of 33
(2,500 Views)

Hi nathand,

I done as you suggested and researched pwm using counter output from my daq and from this i have developed the following program.

My problem is that when i run my program the motor switches on and off and there is no reaction from the PID.

Can you plesae help, as i am very new to lab view and my daq.

I have attached my program and a screen shot.

 

Regards Anthony

Download All
0 Kudos
Message 13 of 33
(2,478 Views)

Hi nathand,

Just a suggestion is it possible to ring you as i find sometimes talking direct can be more productive with questions and so on.

If not dont worry the help is greatly appreciated.

 

Regards Anthony

0 Kudos
Message 14 of 33
(2,474 Views)

You need to go through some LabVIEW basics. You have two separate loops - one for the measurements, and the other for the PWM. This was fine when those functions were completely separate. Now you've added the PID, so the PWM depends on the measurement. You cannot use a wire to pass data between loops that need to run in parallel, because there's no data on the wire until the first loop completes, and the second loop cannot start until there's data on all of the wires that feed into it. If this doesn't make sense, run the VI with execution highlighting (the lightbulb icon in the toolbar).

 

Using the counter output to generate the PID signal, there's no longer a need for two separate loops. The counter will continue to generate output without writing samples to it constantly unlike the digital output that you used initially. Try moving the PID and PWM generation into the main loop.

0 Kudos
Message 15 of 33
(2,465 Views)

Hi nathand,

The vi, runs fine now with everything in the one loop.

I have connected the rev per min to the process variable and a slider to the set point.

My problem now is where does the out put connect to i tried to connect it to the duty cycle on the DAQmx write but no response.

Also to change the speed of the motor i am varying the duty cycle, but i have to stop the vi everytime i want to vary the speed, how do i get around this as i dont want to start the motor under load. this did not ocur when using the other vi's for PWM.

 

Attached is my vi and screen shot

 

Regards Anthony

Download All
0 Kudos
Message 16 of 33
(2,452 Views)

All of the counter setup should be outside the loop; only the DAQmx Write should be inside the loop. Have you looked at whether your code generates any errors? You can only set the duty cycle when the code starts because after the first loop iteration, your current code returns an error when you try to create the the DAQ task since the counter resource is already in use (by the task that was created on the first loop cycle). If you create the task only once, outside the loop, you won't have this problem.

 

Change the duty cycle by using the Duty Cycle input to DAQmx Write.

 

Why do you have a completely unused DAQ task being created outside the loop, and then cleared inside it? Also, clean up your wires - there's no need for wires to run underneath the while loop.

 

When you connected the PID output to the duty cycle input, did you probe the output from the PID to see if it's responding? The Duty Cycle input is 0-1 (for 0-100%). You appear to have the PID output range set to 0-5, why? The PID output range should match the limits of the duty cycle. Have you tuned the PID at all? You are unlikely to get any sort of good response from your system prior to tuning, and there are many resources available (the PID toolkit manual, other posts on this forum, and elsewhere on the web) to help you tune a PID loop.

0 Kudos
Message 17 of 33
(2,449 Views)

The new vi is now tidy and looks presentable.

for some reason the pid gains and ouput settings dont save. thats why you saw the figures that you did.

I have now connected the duty cycle to the output of the PID and i do get a response, but now i cant vary the speed as i have no control of the duty cycle, also the motor is now pulsing when i run the vi. I cannot start to tune the PID untill the program is right.

Attached is the updated vi and screen shot.

 

Regards Anthony

 

Download All
0 Kudos
Message 18 of 33
(2,439 Views)

The cleanup is a good improvement. You still have a DAQmx Task that's not doing anything and should be deleted.

 

This sounds like the program is right and the PID gains are wrong, probably leading to the motor pulsing. You can save the initial PID gains and output limits by making the desired values the default values (right-click on the control, make current value default). Start with all the PID gains at 0 and you should get no output from the motor. Note that you'll get an error if you write a duty cycle of 0, so make the PID output minimum some very small value greater than 0 instead. Then slowly increase the proportional gain only until you start to get some response. Once that works, you can start trying to tune. If you really need a zero duty cycle then you need to write some additional code to stop the task when the duty cycle is 0 and restart it when the duty cycle is greater than 0, but usually some very small value is sufficient instead of 0.

 

EDIT: by the way, many forum users won't look at screenshots saved as Word documents. Word isn't an image format. Paste the screenshot into mspaint and save it as a PNG; that way you can embed it directly into your post (if you want) and it will be in a standard format.

0 Kudos
Message 19 of 33
(2,433 Views)

Hi nathand,

I am having problems.when the set point speed is set to 0. the motor still pulses, this should not happen.

Then when it is runnig the program crashes. I had the motor running at one stage but no matter what values i put in for the proportional gain the actual speed  never tried to follow the set speed.Do i need to chage the frequencey. The values you see on the program are what i started to test with.

 

Regards Anthony

Download All
0 Kudos
Message 20 of 33
(2,422 Views)