adccommunitymod (AutomationDirect) asked a question.

Click PLC Encoded Switch Scanning

Created Date: March 26,2009

Created By: dicklee88

**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****

I'm an old hand with procedural/object programming, but a noob with PLC ladder programming. I have a trivial process problem for managing my hot-water recirculation pump on "probable demand ". The basic logic requires two timers and about 5 rungs. Oh, and a motion detector in the bathroom. The problem I ran into was getting variable timer data into the Click CPU unit. I'm using two-digit BCD encoded switches for each of two timer durations. Physically, the switches are connected between Y001-004 and X001-004 with diodes for isolation. What I found was that it's not simple to turn the X inputs into DS binary values. I finally got around the data limitations by using the X inputs as enables to Math functions that loaded the bit values into DS1 - DS3, then later summed those bit values into another DS register. The two BCD digits are then converted to a binary value as DSa + 10*DSb. It was convenient to use a subroutine for the low-level Xn to BCD code conversion. The final version uses a shift register to generate an 11-phase clock to time the Y output scanning, reading the X inputs and converting to two binary values, triggering scans at a 1 second rate. The example program uses 18 rungs, and the subroutine uses 9 rungs. The printout is attached as a pdf file. Revision: replace the Calls to bcddigit with a Packed Copy from X1-X4 to DH1, and replace the first four Math blocks with a Copy from DH1 to DSn. Thanks to bcarlton for the suggestion.


  • adccommunitymod (AutomationDirect)

    Created Date: March 27,2009

    Created by: bcarlton

    Warning - I haven't tried this. In your BCDDIGIT subroutine you might want to investigate using the 'Pack Copy ' version of the Copy command. Source X1 thru X4, destination a single DS register. That may substitute for the whole subroutine plus the Math (DS1 + DS2 + DS3 + DS4) blocks in the main routine.

  • adccommunitymod (AutomationDirect)

    Created Date: March 27,2009

    Created by: dicklee88

    Copy from X to data register

    Thanks. You are correct. It seems that X bits must be copied to a DH register, and then to a DS register for use by a timer, but the use of copy is simpler and more direct than my subroutine.

    The Click software imposes some interesting limitations on how various bits and registers are allowed to interact, and I'm just getting used to this.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: March 31,2009

    Created by: bcarlton

    Another possibility

  • adccommunitymod (AutomationDirect)

    Created Date: May 17,2009

    Created by: Tubecut

    I just noticed that you are using the PLC to generate the scan and return for a key pad implementation( at least that is what I think you doing?). Recently I posted a drawing that used a CMOS key scan chip that can interface a 4X4 (16 key) keypad. It used two cap's to determine the scan time and debounce time. When a key press is detected, it will ouput 4 bits (0x00 0 0x0f) to indicate which key was pressed. It also would generate a interrupt signal to indicate a new key press. The outputs would require going through a buffer like the ULN2003 devices to handle the CMOS to PLC (24 VDC) levels. That would make the programming very simple to detect the key press. If this is what you are looking for send me email and I will look for the drawing I made and posted.

    This is a quick reply and I don't have the key decode device number right in front of me. Also, due to a recent install of the OS I lost many of those documents :-(

    I did find the PDF file I posted , I did a search for user name and keypad.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: March 26,2009

    Created by: dicklee88

    I'm an old hand with procedural/object programming, but a noob with PLC ladder programming. I have a trivial process problem for managing my hot-water recirculation pump on "probable demand ". The basic logic requires two timers and about 5 rungs. Oh, and a motion detector in the bathroom.

    The problem I ran into was getting variable timer data into the Click CPU unit. I'm using two-digit BCD encoded switches for each of two timer durations. Physically, the switches are connected between Y001-004 and X001-004 with diodes for isolation. What I found was that it's not simple to turn the X inputs into DS binary values.

    I finally got around the data limitations by using the X inputs as enables to Math functions that loaded the bit values into DS1 - DS3, then later summed those bit values into another DS register. The two BCD digits are then converted to a binary value as DSa + 10*DSb.

    It was convenient to use a subroutine for the low-level Xn to BCD code conversion.

    The final version uses a shift register to generate an 11-phase clock to time the Y output scanning, reading the X inputs and converting to two binary values, triggering scans at a 1 second rate. The example program uses 18 rungs, and the subroutine uses 9 rungs.

    The printout is attached as a pdf file.

    Revision: replace the Calls to bcddigit with a Packed Copy from X1-X4 to DH1, and replace the first four Math blocks with a Copy from DH1 to DSn.

    Thanks to bcarlton for the suggestion.

    Expand Post