LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Again, you still have a DAQmx Task that's not doing anything. Why is it there? (admittedly it's not hurting anything)

 

I can duplicate your crash on my machine with simulated hardware. The problems appears to be that you don't always have any pulses detected, so when you take the reciprocal you get Infinity, and that causes problems somewhere later (I think when you try to write the duty cycle, but maybe earlier). This will happen any time the motor isn't spinning, so you should add some logic to check for this situation and substitute an appropriate speed. You might also consider doing the pulse counting in hardware using a second timer channel if your myDAQ has one.

 

You can set the lower limit of the PID output much lower than the current 2% (0.02). It might be that your motor still pulses at that duty cycle. I think the minimum duty cycle is around 1e-10. Alternatively, you can stop the pulse output entirely by stopping the task, but you then need to restart it when the duty cycle is no longer 0.

0 Kudos
Message 21 of 33
(1,525 Views)

nathand,

I have changed the pwm side of the program and get a better response from the motor, i can varie the speed by varying the duty cycle.but i dont want this as i would have to varie the duty cycle and the set speed which does not make sense.

 

To be honest i think i am going round in circles, i dont now what to do from here.Even with the new program i cant and dont now how to connect the output of the pid. I am starting to think i should scrap the whole thing and try a different approach but time is not on my side and i have to be honest and say its not a lack of trying or researching.

 

Regards Anthony 

 

 

0 Kudos
Message 22 of 33
(1,512 Views)

You have everything connected properly in your "rev per min 6.vi." The problem as far as I can tell is that when the rotations per minute is 0, the Pulse Measurements VI returns a period of 0. Then you take the reciprocal value of that, and the division by zero returns a result of infinity. Then you store that infinity in the shift register so it's stuck there for the next several cycles. Of course, when the revolutions per minute is infinite, the PID doesn't respond properly. You need to add some additional logic to handle this situation, so that it correctly computes a speed of 0 RPM.

 

Have you used any of the LabVIEW debugging tools (probes, execution highlighting) to watch what your code is doing? That may help.

 

Also, as I keep mentioning, there's a DAQmx Create Task that's unnecessary on the left side of the loop, connected to a DAQmx Clear Task inside the loop that also isn't needed. You should delete these.

 

EDIT: I should add, if you want to use the "rev per min 5.vi" as your starting point, you just need to wire the PID output instead of the Duty Cycle local variable. You still have the same 0 RPM problem, though, and you don't need two stop buttons nor the "Is Task Done" function.

0 Kudos
Message 23 of 33
(1,507 Views)

nathand,

Why is it that when the set speed is set to and when i run the vi the motor pulses.should it not sit still untill i increase the set speed.

The rotations per minute returns to 0 when i stop the vi. When you open my vi, the values you see is when i stop the vi, also i am unsure how to go about fixing the 0 problem .

Regards Anthony

0 Kudos
Message 24 of 33
(1,502 Views)

I don't know anything about your motor configuration. However, you have set the minimum duty cycle to 2%, and the frequency is 1hz. That means you'll still get a fairly long pulse (20ms) which might be enough to activate your motor. As I suggested earlier, you can make that minimum duty cycle much shorter, or stop the task entirely. When you use the manual control (no PID) and you set the duty cycle to 2%, does the motor still move? Also, how did you pick 1hz?

 

Adding some logic to deal with the case where the period is 0 is easy; you just need a case structure around the math so that when the period is 0 (or, better, less than some small value) the RPM is 0. Do you understand why 0 RPM would cause a problem with your code?

0 Kudos
Message 25 of 33
(1,497 Views)

nathand,I have added the case structure,can you check it for me. also when i set everything in the program to 0 the motor still runs (pulses).Why?

I have used the same program just to test the motor like in rev per 5 and it works fine.

I also used the highlight and saw two errors -200684 and -200279.

 

Regards Anthony

0 Kudos
Message 26 of 33
(1,505 Views)

@Anthony_Bracken wrote:

nathand,I have added the case structure,can you check it for me. also when i set everything in the program to 0 the motor still runs (pulses).Why?

I have used the same program just to test the motor like in rev per 5 and it works fine.

I also used the highlight and saw two errors -200684 and -200279.


Did you read the text of those errors? You can ignore -200279, that's occurring only because execution highlighting slows down the code execution. Error -200684 says "Pulse duty cycle specified is not supported for this device given the pulse frequency and Counter Timebase Rate." So, you can't use whatever duty cycle you're trying to set. What duty cycle value is that? Where is the error occurring? Note that you start with an initial duty cycle of 0.5 (the default value when you create the task, since you left it unwired). I'm guessing that the invalid duty cycle is being ignored and it's continuing to run at that initial 50%. However, I can't see your system. Does it look like it's running at 50% duty cycle? Have you tried hooking up an oscilloscope instead of the motor to look at the signal?

 

The case structure looks fine. EDIT: sorry, typed too fast, the case structure is NOT fine. Check your logic. TEST! You could easily verify whether your code is correct by pasting the logic and case structure in a new VI and looking at the results, instead of asking me to do it.

Message 27 of 33
(1,503 Views)

Hi Nathand,

I have made some changes to the program, i am able to run the motor at the settings you see on the program, I still get the error -200684, i dont no why as my duty cycle is within limit 0-1.It is set at 0.7 any lower and the motor wont run.I have changed the case structure and when i test the logic seems fine to my understanding.

I do get a reaction from the mtor when i change the Kp gain. But I still have no control over the motor and i cant see why? Can you help with this. I am using a solid state relay to switch the motor maybe this is the problem and the out put to this is digital. I was looking to increase the speed of the motor gradually,like with PWM.

 

Regards Anthony

0 Kudos
Message 28 of 33
(1,491 Views)

Sorry for my confusion in the previous post; the case structure looks OK (at least in the most recent one), the logic is just backwards from the way I would have set it up and I didn't look at it too closely. I find that 1<value is harder to understand than value>1, but maybe that's just me.

 

Which function is generating the -200684 error? Please READ the error text. It is telling you that you can't set the duty cycle you want (even though it's in the 0-1 range). This is due to the way the counter works. It can only count up to a certain value (and I don't know what that value is on the myDAQ, but you might be able to find it in the specifications). It counts at a certain frequency. For simplicity, let's say it's an 8-bit counter, so it can count to 255, and that it counts at 1khz. The longest period of time that it could be either on or off would then be 255ms; anything longer and the counter would overflow. That limits the achievable combinations of duty cycle and frequency. The myDAQ counter is certainly more than 8 bits, but I don't know how many it is, nor do I know what the base frequency is. You might be able to adjust the counter timebase using a DAQmx channel property node; I don't know if the myDAQ supports this nor whether it will solve the problem. Alternately try using a higher frequency, if your motor allows it. You are unlikely to get control over the motor if some duty cycle values generate errors (and therefore don't get set).

0 Kudos
Message 29 of 33
(1,487 Views)

Hi nathand,I have managed to get rid of the error -200684 which was showing up at daqmx write by changing the frequencey and duty cycle as you can see from the updated vi.I have then tried to tune the pid by using the ziegler-nichols method but its not working for me. I am using a variable power supply and when i vary it the motor speed varies.so if the motor is running at 1700 revs and i set the set point at 1750 no matter what values i put in the motor speed will not increase unless i increase the power supply.Can you help?

Regards Anthony

Download All
0 Kudos
Message 30 of 33
(1,470 Views)