Go Down

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

DeltaV_Kit1

Hi!

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() {

  Serial.begin(115200);
  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();

  delay(500);

  //Interrupts
  hallCount = 0;
  pinMode(INTERRUPT_PIN, INPUT);
  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.println("Looping...");
  Serial.print("irqFlag status: ");
  Serial.println(irqFlag);
  //Battery
//  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) {
    hallCount++;
    Serial.print("Hall count: ");
    Serial.println(hallCount);
    irqFlag = false;
  }
  //Ping the samd11
  //controller.ping();
  delay(200);
}

Go Up