+ Reply to Thread
Results 1 to 6 of 6

Thread: SPI communication 4-20mA T click Transmitter

  1. #1
    New Member New Member hike96 is on a distinguished road
    Join Date
    Apr 2019
    Posts
    4
    Points
    45

    SPI communication 4-20mA T click Transmitter

    Hi,

    I am very new to Dave and microcontroller programming in General.

    Has anyone ever combined a xmc with the 4-20mA T click Transmitter by mikroElektronika?

    I want to use my XMC4300 microcontroller to control a 4-20mA current Loop. The 4-20mA T click communicates with the target board via three SPI lines.
    In Dave, I found the SPI_MASTER app and example Code. I tried to set it up. My Goal is to, by sending different values via SPI, using the "SPI_MASTER_Transmit"-function, to change the current within the 4-20mA-loop. However, I am somehow unable to change the current.

    I found Driver Code belonging to the Transmitter. Can anyone tell me if it is necassary to include this Code? Is it necassary to do slave configuration like in the SPI_MASTER app example?

    I am sorry for the very stupid questions.

    Regards!

  2. #2
    New Member New Member Rengineer is on a distinguished road
    Join Date
    Oct 2018
    Posts
    8
    Points
    117.5
    What mode are you running the SPI channel - Direct, Interrupt or DMA? Do you see any of the 3 signals toggling on the board?
    The example in the spi_master.h file shows a basic transfer using Direct mode with FIFO.
    If you copy that and use the right values to talk to the transmitter it should work, but you have to make sure your baud rate (Bus Speed), word and frame length are correct for the part you are communicating to.

    once you get the pins toggling, you can verify with a scope to make sure your timing is correct and adjust them with DAVE as necessary. With the receive FIFO enabled, you can also read back the response (if the part sends one), which might include some status info.

  3. #3

    Infineon Employee
    Infineon Employee
    jferreira will become famous soon enough
    Join Date
    Oct 2012
    Posts
    601
    Hi,

    Just search for MCP49xx Arduino library and make a port of it using XMCLib or the API provided by SPI_MASTER APP.
    Alternatively you can also use Arduino APIs on XMC, https://github.com/Infineon/XMC-for-Arduino

    Regards,
    Jesus
    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.

  4. #4
    New Member New Member hike96 is on a distinguished road
    Join Date
    Apr 2019
    Posts
    4
    Points
    45
    Thank you for your replies!

    In the meanwhile, I often do have my desired current (4-20mA) in my current loop, however, I still have Problems with Controlling the current: Increasing the input value sometimes does increase the current as well, but then, it suddenly goes down again or sometimes, I don't get a signal at all. It seems to be very non-reconstructable. Do you have any ideas where this Problem could be caused? I really have not found a way yet to control my current properly.

    How do I know which bus speed is correct?

    I found this code where the 4-20mA Transmitter is connected to an Arduino. In this case, not only the message (12 Bit, as its a 12 bit DAC? ) is being sent, but also some bits in advance:

    Click image for larger version

Name:	code_part_arduino.PNG
Views:	1
Size:	36.2 KB
ID:	3935

    Do you know if setting these bits will be necassary in my case? I decided to send 1 word at the moment with the size of 16 bits, where I make sure that the first bits are set like in the Arduino example above:

    master_send_data |= 0x3000;

    As I said, I do get current flow doing it like this, but the current is not really controllable but rather "jumping" sometimes when only increasing the Input a little bit or so.

    And if theres the possibility to include an Arduino library by making a port of it, @jferreira, could you go into a Little bit more Details on how to do that?

    Thanks a lot!

  5. #5
    New Member New Member Rengineer is on a distinguished road
    Join Date
    Oct 2018
    Posts
    8
    Points
    117.5
    I'd check to make sure you have setup to clock out the data on the falling edge of SCK, as the MCP4921 reads the data on the rising edge. Since it is working sometimes, it could be that you are violating the setup time by clocking out the data on the same edge as the DAC is reading it.

  6. #6
    New Member New Member hike96 is on a distinguished road
    Join Date
    Apr 2019
    Posts
    4
    Points
    45
    Thank you , this helped alot!

+ 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.