element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino Projects
  • Products
  • Arduino
  • Arduino Projects
  • More
  • Cancel
Arduino Projects
Blog Automatic cat door with Arduino interface and PLC
  • Blog
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino Projects to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Steve524
  • Date Created: 23 May 2024 1:09 PM Date Created
  • Views 2301 views
  • Likes 3 likes
  • Comments 2 comments
  • plc
  • arduino_projects
  • stepper
  • arduino
  • motor and motion control
Related
Recommended

Automatic cat door with Arduino interface and PLC

Steve524
Steve524
23 May 2024
Automatic cat door with Arduino interface and PLC

This project is not entirely Arduino, but I think it is a good example of how Arduino's can be incorporated into other systems. The initial design of this project was to automatically open and close the cat door and track the cat's activity also control when the cat can go in or out. The PLC was chosen for the main I/O and stepper motor controls because of its robustness and the Arduino was chosen for the cat counting activity process. The system features three main modes of operation which is 1 - manual up down, 2 - automatic up down, 3 - in only. The up and down operations can be controlled by a pendant station or RF remote and IP website controls. For the stepper motor and linear rail safety for the cat there is a proximity sensor in the cat door to detect anything in the door and stopping operations also the linkage from the linear rail to the door has been designed so if anything closes onto a cat or anything else in the door will not shut. There are four sensors on the door, two low sensors (inside/outside) to detect the cat and two high sensors (inside/outside) to detect humans and prevent the cat door from opening necessarily. The Arduino cat counting is basically for detection if the cat is currently outside or inside by reading even or odd numbers there will be more updates to this system in the future.

I have included all the documentation at the bottom for your reference.

image

image

image

image

image

image

image

image

image

image

image

imagePDF

Fullscreen cat_counter_working_single_count_LED_serial_arduino_v1.txt Download
#include <SoftwareSerial.h>
SoftwareSerial SoftSerial (0, 13);

                                      // BCD 1
int a1 = 4;   //Bit 0 Decoder 1
int a2 = 5;   //Bit 1 Decoder 1
int a3 = 6;   //Bit 2 Decoder 1
int a4 = 7;   //Bit 3 Decoder 1

                                      // BCD 2
int b1 = 8;   //Bit 0 Decoder 2
int b2 = 9;   //Bit 1 Decoder 2
int b3 = 10;  //Bit 2 Decoder 2
int b4 = 11;  //Bit 3 Decoder 2

int n = 0;                            // Setting initial value of n to 0
int d1;
int d2;
int button = 2;
int state = 0;
int count_value = 0;
int prestate = 0;
int buttonRst = 3;
int buttonState1 = 0;                 // variable for reading the pushbutton reset status
int SMdataIN = 0;                     // Serial monitor data input
int SScount;

void setup()
{
Serial.begin(9600);
SoftSerial.begin(9600);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
attachInterrupt(2,button,RISING);      // PIR output
attachInterrupt(3,buttonRst,RISING);   // Reset button
}

void loop()
  {
    Serial.print("state");             // Serial.print stuff
    Serial.print(" ");
    Serial.print(state);
    Serial.print(" ");
    Serial.print("Count");
    Serial.print(" ");
    Serial.print(n);
    Serial.print(" ");
    Serial.print("SS");
    Serial.print(" ");
    Serial.print(n);                    // Count
    Serial.print(" ");   
    Serial.print("SM data: ");          // SM Recived data
    Serial.println(SMdataIN);
    
                                        //SoftSerial.write(SMdataIN);
    {
    SoftSerial.write("CNT");
    SoftSerial.print(n);
    }                                     
 if (Serial.available() > 0)            // send data only when you receive data:
  {    
   SMdataIN = Serial.read();            // read the incoming byte:
  }
     
 state = digitalRead(button);           // read the state of the pushbutton value
 
 if(state == HIGH && prestate == 0)     // check if the pushbutton is pressed. If it is, then the buttonState is HIGH
  {
  n++;                                  // Count value
  prestate = 1;
  } 
  else if(state == LOW) 
  {
  prestate = 0;
  }         
                                         
 if(state == HIGH)                      // LED on while counting
 {
 digitalWrite(12, HIGH);
 } 
 if(state == LOW)
 {
 digitalWrite(12, LOW); 
 }                                        
  
 if(n == 100)                           // Reset at 100 to 0 
 {
   n = 0;
 }
 
 buttonState1 = digitalRead(buttonRst); // Reset to 0 if button is pressed
 if (buttonState1 == HIGH)
 {
   n = 0;
 }

 // _____________________________________  BCD conversion and output to pins
 
 d1=n%10;                               // This will divide n by 10 and the remainder will be stored in d1
 d2=n/10;                               // This will divide n by 10 and the value before decimal will be stored in d2
 disp1(d1);
 disp2(d2);
 delay(100);                            // 100 ms delay to debounce
}
void disp1(int num)          // Display 1
{
  if(num == 0)               // 0000
  {
    digitalWrite(a1, LOW);   // 0 
    digitalWrite(a2, LOW);   // 0
    digitalWrite(a3, LOW);   // 0
    digitalWrite(a4, LOW);   // 0
  }
  if(num == 1)               // 0001
  {
    digitalWrite(a1, HIGH);  // 1
    digitalWrite(a2, LOW);   // 0
    digitalWrite(a3, LOW);   // 0
    digitalWrite(a4, LOW);   // 0
  }
  if(num == 2)               // 0010
  {
    digitalWrite(a1, LOW);   //0
    digitalWrite(a2, HIGH);  //1
    digitalWrite(a3, LOW);   //0
    digitalWrite(a4, LOW);   //0
  }
  if(num == 3)               // 0011
  {
    digitalWrite(a1, HIGH);  //1
    digitalWrite(a2, HIGH);  //1
    digitalWrite(a3, LOW);   //0
    digitalWrite(a4, LOW);   //0
  }
  if(num == 4)               // 0100
  {
    digitalWrite(a1, LOW);   //0
    digitalWrite(a2, LOW);   //0
    digitalWrite(a3, HIGH);  //1
    digitalWrite(a4, LOW);   //0
  }
  if(num == 5)               // 0101
  {
    digitalWrite(a1, HIGH);  //1
    digitalWrite(a2, LOW) ;  //0
    digitalWrite(a3, HIGH);  //1
    digitalWrite(a4, LOW) ;  //0
  }
  if(num == 6)               // 0110
  {
    digitalWrite(a1, LOW);   //0
    digitalWrite(a2, HIGH);  //1
    digitalWrite(a3, HIGH);  //1
    digitalWrite(a4, LOW) ;  //0
  }
  if(num == 7)               // 0111
  {
    digitalWrite(a1, HIGH);  //1
    digitalWrite(a2, HIGH);  //1
    digitalWrite(a3, HIGH);  //1
    digitalWrite(a4, LOW) ;  //0
  }
  if(num == 8)               // 1000
  {
    digitalWrite(a1, LOW);   //0
    digitalWrite(a2, LOW);   //0
    digitalWrite(a3, LOW);   //0
    digitalWrite(a4, HIGH);  //1
  }
  if(num == 9)               // 1001
  {
    digitalWrite(a1, HIGH);  //1
    digitalWrite(a2, LOW);   //0
    digitalWrite(a3, LOW);   //0
    digitalWrite(a4, HIGH);  //1
  }
}

void disp2(int num)          // Display 2
{
  if(num == 0)               // 0000
  {
    digitalWrite(b1, LOW);   //0
    digitalWrite(b2, LOW);   //0
    digitalWrite(b3, LOW);   //0
    digitalWrite(b4, LOW);   //0
  }
  if(num == 1)               // 0001
  {
    digitalWrite(b1, HIGH);  //1
    digitalWrite(b2, LOW);   //0
    digitalWrite(b3, LOW);   //0
    digitalWrite(b4, LOW);   //0
  }
  if(num == 2)               // 0010
  {
    digitalWrite(b1, LOW);   //0
    digitalWrite(b2, HIGH);  //1
    digitalWrite(b3, LOW);   //0
    digitalWrite(b4, LOW);   //0
  }
  if(num == 3)               // 0011
  {
    digitalWrite(b1, HIGH);  //1
    digitalWrite(b2, HIGH);  //1
    digitalWrite(b3, LOW);   //0
    digitalWrite(b4, LOW);   //0
  }
  if(num == 4)               // 0100
  {
    digitalWrite(b1, LOW);   //0
    digitalWrite(b2, LOW);   //0
    digitalWrite(b3, HIGH);  //1
    digitalWrite(b4, LOW);   //0
  }
  if(num == 5)               // 0101
  {
    digitalWrite(b1, HIGH);  //1
    digitalWrite(b2, LOW) ;  //0
    digitalWrite(b3, HIGH);  //1
    digitalWrite(b4, LOW);   //0
  }
  if(num == 6)               // 0110
  {
    digitalWrite(b1, LOW);   //0
    digitalWrite(b2, HIGH);  //1
    digitalWrite(b3, HIGH);  //1
    digitalWrite(b4, LOW);   //0
  }
  if(num == 7)               // 0111
  {
    digitalWrite(b1, HIGH);  //1
    digitalWrite(b2, HIGH);  //1
    digitalWrite(b3, HIGH);  //1
    digitalWrite(b4, LOW);   //0
  }
  if(num == 8)               // 1000
  {
    digitalWrite(b1, LOW);   //0
    digitalWrite(b2, LOW);   //0
    digitalWrite(b3, LOW);   //0
    digitalWrite(b4, HIGH);  //1
  }
  if(num == 9)               // 1001
  {
    digitalWrite(b1, HIGH);  //1
    digitalWrite(b2, LOW);   //0
    digitalWrite(b3, LOW);   //0
    digitalWrite(b4, HIGH);  //1
  }
}

imagePDF

imagePDF

Fullscreen IO_List.txt Download
INPUTS		D2-16ND3-2		Slot 0									
													
PLC Card	Wire#	Ref	Function	Part Type	Connection								
CA	W10100	-24V	Comm		CA								
0	W10101	MPB-1	Run/Stop	PENDENT E-Stop SW	12								
1	W10102	SS1-2	Mode Auto 1	PENDENT 3 Pos SW	14								
2	W10103	SS1-3	Mode Auto 2	PENDENT 3 Pos SW	24								
3	W10104	PB1	UP PB-Green	PENDENT PB	24								
4	W10105	PB2	DN PB-Red	PENDENT PB	24								
5	W10106	RF/IP	UP	DASH LILGO/RF REMOTE	K1-NO/A1-NO								
6	W10107	RF/IP	DN	DASH LILGO/RF REMOTE	K2-NO/A2-NO								
7	W10108	LSW1	UP Limit	MICRO SW	NC								
CB	W10200	-24V	Comm		CB								
0	W10201	LSW2	DN Limit	MICRO SW	NC								
1	W10202	PX1	Cat In Door	Taiss M18 Prox	BK								
2	W10203	POD-1	Cat Inside	AM312 PIR	K-1-C								
3	W10204	POD-2	Cat Outside	AM312 PIR	K-2-C								
4	W10205	POD-3	Human Inside	AM312 PIR	K-3-C								
5	W10206	POD-4	Human Ouside	AM312 PIR	K-4-C								
6	W10207	MRSW-1	Door open	MRSW	NC								
7	W10208	PCD1	Light Level	Photo Cell	17								
													
OUTPUTS		D2-08TR		Slot1									
													
Card	Wire#	Ref	Function	Part Type	Connection								
0	W10301	SMC01	Stop	ZK-SMC01_Controller	0								
1	W10302	SMC01	REV-UP-CCW	ZK-SMC01_Controller	1								
2	W10303	SMC01	FOR-DN-CW	ZK-SMC01_Controller	2								
3													
4													
5													
6													
7													
C		SMC01	COMM	ZK-SMC01_Controller	BLACK								
													
OUTPUTS		D2-08TR		Slot2									
													
Card	Wire#	Ref	Function	Part Type	Connection								
0	W10505	ENA+	Enable	SMD1	Screw 2								
1													
2													
3													
4													
5													
6													
7													
C													
													
ZK-SMC01 DIP Settings			RF Remote Control Jumper Settings										
													
SW1	On	4.9A	PIN 1	PIN 2	PIN 3								
SW2	Off	4.9A											
SW3	Off	4.9A	No Jumpers	No Jumpers	No Jumpers								
SW4	Off	1/2 Curr											
SW5	On	800											
SW6	Off	800											
SW7	On	800											
SW8	On	800											
													
													
													
PART LIST													
													
No	Ref	MFG	Model No	Part Type	Cost								
	MPB-1	TWTADE	hz-11ZS-20X-GR	PENDENT E-Stop SW	$26.98 								
	SS1	TWTADE	hz-11ZS-20X-GR	PENDENT 3 Pos SW									
	PB1	TWTADE	hz-11ZS-20X-GR	PENDENT PB									
	PB2	TWTADE	hz-11ZS-20X-GR	PENDENT PB									
	RF	Unknown	Unknown	RF REMOTE									
	RF	Unknown	Unknown	RF REMOTE									
	IP	DASH LILGO	T-Relay ESP32	IP REMOTE									
	IP	DASH LILGO	T-Relay ESP32	IP REMOTE									
	LSW1	WWZMDiB	V-156-1C25	MICRO SW									
	LSW2	WWZMDiB	V-156-1C25	MICRO SW									
	PX1	Taiss	E3F-DS30P1	Proximity SW									
	MRSW-1	Unknown	Unknown	MAGNETIC REED SW									
	PHO												
	TB#	GUETNEU		Terminal Block									
													
													
													
													
	POD-1	PCE	AM312	PIR Ampifler									
	POD-2	PCE	AM312	PIR Ampifler									
	POD-3	PCE	AM312	PIR Ampifler									
	POD-4	PCE	AM312	PIR Ampifler									
	PS	Koyo	D2-04B	PLC Card									
	CPU	Koyo	D2-230 CPU	PLC Card									
	Input	Koyo	D2-16ND3-2	PLC Card									
	Output	Koyo	D2-08TR	PLC Card									
			ZM-SMC01	Stepper Cotroller									
			DM556	Stepper Motor Driver									
	PS1	Sola	SDN 2.5-24-100P	24VDC Power Supply									
	PS2	PCE	LM7812c	24V to 12V Power Supply									

  • Sign in to reply

Top Comments

  • DAB
    DAB over 1 year ago +1
    We once had a dog door that the cat would use. One day I yelled at the cat to go out and catch a mouse. The cat went out and returned with a live mouse in its mouth and proceeded to play with it inside…
  • rscasny
    rscasny over 1 year ago in reply to DAB

    I bet you don't have any mice around your place!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 1 year ago

    We once had a dog door that the cat would use.

    One day I yelled at the cat to go out and catch a mouse.

    The cat went out and returned with a live mouse in its mouth and proceeded to play with it inside the house.

    I never challenged that cat again.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube