Reading analog inputs / network variables.

john
2011-09-27
2011-10-04
  • john - 2011-09-27

    Hi
    I am a new user of the codesys, and i have 2 questions that i could not fint the answer for in the manual.

    1: How do i read a analog input and use it in my code?
    I have defined it in the input section and given it the variable name HWtemp.
    I just cant find anywhere to read it like a digital input switch.

    2: I will be using several PLC connected on a TCP/IP network.
    How can i read a global variable in one PLC from another PLC or HMI Display?

    I am using:
    ABB AC500 PLC's
    PS501 V. 2.1.0 (Control builder)
    Codesys V 2.3.9.28 (LD programming)

    John Jensen
    Rio de Janeiro

     
  • Rolf-Geisler - 2011-09-29

    Hi John,
    can't answer all your questions, but I can give a hint ref the analogue input.

    Normally analogue inputs get a signal -10 .. +10 V or 0(4) .. 20 mA. This is digitized by an analogue to digital converter just behind the terminals. The conversion result can be read by the PLC.
    Format of analogue signals at PLC depends on the used hardware. It may be of INT or of WORD type.

    To use an analogue signal in your PLC program, you have
    1. to read the input signal, as described above. For that, you have to declare an input variable (e.g. resp. . * is a placekeeper for the real address)
    2. to convert the value into a physical meaning by a "scaling procedure".
    http://www.geisler-controls.de, which has particularly for step 2. Unfortunately, documentation is in German, but maybe the code helps you to understand how to do the job.

    Can't tell anything about the 2nd question. Did not yet work with PLCs in a network .

    Have success
    Rolf

     
  • spfeif - 2011-10-04

    What is the analog value? In other words do you have a switch connected to an analog input but you want to use as digital?

    Assuming the analog value requires no filtering and you have a 10bit analog = 1024 then

    xstate := FALSE;
    (* With debounce added DebounceOn = TON*)
    DebounceOn(IN := (HWtemp > 512), PT := T#20ms);
    If (DebounceOn.Q = TRUE) then
    Β  Β  xstate = TRUE;
    end_if
    

    Your digital input is xstate.

    If it is a true analog input that varies sporadically then filter it.

     

Log in to post a comment.