Professional Documents
Culture Documents
int PWM = 3;
double error;
double U;
float U1 = 0;
double ref = 1000;
int PPR = 2;
volatile int ISRCounter = 0;
unsigned int pulsos = 0;
unsigned long Time = 0;
unsigned int RPM = 0;
void setup()
{
pinMode(channelPinA, INPUT_PULLUP);
Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(channelPinA), doEncode, CHANGE);
Time = millis();
void loop()
{
if(millis() - Time >= 1000)
{
pulsos = ISRCounter/PPR;
RPM = (pulsos/2)*30;