Go Down

Topic: MKR Motor Carrier Shield: Rotary encoder and hall effect sensor not working (Read 7160 times) previous topic - next topic



I've been trying everything I can to try and isolate the problem. Some background:

  • The rotary encoder did work initially and I managed to complete the motor characterization exercise
  • When I came to the section where I am to read the speed of the flywheel motor I realized that no signal was being detected from the hall effect sensor
  • I have tested the hall effect sensor using a multi-meter. When provided with 5V and a magnet comes close enough I get a 5V signal on the output. This to me means that the sensor is working.
  • I wired up the sensor directly to the MKR1000 board and used the code below to check that the whole interrupt thing is working and it did. So the sensor works and the MKR1000 can detect its signal.
  • I have tried generating a more "reliable" signal using a button and pull-up resistor. The MKR1000 detects the signal, but I am unable to get anything from/through the Motor Carrier.
  • I have tried various firmware updates as well as using the Flasher as suggested here. Note that I commented out anything that realtes to the Motor Carrier since it was not connected for this test.
  • Through steps in the motor characterisation excercise I can run the motor, but only get 12 as an answer using readCount(enc), regardless of how many times it has turned. This seems to be similar to the issue encountered in the post referred to above. (I tried this on both encoder channels HA1/2 and HB1/2)

So, given the above I believe the problem is on the Motor Carrier. Whether it is a hardware or software issue I cannot say. But I am fairly new to all of this, so my findings might very well be hogwash.

Any thoughts? Please?

Code: [Select]

  Arduino Engineering Kit Hall Sensor Test
  This sketch demonstrates some APIs exposed by the MKR Motor Shield library.
  For the complete list, visit the reference page on https://www.arduino.cc/en/Reference/MKRMotorShield
  This example code is in the public domain.

//#include <MKRMotorCarrier.h>

//#define INTERRUPT_PIN A6 // IN1
//#define INTERRUPT_PIN A5 // IN3
//#define INTERRUPT_PIN A1 // IN2
#define INTERRUPT_PIN A1 //A2 IN4

int batteryVoltage;
int hallCount;

void setup() {

  while (!Serial);

//  // Start communicationg with the motor shield
//  if (controller.begin()) {
//    Serial.print("MKR Motor Shield connected, firmware version ");
//    Serial.println(controller.getFWVersion());
//  } else {
//    Serial.println("Couldn't connect! Is the red led blinking? You may need to update the firmware with FWUpdater sketch");
//    while (1);
//  }
//  // Reboot the motor controller; brings every value back to default
//  Serial.println("reboot");
//  controller.reboot();


  hallCount = 0;
  attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), Isr, RISING);

  Serial.println("System ready: Place the magnet close the the hall sensor...");

volatile bool irqFlag = false;

void Isr() {
  irqFlag = true;
  Serial.print("Intterupt detected");

void loop() {
  Serial.print("irqFlag status: ");
//  float batteryVoltage = (float)battery.getConverted();
//  if (batteryVoltage < 10) {
//    Serial.print("Battery voltage: ");
//    Serial.print(batteryVoltage);
//    Serial.println(" ");
//    Serial.println("WARNING: LOW BATTERY");
//    Serial.println("ALL SYSTEMS DOWN");
//    M1.setDuty(0);
//    M2.setDuty(0);
//    M3.setDuty(0);
//    M4.setDuty(0);
//    while (batteryVoltage < 11) {
//      batteryVoltage = (float)battery.getConverted();
//    }
//  }

  if (irqFlag == true) {
    Serial.print("Hall count: ");
    irqFlag = false;
  //Ping the samd11


Go Up