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

Raspberry Pi: List of available drivers / libraries

Runtime
2014-09-11
9 hours ago
  • Moderator3S

    Moderator3S - 2015-02-16

    Author: Erikk
    Date: 16.2. 2015
    Version: 1.0.0.0

    I´ve attached my library for the SHT21.

    It has an internal statemachine inside the _iState, dont know if this was neccesary but i think the symbolic status of the device changes if it isnt "10" ?
    It has a TON Timer of 50ms before Writing a measurement request ( i´ve only tested the No-Hold commands ).
    The internal state machine has these states:
    10: Write Temp measurement command -> Send to state 11.
    11: Read/wait for respons, when respons is found -> Send to state 20.
    20: Write Humidity measurement command -> Send to State 21.
    21: Read/wait for respons, when respons if found -> Send to state 10.

    Every read checks the statusbit of the second byte, to check if it is the correct measurement that is read(temp/humidity), and sets or resets the xTempValid and xHumidityValid booleans.
    It dont use the checksum.

    After a Temperature measurement request is sent, a 100ms TON is set, before doing a Read, same with Humidity Measurement, but only 40ms.
    If the read isnt successfull it will try again in the next cycle.

    I tried withouth these timers with 4ms cycle time. On the 17th Temperature read (68ms) I got a respons from the sensor, and the 7th Humidity read (28ms).
    So to take some cycles of the Cpu and the bus, i think its the right way to go. But you could probably go down to ~65-70ms for a temperature read and ~30ms for a Humidity.

    It also has a internal watchdog timer, which is needed if it doesnt get a respons at all (i made a short between the SCL/SDA lines and it got stuck in a reading state), when it runs out, it starts from _iState 0 (complete restart).

    If you dont specify a I2C address, in _iState 0 it automatically sets the address 0x40 (decimal 64), which is specified in the SHT21 manual.

    Its probably not the best written library but it works very well.
    Hope it will be of some use to someone.

    SHT21 Humidity & Temperature Sensor

    I2C_SHT21.library [348.46 KiB]

    SHT21.devdesc.xml [2.35 KiB]

     
    👍
    1
    • FabioPD

      FabioPD - 2020-03-04

      Hello Can I have an example? a project to test? I used that for my AM2315 (address 0x5c) but codesys crash when I go online mode ...

       
  • Moderator3S

    Moderator3S - 2015-09-19

    Author: Oleg Wagner
    Date: 3.09.2015
    Version: 1.0.0.1

    MAX7219 which enables to drive up to 20 casceded (daisy chained) MAX7219 devices
    (7-segment displays as well as 64-LED matrices).

    Following functions are included:
    - Display Test
    - Set number of digits
    - Shutdown mode
    - Set brightness/intensity
    - Clear Digit or Row
    - Clear all segments/LEDs of a device
    - Write particular segments of digits
    - Write BCD numbers
    - Write characters
    - Write multi-digit integer
    - Write multi-digit floats
    - Write particular LEDs in row
    - init device
    - all necessary methods to set up SPI communication and data transfer

    A device description file is also part the library.

    For first impression see attached screen shots.

    I would like to share this library if there is interest (no engagement).

    Update to 1.0.0.1 Version include:
    Extension of device description file:

    • Icon added
    • Initialization parameters for devices:
    • Intensity level
    • Number of digits of the device
    • Shutdown
    • Display Test
    • Clear Device

    Extension of “Initialize”-method in library with setting of above mentioned parameters

    Raspberry SPI MAX7219_1001.rar [544.94 KiB]

    Raspberry SPI MAX7219.rar [447.2 KiB]

     
  • Moderator3S

    Moderator3S - 2015-10-26

    because i had some problems with the standard Adafruit PWM and made my own version.
    Sometimes i need the PWMs and / or the servo control function.

    Use a Array[0..15] to send values from 0 - 100 for PWM function or 101 - 200 for servo control (1.01 to 2.00 ms Pulse)
    I added a accessible trim function for servo pulse finetuning.
    The State shows if the device is present and accessible.
    The IN shows the actual frequency register value.

    PCA9685.devdesc.xml [3.2 KiB]

    I2C_PCA9685.library [278.88 KiB]

     
  • Moderator3S

    Moderator3S - 2015-12-31

    Author: PhilipLykov
    Date: 12.10. 2015
    Version: 1.0.0.0

    A library for UPS PIco for Raspberry Pi. Includes the following functions:
    - read voltage
    - read temperature
    - read analog inputs
    - read other parameters
    - control LEDs
    - control of cooler (including automatic control based on temperature)
    - Still Alive Timer (watchdog which will reboot the Raspberry Pi if your code will stop)
    - initial configuration of the device out of your code

    UPSPIco.project [177.26 KiB]

    I2C_UPSPIco.library [381.52 KiB]

    UPSPIco.devdesc.xml [2.42 KiB]

     
  • Moderator3S

    Moderator3S - 2017-05-28

    Author: Dag H. Hanssen
    Date: 09.05.2017

    Here is a library I made for the device LSM9DS1, an Accelerometer/Gyro/Magnetometer form ST life.augmented, on a break-out board from Adafruit. (I had to zip the library-file since the size was more than 500kB, which is maximum upload file-size for this forum.)

    The device has actually two slaves, but I chose to integrate them both with on device-description. It doesn't matter if the user assigns a slave address in the project, the code in the library alters anyway between two different slave-addresses when writing/reading data.

    Though the device has built-in FIFO-registers, for faster and less time-/power-consuming readouts, I have not used this option in this version of the library. Instead, the readout is timer-controlled, with a user-specified read-rate.

    I have also uploaded a very simple test-project.

    Hope someone finds the library useful,
    Dag Hansa

    Testing_LSM9DS1.project [120.94 KiB]

    I2C_LSM9DS1 library file.zip [202.45 KiB]

    LSM9DS1.devdesc.xml [2.51 KiB]

     
  • Moderator3S

    Moderator3S - 2017-11-26

    Autor: Stefan2
    Date: 17.11. 2017
    Version: 1.0.0.0

    Hello,

    Here is my Library for some I2C devices for CODESYS.
    You can place all devices behind a multiplexer to reduce address conflicts.
    Although include the BME280 Environment sensor and an SD1306 Display Driver.
    Look at google for these little funny Displays.
    All fonts are working on the display, but not the biggest. There the bits have to be twisted.
    If you find any problems, tell me, the Drives have not been tested all.

    Don't look at the documentation, there is none ... .

    In the I2C_Base FB I did write some info’s for the muxing.

    With the muxing IC you can connect about 33554432 BME280 on the raspi, but then bus cycle time is no longer a problem .

    You will need the OSCAT building lib to compile. i can not uplode it here like the OSCAT BASIC lib(to big), so try the lib from the store.

    Device list:

    BME280
    25C512 64KiB EEPROM
    An 4channel dimmer (I done this for an friend)
    PCA9555 as 16 bit input
    PCA9555 as 16 bit output
    PCA9685 a 16 channel 12bit PWM output, inspired by example code of CODESYS but writes only when output value is changing
    PCF8575 as 16 bit input
    PCF8575 as 16 bit output
    SSD1306 Display Driver
    TCA9548 8 channel I2C Multiplexer/switch
    https://github.com/stefandreyer/I2C-Multiplex

    TSL2561 lux sensor, state I would say experimental

    Greetings Stefan

    Raspberry I2C MUX_update.projectarchive [416.51 KiB]

    Raspberry I2C MUX.projectarchive [388.84 KiB]

    BASIC.projectarchive [398.68 KiB]

    xml devices.zip [18.38 KiB]

     
  • Moderator3S

    Moderator3S - 2018-12-13

    Autor: johan76swart
    Date: 25.07. 2018
    Version: 1.0.0.0

    Hello fellow Raspberry enthusiast!

    Here is a device library for the MCP4728 4-Channel 12-bit DAC, default address = 0x60.

    Input an integer 0-4095 for each channel.

    MCP4728.devdesc.xml [2.38 KiB]

    I2C_MCP4728.library [335.03 KiB]

     
  • Moderator3S

    Moderator3S - 2018-12-13

    Autor: Aliazzz
    Date: 11.02. 2018
    Version: 2.0.0.0

    Monarco.io

    Codesys Application Composer "FirstSteps" Example implemented with the Monarco V2.0.0.0 Library;
    https://github.com/Aliazzzz/Monarco-HAT ... FirstSteps m

    IMG: MonarcoHat.png

    IMG: Monarco3.png

    IMG: Monarco2.png

    IMG: Monarco.png

     
  • Moderator3S

    Moderator3S - 2019-08-19

    Author: Reinhard Hesse
    Date: 13.08.2019
    Version: 1.0.0.0

    Library for I2C – PCF8574 LCD contains:
    02_Lib -Library
    03_LCD_Basic - Example Project
    04_LCD_Visu -Example Project
    01_XML Device Description
    I2C-LCD mit CODESYS.pdf documentation

    IMG: LCD.png

    Fertig.zip [2.35 MiB]

     
  • Moderator3S

    Moderator3S - 2019-08-19

    Autor: e.kislov
    Date: 5/2019

    Link to the post(including attachements):
    l viewtopic.php?f=23&t=9760 l

    There is a simple example how to generate a QR-code and show it in web-visu: Example_QrCode_RPI.projectarchive

    Image Image

    Requirements:

    1. You need to install qrencode:

    sudo apt-get install qrencode

    1. You need to install OwenStringUtils library. It included in projectarchive or you can install it separately: download
      It's nice lib with additional string functions like ASCII/Unicode conversion, formatting and parsing.

    2. In example used SysProcess library.
      So you need to add in /etc/CODESYSControl_User.cfg next lines:

    [SysProcess]
    Command=AllowAll

    Keep in mind that you need to have write access rights:

    sudo chmod 0666 /etc/CODESYSControl_User.cfg

    1. You need to set write access rights for /visu directory:

    sudo chmod 0666 /var/opt/codesys/PlcLogic/visu

    1. You can see qr-code in web-visu, but not in service-visu (CODESYS IDE-visu).
     
  • Moderator3S

    Moderator3S - 2019-08-19

    Autor: Aliazzz
    Date: 06.04.2019

    l viewtopic.php?f=23&t=9665 l

    This library enables the usage of RETAIN data on the Raspberry Pi platform which natively does not support this.
    It is based on the mcp7941x RTC chip which also contains 64 bytes Battery Buffered SRAM.

    For details and package: https://forge.codesys.com/drv/mcp7941x/ m

     

Log in to post a comment.