17
votes
Accepted
Reading several rotary encoders
Library and schematics are at https://github.com/maxgerhardt/rotary-encoder-over-mcp23017.
To read a rotary encoder (i.e., detect state changes of the knob), there are two possible implementations:
...
11
votes
How to design and debug a custom I2C master-slave system?
This tutorial I gave at the Embedded Linux Conference tries to answer the questions, providing links to more detailed description of the topics addressed and using the practical example of driving a ...
6
votes
How to detect the direction of a rotary encoder?
I have a page about rotary encoders - in that I show how you can detect encoder changes (and direction) using one interrupt pin and another pin, like this:
// Wiring: Connect common pin of encoder to ...
4
votes
Accepted
Reading from a KY-040 rotary encoder with Digispark
Shown below is a KY-040 test program that in my tests doesn't lose any counts and is more accurate than some other software; it picks up the counts between detents as well as those at detents. You ...
3
votes
How to detect the direction of a rotary encoder?
Using polling to read multiple encoders may work if you program quite carefully and if you dedicate the processor just to reading encoders; but generally, interrupt-driven encoder processing has a ...
3
votes
Accepted
Interfacing pc mouse (serial port DB-9)
A serial mouse is designed to connect to a PC's true serial port - it's an actual RS-232 device using ±5V. As such it won't connect directly to the Arduino's RX/TX pins, you'll have to go through an ...
3
votes
Accepted
Interfacing with an SSI sensor?
It's just SPI.
SPI.begin();
SPI.setDataMode(SPI_MODE2);
// ...
uint8_t h = SPI.transfer(0x00);
uint8_t l = SPI.transfer(0x00);
delayMicroseconds(20); // Indicate EOT
uint16_t v = (h << 8) | l;...
3
votes
Will a simple RC filter work with my mechanical rotary encoder, or do I need a Schmitt trigger?
Having just chased a problem using a software based debounce for several days, what I'll add is that for the encoders I was using (green no-name Chinese ones), if you put 10mA though the contacts then ...
3
votes
How to sample incoming 600khz pin and divide it by 4 and generate low frequency signal at output pin of arduino
This is probably too fast to have have software involved in the loop.
You should try to use a hardware-only solution. Note the Arduino timers
should be usable as hardware frequency dividers:
...
3
votes
Accepted
Unexplainable int behavior in encoder/LED project
Here:
CRGB leds[NUM_LEDS];
you are defining an array of NUM_LEDS objects of the CRGB type.
Valid indices for this array range from 0 to NUM_LEDS-1.
Here:
for (int i = 0; i <= NUM_LEDS; i++) {
...
3
votes
How do you determine Lead Screw position using Absolute Encoder?
The encoder attaches to the motor (or other) shaft and sends a 10-bit rotational position for a precision of 0.35 deg, and a claimed accuracy of +/- 0.7 degrees. It will be up to the application to ...
3
votes
Accepted
Change Interrupts on the ATTiny 88
Interrupt types
One source says there are only two interrupt pins, ...
There are two "external interrupt" pins; that is the term you'll find in the chip's datasheet. This is the term that ...
2
votes
Shaft Encoder Accuracy
If the encoder only gives +1 pulse per 90 degrees, you aren't going to get better than 90 degree accuracy out of it.
In the example code at the link, the val{x,y,z} are measured analog variables of ...
2
votes
Reading from a KY-040 rotary encoder with Digispark
int pinA = 0; // Connected to CLK on KY-040
...
Serial.begin (9600);
Hardware Serial uses pins 0 and 1. I would try other pins. (Oh, it's an ATtiny - well I'm not sure about HardwareSerial on ...
2
votes
How do I read a sub-degree angle?
Try a spirit level (also called bubble level) app on your phone or tablet. It can get to sub-degree accuracy, but it is relative and not absolute accuracy. If that is good enough for you, then you ...
2
votes
How do I read a sub-degree angle?
I've looked at rotary encoders, but even those with no detents have about 24 pulses per rotation.
It sounds like you have been looking at encoders intended for user input controls.
Optical Rotary ...
2
votes
Accepted
Why is my code only reading the change of the encoder's pin A?
You're confusing interrupt events and pin states here.
A pin can be either HIGH or LOW. Never anything else.
An interrupt can trigger on one of four events:
The pin transitions from HIGH to LOW (...
2
votes
Arduino Rotary Encoder Pulses?
Add Serial.begin(115200); in setup() and use Serial.println() or Serial.print() to print to Serial.
In Arduino IDE open Serial Monitor and set baud rate to 115200.
EDIT: The question turned out to ...
2
votes
Accepted
Problem in reading data from encoder with arduino
In my experience (industrial encoders and PLCs) when the output don't change when the motor shaft is rotated its usually one of the following:
The set screw connecting the motor shaft to the encoder ...
2
votes
Optical Rotary Encoder Index issue
In your onReset() function you have an assignment instead of a comparison:
if (i = 1) // This is always true
{
encoder0Position = 0;
}
i = 1 should be i == 1
2
votes
Will a simple RC filter work with my mechanical rotary encoder, or do I need a Schmitt trigger?
The answer seems to be no. I added the RC filter suggested by the manufacturer and the results still jump around (The values sometimes increase by several steps at once, or decrease even when turning ...
2
votes
Accepted
How to add numbers to a position when controlling a seven-segment display
In your code, you call:
newPos = encoder.getPosition();
which grabs the absolute position of the encoder. When you rotate this one step, the value of newPos goes up (or down) by one.
Then, you make ...
2
votes
Undocumented industrial servo with 8-wire encoder: how to read this encoder?
I had some trouble figuring this out too.
I did some more googling and found this site below via an Arduino forum post:
8 wire connection for quadrature encoder, differential wiring
Here is what they ...
2
votes
Accepted
KY-040 rotary encoder skipping steps
I applaud you for your tenacity with the "debouncing" idea, but there is an excellent library for this rotary encoder, and the author has also written an article about it: Ben Buxton - rotary encoders ...
2
votes
Accepted
Is it possible to get which pin generated interrupt?
It is not possible to know which interrupt caused the ISR to be called. The INTFx flag gets cleared when the interrupt routine is called, so you lose that information (which is a shame).
The closest ...
2
votes
Accepted
Basic doubt regarding encoders with Arduino
You code counts pulses just fine when tested here.
Fan/motor tachometer outputs and encoders frequently are set to switch your signal contact to ground, either with a transistor or mechanically. When ...
2
votes
Accepted
Multi turn potentiometer are a pain should I use a incremental encoder instead?
Yes, you can use a rotary encoder. However, there are two kinds of rotoary encoder: absolute, and relative. Relative encoders are the small common ones you find being used for things like volume ...
2
votes
Accepted
Setup Due counter
You need to pick a timer that isn't being used for anything else and configure it as a simple counter with the clock source set to the external clock pin for that timer.
At block level, input clock ...
2
votes
I want a Rotary Encoder to make 10 steps at once, but my code isn't working. What am I doing wrong?
This is not an answer to the question, but a tip about simplifying your code.
This is a snippet of your code.
void loop() {
// some more code here
int encoder1State = encoder1.get_change();
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
rotary-encoder × 109arduino-uno × 26
interrupt × 21
arduino-mega × 17
motor × 12
sensors × 7
programming × 6
arduino-nano × 6
arduino-due × 6
c++ × 4
i2c × 4
robotics × 4
debounce × 4
serial × 3
arduino-ide × 3
spi × 3
arduino-leonardo × 3
code-review × 3
switch × 3
signal-processing × 3
joystick × 3
oled × 3
lcd × 2
pwm × 2
atmega328 × 2