Rotācija un pozīcija

ElektronikaSensori – Rotācijas un pozīcijas sensori

Rotary encoder module
KY-040 rotācijas sensors

Griežot rotācijas kodētāju, var saskaitīt izejošās frekvenču maiņas pozitīvā un arī pretējā virzienā un rotāciju skaits nav ierobežots (ko nevar rotācijas potenciometra skaitītājs). Nospiežot pogu uz rotācijas kodētāja, skaitīšana tiek sākta no 0.

KY-040 slēguma shēma
Module CLK –> Arduino Pin 2 (Data Output 1)
Module DT –> Arduino Pin 3 (Data Output 2)
Module SW –> Arduino Pin 4 (Switch, LOW when pressed)
Module GND –> Ground
Module + –> +5V (pull up CLK and DT with 10 KΩ resistors)

Connect a 0,47µ capacitor from ground to CLK (debouncing)
Connect a 0,47µ capacitor from ground to DT (debouncing)
Connect a 10 KΩ resistor from +5V to SW (no integrated pullup for SW !!)

It is better NOT to use internal pull-up resistors on the Arduino, instead use the integrated pull-ups of KY-040 (this requires “+” to be connected to 5V).
You can check if your version of the KY-040 has pull-up resistors on the bottom side ouf the printed circuit board. If not, use internal pull-ups from Arduino or external pull-ups.

In the stopping positions the KY-040 has always HIGH signals on both CLK and DT.
When you turn the encoder from one position to another, either CLK or DT goes LOW before the other signal goes LOW as well.
The signal that goes LOW first determines if the encoder is turned left or right.
Once you reach the next stopping position both signals will be HIGH again.

If you press the push button, the current count can be reset to ZERO.

For faster response you might increase the speed of the serial connection.
(Make sure, that the Serial Monitor is also set to a higher speed, otherwise you will get no output).

Rotary encoder sometimes behaves strange (e.g. it gives a signal to the SW pin – although I did not press the button.). So for serious projects invest a dollar more and buy a quality product.

___________

KY-023 XY-axis joystick module
2-asu kursorsvira (džoistiks)

PS2 spēļu kursorsvira (džoistiks) sastāv no potenciometru sistēmas. Kursorsvira ir 2-asu (x,y) analogo izeju un digitālās izejas (z) pogas kombinācija.

Slēguma shēma
Arduino GND –> Module pin –
Arduino +5V –> Module pin +5V
Arduino Analog 0 –> Module VRx
Arduino Analog 1 –> Module VRy
Arduino Digital –> Resistor?* –> Module SW

* Vajadzīgs rezistors, bet var lietot Arduino iebūvēto pullup rezistoru, komanda ( pinMode(pin, INPUT_PULLUP); ) to izdara.

___________

Daudzums uz vietas

KY-040 Rotary encoder module – 1 gab.
1.90€ gab.
Operating voltage: 5V
1 circle pulses: 20

KY-023 XY-axis joystick module – 1 gab.
1.90€ gab.
Op