I have a CFC block which is supposed to read a value from a I2C device regularly, but before that, the device (actually an ADS1115) has to be configured once before the the evaluation of the block starts. I thought that could be done in the method FB_Init for the block. But it can't. The code compiles without any problems, but after download I get an Exception which says AccessViolation. Why? And how do I configure the device only once?
It is a bad idea to utilize or reference any (external) objects in FB_Init other than the FB that you are initializing as you run the risk of the object (I2C_master in this case) not "existing" in memory yet when the FB is initialized.
I have a CFC block which is supposed to read a value from a I2C device regularly, but before that, the device (actually an ADS1115) has to be configured once before the the evaluation of the block starts. I thought that could be done in the method FB_Init for the block. But it can't. The code compiles without any problems, but after download I get an Exception which says AccessViolation. Why? And how do I configure the device only once?
It is a bad idea to utilize or reference any (external) objects in FB_Init other than the FB that you are initializing as you run the risk of the object (I2C_master in this case) not "existing" in memory yet when the FB is initialized.
Did you write a driver for the ADS1115? If you do, you can set the initial config of the ADS1115 using the state machine built into the template found at https://forge.codesys.com/drv/io-driver ... ?version=1 m