Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

ENCODER / NI USB 6341

Greetings everybody, at first i want to excuse my terrible english, but i am gonna do my best 🙂

 

description:

 

I am in my summerholidays, working in a company which produces electrcal maschines.

My job is it to measure the time and de distance which passes by between  the moment an emergency-stop occured and the point where the velocity of my machine is < 0,01 m/s

 

As you can see in my Vi (attachments) i programmed an eventstructure where i can handle some options through the frontpanel.

 

My question is about the event-case MESSUNG.

 

In this Event-Case i Measure the Period and de Count_Edges from my Encorder after a Trigger starts. This trigger starts after the emergency-stopp-button is set to true.

 

in the while-loop i always take 10 samples from the buffer and calculate the velocity, proof that this velocity is >0,01m/s, store the Counter-Sample in an array, give 5 V to an analog output.

 

When the velocity is <0,01m/s the while-loop stops and i  calculate
way = max.counter.value *0,1mm

time = number of measured samples/sampleRate

 

This process i repead 11 times, because i have to make 11 measures and then take the worst case out of them.

 

Today i tried my program on a machine and failed.

 

1) Question

i took Implicit- Timing for my Period-measurement and Sample-Clock Timing for my Counter-Measurement. Otherwise it didn´t work.

 

2) Problem

When the velocity is < 0,001 m/s the while-loop doesn´t stopp, but an error 20028 occures at the Read-VI from the Period.

 

3) the values i get are often wrong, seldom write. I just don´t know whay it doesn´t work as i want.

 

Can anybody help me and give me some tipps or tell me what i am doing wrong?

 

i just work with labview for 2 weeks, i know that i know nothing 🙂

 

would be very nice of you.

 

 

0 Kudos
Message 1 of 9
(3,706 Views)

Hello Amadeus,

 

thank you for posting your Questions. First of all i can see some basic programming issues, like putting a lot of code, includings loops  inside an event structure etc.. It is always recommended to take part in some of NIs Trainings. You can always do some self paced  online courses: to improve your skills, if you do not have the chance to visit a full training:

 

Online Training

http://sine.ni.com/tacs/app/fp/p/ap/ov/lang/en/pg/1/sn/n5:selfpacedonline/

 

On the other hand ther is a very good online Documentation, especially about Data Acquisition with DAQmx:

 

Getting Started with NI-DAQmx

http://www.ni.com/white-paper/5434/en/

 

But lets take a look at your Questions:

 

1) Question

i took Implicit- Timing for my Period-measurement and Sample-Clock Timing for my Counter-Measurement. Otherwise it didn´t work.

 

So, you use implicit timing if you don't need to have a reference, like for counting edges. Therefore you use a Sampleclock.

 

2) Problem

When the velocity is < 0,001 m/s the while-loop doesn´t stopp, but an error 20028 occures at the Read-VI from the Period.

 

Are you sure its Error -20028?

 

3) the values i get are often wrong, seldom write. I just don´t know whay it doesn´t work as i want.

 

Which Values?

 

You can try to seperate parts of your code and take a look at the issues one by one.

 

Take some Examples from the LabVIEW Examplefinder and test some of them. This will also help you to understand what you are doing and why it does not work.

0 Kudos
Message 2 of 9
(3,633 Views)

Hello GregorP, 

 

today i am going to change the structure a little bit, like it´s done in the example vi state machines fundamentals...

so that i don´t have that much code in the event-structure anymore.  I don´t know, why that should help anything, but maybe the timing is better.

 

So, you use implicit timing if you don't need to have a reference, like for counting edges. Therefore you use a Sampleclock.

 

I don´t get it. I use sample-clock if i want to set the sample rate by my own? And i use the implicit -timing if i (for example) just want to count edges?

What do you think, does my program have a timing-problem? Because i think, that i must get samples in the same time. I read the Period-Task and de Counter-Task as long as the velocity is 1mm/s.

When its slower, i stopp the measurement. After that i need the last value oft the Counter and also the number of samples i read.

 

The time, my measurement required is : numbers of samples while the measurement/sample Rate.

 

Therefore i need a exact sample rate!

 

Are you sure its Error -20028?

 

Sorry, my fault. It´s Error 200284. The problem is, that i don´t finde any descriptions for this error, I think it has to do with the timeout from my read-task. But i set it to 10 sec, and the while-loop should end when the period is >1s which is equivalent to a velocitiy 1mm/s.

 

Which Values?

 

When the measurement ends, i get the values (nachlaufzeit = measurement-time; nachlaufweg= measurement-way)

measurement-time = samples while the measurement/samplerate
measurement-way = max.counter value * 0,1 ( because 10 inkrements = 1mm)

 

And this values aren´t consistent true. I don´t know why, but mostly i geht 860ms for the measurement-time...even if i start the measurement with 3m/s or 0,2 m/s.

The measurment-way is mostly correct. Just if the velocity is too slow, i get wrong values. For example(sample-rate is 10.000 Hz) i simulate an braking action at 2m/s highspeed and 800mm braking distance. Then my measurement for the measurement-way is good and i get the 800m. But when i simulate the same settings, just change the velocity highspeed from 2m/s to 0,2 m/s the value of the measurement-way is totaly wrong. About 17mm or something. When i have such slow velocity´s, i have to scale down the sample rate to ~1000Hz to get correct values. But whats the difference? I just get less values/sec.

 

do you have an idea?

 

 

For your information: the idea of this program is to measure the way  and the time a machine needs from highspeed to stopp after an emergency-stopp!

 

My measurement is triggert by an input which i get from the safety of the machine. So exactly when i get the trigger at PFI6, de machine begins to stopp! And then my measurement ends when the velocity of the machine is < 1mm/s.

 

So i count the edges and the period of an encoder.

 

 

 

thank you for your help!

amadeus

 

 

0 Kudos
Message 3 of 9
(3,626 Views)

Hi Amadeus,

 

you are running into a timeout error. 

Why Do I Get Error -200284 from my DAQmx Read VI?

http://digital.ni.com/public.nsf/allkb/FEF778AD990D5BD886256DD700770103?OpenDocument

 

Try to set the timeout Value to "-1", then there will never be a timeout.

 

My second thought would be to measuere the time with the loop. You could just do a Benchmark from start to stop. So you could eliminate one of your DAQmx paths and just do the Edge counting for the distancec measurement.

 

Here is some more information about sample timing types

 

Sample Timing Types

http://zone.ni.com/reference/en-XX/help/370466V-01/mxcncpts/smpletimingtype/

0 Kudos
Message 4 of 9
(3,622 Views)

Hi Gregor,

 

the problem is, that i do have to show a velocity-waveform. So i have to measure the period anyway.

 

 

My first concept was exactly your secound thought, but if i do it that way, i  don´t get the accuracy i need. I am not allowed to make deviations of more than 100ys. So i would like to sample with 100000Hz and read 100 values out of the buffer in one loop. So i do have this accuracy of exactly 100ys!.

 

I now try the modified structure and the timeoutvalue -1. I just don´t think that this will clear the problem with the wrong values.

 

I read your link about the sample timing types, but i still dont get it why i can´t set the sample clock timing in the period-task!

 

 

Best Regards,

Amadeus

0 Kudos
Message 5 of 9
(3,617 Views)

I think the problem is that i can´t sample the two input-tasks (period/counter) with the same samplerate.. therefore this two channels aren´t synchron.

 

Is there anybody who can explain to me, why i can´t use a sample clock timing when i want to measure the period of my input signal or how i can synchronize this two measurements?

 

best regards

 

amadeus

0 Kudos
Message 6 of 9
(3,581 Views)

here my solution by now.

 

I deleted the task for the period-measurement and took all the inforamtion from the edge counting task.

 

I now think i have to change the calculation for the velocity to moving average calculation. but that shouln´t be the problem.

 

I have to check, if i can handle the demand on the accuracy.. but with right settings on sample-rate and samples per loop it should be possible.

 

Here my VI

 

If anybody has ideas for changes, would be happy for further inforamtions

 

greetings

 

amadeus

0 Kudos
Message 7 of 9
(3,565 Views)

Now i have the Problem that the while-loop in The Case Measurement sometimes starts without any triggersignal on PFI 6.

 

When i make 10 Measurements, there is an average of 2/10 fails.

 

I really don´t know how this can happen.

 

Does anyone of u see a mistake in my programm or is this a Problem from my Hardware?

 

 

best regards,

 

amadeus

0 Kudos
Message 8 of 9
(3,518 Views)

Edit: Problem solved!

 

🙂 reason was the mechanical brake of the servoengine

0 Kudos
Message 9 of 9
(3,505 Views)