Hello,
Im using Mbed studio OS 6 with Nucleo F303K8 MCU
I have a gear motor with encoder, im using the QEI library with x2 encoding.
I want to count the number of pulses the motor does. I use the getpulses function in QEI library.
I have noticed when i combine a printf inside the code, the counting doesnt rising or rising very slowly.
another thing, when i disconnect the encoder its looks like the counter is rising again as it suppose to be.
This things doesnt happend when im not using printf function.
#include "mbed.h"
#include "Motor.h"
#include "QEI.h"
QEI wheel(PA_6, PA_2, NC, 1900);
Motor Wheel(PA_7, PA_5); // Make the motor object
int counter = 0;
int main() {
Wheel.speed(0.5);
while(1){
thread_sleep_for(100);
counter = wheel.getPulses();
printf("Number of Pulses%d\r\n",counter);
}
}
In the QEI library using interup in on the digital input of the encoder. any time a pulse coming the counter suppose to rise.
but when using printf it doesnt.
If its important i add to mbed_app.json the code lines that allow you using printf in MBED OS 6.
"platform.stdio-baud-rate": 115200,
"platform.stdio-buffered-serial": 1
Thank you
Noam