Neuron L503 - Group 2 analog inputs

  • Hi,

    I'm trying to connect some pH and EC "water-quality sensors" and I have some issues in working with the AIs.

    More information about the sensors:

    • The sensors are connected to a transmitter which has a display (so I can see the actual measured value) and it also has a 4-20mA (Active) output.

    • 2 sensors (4-20mA) connected to AI2.1 and AI2.2, using the the 2 AGN next to each input.

    Questions related to Neuron-Codesys

    • What is the correct way to configure the output to read "current"? I've added the necessary channels for reading the input and also to select the AI mode. AI2.1 seems to be in "current mode - 3" but I'm doing the same thing for AI2.2 and it doesn't read anything.

    • What values does it read? Because I'm seeing values like "10579" if I'm reading the analog input.

    • The value I'm reading is not stable at all and jumps all over the place, 7852, 10813, 9681... all for the same measurement. Any clues what this could be?

    Hopefully you can help as it is one of the last steps to get our set-up running :)

    Thank you.

  • Hereby some screenshot on how I'm trying to read the AI, feel free to comment!

    0_1525960256242_Modbus Slave Channel.PNG -> Line 27-30

    0_1525960308786_ModbusTCPSlave IO Mapping.PNG

    0_1525960329975_PRG_AI.PNG -> Rank 3/4 (placeholder for conversion from input to what I need)

    So this doesn't seem to work, any suggestions on putting the Unipi AI in the right mode (mA current, setAI21 and setAI22) AND on how to read the values (AI21 and AI22)

    Thank you.

  • Hi Oliver,

    I believe that the issue is how the inputs are encoded in the modbus registers.

    There is an admittedly cryptic explanation of how to read analog inputs from groups other than group 1 in the data sheet.
    Analog inputs for example are encoded as IEEE754 values in two registers for each input. The Function RegistersToReal can be used to convert the two register values to REALs.
    In a little more detail to read a single AI, map a channel to read two registers
    Map those two registers into a pair of words, I tend to use an array, which can be mapped like this
    or like this
    The code below shows how to convert the registers to a real.

    As far as setting the mode of the input, see the Neuron Technical Documentation, it states

    To set this value, create a channel like this 0_1525979240724_upload-b844b4af-96bc-40b8-9e0a-7bd217b8c62e and then map a word with the required value (Be careful that codesys doesn't optimise out the word in your application if it is just declared).

    I hope that gets you going - please ask again if you need more assistance.

  • Thx!! It works perfectly :)

    For those that would like to see the full code:

  • @OlivierP, what type of pH and EC sensors do you use? Would you recommend some?

    Thanks in advance!

Log in to reply