Arduino Absolut Encoder Wachendorff rs485

Hallo Zusammen

Ich versuche verzweifelt einen Absolut Encoder von Wachendorff auszulesen.
Folgende Hardware:
Encoder
SN75179B RS485
Arduino Mega

Anschlüsse:

A and B to Data+ and Data-
R to receive in arduino input (DI6)
Y and Z to clock+ and clock-
D as arduino output to generate clock (DI5)

Code:

const int CLOCK_PIN = 5;
const int DATA_PIN = 6;
const int BIT_COUNT = 13;

void setup() {
  //setup our pins
  pinMode(DATA_PIN, INPUT);
  pinMode(CLOCK_PIN, OUTPUT);

  //give some default values
  digitalWrite(CLOCK_PIN, HIGH);

  Serial.begin(19200);
}


void loop() {
  unsigned long reading = readPosition();

  Serial.print("Reading: ");
  Serial.println(reading, DEC);

  delay(1000);
}

//read the current angular position
int readPosition() {
  unsigned long sample1 = shiftIn(DATA_PIN, CLOCK_PIN, BIT_COUNT);
  return sample1;
}

//read in a byte of data from the digital input of the board.
unsigned long shiftIn(const int data_pin, const int clock_pin, const int bit_count) {
  unsigned long data = 0;
  for (int i=0; i<bit_count; i++) {
    data <<= 1;
    digitalWrite(clock_pin, LOW);
    delayMicroseconds(1);
    digitalWrite(clock_pin, HIGH);
    delayMicroseconds(1);

    data |= digitalRead(data_pin);
  }

  return data;
}

Ausgabe beim drehen:

Reading: 1170
Reading: 1170
Reading: 1170
Reading: 1170
Reading: 1170
Reading: 1170
Reading: 1170
Reading: 1170
Reading: 1170

Kann mir jemand Helfen?

Ich würde gerne den RAW wert auslesen, sodass ich bestimmen kann wie viele Umdrehungen und wo der Geber in der Umdrehung steht.

Vielen dank für eure bemühung.

Gruss

Hallo,
schon mal nach Arduino SSI gesucht ?

Heinz

Hallo Heinz

Leider bin ich nicht fündig geworden.
Bez. konnte mein Problem nicht lösen

Hallo,
ich hab mit mal den Encoder angesehen, der ist ja für 10-30V geeignet. Mit dem SN Ding willst Du das auf 5V Pegel wandeln, oder wozu soll das sein ? Ich kenne mich mit SSI schnittstelle auch nicht aus, deshalb wäre es erst mal wichtig heraus zubekommen ob die Signale erkannt werden.
Ich hatte beruflich mit Wachendorff zu tun , die sind eigentlich sehr hilfsbereit bei Problemen.
es scheint auch eine Lib zu geben für SSI Schnitstelle .
Wiso wirst Du nicht fündig 66.000 Ergebnisse in 0,5s suchen und filtern musst Du schon selber.

Da Du vermutlich zur you tube Generation gehörts als Einstieg.

ich habs mir allerdings nicht angesehen
Heinz

laut dem Datenblatt kann der Dncoder auch mit 4.75 -5.5V betrieben werden, benötigt dann jedoch anstatt der 50mA (bei 10VDC-30VDC) 80mA.
Das SN-Dingens wegen dem RS485, denn laut Datenblatt ist der Daten-Output für RS485 Interface.

Hallo,
dann sieh dir noch mal den Bestellschlüssel auf der Seite 3 genau an was Du eigentlich hast.
Heinz

Was bedeutet "<<= "?

Hallo,
das stammt eventuell von hier.

Wenn das "Bit schieben links" sein soll ist das = zuviel

Hallo Zusammen

Ich habe es vor ca. 30 minuten zum laufen gebracht! :slight_smile:
Danke für eure Links und motivierenden Worte!
Sobald ich wieder am Rechner bin (Morgen) werde ich euch mitteilen welche Quellen und Angehens-weisen ich verwendet habe.

Gruss schnibli

data = data << 1; // Inhalt um 1 nach links schieben ( *2 )

Syntax ähnlich wie beim vermutlich geläufigeren
x += 10; // Kurzform für x = x + 10;

ok, aber funktioniert die Syntax <<= ?

unsigned long data=1;

void setup()
{
  Serial.begin(115200);
  Serial.println(F("Start..."));
}

void loop()
{
    data <<= 1;
    Serial.println(data);
    if (data > 100) while(1);
}
20:27:50.729 ->Start...
20:27:52.230 -> 2
20:27:52.230 -> 4
20:27:52.230 -> 8
20:27:52.230 -> 16
20:27:52.230 -> 32
20:27:52.230 -> 64
20:27:52.230 -> 128

Klar funktioniert das - vorwärts und rückwärts und für alle ganzzahligen Datentypen:


// https://forum.arduino.cc/t/arduino-absolut-encoder-wachendorff-rs485/933135

void printValues( const char* text, const uint8_t b, const uint16_t w, const uint32_t l)
{
  Serial.println();
  Serial.println(text);
  Serial.print(F("byte: "));
  Serial.print(b);
  Serial.print(F("   word: "));
  Serial.print(w);
  Serial.print(F("   long: "));
  Serial.println(l);
}

void setup()
{
  Serial.begin(115200);

  uint8_t valByte = 2;
  uint16_t valWord = 5;
  uint32_t valLong = 10;
  printValues("*** vorher ***", valByte, valWord, valLong);

  valByte <<= 1;
  valWord <<= 1;
  valLong <<= 1;
  printValues("*** 1x shift left ***", valByte, valWord, valLong);

  valByte <<= 2;
  valWord <<= 3;
  valLong <<= 4;
  printValues("*** {2|3|4}x shift left ***", valByte, valWord, valLong);

  Serial.println();
  Serial.println(F("und wieder zurück..."));
  valByte >>= 3;
  valWord >>= 4;
  valLong >>= 5;
  printValues("*** {3|4|5}x shift right ***", valByte, valWord, valLong);

}

void loop()
{
  // put your main code here, to run repeatedly:

}

ergibt:

20:34:10.303 -> 
20:34:10.303 -> *** vorher ***
20:34:10.303 -> byte: 2   word: 5   long: 10
20:34:10.303 -> 
20:34:10.303 -> *** 1x shift left ***
20:34:10.303 -> byte: 4   word: 10   long: 20
20:34:10.303 -> 
20:34:10.303 -> *** {2|3|4}x shift left ***
20:34:10.303 -> byte: 16   word: 80   long: 320
20:34:10.303 -> 
20:34:10.303 -> und wieder zurück...
20:34:10.349 -> 
20:34:10.349 -> *** {3|4|5}x shift right ***
20:34:10.349 -> byte: 2   word: 5   long: 10

Danke

Hallo,
Dem Dank möchte ich mich anschließen, bin ja ebenfalls über das = gestolpert
Heinz

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.