10-27-2009 06:33 AM
Hi,
I'm trying to control a dc motor and currently using a HEDL-5540 encoder. I used to get some measurements with p-control, but since i had too many oscillations i used sample clocks. Now i get a message that i need to use an external clock. the error that occurs is:
Error -200303 occurred at DAQmx Start Task.vi:2
Possible reason(s):
Measurements: External sample clock source must be specified for this application.
Unspecified Property: SampClk.Src
Channel Name: Dev3/ctr0
Task Name: _unnamedTask<3A>
I'm using a usb-6221 card
Is there anyway to avoid it or to fix it?
thanks in advance
10-28-2009 02:59 PM
Hello,
The reason you are receiving this error is because when performing buffered (sample clock) encoder measurements you must use an external clock. One thing you can do is generate a pulse train with the other counter and use that as the sample clock. I also noticed that you had your sample rate set to 1MHz. The max sample rate for the USB-6221 is 250 kS/s, so you will want to look into reducing your rate. Please let me know if you have any additional questions.
Regards,
10-30-2009 05:14 AM
Well, i'm not sure i understand how this works. For example i've used the example retriggerable ao and i dont understand wether i need for my vi the waveform buffer generation, (see i've recently started using labview). I haven't achieved something yet. Also at the example vi when i put a desired frequency of 250k an error occurs
Error -200077 occurred at Property Node DAQmx Timing (arg 1) in Waveform Buffer Generation.vi->retriggerable_ao.vi
Possible reason(s):
Measurements: Requested value is not a supported value for this property.
Property: SampClk.Rate
You Have Requested: 12.500000e6
Valid Values Begin with: 22.250739e-309
Valid Values End with: 10.0e6
Task Name: _unnamedTask
But shouldn't i put the cards samplerate??
10-30-2009 07:46 AM
11-02-2009 03:43 PM
Hello,
One thing I noticed is that you don't actually write anything to the card before you begin generation. Also, what rate are you actually setting the output to and how many channels are you writing to?
Regards,
11-03-2009 03:11 AM
Hello Brandon B
thanks for the reply,
Let's leave the rate at the moment because it is something that can be easily arranged(i think). I ve been looking over some examples and noticed that we use a CO freq for the implicit timing and an ΑΟ channel for the generation. I want to write to an AO but voltage which I control, or better the error i build through the PID and the saturation (at the vi i have only Kp).
the usb-6221 i use i found out that the AO 0 channel does not work properly. So now remains only one AO, AO1.
So here is the issue...
I tried to simplify things and used the vi that is included. This vi generates a pulsetrain that is retriggerable.I have added two comments of my own to explain what i'm trying to achieve .
Can i use for external clock a simplier vi? and can i do it using only one analog output channel? If i solve this i believe i can fix the vi that posted in previous threads.
Sorry if i haven't specified or understood everything, but i'm new at this. Thanks in advance..
11-04-2009 12:13 PM
Hello,
There are a couple of notes that I would lilke to add to the examples that you have submitted. The first is that your program is configured to use a retriggerable finite counter as your sample clock. You won't be able to do this with your application because retriggerable finite counters require the use of both counters on your DAQ card, and since you would like to use the other counter for encoder measurements, your best bet would be to use continuous pulse train generation, which only requires one counter, as your sample clock. There is an example in the NI Example Finder (Help>>Find Examples) called Gen Dig Pulse Train-Continous-Dig Start.vi that I think will be perfect for your application.
For your encoder task you should take a look at the example Meas Angular Position-Buffered-Cont-Ext Clk.vi, which is also in the NI Example Finder. Notice how they use a DAQmx Timing VI, which is necessary for continuous encoder measurements. For the sample clock source of your encoder measurement you will want to choose your devices internal counter signal. For instance, if my device was Dev 1 and I was using counter 0 as the counter for pulse train generation, then the sample clock source would be "/Dev1/Ctr0InternalOutput". If you do not see this option in the drop down menu for Sample Clock Source then you need to right click on the drop down menu and select I/O Name Filtering. In the Filter Names menu make sure that Include Advanced Terminals is selected. Once you do this you should be able to find your counters internal output in the drop down menu.
The last step is the analog output task. This task doesn't require a sample clock because you will only be writing to it after processing your counter measurements. You can get rid of the DAQmx Timing VI as well as the Waveform Buffer Generation VI for this task. This way, a write will occur only when the VI is called, which is after the counter measurement is processed. Also, you want to make sure that you are clearing your analog output task, which I noticed you weren't doing in your original VI (input-output kp only with clock-1.vi). A good example for this is the Gen Mult Volt Updates-SW Timed.vi from the example finder.
So in summation, each of those three examples is how you would want to configure each task. Each example also has a while loop in it, so you would want to combine them into one large while loop, which included your PID algorithm. Try this out and let me know if you have any questions or encounter any problems.
Regards,
11-10-2009 02:48 AM
Hello Brandon,
thanks for the reply. I created a vi under your suggestions, that works fine, but unfortunatally does not fix my problem with the oscillations, perhaps i need to try some other way to fix it.I thought that a quicker sampling could do it . I did not use the example of analog output you suggested (although i tried it) because i think the one i use is simplier. I have attached the vi, in case i have something wrong that i haven't taken in mind and maybe helps. I don't know if there is a better way to wire the errors, for example i have seen some vi.s where the error wiring starts eg from the analog output, and passes through the CO pulse freq and the timing .vi. If you have some suggestions they are more than welcomed.
11-10-2009 02:51 AM
11-10-2009 06:52 AM
additionally:
to give you a full idea of what i'm doing. I'm trying to control an RE40 150w maxon dc motor. the hedl 5540 encoder provides me the position feedback. from the usb-6221 i take the voltage output to a maxon 4-Q-DC servoamplifier to the set values connectors. I use current control and have adjusted the pins and potentiometers for current control. I could use encoder control, but it is my thesis so I want to do the control, not the amplifier.
the problem is that when i operate the system, with Kp=1 for example i have oscillations. I set for example setpoint=1 with initial position=0 it builds the error correctly but i have oscillations from -75to 80 all measured to radians.
I also have added a mass on the motor to increase inertia
I don't know if this information is helpful, but any ideas, if my problem has nothing to do with the sampling, are welcome.