Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

How to connect own I2C / SPI devices

2014-05-22
2019-02-21
  • eschwellinger

    eschwellinger - 2014-05-22

    Hi,

    how to generate the driver for own I2C devices?
    Please read attached documentation (this is the product datasheet from the store)
    Chapter 10. Connect additional devices via IΒ²C and SPI

    Where are the device description files (examples for the other I2C devices which are already in the system

    Usually you could get them by:
    1. Generate an empty project add all available I2C devices, then save this project as projectarchive
    open this as zip (rename it) - you find in the zip all devices which you added to the project -the easies way to grab them
    2. location for the device repository is: c:\ProgramData\CoDeSys\Devices\500 (500 are I2C devices, 501 SPI devices) you could copy them from there. (for this you need to know the ID of the device)
    3. attached to this post.

    BR
    Edwin

    raspberrypi_en.pdf [814.57 KiB]

    Devices.zip [17.04 KiB]

     
  • switcher - 2014-05-23

    Hi,

    I am preparing library for I2C PCF8574A (IO expander).
    Reading values from PCF8574 works ok.

    I have a problem with writing values to PCF8574.
    If I put write8 function in Method BeforeWriteOutputs, writing values don't work:

    If I put write8 function directly in FB, it works:

    What is the right way?

    Best regards,
    Zdenko.

    IMG: Bild

    IMG: Bild

     
  • kdebu - 2014-05-23

    Please check your device descirption:

    The device description must look like this:

    The PCF8574 does not have any registers. So you can use

    Write(ADR(PCFOUT), 1);
    

    in the "BeforeWriteOutputs" - Method (not in FB)

    This should solve the problem.

    Best regards,
    kdebu

    IMG: Bild

     
  • switcher - 2014-05-23

    Hi,

    yes, the method BeforeWriteOutputs Method have to be defined in the device description also.

    it work perfectly now !

    Thank you very much!

    BR
    Zdenko.

     
  • mbruck - 2014-05-26

    Zdenko,

    As I see you finish PCF8574 library ? Is possible to share it with us in source code? I'd like to see how you write it, so I believe I can write another library for some interesting IC's on I2C.

    Regards !

    Mladen Bruck

     
  • switcher - 2014-05-27

    Hi Mladen,

    Enclosed are my PCF8574 lib. This is for PCF8574A type. If you are using PCF8574 you have to change the address (usiAddress).

    There are also devicedescription file and sample project.

    Best regards,
    Zdenko.

    PCF8574.zip [240.56 KiB]

     
  • mbruck - 2014-05-28

    Hi Zdenko !

    Thank you very much.

    Beside investigating your code, I just have to pick some IC's from ebay and try it.

     
  • switcher - 2014-08-21

    Hi,

    I like to connect more than one PCF8574 on the same I2C bus, using different address on each one.
    What is the best way to integrate different addresses in the same lib?

    Best regards,
    Zdenko.

     
  • Noodles - 2014-12-28

    Hi,

    the Output worked great, but how is it possible to Read the Inputs with the PCF8574?
    Can somebody please post a sample or a picture of the code.

    Greatings
    Noodles

     
  • Fab - 2015-05-07

    Does somebody know how i can deinstall I2C devices? I deleted it in the Device Folder (500) but it is still in this window:

    it says "Device not found"

    IMG: screen.png

     
  • eschwellinger

    eschwellinger - 2015-05-07

    Hi,
    you need to uninstall your device here:

    BR
    Edwin

    IMG: UninstallDevices.jpg

     
  • Damian7546 - 2018-02-14

    Hi,

    Could anyone write to me instruction how generate driver for my I2c device : LCD Panel. ?

     
  • Damian7546 - 2018-02-16

    I did it.

     
  • RasPi-User - 2019-02-21

    Hello,

    Is the driver for HD44780 LCD with I2C? Is possible to share it with us in source code?

    best regards

     

Log in to post a comment.