Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

event based sampling and output

Solved!
Go to solution
Try this and tell me how it works out.  I might try to test it myself later today if I get a chance.  Cheers, Matt
Message 11 of 41
(2,239 Views)
Solution
Accepted by LucyXF

Hi guys,

 

I think Matt has the right idea, but rather than triggering the tasks off of the signal from the counter I would use this signal as a Sample Clock.  From what it sounds like you want to update a single sample every N degrees, so all you would need to do is generate a sample clock edge based off of the encoder.

 

One reason that this solution would be preferable to using triggers is that M series boards do not support retriggerable analog tasks.  You would have to start/stop the task in order to trigger again and risk missing samples.

 

 

I went ahead and put together an example on our Community Site.  I admit that the block diagram might be a little messy, so if you need any help understanding what's going on don't hesitate to ask.  The example will only work properly if the encoder is counting in a single direction (since it generates the sample clock based off of encoder ticks regardless of which direction they occur).

 

Update AI/AO Every N Degrees of Encoder Measurement

 

 

-John

John Passiak
Message 12 of 41
(2,236 Views)

Hi John,

 

I like your idea of not needing to retrigger the task. However, the usb-6211 that I'm using only has two counters. I have another encoder(counter) measurement besides the one that we've been discussing about. The freqout signal is also occupied now. I don't know if there's anyother way of creating a sample clock without using an extra counter. Thanks!

 

-Lucy

0 Kudos
Message 13 of 41
(2,219 Views)

Nice, John. I already feel smarter Smiley Happy.  If I am to understand this correctly, to make this simple (as in my VI), you would remove the trigger that I have and then change the clock on the AO to Sample Clock using the internal output of counter 0 (what I have) as the source?  She is only doing a single AO shot, so she shouldn't have to build an AO signal, correct?

 

It looks like you have two encoder inputs for the CI Encoder Angle - why two?  Will this just produce a measurement of a relative angle if you have two encoders?

Message 14 of 41
(2,218 Views)

Hi mtat76,

 

Thanks for your constant help. I understand what you said and will try your scheme later. We have two different rotational parts in our system and we want to measure the angular velocity of the other part using the other counter. 

 

I'll let you know if the scheme works. 🙂

 

Thank you so much!

 

-Lucy

0 Kudos
Message 15 of 41
(2,215 Views)
Lucy, you actually have 8 PFI lines that you can use for this signal - are you counting on the other encoder?  But, maybe I am jumping the gun  - I still don't understand why John's VI is consuming both counters.  OK, I'll be quiet now and let John explain Smiley Wink.
Message 16 of 41
(2,214 Views)

Maybe I got it wrong. I assumed that John's vi would use two counters since I saw one CI and one CO tasks. Please let me know if I'm wrong. Sorry I'm a newbie.:P

 

-Lucy

0 Kudos
Message 17 of 41
(2,210 Views)

Hi Guys,

 

My VI was using two counters since I had assumed you wanted to measure the angular position as well as control AI and AO (I wasn't aware of another counter task going on somewhere else).  If you take the angular position task out then it would only require a single counter to generate the sample clock

 

Are we sure about a single shot of AO?  I had assumed Lucy wanted to update the voltage every 30 degrees (for example).  If we were just doing a single-shot of AO, then using a trigger as in Matt's example would be fine, although setting the AO sample clock to Implicit should throw an error (use a Sample Clock instead). 

 

You're correct that changing the simple example to use Sample Clock with the Internal Output of the counter as the source would route the counter signal to the sample clock--my example ended up looking pretty complicated in retrospect due to all of the conversions to make the front-panel more user friendly.  It could have probably used a couple of sub-vis in retrospect.

 

 

If we could get a more complete description of what exactly needs to happen (including timing diagrams if possible), it would probably be easier to offer advice.  With exact requirements it would be easier to do some brain-storming to see what we could come up with.

 

 

-John

John Passiak
Message 18 of 41
(2,203 Views)

Hi John,

 

I think I do need to know if the encoder is rotating clockwise or counter-clockwise. Is there anyway of getting this information while providing sample timing using only one counter? And also, I do need to update the AO every 30 degrees. I guess this means that we have to adopt the idea of sampling using the counter timing?

 

The overall system goes like this: we have 1 AI input (which also requires a pusle train excitation by the Freqout port of the board); 1 encoder measurement measuring the angular velocity of some part; 1 AO to control the motor; 1 counter/encoder(angle/position measurement) input based on which the timing of the other tasks will be defined. Everytime the angle passes certain degrees (e.g. 30 degrees), the AI and the velocity measurement tasks take in measurement values, based on these values, the controller calculates a control input value and passes it to the AO port to control the motor. All of the input and output signals need to be updated every 30 degrees. It will also be better if the vi can only start working after the z-index of the encoder signal generates a pulse (meaning that it passes certain position). The excitation signal for the AI measurement will be working based on independent timing though.

 

I don't know if I have stated the situation clearly. Please let me know if there is some key information that is missing.

 

Thanks a lot!

 

-Lucy

0 Kudos
Message 19 of 41
(2,182 Views)

Hi Lucy,

 

Ah, so it sounds like the AO samples are not predetermined such that you could perform a buffered AO task (as in my example).  Thanks for the clarification.  Out of curiosity, why do you need to update the controller every 30 degrees?  I would think you would want to update it as quickly as possible.  If the output value is going to be based off of the inputs then there will be some latency there and synchronizing to every 30 degrees doesn't make as much sense.  Since you are on a USB DAQ device the latency would be relatively high just to make the transfers from the 6211 and back.

 

Also, are there one or two analog inputs?  It sounds like you currently have one based off of Freq Out which shouldn't be necessary since AI has its own sample clock engine.  You can only have 1 sample clock and trigger shared across all of the AI channels, so if you want to run one AI task based off of a clock and the other based off of the encoder than this would not be possible.

 

If I was using the USB 6211 for motor control, I would probably elect to use software-timed single-point AI and AO.  This way, every time the loop runs in software we would simply pull back whatever AI data is available at that time and output to the AO based off of this data.  However, this would completely disregard the request to sample AI and AO every 30 degrees.  Keep in mind that USB is inherently non-deterministic, so even on a RT system we wouldn't be able to get the AO to update at a consistent delay from the AI.

 

 

-John

John Passiak
Message 20 of 41
(2,175 Views)