SSI Communication using Arduino Nano for Magnetic Rotary Encoder

Hi,

I am new to the SSI (Synchronous_Serial_Interface) through Arduino Nano. I am facing some difficulties in the program and connections. I have connected my rotary encoder [RLS] sensor Data+,Data-, Clock+,Clock- to RS422 Zihatec interface.I connect the RS422 TX and RX to D6 and D5 of Arduino Nano pins, respectively.

I have searched for many solutions and followed this link. I haven't succeeded as I resulted with 8191 CPR for my 13-bit magnetic rotary encoder all the time even I have turned my magnetic shaft.

My code modification seems as below from the first code by @johnwasser in the post:

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

I obtain the following results with timestamps:

8191
8191
8191
8191
8191
.....
.....

Is there any issue with the connections or should I have to modify the program?

All solutions and suggestions are appreciated.

Thanks in advance.

with regards,
Nutakki

8191 = 0x1FFF = all 13 bits HIGH
Looks like you data input pin(6) is stuck HIGH.

Not all differential (+/-) signals are RS422.

I would try removing the RS422 interface, connect Data+ to D6, Clock+ to D5, and Data-/Clock- to Ground.

Do you have the datasheet for the encoder?

Yes, I can share the datasheet of the single turn RLS magnetic rotary encoder on page7 with RM58SI in datasheet.

I have kept the DIP switches settings for RS422 as of Zihatec page 6 in Datasheet and DIP Switch Settings (current version) in this link.

If I connect as you have suggested, will the Arduino nano get affected? Because the RLS sensor needs an RS422 interface, as shown on page7 with RM58SI in the datasheet.

It will be a great help with the connections and the code.

Thanks in advance.

with regards,
Nutakki

How do you have the Raspberry Pi 'hat' connected to your Arduino Nano?

I thought the signal comes from TX, RX, RE pins of the 'hat' as mentioned in the 'Schematic' diagram in the link provided earlier. So, I have connected TX (data output), RX (clock input) pins from 'hat' to D6 (data input), D5 (clock output) of the Arduino nano through jumper wires.

And power?

I am giving the 5V power directly from Arduino nano to the RLS sensor.

I have connected the GND from Arduino nano to the RS422 and RS422 have shield that acts as GND as I have seen in the online and is connected to GND of the RLS sensor.

The following are the total connections:

RS422 <--> RLS sensor
B <--> Data-
A <--> Data+
Z <--> Clock+
Y <--> Clock-

RS422 <--> Arduino Nano
TX <--> D6
RX <--> D5
GND <--> GND

Arduino Nano <--> RLS sensor
+5V <--> Vdd

Are you not providing power to the RS422 interface? I would think +5V from the Arduino should go to the 'hat'. Maybe 3.3V, too.

Do you mean the final connection should be like this for SSI communication?

RS422 <--> RLS sensor
B <--> Data-
A <--> Data+
Z <--> Clock+
Y <--> Clock-
Shield <--> GND

RS422 <--> Arduino Nano
TX <--> D6
RX <--> D5
GND <--> GND
+3V3 (Pin 1) <--> +3V3
+5V (Pin 2) <--> +5V
+5V (Pin 4) <--> +5V

Arduino Nano <--> RLS sensor
+5V <--> Vdd

If I connect the power supply to RS422 as above, will that effect the RS422?

Do I have to make any modifications in the first post of your code @johnwasser for single-turn magnetic encoder 13-bit in this link?

Hi, @nutakki
Please draw your circuit, it will be worth a thousand words.
Please include power supplies.
Just pen(cil) and paper, then send an image of it.

Any reason why a Rasp Pi hat for an Arduino project?
Why a 422 interface?

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

Hi @TomGeorge,

I have already mentioned the pin structure in the above reply along with the RS422 interface and RLS sensor datasheets.

The RLS sensor depends on RS422 interface as it was provided in the datasheet.
There is not much difference of the 'hat' that fits on to the Arduino or Raspberry depending on the alignment.

The purpose for both are same with the functionality of the pins.

For power, you need both +5V/Vdd and Gnd for both the hat and the encoder. Your list doesn't show the power ground connection for the encoder.

Do you have the switch set to ground the ^RE (Receive Disable) pin of the RS422 interface?

RS422 <--> RLS sensor
B <--> Data-
A <--> Data+
Z <--> Clock+
Y <--> Clock-
Shield <--> GND

RS422 <--> Arduino Nano
TXD (GPIO14, Pin 8) --> D6 (DATA_PIN)
RXD (GPIO15, Pin 10) <-- D5 (CLOCK_PIN)
GND <--> GND
+3V3 (Pin 1) <--> +3V3
+5V (Pin 2) <--> +5V
+5V (Pin 4) <--> +5V

Arduino Nano <--> RLS sensor
+5V <--> Vdd
GND <--> GND

Hi @johnwasser,

I have attached the DIP switches for RS422 in the below pdf file. On page6, of SW1 that represents 4th row is the ^RE (GPIO 18). I kept this pin in ON mode.

The GND is blue wire in the RLS encoder that is connected to RS422 shield.

DIP switches:
Datasheet RS485 HAT Rev C.pdf (1.3 MB)

Hi @TomGeorge,

I have attached my connection diagram in the figure below. If there are any modications then please let me know.

connection diagram:
*PC represents Personal Computer

with regards,
Nutakki

Hi, @nutakki
Note that the 422 device has galvanic isolation.
Have you measured the voltage between 5V to gnd AT the encoder terminals to see if it is getting supply.

Galvanic Isolation means COMPLETE voltage/current isolation between input and output

Just connecting 5V with no gnd connection through the 422 device, will not supply your encoder.

Tom... :smiley: :+1: :coffee: :australia:

Hi @TomGeorge,

I hope that the encoder is attaining the 5V power supply.

The shield port from RS422 gives the GND connection that is connected to blue wire of the RLS sensor.

Do you mean to connect like this?
RS422 <--> RLS sensor
B <--> Data-
A <--> Data+
Z <--> Clock+
Y <--> Clock-
Shield <--> GND

Arduino Nano <--> RLS sensor
+5V <--> Vdd
GND <--> GND

and the rest with RS422 <--> Arduino Nano as this post.

Hi,

Yes.
Do you have a DMM?

Tom... :smiley: :+1: :coffee: :australia:

No, I don't have DMM.
After these connections, any suggestions for the code for the 13-bit single-turn magnetic encoder.

Hi,
You need to address post #8, how are you powering the 422 module?
We see no 5V supply going to it.

You need to research how the Rasp Pi powers the "HAT".

Can you please post a picture of your project, so we can see your component layout?

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