Go Down

Topic: Need help to program encoder with Absolute binary synchro-serial interface (SSI) (Read 2621 times) previous topic - next topic

Alechco

Need help to program encoder with Absolute binary synchro-serial interface (SSI)
In the project I have encoder with 13 bit resolution connected via SP1490E (RS-485 interface)
The result doesn't change: Reading:  52 Angle: 0
Arduino sketch
-------------
  int clkPin = 53;
  int dataPin = 52;
//  int value = 0;
  float angle = 0;

  void setup()
  {
    pinMode(clkPin, OUTPUT);  // Tx for RS422
    pinMode(dataPin, INPUT);  //Rx for RS422
 
    digitalWrite(clkPin, HIGH); //give some default values
 
     Serial.begin(115200);
   
          //variables to keep track of position
          int reading = 0;
          float angle = 0;
 
  }
 
  void loop()
  {
    int reading = 0; 
       reading = dataPin;
       //delay (50);
     
     if ( reading >= 0)
     {
          angle = ((int)reading / 8192) * 360.0;  // 13 bit resolution
          Serial.print("Reading: ");
          Serial.print(reading, DEC);
          Serial.print(" Angle: ");
          Serial.println((int)angle, DEC);
     }
     else
     {
         Serial.print("Error: ");
         Serial.println(reading);
     }
 

    for   (int i=7; i>=0; i--)
    {
      i = clkPin;

    digitalWrite(clkPin, HIGH); 
    delayMicroseconds(1);         
    digitalWrite(clkPin, LOW);
    delayMicroseconds(1);          // delayMicroseconds(1ms);
    }
   
  }
     
-------------------------------
Please advise.
Thank you,
Alechco


johnwasser

Code: [Select]

  int clkPin = 53;
  int dataPin = 52;
...
     reading = dataPin;
      
     if ( reading >= 0)
     {
          angle = ((int)reading / 8192) * 360.0;  // 13 bit resolution
          Serial.print("Reading: ");
          Serial.print(reading, DEC);
          Serial.print(" Angle: ");
          Serial.println((int)angle, DEC);
     }


Of course if you set 'reading' to 52 it will print out as 52.

I'm guessing you need to pulse the clock line and read the data line for each bit but without the datasheet for the encoder I can't be more specific.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp
See who has no social life: https://forum.arduino.cc/index.php?action=stats :)

GertJL

Hi Alecho,
I am starting an application where I require
to determine absolute angular position on a shaft
rotating from 0-180degrees only, thus -90 - 0 - +90,  and slowly....
Degrees resolution required - better than 1deg.
Can you please advise which encoder you are using, for me as a jumpBoard eval.

re the SSI interface, i assume with RS422 interface?
Are you using a RS485 driver to interface to the SSI encoder?
This means you have a clock(tx) diff wire pair and a data(rx) diff wire pair
running between the Master and Encoder?
I intend to use cat5e utp, distance ~150m.
Because of the slow shaft rotation speed and cable distance,
I intend to use a comms speed of 9600bps.

I hope you can give me some pointers on above, thanks!

Regards,
Gerhard


Go Up