Electronics > Microcontrollers

Arduino control by electronic crank

(1/2) > >>

Plopiche:
Hi,

I would like to order a stepper motor with an electronic crank.
Signals A and B from the crank will be sent to 2 digital inputs of an Arduino Uno.
When I connect outputs A and B of the crank (with or without bounce management, to 2 interrupt inputs or not, it does not work correctly.

Is there a need for an interface circuit between A and B and the inputs of the Arduino Uno?
And if so, which circuit?


Thanks for your help.

ledtester:
It is possible that the A and B signals are "open collector". Try putting a 5K or 10K resistor from each signal line to Vcc (+5 in the case of the Arduino Uno).

Plopiche:
La manivelle :

https://fr.aliexpress.com/item/33031046760.html?spm=a2g0o.order_list.order_list_main.22.1c275e5bQGccTL&gatewayAdapt=glo2fra

ledtester:
Did adding the pullup resistors work?

Can you monitor one of the signal lines with a scope? Otherwise I'd use a simple program like the following to see if the input is changing as you expect:


--- Code: ---const int signalA = 6; // whatever you connect signal A to

void setup() {
    Serial.begin(9600);
    Serial.println(("Starting..."));
    pinMode(signalA, INPUT);
}

static bool oldA = false;

void loop() {
    bool newA = digitalRead(signalA);
    if (oldA != newA) {
        Serial.println(newA ? "1" : "-");
    }
    oldA = newA;
}

--- End code ---

pqass:
I initially didn't understand your "electronic crank" reference.  But given the Aliexpress link, I'm sure you mean rotary or quadrature encoder.

I tried searching for a datasheet but only managed to find this reference to "Output NPN" which likely means open collector and therefore requires a 10K (or so) pull-up resistor to Vcc. Given that the encoder also has a Vcc input (probably because it uses optical slot switches), you should confirm that the pull-ups are present. That is, use a multimeter on A then B outputs to see if they can produce both Vcc and 0V as you turn the wheel slowly.

There are many examples of interfacing encoders with Arduino like this one.

If you want to use interrupts (vs polling), then it's only necessary to connect one of the encoder outputs to an Arduino interrupt pin.  The interrupt routine will read the state of both encoder outputs to determine direction.  To debounce, from each encoder output put a 10K series resistor then 10nF cap to ground before the Arduino input pin (see attached).

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod