0
\$\begingroup\$

I am using Feather M4 express development board with DC Motor + Stepper FeatherWing and Ethernet FeatherWing stacked on it. The idea is to control the steps of the stepper motor by reading the encoder values. The SPI bus is shared between the Ethernet FeatherWing and the AS5045 encoder and they have their unique CS pins.
I am using this library for reading the encoder values. The encoder board is connected to the main board using cables. Since the encoder is operating on 5V logic while the Ethernet board on the 3.3V, I am using a level shifter for the encoder board.

Using this setup, only the EthernetWing seems to work but not the encoder as it always reads a full scale value. Removing the EthernetWing and connecting the encoder directly in its place with 5V power works as the encoder reads all the correct positions. Is the level shifter not compatible with this current design? How can this issue be solved?

schematic

enter image description here

#include <AS5045.h>
#include <Adafruit_MotorShield.h>

#define CSpin 9
#define CLKpin 25
#define DOpin 23

AS5045 enc(CSpin, CLKpin, DOpin);
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 1);

uint16_t angle = 0;

void setup() {
  Serial.begin(9600);
  if (!enc.begin())
    Serial.println("Error setting up AS5045");
    Serial.println("Stepper test!");

  if (!AFMS.begin()) {  
    Serial.println("Could not find Motor Shield. Check wiring.");
  }
  else {
    Serial.println("Motor Shield found, reading encoder");
  }

  myMotor->setSpeed(60);
}

void loop() {
  myMotor->step(50, FORWARD, DOUBLE);
  Serial.print("Encoder reading: ");
  angle = enc.read()* 0.08789;
  Serial.println(angle);
  delay(100);
}
\$\endgroup\$
3
  • \$\begingroup\$ Maybe the level shifter not releasing SDA properly.. The schematic is blurry.. \$\endgroup\$
    – Dorian
    Commented Jul 12 at 10:15
  • 1
    \$\begingroup\$ It could be solved by taking measurements with a scope. What we see is random black boxes connected together. Schematics how each board will drive their SPI buses should be examined. For example the level shifter needs a correct environment to work properly. Now why it does not work in an unknown environment is a challenge. The 3V3 MISO is either an input or output from the POV of the shifter, because either the encoder drives the 5V side or the Ethernet drives the 3V3 side. Even some pull-ups or pull-downs or too much stray capacitance may make a wrong environment for the level shifter. \$\endgroup\$
    – Justme
    Commented Jul 12 at 10:26
  • \$\begingroup\$ Also posted in arduino.stackexchange.com/questions/96520/… \$\endgroup\$
    – hcheung
    Commented Jul 12 at 12:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.