Share this

CAN bus-based robotic arm control system

2026-04-06 04:29:42 · · #1
Abstract: Open-structure robot control systems based on fieldbus are the current development direction of robot control. This article introduces a material handling robot device and its control system, proposes a robot control system scheme based on CAN bus, analyzes the structural composition of the control system, and provides a detailed discussion of the development of CAN bus control system software using VC++6.0 on the Windows 98 platform. Keywords: CAN bus, robot, open-structure control, VC++6.0 1 Introduction Robots can grasp and place objects in space, with flexible and diverse movements, suitable for medium and small batch automated production with variable product types, and widely used in flexible automated lines. The material handling robot we developed for heat treatment quenching is an automated device that sorts, transports, and quenches workpieces according to a pre-set program. It can partially replace manual labor in monotonous and prolonged work in high-temperature and hazardous work areas, and can change relevant control parameters at any time according to changes in the workpiece and the requirements of the quenching process. Since most commercial industrial robots (or manipulators) currently use a closed-structure dedicated control system, they generally use a dedicated computer (such as the PDP-11 used by PUMA industrial robots) as the upper-level main control computer, use a dedicated robot language (such as VAL) as an offline programming tool, use a dedicated microprocessor, and solidify the control algorithm in EPROM [1]. Such dedicated systems are difficult to expand, modify, or re-integrate external hardware (such as sensors) and software. Therefore, we have independently developed a three-degree-of-freedom cylindrical coordinate manipulator driven by a hybrid pneumatic and electric system and a corresponding material sorting device, and designed a distributed open structure manipulator control system based on CAN bus according to its control requirements. This paper focuses on the structural composition of the manipulator control system and further analyzes the design method of the control system software from multiple aspects. 2 Basic Structure of the Manipulator The material handling manipulator consists of two parts: the manipulator and the material sorting device. As shown in Figure 1, the robot mainly consists of a base (driven by a stepper motor), a horizontal arm (using a linear coordinate cylinder HMP-20-200), a vertical arm (using a slider cylinder SLT-16-50), and a gripper (using a parallel gripper HGP-10-A). The material sorting device is composed of three ordinary cylinders, which are used to send workpieces of different lengths to different tracks for the robot to grab and transport respectively. [align=center] Figure 1 Simplified diagram of the material handling robot[/align] 3 Composition of the robot control system based on CAN bus In the development of the robot control system, we always adhere to the design concept of open structure robot controller [2], which is mainly reflected in the following aspects: (1) The hardware is based on the standard bus structure, which can realize data communication between field devices, between devices and various sensors, and between field devices and the control room. Fieldbus is one of the hot spots in the development of automation technology today, and is known as the computer local area network in the field of automation. CAN (Controller Area Network) bus is a branch of fieldbus. It is a system used to realize bidirectional serial multi-node digital communication between control devices in the production field. It is an open, digital, low-level control network. Due to its high reliability and performance-price ratio, it has become an international standard and has received widespread attention from the industry. It has been recognized as one of the most promising fieldbuses [3]. The robot control system is based on the CAN bus network, which can better meet its requirements for openness and reliability. As shown in Figure 2, the host computer in the control system is a PC. The CANPCA single-port CAN bus adapter card of Ruilongde Company is installed in the PCI bus slot of the host computer. The slave computer uses several CAN bus intelligent nodes, which are connected to the air valve, stepper motor driver, sensor, switch, etc. The data communication between the host and slave computers is realized through their respective CAN bus controller SJA1000 chip and CAN bus transceiver 82C250 chip. Among them, SJA1000 has all the features required to complete the CAN bus communication protocol. It is fully compatible with the independent CAN bus controller 82C200 and has new functions such as supporting CAN2.0B protocol, extended receive buffer, enhanced error handling capability and enhanced acceptance filtering. The four lower-level intelligent nodes independently complete the field data acquisition and operation control tasks, and realize data reception and transmission with the upper-level computer through SJA1000. The upper-level computer accesses the CAN controller through the PCI bridge and interface control circuit, thereby realizing data communication with the lower-level computer. [align=center] Figure 2 Schematic diagram of CAN bus control system for material handling robot[/align] (2) Use a development system based on a non-dedicated computer platform (a PC is used in this control system). (3) Use a standard operating system and a standard control language. The robot control system monitoring software uses Visual C++ 6.0 as the development tool and runs on the Windows 98 platform. VC is an object-oriented programming language that provides a visual programming environment, especially the MFC class library, which encapsulates Windows API interface functions and establishes an application framework, allowing program developers to focus their main efforts on the specific problems to be solved. In addition, in the servo control of the horizontal arm cylinder of the robot, the servo positioning controller SPC200 of the German company Festo and its matching built-in displacement sensor MLO-POT-0225, servo positioning control connector SPC-AIF-POT and proportional directional flow valve MPYE-5-1/8-LF-010-B are used. The rotation control of the robot uses the BD-3Y three-phase hybrid stepper motor driver of Beijing KND CNC. 4 Design of robot control system monitoring software 4.1 Basic structure of monitoring software The robot monitoring software uses VC++6.0 as the development tool and uses its MFC class library and APPWizard function to generate SDI single document interface application[4]. VC++6.0 provides ready-made window and toolbar creation methods, which greatly simplifies the interface development process and makes the developed interface have the style of configuration software, which is convenient and flexible to use. As shown in Figure 3, the monitoring software is mainly composed of system interface, CAN bus communication, robot monitoring and running status display modules. The following is a further analysis of the data communication, running monitoring and dynamic display parts. [align=center] Figure 3 Functional block diagram of robot monitoring software[/align] 4.2 CAN bus data communication CAN bus is a multi-master serial bus that effectively supports distributed control and real-time control. It has many superior performances such as flexible short message frame transmission and reception, non-destructive priority-based bus arbitration technology. In the robot control system, CAN bus data communication is achieved by providing relevant function calls in Pcicandrv.LIB (CAN bus function library) together with the CANPCA adapter card [5]. In order to understand the CAN bus status in a timely and accurate manner and to minimize faults and reduce the fault range as much as possible, a test program is specially designed in the control software to be responsible for the debugging and operation of the CAN bus interface and communication part. Only after successful testing can the CAN bus be used to control the robot. CAN bus data comes in standard frames and extended frames, both consisting of information and data, differing only in the number of bits in the address identifier. Below is a portion of the code for CAN bus initialization and CAN standard frame data transmission and reception. // CAN bus initialization void CWuLiao::InitCAN() { int retval; retval = CAN_Open(); // Open PCI adapter card function if (retval != 1) AfxMessageBox("Failed to open PCI card!"); ptrConfig = &Config; ptrStruct = &Struct; // Define CAN data frame structure pointer ptrConfig->timer0 = 0x3f; ptrConfig->timer1 = 0xff; // Set baud rate to 5K ptrConfig->workMode = 0; // Use 11-bit CAN node address ptrStruct->card = 0; // PCI adapter card number ptrConfig->accCode = 0; // CAN receive code ptrConfig->accMask = 0xff; // CAN mask code ptrConfig->control = 1; // Enable interrupt ptrConfig->filterMode = 0; // CAN controller uses single filtering method retval = CAN_Init(ptrStruct, ptrConfig); // Call CAN initialization function if (retval!=1) AfxMessageBox("Initialization failed!"); } // CAN data transmission void CWuLiao::OutputCAN(unsigned int CanID, unsigned char H8B, unsigned char L8B) { int retval; ptrPacket = &Packet; ptrStruct = &Struct; ptrStruct->card=0; ptrPacket->length=4;//Send data length 4 bytes ptrPacket->rtr=0;//Indicates that a data frame is sent, not a remote frame ptrPacket->CAN_ID=CanID;//Define CAN node address ptrPacket->data[0]=0x44; ptrPacket->data[1]=0x4f;//CAN data transmission command word ptrPacket->data[2]=H8B; ptrPacket->data[3]=L8B;//High and low bytes to be sent retval=CAN_Trans(ptrStruct,ptrPacket);//Call the function to send data frames} //CAN data reception void CWuLiao::InputCAN(unsigned int ID) { ptrPacket = &Packet; ptrStruct = &Struct; int Rece_Length,retval,n; ptrStruct->card=0; ptrPacket->length=2; ptrPacket->rtr=0; ptrPacket->CAN_ID=ID; ptrPacket->data[0]=0x44; ptrPacket->data[1]=0x49; //CAN data reception command word retval=CAN_Trans(ptrStruct,ptrPacket); //Call the function to send data frames and send the reception command if(retval==1) { retval = CAN_Rece(ptrStruct, ptrPacket); // Call the function to receive data frames if (retval == 1) // If the reception is successful, the return value is 1 { Rece_Length = ptrPacket->length; // Get the length of the received data for (n = 0; n { Rece_Data[n] = ptrPacket->data[n]; // The received data is read from the member variable Data of ptrPacket, Race.Data[8] has been set as a global variable} } } } 4.3 Application of multithreading technology in real-time monitoring of robotic arms The robotic arm control program was developed under Windows 98. In addition to having a rich user graphical interface, the control program also needs to complete real-time data acquisition and control tasks. However, Windows 98 is not a real-time operating system. It is a preemptive multitasking system based on message-driven mechanism and does not provide sufficient real-time processing functions. Therefore, in the program development, we use multithreading technology to realize the real-time function of the system. Thread is the basic unit of multitasking and is the smallest unit used by the operating system to schedule execution [3]. A process can be composed of multiple threads. The system scheduler divides the CPU time slices to each thread. Each thread uses the CPU in its own time slice, thereby realizing the multitasking effect of micro-level round-robin execution and macro-level concurrent operation. In order to avoid slow response or task blocking caused by the program loop of CAN bus data acquisition and robot control instructions in the front-end display interface of the robot control software, and to enhance the fast response characteristics of the application, we define the main data acquisition and control tasks, "robot handling" and "material sorting", as independent work threads that can be executed in parallel. This work thread completes the data input and control parameter output tasks in the background by reading and writing CAN bus nodes. The front-end display interface communicates with the background data acquisition and control program through the PostMessage() function to obtain and display real-time data in the form of shared data units. A button is set in the "Robot System Run" interface for starting the data acquisition and control thread. The following is part of the "feeding cylinder" running control code: // Set global variable int Rece_Data[8]; // CAN input data array // The following is the main thread... #define WM_THREADCAN WMUSER+10 // User message definition... ON_MESSAGE(WM_THREADCAN,OnThreadCAN) // Use macros to link messages and processing functions... LRESULT CWuLiao::OnThreadCAN(WPARAM wParam, LPARAM lParam) { CWuLiao::InputCAN(0x10); // Read the input status of CAN node #2 if (Rece_Data[2] == 0x7e) CWuLiao::OutputCAN(0x10, 0x00, 0x55); // If the condition is met, output control of the feed cylinder movement... return 0; } void CWuLiao::OnWuLiaoThread() { InitCAN(); // CAN bus initialization pThread = AfxBeginThread(CAN_IN, GetSafeHwnd(), THREAD_PRIORITY_NORMAL); // Create worker thread } // The following is the CAN data acquisition and control sub-thread UINT CAN_IN(LPVOID pParam) { HWND hWnd; hWnd = (HWND)param; do { PostMessage(hWnd,WM_THREADCAN,0,0); Sleep(10); } while (Rece_Data[2]!=0xef); //The work thread is stopped when the stop button is pressed return 0; } In the above code, the main thread creates and initializes the child thread, and the child thread is responsible for reading the status data of the CAN node and giving the corresponding control signal through analysis and calculation to complete the control task. Once the child thread is created, it will run independently of the main thread that created it. Since all threads in a process share the virtual address space of the process, all global variables of the process can be accessed by declaring the data that needs to be shared between the main thread and the child thread as global variables. Introducing a multi-threaded mechanism into the robot monitoring program makes full use of the multi-tasking characteristics of the Windows system, which can effectively overcome the stagnation and untimely response in the CAN bus data acquisition and control process, and can greatly improve the running efficiency and reliability of the program. 4.4 In industrial monitoring software for dynamic display of robotic arm operation, all data collected on-site needs to be displayed on the screen in some way. In the robotic arm system, the main controlled objects are cylinders and stepper motors. To intuitively reflect their operating status, the status of each sensor acquired via the CAN bus and the operation of moving parts must be displayed in animation. For this purpose, we adopted ActiveX control development and application technology. ActiveX controls are powerful programming and development technologies provided by Microsoft, and are an important means of improving program openness and reusability. In the robotic arm control program, MFC ActiveX Controls are used... Wizard established an ActiveX control application framework called jixieshou and generated a dynamically displayable graphical control for the robotic arm device. The shape of the control is changed by setting attributes such as cylinder width and height; the cylinder speed is changed by the delay and distance of each step the cylinder piston moves; the movement and status of the cylinder, stepper motor, and sensors are displayed by calling the interface function of the control. The above behavior is triggered by the CAN bus data acquisition and control sub-thread passing the values ​​of the corresponding global variables to the main thread, thus closely linking the graphical display with the actual action. 5 Conclusion Using CAN bus technology and adopting object-oriented programming methods, multi-threading technology, ActiveX technology, etc., the monitoring software can have strong versatility, scalability and reliability, while further improving the openness and real-time performance of the control system. The application in the control of the material handling robot shows that the control system is reliable and can fully meet the design requirements. References: [1] Zhou Xuecai, Li Weiping, Li Qiang. Open Robot General Control System, Robot. 1998, 20(1). [2] William E. Ford. What is an Open Architecture Robot Controller? 1994 IEEE International Symposium on Intelligent Control, 16-18 August, 1994. Columbus, Ohio, USA. [3] Yang Xianhui. Fieldbus Technology and Its Applications. Tsinghua University Press, 1999.6. [4] Hu Zheyuan. Mastering Visual C++—MFC Programming and Analysis. Tsinghua University Press, 2001.7. [5] Ruilongde Company. PCI Non-Smart Card User Manual. 2002.
Read next

CATDOLL 123CM LuisaTPE

Height: 123cm Weight: 23kg Shoulder Width: 32cm Bust/Waist/Hip: 61/54/70cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22
CATDOLL 146CM Mila TPE

CATDOLL 146CM Mila TPE

Articles
2026-02-22
CATDOLL Ava Hard Silicone Head

CATDOLL Ava Hard Silicone Head

Articles
2026-02-22