Quantcast
Channel: Counter/Timer topics
Viewing all articles
Browse latest Browse all 1271

dealing with vibration noise in encoder readings

$
0
0

Python 3.9

CRIO 9053

9411 module

Automation Direct/koyo trd-n5000-rzwd encoder (5000 pulses per rotation, totem pole output)

192 mm circumference wheel

 

Now that I have the encoder readings working, I have hit my next problem.

 

The bit of code below reads things just fine, but when I slap the side of the encoder, I see a series of spikes that incorrectly lead the the conclusion that the encoder has moved backwards and then forward by 0.038 mm.  Looking at the trace, I can see why -- my scope skills are not that great, but I measure the spike at 7.8 ms.

This may just be no big deal, given that the error I see over 15 seconds of repeated vibration yielded total false movement of 0.038 mm, a value far below the precision I need -- but still, I want things to be tidy.

 

 

Is there a mechanism I am overlooking for dealing with this?  Just using the minimum pulse width does not seem to be the best way forward here.

 

self.log.debug("Begin rotation detection using Angular Encoding")
task = ni.Task(new_task_name=constants.RIO_TASK_NAME)
#channelA = task.ci_channels.add_ci_ang_encoder_chan(counter = 'Mod3/ctr0', decoding_type = EncoderType.X_1, zidx_enable=True, units=AngleUnits.DEGREES, pulses_per_rev=1000, initial_angle=0.0)

# Add the channel as an angular encoder without Z index support, as we really don't care about the number of rotations
channelA = task.ci_channels.add_ci_ang_encoder_chan(counter = 'Mod3/ctr0', decoding_type = EncoderType.X_1, zidx_enable=False, zidx_val=0, units=AngleUnits.DEGREES, pulses_per_rev=self.encoderClicksPerRevolution, initial_angle=0.0)


channelA.ci_encoder_a_input_dig_fltr_min_pulse_width = 0.0001
channelA.ci_encoder_a_input_dig_fltr_enable = True
channelA.ci_encoder_a_input_term = 'PFI0'
channelA.ci_encoder_b_input_dig_fltr_min_pulse_width = 0.0001
channelA.ci_encoder_b_input_dig_fltr_enable = True
channelA.ci_encoder_b_input_term = 'PFI1'
channelA.ci_encoder_z_input_dig_fltr_min_pulse_width = 0.0001
channelA.ci_encoder_z_input_dig_fltr_enable = True
channelA.ci_encoder_z_input_term = 'PFI2'

task.timing.samp_clk_overrun_behavior = nidaqmx.constants.OverflowBehavior.TOP_TASK_AND_ERROR

task.start()
previous = 0.0
running = True

# This loop will run until things are gracefully shut down by another thread
# setting running to False.
while running:
try:
ang =task.read(number_of_samples_per_channel = 1) #nidaqmx.constants.READ_ALL_AVAILABLE)
#print("Current register is {}".format(channelA.ci_count))
except nidaqmx.errors.DaqError:
self.log.error("Read error encountered")
continue

# If the current reading has changed from the previous reading, the wheel has moved
if ang[0] != 0 and ang[0] != previous:
try:
# Put the current angular reading in the queue
self._changeQueue.put(float(ang[0]), block=False)
except queue.Full:
self.log.error("Distance queue is full. Reading is lost.")
previous = ang[0]

 

 

IMG_0287.jpg


Viewing all articles
Browse latest Browse all 1271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>