RS485 Encoder eCoder 20-trouble to read the position

C:
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/pin_map.h"
#include "driverlib/uart.h"
uint32_t g_ui32SysClock;
#define ASO_BITS 21
#define AS2_BITS 3
#define BAUD_RATE 2500000
unsigned char temp = 0, temp2 = 0, temp3 = 0;
uint32_t ui32SysClock;
unsigned char Recieved_value;
#define DE_PIN GPIO_PIN_4
#define RE_PIN GPIO_PIN_5
unsigned long val, val2;
uint32_t position_data;

#define System_Clock_frequency 120000000
int main(void)
{

    ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN |
    SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_240),     System_Clock_frequency);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    //SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);

   GPIOPinConfigure(GPIO_PA0_U0RX);
    GPIOPinConfigure(GPIO_PA1_U0TX);
    //GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, DE_PIN);
    //GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, RE_PIN);
    //GPIOPinWrite(GPIO_PORTA_BASE, DE_PIN ,0);

    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
 // UARTFIFOEnable(UART0_BASE);
UARTFIFODisable(UART0_BASE);

    UARTConfigSetExpClk(UART0_BASE, ui32SysClock, 2500000,
                        (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                        UART_CONFIG_PAR_NONE));
    // GPIOPinWrite(GPIO_PORTA_BASE, DE_PIN | RE_PIN, DE_PIN|RE_PIN);

/*
     unsigned int i;
     for(i=0;i<10;i++)
     {
     UARTCharPut(UART0_BASE, 0x02);
     SysCtlDelay(1600);
     }
*/


    do
    {



        UARTCharPut(UART0_BASE, 0x02);
        SysCtlDelay(4800);

        temp3 = 0;

        val = 0;
        while (UARTCharsAvail(UART0_BASE))
        {

            Recieved_value = UARTCharGet(UART0_BASE);
            temp3++;
        //    temp2 = Recieved_value;
          //  val |= temp2;
         //   val = val << 8;

            //if (temp3 == 3)
            //    break;
        }
        val2 = val;

              // Now 'val' contains the 24-bit data, and it represents your position information

    }
    while (1);

    return (0);
}

/* */
I am trying to read the position from an absolute RS485 encoder eCoder20M (Multiturn). I am using SN75716 for transmitting and receiving and the controller I am using is a TM4C1294 launchpad.

I am transmitting 0x02 to the encoder and receiving some random data, I cannot understand how to extract it, and by rotating the shaft of the motor, it doesn't seem to be changed.

If anyone has faced this issue, please help me out of this, I have attached the code, and the image of the scope where the yellow traces represent the transmit signal (0x02), Ignore the noise it's due to the scope probe and the blue trace represents the receiving signal at the'R' pin of SN75716.
I have also attached the snapshot of the datasheet.
 

Attachments

Top