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
    0_1525978199216_aichannel.PNG
    Map those two registers into a pair of words, I tend to use an array, which can be mapped like this
    0_1525978542292_mapping1.PNG
    or like this
    0_1525978629982_mapping2.PNG
    The code below shows how to convert the registers to a real.
    0_1525978740234_upload-91132416-afa0-4ea2-9482-ef356d3ee605

    As far as setting the mode of the input, see the Neuron Technical Documentation, it states
    0_1525979116199_upload-15badc7f-8787-4eab-9a3c-5ebe12881b2b

    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:
    0_1526107556284_AIR_new.PNG



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

    Thanks in advance!