kopia lustrzana https://github.com/peterhinch/micropython-samples
ENCODERS.md: Add note on missed pulses. encoder.py: replace property with function.
rodzic
2f5f2d0c3d
commit
c1c2cb7c71
|
@ -92,6 +92,12 @@ hardware may need to be adapted to limit the rate at which signals can change,
|
||||||
possibly with a CR low pass filter and a schmitt trigger. This clearly won't
|
possibly with a CR low pass filter and a schmitt trigger. This clearly won't
|
||||||
work if the pulse rate from actual shaft rotation exceeds this limit.
|
work if the pulse rate from actual shaft rotation exceeds this limit.
|
||||||
|
|
||||||
|
In a careful test on a Pyboard 1.1 with an optical encoder pulses were
|
||||||
|
occasionally missed. My guess is that, on rare occasions, pulses can arrive too
|
||||||
|
fast for even hard IRQ's to keep track. For machine tool applications, the
|
||||||
|
conclusion would seem to be that hardware decoding or possibly a rate limiting
|
||||||
|
circuit is required.
|
||||||
|
|
||||||
# Problem 3: Concurrency
|
# Problem 3: Concurrency
|
||||||
|
|
||||||
The presented code samples use interrupts in order to handle the potentially
|
The presented code samples use interrupts in order to handle the potentially
|
||||||
|
|
|
@ -24,7 +24,6 @@ class Encoder:
|
||||||
self.forward = self.pin_x.value() ^ self.pin_y.value() ^ self.reverse ^ 1
|
self.forward = self.pin_x.value() ^ self.pin_y.value() ^ self.reverse ^ 1
|
||||||
self._pos += 1 if self.forward else -1
|
self._pos += 1 if self.forward else -1
|
||||||
|
|
||||||
@property
|
|
||||||
def position(self):
|
def position(self):
|
||||||
return self._pos*self.scale
|
return self._pos*self.scale
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue