Detailed Guide on Building a Complete AGV Control System with S7-1200
Search on WeChatTechnical Training
Introduction
This article introduces the implementation process of the Automated Guided Vehicle (AGV) control system, divided into hardware setup and software design.
(1) Onboard Controller1.1 Types of Onboard ControllersThe onboard controller is the core of the control system and the entire AGV. So, which controller should be chosen? Based on the author’s experience, the onboard controllers used in AGVs can be divided into the following three types from a hardware perspective:
1. PLC: Representative products include Siemens S7-1200 and 1500 series, used by AGV manufacturers like Jiashun and Jiateng. PLCs are known for their stability and reliability, but their strengths lie in logic control, typically limited to simple motion control. The price of Siemens PLC ranges from 2000 to 12000 yuan.2. Industrial Computer: Representative products include Beckhoff CX5130, used by manufacturers like Kunshan and Robert Wood. An industrial computer is essentially a computer designed to have strong anti-interference capabilities, suitable for harsh industrial environments such as vibration and electromagnetic radiation. Industrial computers are compact and can run general operating systems like Windows and Linux. For example, after installing Beckhoff’s TwinCAT control software, it inserts a real-time kernel into the Windows operating system, transforming the computer into a real-time control system suitable for industrial scenarios. The price of Beckhoff industrial computers ranges from 5000 to 30000 yuan.3. Microcontroller: Representative products include STM32, used by manufacturers like Haitong and Jike. Compared to the first two, microcontrollers are much cheaper, and the cost of peripheral devices is usually less than one thousand yuan. One drawback of using microcontrollers is that if you want to develop a mature product, you need to spend a lot of effort designing external circuits and various underlying algorithms. The software development environment may be less robust.The above classification does not mean that the three are completely distinct. For example, the core chip of a PLC may be a microcontroller; the programming languages for industrial computers may use ladder diagrams and ST language common in the PLC field; microcontrollers can also run operating systems, forming a complete controller. Thus, while each has its applicable field, they can also complement each other, evolving into a situation where each has elements of the others.Of course, there are now dedicated AGV controllers available on the market, such as the CVC600 from NDC in the USA, ANT from BlueBotics in Switzerland, MRC5000 from Zhejiang Kecong Intelligent, and SRC from Shanghai Xianzhi Robot. Compared to general industrial motion controllers or PLCs, these controllers integrate mature navigation and motion control algorithms, saving users a lot of work, and their stability and protection levels are higher, but they are also more expensive (20,000 to 60,000 yuan).
1.1 Siemens S7-1200 PLCI chose Siemens S7-1215C PLC as the onboard controller for the AGV (hereinafter referred to as S1200), as shown in the figure below. Since Siemens has a wide variety of product models, each with slight differences in interface types and performance, it is best to use the order number to accurately describe which model is being purchased. Siemens products have a unique order number for each item, and you only need to provide this number during procurement. You can also find the corresponding model in Siemens’ programming software by the order number. Of course, there are some disadvantages to using Siemens products, such as the fact that its PLC is a general product not specifically designed for vehicle control. For the price of an ARM development board costing only 100 yuan on Taobao, Siemens products require a high price for similar interfaces like RS485, CAN, and Ethernet, and the openness of Siemens products is quite poor. Therefore, future AGVs will gradually phase out Siemens products.
What are the Host and Slave Devices?Some devices can access other devices, such as reading data from memory or writing data to memory, these devices have higher permissions and status, hence they are called host devices. Some devices can only be accessed by other devices and do not have the authority to access other devices, these are called slave devices. In this article, the PLC is the slave device, while the programming computer is its host device.To configure or program the PLC, you need to connect the S1200 to the host computer using a network cable, simply set the host computer’s IP address to be in the same subnet as the PLC. The default IP address for the S1200 is generally 192.168.0.1, so you can set your computer’s IP to 192.168.0.2. For mobile devices like AGVs, wireless communication is typically used, such as receiving control commands from the scheduling system. Wireless communication methods include WIFI, ZigBee, etc. Since WIFI is commonly used in practice, I will introduce its configuration method. Connecting to Siemens PLC via WIFI is very convenient; just connect the PLC’s Ethernet port to the LAN port of a wireless router with a network cable, then use a laptop to search for the corresponding WIFI and connect to access the PLC. The wireless router can be any brand, even a home router. (The author once bought a domestic Ethernet to WIFI converter on Taobao, but strangely it did not support the TIA Portal software (the software could not access the PLC), so it is better to confirm with the seller before purchasing if it can be used with TIA Portal. If you want to pursue more stable and reliable communication, you can choose industrial-grade communication modules, such as Moxa (MOXA), which are compatible with a power supply voltage of 12V~48V.)
(2) DriverIf the onboard controller is the AGV’s brain, then the AGV also needs a heart and muscles to move, and the driver provides current to the motors of the wheels, akin to a heart.2.1 Low Voltage Driver BrandsSince AGVs generally use batteries for power supply, their voltage is usually around 12V~72V. Therefore, the drivers used in AGVs are classified as low-voltage DC servo drivers. Foreign low-voltage driver brands include: AMC, RoboteQ, ZAPI, Curtis, Elmo, etc. Domestic low-voltage driver brands include: Buke, Senchuang, Yingboer, Kelly.2.2 PLC Communication with DriversFor the PLC to control the driver, it must send command data to it. Low-end drivers can transmit data using analog signals or pulse signals, while high-end drivers use standardized communication protocols to transmit data, which can be achieved through RS-232, RS-485, CAN, EtherCAT, and other protocols. Since the CPU module of the S1200 does not have these communication interfaces, to connect to the driver, you need to purchase additional communication modules (CM: Communication Module). Siemens has corresponding communication module support for several of the mentioned protocols, such as Siemens’ 232, 485, and CANopen communication modules as shown in the figure below (these three modules are identical in shape), note that the 232 and CANopen modules have male connectors, while the 485 has a female connector.
For mobile devices, CAN bus is the most commonly used communication method; vehicles, excavators, and AGVs generally use CAN bus communication. The CAN bus is fast (up to 1Mb/s, faster than 485), stable (uses differential signals, resistant to interference), and more intelligent (has priority and arbitration mechanisms), so CAN bus should be prioritized. However, considering that Siemens itself does not have a CAN communication module (if you want to use CAN, you need to purchase a CANopen module from a third-party company like HMS), this article uses drivers that adopt the 485 protocol, so we choose the 485 module.One subsequent question is: How many communication modules can the S1200 expand? The answer is: 3. Regardless of the type of communication module, a maximum of 3 can be used, and the types can be mixed. If your driver is bus-type (both 485 and CAN are bus types), then only one 485 module or CANopen module is needed. Note that 232 is not bus-type, so if two drivers are used, two communication modules must be added. If your AGV has other sensors using different communication protocols (such as magnetic navigation sensors, RFID sensors), then 3 communication modules may become insufficient.
The Siemens 485 module uses a standard 9-pin D-sub connector. To connect the driver and PLC, we need to purchase a DB9 connector and connect the two ends with signal wires. Here we only need to use two signal wires. It is worth noting that Siemens’ 485 interface definition is different from conventional 485; in conventional 485, the signal transmission is on pins 1 and 2, while in Siemens’ 485, it is on pins 3 and 8 (refer to page 1769 of the manual). Therefore, when wiring, you should solder according to the corresponding order of 3-2 and 8-1, as shown in the figure below.
(3) Mobile MechanismFor the AGV to achieve transportation and transfer, it must have a mobile mechanism. Commonly used mobile mechanisms include steering wheels, differential wheels, and Mecanum wheels. What are the characteristics of each, and in what scenarios should each type of wheel be used?The advantage of Mecanum wheels is high motion precision, but they have a complex structure, severe wear, and are picky about the ground surface. Although Mecanum wheels have been around for over 30 years, their actual application is not widespread, indicating that they are not practical products. Below we mainly discuss steering wheels.Steering wheels are highly integrated mobile mechanisms composed of wheels, rotary supports, gearboxes, drive motors, steering motors, encoders, limit switches, and brakes. They can provide traction and actively steer, thus a steering wheel has two degrees of freedom. An AGV can achieve omnidirectional movement with one or more steering wheels: rotating in place, moving diagonally, lateral movement, etc. Steering wheels are generally used in indoor environments, so the wheel surface material is mostly polyurethane. Depending on the position of the motor installation, steering wheels can be divided into two types: horizontal and vertical, as shown in the following two figures. Horizontal steering wheels have the drive motor mounted horizontally, making the overall height very low. Some AGVs have height requirements (for example, a low-profile AGV needs to be very short to fit under cargo), so horizontal steering wheels are suitable in this case; vertical steering wheels have the drive motor mounted vertically, resulting in a higher overall height. Their advantage is that they allow for isolation of the motor, which is suitable in some scenarios (e.g., hazardous material factories) where the steering wheel motor must be isolated from the external environment. Major steering wheel manufacturers abroad include CFR from Italy and Schabmuller from Germany, later a manufacturer called Maluda was spun off from CFR. These steering wheel manufacturers generally only sell steering wheels and do not provide drivers, which are supplied by agents. The most expensive component on an AGV is the steering wheel; for an AGV costing around 100,000 yuan, equipping two steering wheels would require 40,000 to 50,000 yuan, accounting for nearly half of the total cost. However, the good news is that domestic steering wheel manufacturers are starting to compete, which will lower AGV costs.
(4) Magnetic Navigation Sensors and Magnetic Strips4.1 Magnetic StripsMagnetic strip navigation is one of the most commonly used navigation methods for AGVs. Simply lay down magnetic strips on the ground in advance, and the AGV will move along the path formed by the magnetic strips. Magnetic strips are generally 3-5 cm wide, resembling tape, with one smooth side and one sticky side, allowing for easy installation by adhering the sticky side to the ground. Magnetic strips have polarity, so be mindful of whether you purchase N-pole or S-pole, as the polarity of the magnetic strip corresponds to the polarity of the magnetic navigation sensor, although some sensors are compatible with both polarities. Magnetic strips are relatively soft and not pressure-resistant, so repeated compression by wheels may flatten or dislodge them. Most AGVs arrange their drive wheels on the sides of the vehicle (differential type) or in a diagonal symmetrical position to avoid damaging the magnetic strips.
4.2 Magnetic Navigation
Magnetic navigation sensors, also known as magnetic tracking sensors, help AGVs follow the line. Magnetic navigation sensors are typically installed on the AGV body or the drive wheel assembly, maintaining a certain height above the magnetic strip while the AGV is in motion. The installation position of the magnetic navigation sensor is generally along the symmetrical central axis of the vehicle, usually installed symmetrically, such as one at the front and one at the back or one on each side. The principle of magnetic navigation sensors is simple; the sensor has several probes, each capable of detecting the magnetic field. Probes located above the magnetic strip (within a certain height) output signals, while those outside the magnetic strip do not. The probes are commonly referred to as “points”; the more points, the higher the sensor’s resolution, and naturally, the price is higher. Common point counts for sensors include: 6-point, 8-point, and 16-point options. Magnetic navigation sensors are not mysterious devices; the author once disassembled a magnetic navigation sensor, and the probes mentioned are simply of two types: Hall elements and geomagnetic sensors. Hall elements can sense magnetic fields, are inexpensive but usually have low precision; geomagnetic sensors typically use products from the American company PNI.They must be paired with a dedicated driver chip PNI-12927, which is powered by 3.3V, hence the sensor must be designed with a 3.3V voltage regulation circuit. Additionally, this driver chip uses the SPI bus, requiring signal processing and voltage conversion, which is typically handled by a microcontroller. The output signal of the magnetic navigation sensor can be either digital or bus-type data; for sensors with more points, bus-type is generally used, as using digital signals would require many wires. For instance, if an AGV uses 4 sensors, each with 16-point resolution, that would require 4×16=64 outputs, necessitating the PLC to have 64 digital input ports, making wiring very cumbersome and prone to faults (e.g., a loose connection).Magnetic navigation is simple to implement and inexpensive, but it also has many drawbacks, one serious issue being interference. The author discovered during AGV debugging that even when the sensor is not above the magnetic strip (sometimes even when there are no magnetic strips nearby), the sensor still outputs signals. After some thought, the author identified the issue. There was a railway track in front of the AGV, and iron can easily be magnetized. Not only iron products, but also energized wires can cause false positives for the sensor. Therefore, using magnetic strip navigation requires eliminating these interferences.The output of the magnetic navigation sensor can be either IO or numerical (representing the distance from the sensor to the center of the magnetic strip). How do we connect the magnetic navigation sensor to the PLC? As mentioned, if the sensor transmits data via a bus (e.g., 485), simply connect the bus to the corresponding (485) communication module. If the sensor uses a digital interface, it must connect to the digital input ports of the PLC. Here’s a very important question: you need to be clear whether the sensor output signal is PNP or NPN type, which corresponds to the type of transistor. The difference is that when there is a signal, PNP outputs a high level (e.g., 24V), while NPN outputs a low level (e.g., 0V). On the S1200, there is a COM port next to each input-output port, which serves to select whether the input is PNP or NPN type. If it is PNP type, the COM port should be connected to 24V; if it is NPN type, it should be connected to 0V. You can test a magnetic strip with a multimeter; if it shows 24V when placed on the magnetic strip, it indicates it is PNP type. You will find that many sensors are divided into PNP and NPN types, and their connections are the same.
(5) Power Supply System5.1 BatteriesAGVs require a large current at startup, so they need to use power batteries. The most commonly used power batteries are lead-acid and lithium batteries. Lead-acid batteries have a short lifespan and low energy density, while lithium batteries have high density but also high costs. There is also a type of battery called supercapacitors, which have a long lifespan but very low energy density, so they are not widely used.Renowned battery manufacturers include Hawker and Hoppecke. The following figure shows the label of a Hawker AGV-specific battery. The rated discharge current of lead-acid batteries is generally 0.5C; for example, an 80Ah battery has a rated discharge current of 0.5×80=40A. The maximum discharge current of lead-acid batteries is generally 3C, which equals 3×80=240A. The battery voltage gradually decreases as the charge is consumed, initially decreasing slowly, then sharply when very little charge remains. Based on this relationship, by detecting the voltage, one can infer how much charge is left in the battery and whether it needs recharging.How do we estimate the required battery capacity for an AGV?The most power-hungry component on an AGV is the motor. Generally, the rated power P of the motor will be indicated on its nameplate. According to basic physics, power equals voltage multiplied by current, that is: P=UIDriving motor rated voltage is generally easy to obtain, so current can be calculated using the above formula. Of course, the actual working power is usually less than the rated power, so a coefficient must be multiplied, depending on the AGV’s load, working surface, etc. The current multiplied by the working time gives the battery capacity. Note that battery capacity and energy are two different concepts; the former is current multiplied by time (measured in ampere-hours (Ah)), while the latter is current multiplied by voltage multiplied by time (measured in kilowatt-hours (KWh)).5.2 Voltage ConversionIf the output voltage of the battery is different from that of the sensors, controllers, and other devices, a voltage conversion module is needed, which can also serve to stabilize the voltage. Commonly used voltages for sensors are 12V, while controllers typically use 24V, so corresponding modules are necessary. You can choose voltage conversion modules from Guangzhou Jinsenyang, which can be equipped with heat sinks and rails for better cooling and fixing, as shown in the figure below for a 48V to 24V module. When selecting a module, the primary concern is the power, i.e., the maximum current it can provide.
(6) Switches6.1 Power SwitchWhen selecting the main power switch, pay attention to whether it is