Read four SSI absolute encoders with Arduino MEGA

Hi to all,

I need to be able to read data from four absolute encoders, like these ones: AEAT-6010/6012 Magnetic Encoder.
They use a 10 b it resolution and this is the graph:

I know I can interface with one encoder by using the SPI connector, like described in this old post: Read in 10-bits Magnetic Encoder AEAT-6010-A06 into Arduino Uno - #4 by Linarism

But, what about having 4 encoders connected to the same Arduino board?
Is it possible?

Thank you!

Hi @marcusbarnet
Yes, it is possible to have multiple SPI devices connected on the same board.
All SPI pins can be wired together, except the CS (SS) pin, which is "who" will select which SPI device is being accessed.
There must be a pin on the board for each CS.

imagem1-158

Is @marcusbarnet needing SSI or SPI.
The specs say SPI but the thread subject says SSI.

Tom... :grinning: :+1: :coffee: :australia:

It's clocking out 10 bits. It's not clear what you get when you clock out 16 bits (SPI does 8 at a time) but it is worth trying.

This data sheet links to a typical SSI absolute encoder.
No SPI need be involved to read it.

Hi,

Sorry my misread..

Many years ago I setup an interface at work for two 18bit SSI absolute encoder and found I had to go to a DUE for speed along with port manipulation to get decent high speed pulses on the data lines.
It involved two encoders measuring shaft defection angle.

I have a faint suspicion it was @johnwasser code that I hacked....
If not it was one of our regular forum contributors.

How fast do you need to update each position.

What is the application?

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

Sorry, guys! Probably, I did a mistake since I've read this page: SPI - Arduino Reference talking about the ICSP pins:

  • MISO (Master In Slave Out) - The Slave line for sending data to the master,
  • MOSI (Master Out Slave In) - The Master line for sending data to the peripherals,
  • SCK (Serial Clock) - The clock pulses which synchronize data transmission generated by the master

and one line specific for every device:

  • SS (Slave Select) - the pin on each device that the master can use to enable and disable specific devices.

and then I checked the encoder datasheet for the pinout:

and I thought that it was a SPI since the encoder has CLK and CS.

However, the encoder uses the SSI interface and this should be a working code for Arduino made by @Linarism able to read from the sensor:

// Read in 12-bits Magnetic Encoder AEAT-6012-A06  into Arduino Nano
// RobinL modified by linarism

// Declarate

const int CSn = 4; // Chip select
const int CLK = 7; // Clock signal
const int DO = 8; // Digital Output from the encoder which delivers me a 0 or 1, depending on the bar angle..

unsigned int sensorWaarde = 0;

void setup(){

  Serial.begin(115200);
  Serial.println("Hello World!"); //send sample text to monitor for debug
  
  //Fix de tris

  pinMode(CSn, OUTPUT);
  pinMode(CLK, OUTPUT);
  pinMode(DO, INPUT);

  //Let's start here
  digitalWrite(CLK, HIGH);
  digitalWrite(CSn, HIGH);
}



void loop() {

  sensorWaarde = readSensor();
  delayMicroseconds(1); //Tcs waiting for another read in
}

unsigned int readSensor(){
  unsigned int dataOut = 0;

  digitalWrite(CSn, LOW);
  delayMicroseconds(1); //Waiting for Tclkfe

  //Passing 12 times, from 0 to 11
  for(int x=0; x<12; x++){
    digitalWrite(CLK, LOW); 
    delayMicroseconds(1); //Tclk/2
    digitalWrite(CLK, HIGH);
    delayMicroseconds(1); //Tdo valid, like Tclk/2
    dataOut = (dataOut << 1) | digitalRead(DO); //shift all the entering data to the left and past the pin state to it. 1e bit is MSB
  }

  digitalWrite(CSn, HIGH); //deselects the encoder from reading
        Serial.println(dataOut);
  return dataOut;

}

Is it still possible to have multiple sensors attached to the same Arduino board?

Hi,
Have you tried the @Linarism code.
Lets see if the Arduino can read one encoder.

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

Honestly, not yet because I haven't bought it for the moment because I would like to understand if it is possible to read four encoder otherwise I should find another solution.

The idea was to purchase 4 encoder at once to save shipping costs, but first I would understand if they can work :thinking:

Hi,
What is the project?

Tom.. :grinning: :+1: :coffee: :australia:

I need to control 4 DC motors 24V/10A in closed loop by using an absolute encoder for each motor.

I was thinking to use 2 x dual channel motor controllers controlled by Arduino.
Since I haven't found any motor controller able to read absolute encoders, I thought to connect the encoders to Arduino.

Hi,
So you are making a servo motor system with some decent torque.
I take it you want position control as well as speed?

They make very expensive controller units to do that sort of thing.
One that I have had experience with uses a resolver system as position/speed feedback.

An absolute encoder system should be possible, but if Arduino controller could be fast enough is the quandary.
As timing would have to be precise, you may need a controller for each motor.
An Arduino Nano, or Pro Micro or Pro Mini, all these run at 16Mhz the same as the UNO.

Having not been down this design path, I'm not sure if you would get satisfactory results.
You may have to go to faster controllers, like the DUE or even ESP32, there are others out there that use the Arduino IDE.

The encoders are not cheap, I used Turck Contactless Encoder, but not in a time sensitive situation.

Your thread subject is spot on, so you might find in the next 24hours as the world turns, you may get some promising advice.

Tom... :grinning: :+1: :coffee: :australia:

I need to use this system for a four steering wheel vehicle where each wheel rotate along its vertical axis. I need to know the accurate position of each wheel every moment, the speed is not important since they will rotate very slow.

I usually use motor controllers from roboteq since they can read absolute encoders, but they are having long delivery time (more than 4 months for new orders) and so I need to find another solution.

It is not a problem to use arduino DUE since it has a more powerful controller.

What is important to me is to find a reliable solution to control the four motors with the four absolute encoders.

Hi,

So you will not have a great degree of rotation, why not use a potentiometer on each of the steering axes to feed back you steering angle.
You are describing a basic, but larger, RC control steering servo.
An absolute encoder looks like overkill in this application.
How precise do you need to know the steering angle?

With pot feedback a single Arduino could possibly to the trick for four servos.

What motor controllers will you be using?

Tom... :grinning: :+1: :coffee: :australia:

I will use 2 x roboclaw motor controllers.
About the accuracy, I should have at least 1024 pulses per revolution and so I don't know if a potentiometer can provide such precision even if it would be a perfect solution for me!

Do you think a potentiometer could be so accurate?

Hi,
So you need 360/1024 = 0.3515625Deg precision.

How far does the axis you are turning rotate?

Tom... :grinning: :+1: :coffee: :australia:

I don't know If I got well your question since I'm not an english speaker.

I will mount the encoder to the final shaft after the gearbox, close to the wheel.

How far does the axis you are turning rotate?
I don't know If I got well your question since I'm not an english speaker.

How many degrees does the wheel turn when the steering is turned full left to full right. If straight ahead is at 0 degrees, does it turn in 45 degrees and out 45 degees?

It is correct, the wheel is centered at 0 degrees and then it can go -45 and +45 at max.

Hi
I asked that back a bit.

How far does the axis you are turning rotate?

So you can use a potentiometer mounted to each shaft.

Tom... :grinning: :+1: :coffee: :australia:
PS, Absolute encoder you are looking at is overkill.