Hello everyone,
Im currently working on a part of a big project that requires me to read the the absolute position of a magnet that's being read on an encoder. I'm using a Teensy 3.2 but want to move over to using a teensy 4.1. The reason why I'm making this post is because the current set up that I have right now, works perfectly fine with my teensy 3.2 but when I try to recreate the same results on my teensy 4.1, the system doesn't work properly. For context, I've attached both the library that I'm using to communicate with the encoder and a simple Arduino script that is supposed to output the position of the magnet to the serial monitor. When I try to recreate my original setup with the teensy 4.1, I get inaccurate/volatile readings. I suspect that it's a software issue where the logic allows for the bits to be read correctly on the 3.2 but not the 4.1
The encoder that I'm using is the AS5045 (https://docs.rs-online.com/e9dd/A700000006770281.pdf). This uses the SSI communication protocol which is very similar to an SPI protocol where there is a Clock, CS, and DATA OUT (which would be the MISO pin on the teensy) pin. However the library that I'm using disregards any of this information and just uses the pins on the teensy as digital IO pins. This is a little confusing because the person that wrote the library named this library "SPIEncoder.h" but IT IS NOT AN SPI PROTOCOL, the person that wrote it just happened to name it that way.
The AS5045 has 5 pins:
3.3V, Ground on the encoder=pin 3.3V and GND respectively
CS on the encoder= pin 10 on teensy
CLK on the encoder= pin 13 on teensy
DATA OUT on the encoder= pin 12 on teensy
*********this is also the case in my original setup with the teensy 3.2 (where it worked!!!) ***************
Arduino Code:
#include "SPIencoder.h"
uint8_t csPin=10;
uint8_t clkPin=13;
uint8_t dataPin=12;
uint8_t nBits=12;
SPIencoder myAS5045(csPin, clkPin, dataPin, nBits);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(myAS5045.EncDeg());
delay(200);
}
Im currently working on a part of a big project that requires me to read the the absolute position of a magnet that's being read on an encoder. I'm using a Teensy 3.2 but want to move over to using a teensy 4.1. The reason why I'm making this post is because the current set up that I have right now, works perfectly fine with my teensy 3.2 but when I try to recreate the same results on my teensy 4.1, the system doesn't work properly. For context, I've attached both the library that I'm using to communicate with the encoder and a simple Arduino script that is supposed to output the position of the magnet to the serial monitor. When I try to recreate my original setup with the teensy 4.1, I get inaccurate/volatile readings. I suspect that it's a software issue where the logic allows for the bits to be read correctly on the 3.2 but not the 4.1
The encoder that I'm using is the AS5045 (https://docs.rs-online.com/e9dd/A700000006770281.pdf). This uses the SSI communication protocol which is very similar to an SPI protocol where there is a Clock, CS, and DATA OUT (which would be the MISO pin on the teensy) pin. However the library that I'm using disregards any of this information and just uses the pins on the teensy as digital IO pins. This is a little confusing because the person that wrote the library named this library "SPIEncoder.h" but IT IS NOT AN SPI PROTOCOL, the person that wrote it just happened to name it that way.
The AS5045 has 5 pins:
3.3V, Ground on the encoder=pin 3.3V and GND respectively
CS on the encoder= pin 10 on teensy
CLK on the encoder= pin 13 on teensy
DATA OUT on the encoder= pin 12 on teensy
*********this is also the case in my original setup with the teensy 3.2 (where it worked!!!) ***************
Arduino Code:
#include "SPIencoder.h"
uint8_t csPin=10;
uint8_t clkPin=13;
uint8_t dataPin=12;
uint8_t nBits=12;
SPIencoder myAS5045(csPin, clkPin, dataPin, nBits);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(myAS5045.EncDeg());
delay(200);
}