Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use StamPLC: Examples, Pinouts, and Specs

Image of StamPLCDesign with StamPLC in Cirkit Designer

Introduction

The StamPLC, manufactured by M5Stack, is a compact and versatile programmable logic controller (PLC) designed for industrial automation. It is capable of controlling machinery, processes, and systems through programmable instructions, making it an essential component for modern industrial applications. The StamPLC is designed to be user-friendly, reliable, and highly customizable, catering to a wide range of automation needs.

Explore Projects Built with StamPLC

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of PLC-Controlled Power Window System with Infrared Sensing and Relay Module: A project utilizing StamPLC in a practical application
PLC-Controlled Power Window System with Infrared Sensing and Relay Module

This circuit is designed to control a motorized window system using a PLC (Programmable Logic Controller) and an array of sensors and switches. It includes power supplies for 12V and 24V DC, an MCB (Miniature Circuit Breaker) for protection, and a relay module interfaced with an Arduino for additional control logic. The PLC manages inputs from pushbuttons, a 3-position switch, infrared proximity sensors, and an emergency stop, and it controls outputs such as the motor speed controller, lamps, and solenoid valves.

Open Project in Cirkit Designer

Common Applications and Use Cases

Technical Specifications

The StamPLC is built to handle demanding industrial environments while maintaining ease of use. Below are its key technical specifications:

General Specifications

Parameter Value
Manufacturer M5Stack
Operating Voltage 5V DC
Input Voltage Range 5V to 24V DC
Digital Inputs 8 channels
Digital Outputs 8 channels (relay-driven)
Communication Protocols RS485, Modbus RTU, UART, I2C
CPU ESP32 (dual-core, 240 MHz)
Memory 16 MB Flash, 520 KB SRAM
Operating Temperature -20°C to 70°C
Dimensions 90mm x 60mm x 25mm

Pin Configuration and Descriptions

The StamPLC features a well-labeled pinout for easy integration into circuits. Below is the pin configuration:

Input Pins

Pin Number Label Description
1 IN1 Digital Input 1
2 IN2 Digital Input 2
3 IN3 Digital Input 3
4 IN4 Digital Input 4
5 IN5 Digital Input 5
6 IN6 Digital Input 6
7 IN7 Digital Input 7
8 IN8 Digital Input 8

Output Pins

Pin Number Label Description
9 OUT1 Digital Output 1 (Relay)
10 OUT2 Digital Output 2 (Relay)
11 OUT3 Digital Output 3 (Relay)
12 OUT4 Digital Output 4 (Relay)
13 OUT5 Digital Output 5 (Relay)
14 OUT6 Digital Output 6 (Relay)
15 OUT7 Digital Output 7 (Relay)
16 OUT8 Digital Output 8 (Relay)

Communication Pins

Pin Number Label Description
17 TX UART Transmit
18 RX UART Receive
19 RS485+ RS485 Positive Line
20 RS485- RS485 Negative Line
21 I2C_SCL I2C Clock Line
22 I2C_SDA I2C Data Line

Usage Instructions

The StamPLC is designed for ease of use in industrial automation projects. Follow the steps below to integrate and program the StamPLC in your system.

Step 1: Powering the StamPLC

Step 2: Connecting Inputs and Outputs

Step 3: Programming the StamPLC

The StamPLC is based on the ESP32 microcontroller, allowing it to be programmed using the Arduino IDE or other ESP32-compatible platforms. Below is an example of how to control an output pin based on an input pin using the Arduino IDE:

// Include necessary libraries for ESP32
#include <Arduino.h>

// Define input and output pins
#define INPUT_PIN 1  // Digital Input 1
#define OUTPUT_PIN 9 // Digital Output 1 (Relay)

// Setup function to initialize pins
void setup() {
  pinMode(INPUT_PIN, INPUT);  // Set INPUT_PIN as input
  pinMode(OUTPUT_PIN, OUTPUT); // Set OUTPUT_PIN as output
  digitalWrite(OUTPUT_PIN, LOW); // Ensure output is initially off
}

// Main loop function
void loop() {
  int inputState = digitalRead(INPUT_PIN); // Read the state of the input pin

  if (inputState == HIGH) {
    // If input is HIGH, turn on the output
    digitalWrite(OUTPUT_PIN, HIGH);
  } else {
    // If input is LOW, turn off the output
    digitalWrite(OUTPUT_PIN, LOW);
  }

  delay(100); // Add a small delay for stability
}

Step 4: Communication Setup

Best Practices

Troubleshooting and FAQs

Common Issues and Solutions

  1. StamPLC does not power on:

    • Verify that the power supply voltage is within the 5V to 24V range.
    • Check for loose or disconnected power cables.
  2. Inputs are not being detected:

    • Ensure the input devices are properly connected to the input pins.
    • Check the input voltage levels to ensure they meet the StamPLC's requirements.
  3. Outputs are not functioning:

    • Verify that the output devices are correctly connected to the output pins.
    • Check the relay ratings to ensure they are not overloaded.
  4. Communication issues with RS485 or I2C:

    • Double-check the wiring and ensure proper termination for RS485 networks.
    • Verify the I2C address and clock speed settings in your code.

FAQs

Q: Can the StamPLC be programmed wirelessly?
A: Yes, the StamPLC's ESP32 microcontroller supports Wi-Fi and Bluetooth, allowing for wireless programming and communication.

Q: What is the maximum current rating for the output relays?
A: Each output relay can handle up to 2A at 30V DC or 0.5A at 125V AC.

Q: Is the StamPLC compatible with Arduino libraries?
A: Yes, the StamPLC is based on the ESP32 and is fully compatible with Arduino libraries and the Arduino IDE.

Q: Can I use the StamPLC for analog inputs?
A: The StamPLC is designed for digital inputs and outputs. For analog input functionality, an external ADC module can be used with the I2C interface.