how to read encoder single channel (incremental)

hello
how can I use the union motor shiled MD25 .. in this engine ...
http://www.micromotorssrl.com/electricaldata_1/e_data_1_pg.html

which pins connect MD25 ( 6 pin) to read this encoder (5 cable)

  • Red : +Motor
    3 Blue : O.C.NPN
    2 Green : Ground
    1 Brown : Vcc (Hall)
  • Black : -Motor

example of program !!

tnx

Your second link doesn't work.

I suspect, if all you want to do is count the pulses from the sensor you just need to connect the output pin to one of th Arduino I/O pins and use digitalRead() to detect when it is HIGH.

If the motor runs fast and produces a large number of pulses you may need to use attachInterrupt() to capture the pulses (see the Reference section). The code for the Interrupt Service Routine (ISR) could be as simple as

void countPulses() {
    pulseCount ++;
}

where pulseCount as been defined as a global variable with

volatile unsigned long pulseCount();

and the ISR is started in setup() with this code

attachInterrupt(0, countPulses, RISING);

Note that interrupt 0 is on Pin2 on an Uno.

...R

Tnx Robin2
I think I connect the 2 motor directly to the motor shield MD 25 and not to the arduino digital pin.


.
.
Maybe I'll have to use a resistor to clean the digital signal !!!
how do you see this engine uses a single channel encoder.
I will try to use routine CC or CCW to read UP or down
Arduino is also connected to the ETH shield
.
I 'm new to the arduino world and still do not know how to do,
where can I get info for standard connections and program
.
.

Can you post a link to the specifications for the motor shield?

I presume that is a picture of the shield? Is it specially made for the encoder motors you are using?

...R

The output is open-collector (OC) so you'll need to use a pull-up resistor to 5V,
preferrably 4k7 or so (the internal pullup is very weak for dealing with a long cable,
note).