-
Notifications
You must be signed in to change notification settings - Fork 32
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
Comments
Looks very good. That is exactly following the logic of the interpreter. I need to think about how to generalise this. BASIC is not the ideal language to handle interrupts because there is no way to define procedures / call backs.
… Am 18.10.2022 um 11:56 schrieb Encom Lab ***@***.***>:
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);
}`
—
Reply to this email directly, view it on GitHub <#31>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACSY56DMPGX5ZBTOT6M7XP3WDZX6HANCNFSM6AAAAAARH43FFU>.
You are receiving this because you are subscribed to this thread.
|
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
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);
}`
The text was updated successfully, but these errors were encountered: