| Due to the shortcomings of traditional controller,such as poor universality and ununified programming language,and the construction of smart factory,enterprises urgently need an open controller based on Internet of things(IOT).Thus,an open IOT controller is developed based on PLCopen standard.The controller takes STM32F407 as the processing core and integrates PLC logic control,PLCopen standard motion control and IOT functions.To meet the requirements of independence,real-time and stability,embedded real-time operating system(RTOS)is used as the system platform,and modularization and multi-task are used as the design guide.According to the idea of modularization,the functions of the control system are divided into PC interaction,logic control,motion control and IOT,which are used as multi-task running modules.Because RTOS cannot meet the strong real-time demand of periodic interpolation of motion control,a real-time guarantee mechanism is designed based on hardware timer and data buffer.In order to satisfy the sequential execution mode of logic control and the activation execution mode of motion control,a PLC operating kernel is designed,so that the logic instructions are explained and executed by the mechanism of stack,and the motion instructions,in the form of message queue,are packaged and sent to the motion control thread to explain and execute.For solving the problem of excessive memory consumption caused by different parameters of motion function block,the measures taken are to save the input and output parameters of the function block in the corresponding structure,and only the identifiers of the function block and the first address of the structure are transmitted through the message queue.The velocity planning of motion control adopts seven-stage S-type velocity planning,and there are 50 kinds of velocity changing trends according to different motion parameters.The s-type interpolation algorithm applied to embedded devices is proposed,which consists of two parts.The first part is the full-type seven-segment S-type acceleration and deceleration algorithm.The algorithm will judge the existence or non-existence of the uniform speed section according to the motion parameters.In view of the non-existence of the uniform speed section,the dichotomy method is used to solve the possible turning speed,so we can figure out the times of each of the seven segment.The second part is the displacement increment algorithm.According to the time of each section in the seven-section formula,the displacement change is calculated in a given control cycle.To meet the functional requirements of the Internet of Things,a set of edge control and Internet of Things monitoring platform is built based on the network architecture of "Client + cloud".The controller packages the processed core data into JSON format and transmits it to the Internet of Things cloud platform through MQTT protocol.On the Onenet platform,the monitoring system of Internet of Things is developed to realize the visual monitoring of Web pages and mobile apps.Finally,the algorithm of full-type seven-section S-type acceleration and deceleration is tested on the controller and the test of logic control function is monitored through the Internet of Things platform Onenet.On the distributed hardware platform,single-axis motion block and biaxial linear and circular motion block are verified.The experimental results show that the designed controller is superior and effective. |