Hardware Reference
In-Depth Information
count_mode = < 0 >;
/* 0 - Quadrature mode, normal 90 phase offset cha & chb.
1 - Direction mode. cha input = clock, chb input =
direction */
swap_inputs = < 0 >; /* Are chan A & chan B swapped?
(0-no,1-yes) */
invert_qa = < 1 >;
/* Should we invert the channel A
input? */
invert_qb = < 1 >; /* Should we invert the channel B input?
These are inverted because my encoder outputs drive
transistors
that pull down the pins */
invert_qi = < 0 >;
/* Should we invert the index input? */
invert_qs = < 0 >;
/* Should we invert the strobe input? */
status = "okay" ;
};
};
};
Then run the following commands:
bone# dtc -O dtb -o bone_eqep2b-00A0.dtbo -b 0 -@ bone_eqep2b.dts
bone# cp bone_eqep2b-00A0.dtbo /lib/firmware
bone# echo bone_eqep2b > /sys/devices/bone_capemgr.*/slots
This will enable eQEP2 on pins P8_11 and P8_12 .
Finally, add the code in Example 2-9 to a file named rotaryEncoder.js and run it.
Example 2-9. Reading a rotary encoder (rotaryEncoder.js)
#!/usr/bin/env node
// This uses the eQEP hardware to read a rotary encoder
// echo bone_eqep2b > $SLOTS
var b = require ( 'bonescript' ),
fs = require ( 'fs' );
var eQEP0 = "/sys/devices/ocp.3/48300000.epwmss/48300180.eqep/" ,
eQEP1 = "/sys/devices/ocp.3/48302000.epwmss/48302180.eqep/" ,
eQEP2 = "/sys/devices/ocp.3/48304000.epwmss/48304180.eqep/" ,
eQEP = eQEP2 ;
var oldData ,
// pervious data read
period = 100 ;
// in ms
Search WWH ::




Custom Search