Home > Forum > Controllers SlimLine e Netsyst (LogicLab) > Manage an I / O expander connected to the extension bus
- This topic has 1 response, 1 participant and was last updated 10 years, 4 months ago da Sergio Bertana.
-
AuthorPost
-
December 30, 2013 at 7: 44 am #35475Sergio BertanaAdministrator Forum
Through the I2C extension bus CPU modules SlimLine any component with I2C interface can be managed. The function SysI2CWrRd allows to read and write data to devices connected to the bus (Topic), it is not possible to manage I2C addresses between 16 # 20 and 16 # 2F which corresponds to the allocation range of our expansion modules.
The simplest way to explain how to interface I2C components on the bus is to connect a simple I / O expander (Example PCA9670 or PCF8574). In hardware manual of our OEM CPU module you can find a connection diagram with a PCA9670, we have chosen this type of I / O expander because it has the reset input that can be connected to the signal RDYO-N of our expansion bus (The signal is FALSE when the system is in run). In this way it is in accordance with the IEC standard which provides for the reset of all outputs if the system is in stop.
December 30, 2013 at 10: 09 am #37954Sergio BertanaAdministrator ForumHere is a simple program to manage a PCF8574 (Datasheet) connected to the extension bus as you can see from photo. The 8 I / O signals of the I / O expander, 4 (From P0 to P3) were used as logic outputs to manage 4 LEDs and 4 (From P4 to P7) were used as logic inputs to acquire keys.
The program is a simple FBD (See screeenshot), the function SysI2CWrRd manages the writing and reading of a byte of data from the / IO expander. In order to use the pins as inputs it is necessary to set them to TRUE, therefore in the creation of the WData byte, in addition to the command of the 4 LEDs, bits from 4 to 7 have been set to TRUE. In this way, the read byte RData contains bits from 4 at 7 the status of the 4 buttons. I attach the source program.
-
AuthorPost
- You must be logged in to reply to this topic.