infineon4engi@twitter infineon@linkedin infineon4engineers infineon@youtube
twitter Facebook Linkedin Youtube

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: Tle5012b ssc via tle987x evalboard,

  1. #1
    Beginner Beginner muratrazi is on a distinguished road
    Join Date
    Aug 2019
    Posts
    35
    Points
    327.5

    Tle5012b ssc via tle987x evalboard,

    Hello everyone,

    I use tle 987x evalboard to comunicate via ssc with tle5012b mangetic angle sensor. Is there anyone that have ssc comunatication example code or document with tle5012b and tle 987x evalboard ?

    Regards,

  2. #2
    Moderator
    Infineon Employee
    Infineon Employee
    Fiz is on a distinguished road
    Join Date
    Jun 2019
    Posts
    68
    Hello Muatrazi,

    Unfortunately we do not have any example code or document to establish communication between the TLE987x and TLE5012b.
    Have you already tried to make them to talk over 3-wire SPI? You could also try using PWM .

    Best,
    Fiz
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  3. #3
    Beginner Beginner muratrazi is on a distinguished road
    Join Date
    Aug 2019
    Posts
    35
    Points
    327.5
    Hello Fiz,

    I have not tried 3 wire spi but i will. I have tried with arduino thanks to github arduino library of tle5012b. But it did not work. I do not know what is wrong

    Kind regards
    Murat.

  4. #4
    Moderator
    Infineon Employee
    Infineon Employee
    Fiz is on a distinguished road
    Join Date
    Jun 2019
    Posts
    68
    Hello Murat,

    Let us know if you have any troubles! Where you able to establish any communication?
    Did you try the PWM interface as well?

    Best,
    Fiz
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  5. #5
    Beginner Beginner muratrazi is on a distinguished road
    Join Date
    Aug 2019
    Posts
    35
    Points
    327.5
    Hello fiz,

    I could have a communication between arduino uno and tle5012b. Now i will rewrite a library for tle987x and i am sure it will work. I will let you know when i am done.

    Kind Regards
    Murat

  6. #6
    Beginner Beginner muratrazi is on a distinguished road
    Join Date
    Aug 2019
    Posts
    35
    Points
    327.5
    Hello Fiz,

    I have some doubts about ssc properties in order to communicate between tle987 and tle5012b e3005. Do you think that the adjustment that is attached below for tle5012b on tle987 is correct ?

    Click image for larger version

Name:	ssc2.jpg
Views:	4
Size:	57.4 KB
ID:	4296Click image for larger version

Name:	ssc1.jpg
Views:	3
Size:	97.0 KB
ID:	4297

  7. #7
    Moderator
    Infineon Employee
    Infineon Employee
    Fiz is on a distinguished road
    Join Date
    Jun 2019
    Posts
    68
    Hi Murat,


    did you look into the XMC2go sensor shield with the TLE55012b? They have some examples using SSC.

    https://www.infineon.com/cms/en/prod..._ms2go/#!tools

    they are using a GUI where you can easily establish communication, or you can check the software on github.
    https://github.com/Infineon/TLE5012-...c-Angle-Sensor

    There you can also find some help how to configure the SSC.

    Best,
    Fiz
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  8. #8
    Beginner Beginner muratrazi is on a distinguished road
    Join Date
    Aug 2019
    Posts
    35
    Points
    327.5
    Hi Fiz,

    I have worked with the library you sent. I am working on arm keil. I am trying to reconfigure the library for tle987. I configured the the ssc properties like in the library but it did not work. So i am asking this.

  9. #9
    Beginner Beginner muratrazi is on a distinguished road
    Join Date
    Aug 2019
    Posts
    35
    Points
    327.5
    Hello Fiz,

    I rewrote tle5012b arduino library for tle987x eval board. My code is below. And i have used the configuration which is below for the ssc communication. I have used 470 ohm resistor for mosi and miso
    before connecting the ssc data pins. I supply tle5012b e3005 with vddexit which is 5v. I have used p0.1 as chip select pin. Any help will be appreciated.
    #include "tle_device.h"
    #include "eval_board.h"
    void setup();
    double calculateAngleSpeed(double angRange, int16_t rawAngleSpeed, uint16_t firMD, uint16_t predictionVal);
    uint8_t crcCalc(uint8_t* crcData, uint8_t length);
    double angleValue;
    uint8_t crc8(uint8_t *data, uint8_t length);
    uint8_t getSecondByte(uint16_t twoByteWord);
    uint8_t getFirstByte(uint16_t twoByteWord);
    void enableSensor();
    void disableSensor();
    enum errorTypes getAngleValue();
    enum errorTypes readFromSensor(uint16_t command, uint16_t *data);

    /************************************************** ***************************/
    /** SSC1: sends one byte (0xAA) as SPI master @ 1 Mbaud **/
    /************************************************** ***************************/
    /** program SSC1 to operate at 1 Mbaud **/
    /** SSC1 sends one byte at P0.3 (CLK), P0.2 (MTSR) **/
    /************************************************** ***************************/

    #define TLE5012B_H

    // Sensor registers
    #define READ_SENSOR 0x8000 //!< base command for read
    #define WRITE_SENSOR 0x5000 //!< base command for write
    #define READ_BLOCK_CRC 0x8088 //!< initialize block CRC check command



    #define SYSTEM_ERROR_MASK 0x4000 //!< System error masks for safety words
    #define INTERFACE_ERROR_MASK 0x2000 //!< Interface error masks for safety words
    #define INV_ANGLE_ERROR_MASK 0x1000 //!< Angle error masks for safety words

    #define CRC_POLYNOMIAL 0x1D //!< values used for calculating the CRC
    #define CRC_SEED 0xFF
    #define CRC_NUM_REGISTERS 0x0008 //!< number of CRC relevant registers
    #define MAX_REGISTER_MEM 0x0030 //!< max readable register values buffer

    #define DELETE_BIT_15 0x7FFF //!< Value used to delete everything except the first 15 bits
    #define CHANGE_UINT_TO_INT_15 0x8000 //!< Value used to change unsigned 16bit integer into signed
    #define CHECK_BIT_14 0x4000 //!<
    #define GET_BIT_14_4 0x7FF0 //!<

    #define DELETE_7BITS 0x01FF //!< values used to calculate 9 bit signed integer sent by the sensor
    #define CHANGE_UNIT_TO_INT_9 0x0200 //!< Value used to change unsigned 9bit integer into signed
    #define CHECK_BIT_9 0x0100

    #define POW_2_15 32768.0 //!< values used to for final calculations of angle speed, revolutions, range and value
    #define POW_2_7 128.0 //!<
    #define ANGLE_360_VAL 360.0

    #define TEMP_OFFSET 152.0 //!< values used to calculate the temperature
    #define TEMP_DIV 2.776

    //!< Prints a binary number with leading zeros (Automatic Handling)
    #define PRINTBIN(Num) for (uint32_t t = (1UL<< (sizeof(Num)*8)-1); t; t >>= 1) Serial.write(Num & t ? '1' : '0');
    //!< Prints a binary number with leading zeros (Automatic Handling) with space
    #define PRINTBINS(Num) for (uint32_t t = (1UL<< (sizeof(Num)*8)-1); t; t >>= 1) Serial.write(Num & t ? " 1 " : " 0 ");

    /*!
    * Error types from safety word
    */
    enum errorTypes
    {
    NO_ERROR = 0x00, //!< NO_ERROR = Safety word was OK
    SYSTEM_ERROR = 0x01, //!< SYSTEM_ERROR = over/under voltage, VDD negative, GND off, ROM defect
    INTERFACE_ACCESS_ERROR = 0x02, //!< INTERFACE_ACCESS_ERROR = wrong address or wrong lock
    INVALID_ANGLE_ERROR = 0x03, //!< INVALID_ANGLE_ERROR = NO_GMR_A = 1 or NO_GMR_XY = 1
    ANGLE_SPEED_ERROR = 0x04, //!< ANGLE_SPEED_ERROR = combined error, angular speed calculation wrong
    CRC_ERROR = 0xFF //!< CRC_ERROR = Cyclic Redundancy Check (CRC), which includes the STAT and RESP bits wrong
    };

    /*!
    * Set the UPDate bit high (read from update buffer) or low (read directly)
    */
    enum updTypes
    {
    UPD_low = 0x0000, //!< read normal registers
    UPD_high = 0x0400, //!< read update buffer registers
    };

    /*!
    * Switch on/off safety word generation
    */
    enum safetyTypes
    {
    SAFE_low = 0x0000, //!< switch of safety word generation
    SAFE_high = 0x0001, //!< switch on safety word generation
    };
    uint8_t mMOSI; //!< Pin for SPI MOSI (pin 0.6 on test board);
    uint8_t mMISO; //!< Pin for SPI MISO (pin 0.7 on test board)
    uint8_t mSCK; //!< Pin for CLOCK (pin 0.8 on test board)
    uint8_t mCS; //!< Pin for chip select (pin 0.9 on test board)

    uint16_t data;
    uint16_t _command1; //!< command write data [0] = command [1] = data to write
    uint16_t _command2; //!< command write data [0] = command [1] = data to write
    uint16_t _received[MAX_REGISTER_MEM]; //!< fetched data from sensor with last word = safety word
    uint16_t _registers[CRC_NUM_REGISTERS]; //!< keeps track of the values stored in the 8 _registers, for which the CRC is calculated
    int main(void)
    {
    /************************************************** ***************************
    ** initialization of the hardware modules based on the configuration done **
    ** by using the IFXConfigWizard **
    ************************************************** ***************************/
    TLE_Init();
    setup();


    for (;
    {
    (void)WDT1_Service();
    Delay_us(1000000);
    enableSensor();
    getAngleValue();
    }
    }

    void setup()
    {
    mMOSI=0x02; //!< Pin for SPI MOSI (pin 0.6 on test board);
    mMISO=0x24; //!< Pin for SPI MISO (pin 0.7 on test board)
    mSCK=0x03; //!< Pin for CLOCK (pin 0.8 on test board)
    mCS=0x01;
    enableSensor();

    }


    enum errorTypes getAngleValue()
    {
    angleValue=0;
    int16_t rawAnglevalue=0;
    uint16_t rawData = 0;
    enum errorTypes status = readFromSensor(REG_AVAL, &rawData);
    if (status != NO_ERROR)
    {
    return (status);
    }
    rawData = (rawData & (DELETE_BIT_15));
    //check if the value received is positive or negative
    if (rawData & CHECK_BIT_14)
    {
    rawData = rawData - CHANGE_UINT_TO_INT_15;
    }
    rawAnglevalue = rawData;
    angleValue = (ANGLE_360_VAL / POW_2_15) * ((double) rawAnglevalue);
    return (status);
    }
    enum errorTypes readFromSensor(uint16_t command, uint16_t *data)
    {
    enum errorTypes checkError = NO_ERROR;

    _command1 = READ_SENSOR | command | UPD_low | SAFE_low;
    uint16_t _received[MAX_REGISTER_MEM] = {0};

    //_spiConnection->setCSPin(mCS);
    PORT_ChangePin(LED1, PORT_ACTION_SET);
    //Delay_us(100);
    //_spiConnection->sendReceiveSpi(_command1, 1, _received, 2);
    PORT_ChangePin(LED1, PORT_ACTION_CLEAR);
    SSC1_SendWord(_command1);
    Delay_us(5000);

    _received[0]=SSC1_ReadWord();

    _received[1]=SSC1_ReadWord();
    *data = _received[0];

    PORT_ChangePin(LED1, PORT_ACTION_SET);
    if (true)
    {
    // checkError = checkSafety(_received[1], _command1, &_received[0], 1);
    if (checkError != NO_ERROR)
    {
    data = 0;
    }
    }

    checkError=NO_ERROR;
    return (checkError);
    }
    void enableSensor()
    {

    PORT_ChangePin(LED1, PORT_ACTION_SET);
    //digitalWrite(mCS, HIGH);
    }

    void disableSensor()
    {
    PORT_ChangePin(LED1, PORT_ACTION_CLEAR);
    //digitalWrite(mCS, low);
    }
    //-----------------------------------------------------------------------------
    // none_class functions

    /*!
    * Gets the first byte of a 2 byte word
    * @param twoByteWord insert word of two bytes long
    * @return returns the first byte
    */
    uint8_t getFirstByte(uint16_t twoByteWord)
    {
    return ((uint8_t) (twoByteWord >> 8));
    }

    /*!
    * Gets the second byte of the 2 byte word
    * @param twoByteWord insert word of two bytes long
    * @return returns the second byte
    */
    uint8_t getSecondByte(uint16_t twoByteWord)
    {
    return ((uint8_t) twoByteWord);
    }

    /*!
    * Function for calculation the CRC.
    * @param data byte long data for CRC check
    * @param length length of data
    * @return returns 8bit CRC
    */
    uint8_t crc8(uint8_t *data, uint8_t length)
    {
    uint32_t crc;
    int16_t i, bit;

    crc = CRC_SEED;
    for (i = 0; i < length; i++)
    {
    crc ^= data[i];
    for (bit = 0; bit < 8; bit++)
    {
    if ((crc & 0x80) != 0)
    {
    crc <<= 1;
    crc ^= CRC_POLYNOMIAL;
    }else{
    crc <<= 1;
    }
    }
    }

    return ((~crc) & CRC_SEED);
    }

    /*!
    * Function for calculation of the CRC
    * @param crcData byte long data for CRC check
    * @param length length of data
    * @return runs crc8 calculation and returns CRC
    */
    uint8_t crcCalc(uint8_t* crcData, uint8_t length)
    {
    return (crc8(crcData, length));
    }

    /*!
    * Calculate the angle speed
    * @param angRange set angular range value
    * @param rawAngleSpeed raw speed value from read function
    * @param firMD
    * @param predictionVal
    * @return calculated angular speed
    */
    double calculateAngleSpeed(double angRange, int16_t rawAngleSpeed, uint16_t firMD, uint16_t predictionVal)
    {
    double finalAngleSpeed;
    double microsecToSec = 0.000001;
    double firMDVal;
    if (firMD == 1)
    {
    firMDVal = 42.7;
    }else if (firMD == 0)
    {
    firMDVal = 21.3;
    }else if (firMD == 2)
    {
    firMDVal = 85.3;
    }else if (firMD == 3)
    {
    firMDVal = 170.6;
    }else{
    firMDVal = 0;
    }
    finalAngleSpeed = ((angRange / POW_2_15) * ((double) rawAngleSpeed)) / (((double) predictionVal) * firMDVal * microsecToSec);
    return (finalAngleSpeed);
    }

    Click image for larger version

Name:	Untitled.jpg
Views:	2
Size:	75.9 KB
ID:	4416

  10. #10
    Moderator
    Infineon Employee
    Infineon Employee
    Fiz is on a distinguished road
    Join Date
    Jun 2019
    Posts
    68
    Hello Murat,

    I am sorry for the long waiting time.
    I am looking into the TLE5012b library and will let you know once I get it running.
    What problems were you experiencing?
    Best,
    Fiz
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

+ Reply to Thread

Tags for this Thread

Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.