![]() |
Welcome to the AutomationDirect Customer Forums.
These
forums are intended as a place for AutomationDirect customers to help one another,
share information, and share ideas.
The forums are not routinely monitored by AutomationDirect
Technical Support staff. While staff members may answer questions occasionally,
for a prompt response to a problem please contact Technical Support directly
at: 1(800) 633-0405 or (770) 844-4200 or e-mail
Tech Support.
|
#1
|
|||
|
|||
|
Click PLC Encoded Switch Scanning
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. Last edited by dicklee88; 03-27-2009 at 11:05 AM. Reason: A better solution thanks to bcarlton: |
|
#2
|
|||
|
|||
|
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.
__________________
thePLCguy |
|
#3
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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. Last edited by Tubecut; 05-17-2009 at 05:50 PM. Reason: additional info |
![]() |
| Tags |
| bcd, click software, input scanner |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|