LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

New to LabVIEW - Need help with a project at work having to do with an absolute rotary encoder

I am currently working with the evaluation version of labVIEW to provide a proof of purchase for the project I am working on. I have very little experience with LabVIEW, so I apologize for my code being terrible. Let me see if I can explain what I am trying to accomplish:

The Hardware:

 

To begin, I have a BEI H25 rotary encoder (http://www.beisensors.com/pdfs/h25-optical-absolute-encoder.pdf) that outputs a 0-10 VDC analog signal. The encoder outputs the signal during one rotation, 0 degrees corresponding to 0 V and 360 degrees to 10V. When the encoder rotates past 360 degrees (or 10V) it immediately drops back to 0 V. I am inputting this voltage signal into labview using the analog inputs on an NI-USB-6009 DAQ.

 

What I am trying to accomplish:

 

 

I have a pretty simple task that I am trying to accomplish. I want to be able to turn the shaft of the encoder one direction, have labVIEW log how long it took from start to finish (time) and how many degrees the shaft rotated. Then, I need to rotate the shaft in reverse and also measure the time that took and how many degrees the shaft rotated back. I need LabVIEW to put the time and degrees for the first and second rotations into a table on the front panel and into an excel file.

 

My Current LabVIEW Code: In Order

 

1. The DAQ Assistant receives the signal continuously from the encoder.

2. The signal runs through a filter VI to reduce noise

3. The signal is multiplied by 36 (to match 0-360 degrees) and offset by -0.12

4. The signal enters an "Amplitude and Level Measurements VI" to measure the mean amplitude of the signal.

5. The mean (dynamic data) inputs to a "Delay Values" VI. It is delayed by one pulse and subtracted from the original signal. If that difference is greater than a certain value, I have a boolean output "True", signifying the shaft is currently in rotation.

 6. This is where things get harder for me. I have the signal enter a state machine. The machine waits until the previous boolean senses a rotation and the signal is not at 0V, then starts a timer. When the rotation stops, the elapsed time outputs to a table.

 

NOTE: The reason I have logic that includes checking if the signal is at zero is because the encoder has a reset switch that I have been using to begin my code.

 

I am having trouble getting this to work the way I want it to. It is very crude. I apologize if I am not clear in explaining this, but I am at my last whim. Do you know of a better way of doing this?

 

Thanks for all the help,

 

Luke

 

 

Download All
0 Kudos
Message 1 of 4
(2,587 Views)

I am currently working with the evaluation version of labVIEW to provide a proof of purchase for the project I am working on. I have very little experience with LabVIEW, so I apologize for my code being terrible. Let me see if I can explain what I am trying to accomplish:

The Hardware:

 

To begin, I have a BEI H25 rotary encoder (http://www.beisensors.com/pdfs/h25-optical-absolute-encoder.pdf) that outputs a 0-10 VDC analog signal. The encoder outputs the signal during one rotation, 0 degrees corresponding to 0 V and 360 degrees to 10V. When the encoder rotates past 360 degrees (or 10V) it immediately drops back to 0 V. I am inputting this voltage signal into labview using the analog inputs on an NI-USB-6009 DAQ.

 

What I am trying to accomplish:

 

 

I have a pretty simple task that I am trying to accomplish. I want to be able to turn the shaft of the encoder one direction, have labVIEW log how long it took from start to finish (time) and how many degrees the shaft rotated. Then, I need to rotate the shaft in reverse and also measure the time that took and how many degrees the shaft rotated back. I need LabVIEW to put the time and degrees for the first and second rotations into a table on the front panel and into an excel file.

 

My Current LabVIEW Code: In Order

 

1. The DAQ Assistant receives the signal continuously from the encoder.

2. The signal runs through a filter VI to reduce noise

3. The signal is multiplied by 36 (to match 0-360 degrees) and offset by -0.12

4. The signal enters an "Amplitude and Level Measurements VI" to measure the mean amplitude of the signal.

5. The mean (dynamic data) inputs to a "Delay Values" VI. It is delayed by one pulse and subtracted from the original signal. If that difference is greater than a certain value, I have a boolean output "True", signifying the shaft is currently in rotation.

 6. This is where things get harder for me. I have the signal enter a state machine. The machine waits until the previous boolean senses a rotation and the signal is not at 0V, then starts a timer. When the rotation stops, the elapsed time outputs to a table.

 

NOTE: The reason I have logic that includes checking if the signal is at zero is because the encoder has a reset switch that I have been using to begin my code.

 

I am having trouble getting this to work the way I want it to. It is very crude. I apologize if I am not clear in explaining this, but I am at my last whim. Do you know of a better way of doing this?

 

Thanks for all the help,

 

Luke

 

 

Download All
0 Kudos
Message 2 of 4
(2,572 Views)

Hi Luke,

 

Thank you for the very detailed explanation of your program.  You state:

"I am having trouble getting this to work the way I want it to."

 

What specifically is not functioning the way you want it to?  What type of "misbehavior" are you seeing?

One suggestion I can give you right away to follow better programming practices is to avoid using local variables where possible.  In the case where you have the 'Elapsed Time' indicator, you can directly wire to that input, rather than create a local variable.

Adam
0 Kudos
Message 3 of 4
(2,526 Views)

 Luke,

 

A few more thoughts as I look at your code:

 

1) The case structure that contains your Elapsed Time VI and other functions will only see the last value that appears at the tunnel (the boxes that connect to the border of the case structure).  So it will not be possible to get a continuous stream of data while timing in this way.

 

2) For a different approach to time the process of your shaft rotating one direction, you can add a few states such that one starts a timer, another continues to collect data and pass forward the start time, and finally a state that finishes the timing by subtracting the start time from a final time.

 

I have attached a quick example I threw together to better explain what I mean.  Let me know if you have questions about this.

Adam
0 Kudos
Message 4 of 4
(2,518 Views)