You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* This sketch shows how to use the six Encoders ports on the Arduino Machine Control as 24V-GPIOs for IRQ detection. *** NOTE *** Please, note that the six Encoder ports are pulled up to 24V by a 10k resitor, thus is possible to detect only HIGH-to-LOW transitions. Circuit: - Arduino Portenta Machine Control - External 24V power supply Testing: - For testing purposes, momentarly short-circuit the desiderd port with GND.*/// Call to PinNameToIndex is needed to create pins// compatible with classic Arduino API from an MbedOS pin (Px_y)
#include<pinDefinitions.h>constauto ENCODER_A0 { PinNameToIndex(PJ_8) };
constauto ENCODER_B0 { PinNameToIndex(PH_12) };
constauto ENCODER_Z0 { PinNameToIndex(PH_11) };
constauto ENCODER_A1 { PinNameToIndex(PC_13) };
constauto ENCODER_B1 { PinNameToIndex(PI_7) };
constauto ENCODER_Z1 { PinNameToIndex(PJ_10) };
volatileauto count { 0ul };
auto prevCount { 0ul };
voidsetup()
{
pinMode(PinNameToIndex(PJ_8), INPUT);
// Wait for Serial Monitor connection
Serial.begin(115200);
for (constauto timeout = millis() + 2500; !Serial && millis() < timeout; delay(250))
;
Serial.println("Testing Encoder Ports as 24V IRQs");
// Encoder ports are pulled up to 24V by a 10k resistor// thus we can only detect HIGH-to-LOW transitionsattachInterrupt(PinNameToIndex(PJ_8), [] { count++; }, FALLING);
}
voidloop()
{
// Print only when new IRQs have been detectedif (count != prevCount) {
Serial.print("IRQ count: ");
Serial.println(count);
prevCount = count;
}
}
Hey! is it possible to use the encoder channels on the portenta machine control as interrups to control a stepper motor?
The text was updated successfully, but these errors were encountered: