Wiring the AS5311 magnetic encoder


i'm trying test as5311 encoder this board.  i'm testing first reading pwm signal itself, separate code i'm unplugging pwm , reading 2 square waves , b pins.  i'm getting reading first pwm test, resolution small me see if value correct.  during second test, i'm not getting signal, strange because exact same code works on as5304 chip has , b encoder signals.

am wrong in assuming , b pins work same as5304 chip?  i've been ignoring other programming pins because assumed intended functions don't need.  honest i'm not entirely sure the other pins do.

here's code i'm using

code: [select]
volatile int pwm_value = 0;
volatile int prev_time = 0;
 
void setup() {
  serial.begin(115200);
  // when pin d2 goes high, call rising function
  attachinterrupt(0, rising, rising);
}
 
void loop() { }
 
void rising() {
  attachinterrupt(0, falling, falling);
  prev_time = micros();
}
 
void falling() {
  attachinterrupt(0, rising, rising);
  pwm_value = micros()-prev_time;
  serial.println(pwm_value);
}


here's encoder test code.  works on as5304
code: [select]
#include <encoder.h>

// change these pin numbers pins connected encoder.
//   best performance: both pins have interrupt capability
//   good performance: first pin has interrupt capability
//   low performance:  neither pin has interrupt capability
encoder knobleft(4, 5);
encoder knobright(7, 8);
//   avoid using pins leds attached

void setup() {
  serial.begin(115200);
}

long positionleft  = -999;
long positionright = -999;

void loop() {
  long newleft, newright;
  newleft = knobleft.read();
  newright = knobright.read();
    serial.print("x");
    serial.println(newleft);
    serial.print("y");
    serial.println(newright);
    positionleft = newleft;
    positionright = newright;
   
    delay(50);
}


another possibility encoder magnet shipped as5311 board isn't compatible as5311.  there's no id marking magnet sent.

any appreciated.  in advance.

i'm trying test as5311 encoder this board.  i'm testing first reading pwm signal itself, separate code i'm unplugging pwm , reading 2 square waves , b pins.  i'm getting reading first pwm test, resolution small me see if value correct.  during second test, i'm not getting signal, strange because exact same code works on as5304 chip has , b encoder signals.

am wrong in assuming , b pins work same as5304 chip?  i've been ignoring other programming pins because assumed intended functions don't need.  honest i'm not entirely sure the other pins do.

here's code i'm using

code: [select]
volatile int pwm_value = 0;
volatile int prev_time = 0;
 
void setup() {
  serial.begin(115200);
  // when pin d2 goes high, call rising function
  attachinterrupt(0, rising, rising);
}
 
void loop() { }
 
void rising() {
  attachinterrupt(0, falling, falling);
  prev_time = micros();
}
 
void falling() {
  attachinterrupt(0, rising, rising);
  pwm_value = micros()-prev_time;
  serial.println(pwm_value);
}


here's encoder test code.  works on as5304
code: [select]
#include <encoder.h>

// change these pin numbers pins connected encoder.
//   best performance: both pins have interrupt capability
//   good performance: first pin has interrupt capability
//   low performance:  neither pin has interrupt capability
encoder knobleft(4, 5);
encoder knobright(7, 8);
//   avoid using pins leds attached

void setup() {
  serial.begin(115200);
}

long positionleft  = -999;
long positionright = -999;

void loop() {
  long newleft, newright;
  newleft = knobleft.read();
  newright = knobright.read();
    serial.print("x");
    serial.println(newleft);
    serial.print("y");
    serial.println(newright);
    positionleft = newleft;
    positionright = newright;
   
    delay(50);
}


another possibility encoder magnet shipped as5311 board isn't compatible as5311.  there's no id marking magnet sent.

any appreciated.  in advance.
read page 11.29 of data sheet,  have control csn enable "incremental interface"

on code:

whenever use ab encoder connect , b 2 interrupts, , use isr update internal counter.

i have never used encoder.h library.

chuck.


Arduino Forum > Using Arduino > Sensors > Wiring the AS5311 magnetic encoder


arduino

Comments

Popular posts from this blog

Valutazione Template - Joomla! Forum - community, help and support

SD Datastring Convention

First use of Arduino Uno : avrdude error on Blink uploading