AutomationDirect Customer Forum  

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.


Go Back   AutomationDirect Customer Forum > Examples and Programs

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-26-2009, 05:51 PM
dicklee88 dicklee88 is offline
Registered User
 
Join Date: Mar 2009
Location: Sussex county, DE
Posts: 2
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.
Attached Files
File Type: pdf subscan1.pdf (35.7 KB, 253 views)

Last edited by dicklee88; 03-27-2009 at 11:05 AM. Reason: A better solution thanks to bcarlton:
Reply With Quote
  #2  
Old 03-27-2009, 01:40 AM
bcarlton bcarlton is offline
Registered User
 
Join Date: Dec 1999
Location: Yakima, WA
Posts: 1,597
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
Reply With Quote
  #3  
Old 03-27-2009, 10:56 AM
dicklee88 dicklee88 is offline
Registered User
 
Join Date: Mar 2009
Location: Sussex county, DE
Posts: 2
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.
Reply With Quote
  #4  
Old 03-31-2009, 01:40 PM
bcarlton bcarlton is offline
Registered User
 
Join Date: Dec 1999
Location: Yakima, WA
Posts: 1,597
Another possibility
Attached Files
File Type: pdf MatrixSwitch.pdf (33.6 KB, 208 views)
__________________
thePLCguy
Reply With Quote
  #5  
Old 05-17-2009, 05:43 PM
Tubecut Tubecut is offline
Registered User
 
Join Date: Jun 2003
Location: Georgiana, AL.
Posts: 239
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
Reply With Quote
Reply

Tags
bcd, click software, input scanner

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 06:02 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.