Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years ago.
I'm not able to use QEI...
I want to use 7S series by Nemicon. This is my program.
________
- include "mbed.h"
- include "QEI.h"
- define ROTATE_PER_REVOLUTIONS 100
Ticker flipper; Serial pc(USBTX, USBRX); Use X4 encoding. QEI wheel(p30, p29, NC, 624, QEI::X4_ENCODING); Use X2 encoding by default. QEI wheel (p30, p29, NC, 624);
float t; float p; float r; float R;
void flip(){ wheel.getCurrentState();
p = wheel.getPulses(); r = 600*wheel.getPulses()/(ROTATE_PER_REVOLUTIONS*4); R = 600*wheel.getRevolutions();
pc.printf("Pulses: %d\n\r", p); pc.printf("Rotate: %f\n\r", r); pc.printf("Rotate Rev: %f\n\r",R); pc.printf(" \n\r");
wheel.reset(); }
int main() { flipper.attach(&flip, t=0.1); the address of the function to be attached (flip) and the interval
pc.baud(115200); pc.printf(" Hello world!\n\r");
while(1){
}
______
Connections
signal A -> R(1k) -> p30
signal B -> R(1k) -> p29
Vcc -> VU
GND -> GND
I got pulses but always 0. Please give me advices.