Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

While you are working on ISR #31

Closed
EncomLab opened this issue Oct 18, 2022 · 2 comments
Closed

While you are working on ISR #31

EncomLab opened this issue Oct 18, 2022 · 2 comments

Comments

@EncomLab
Copy link

EncomLab commented Oct 18, 2022

Morning Stefan! The other way in which I am currently using interrupts for the robot platform is to handle the output from optical rotary encoders. I currently just use this to get a step count by assigning a ENCODERA or ENCODERB command to a variable and assigning the encoder a pin number. Then I just use the variable in an IF statement to issue a STOP command to the motors.

`
//MOTOR AND ENCODER FUNCTIONS
//soft reset
void interruptFunctionSR() {
xbreak();
}

//encoder a
volatile uint16_t interruptCountA = 0;
void interruptFunctionA() {
interruptCountA++;
}

void xencodera() {
x = pop();
short int encoderaPin;
encoderaPin = pinNum(x);

pinMode(encoderaPin, INPUT_PULLUP);
enableInterrupt(encoderaPin, interruptFunctionA, CHANGE);

push(interruptCountA);

}

//encoder b
volatile uint16_t interruptCountB = 0;
void interruptFunctionB() {
interruptCountB++;
}

void xencoderb() {
x = pop();
short int encoderbPin;
encoderbPin = pinNum(x);

pinMode(encoderbPin, INPUT_PULLUP);
enableInterrupt(encoderbPin, interruptFunctionB, CHANGE);

push(interruptCountB);

}`

@slviajero
Copy link
Owner

slviajero commented Oct 19, 2022 via email

@slviajero
Copy link
Owner

Just for info, I now have released the first code with built-in interrupt code. It is documented in the MANUAL, the command EVENT is doing the interrupt stuff. Still working to improve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants