Discussion on Graphical Programming Method of Single Chip Microcomputer
[Copy link]
Single-chip microcomputers can be programmed in assembly language, high-level languages C and Basic, or graphical languages. Programmable controllers are widely used in industrial control. The microcontrollers in their CPU modules are often ordinary single-chip microcomputers, while programmable controllers can be programmed in ladder diagrams or flowcharts. The current intelligent educational robot controllers all use single-chip microcomputers, and the programming of these robots mostly supports flowchart programming. The development of ordinary single-chip microcomputers can definitely use flowchart programming. In fact, the flowchart compilation software of robots can be used as the programming software of the corresponding single-chip microcomputer in turn. The following example is used to explain in detail how to use graphical programming for single-chip microcomputers.
1 Problem Description
On a certain machine, two motors drive the workbench to move sequentially through a ball screw, as shown in Figure 1. The two motors are controlled by a single-chip microcomputer system to achieve the specified sequential actions. When the travel switch KX1 is pressed, the motor D1 drives the clamping mechanism to move right. When it moves right to the collision block pressing KX2, the motor D1 stops, and this state is delayed for a period of time T1. Motor D2 starts to move in the following order: when the travel switch KX3 is pressed, motor D2 drives the workbench to move right. When the workbench moves right to the point where the bumper presses KX4, motor D2 stops, and this state is delayed for a period of time T2; then motor D2 reverses and drives the workbench back to the left. When the workbench returns to the left and presses KX3, motor D2 stops, and at the same time motor D1 reverses and releases the clamping mechanism until KX1 is pressed, and motor D1 stops.
Figure 1 Sequential actions of the clamping mechanism and the workbench
The sequence is shown in Figure 2.
Figure 2 Action sequence diagram
2 Composition of single-chip microcomputer control system
There are many solutions to realize the above control functions, such as relay contactor control system, programmable controller control system, single-chip microcomputer control system, etc. This paper uses a single-chip microcomputer control system to realize the above control actions. The composition of the single-chip microcomputer control system is shown in Figure 3.
Figure 3 Structure diagram of single-chip microcomputer control system
The single-chip microcomputer uses MC68HC11E1. In order to meet the needs of the simulation experiment, the single-chip microcomputer control system uses the main control board in the Ability Storm Robot ASUII of Shanghai Guangmaoda Electronic Information Co., Ltd. The travel switch KX1~KX4 is simulated by the collision switch on the robot, and the collision switch circuit is shown in Figure 4 (a). The motors D1 and D2 are simulated by the driving motors of the robot's two wheels, and the circuit is shown in Figure 4 (b). Among them, the motor drive chip selected is TI's SN754410.
Figure 4 Collision switch circuit and drive motor circuit on Ability Storm robot
3 VJC program flow
Use the programming development environment VJC1.6 of Ability Storm robot to compile, debug and download programs. For the above-mentioned single-chip dual-motor start-stop control system, the flowchart compiled by VJC1.6 is shown in Figure 5. In the actual single-chip control system, as long as the corresponding sensors and their drive circuits, motors and their drive circuits are changed to components that adapt to the actual object, this single-chip control board and corresponding programming software can still be used. Further applications can expand the software and hardware system.
The overall program is a loop program. In each cycle, the four collision switches are detected in turn, and the motors are started or stopped according to the motor action sequence requirements. The use of program modules and the setting method of variables are omitted here. Please refer to the manual or contact Shanghai Guangmaoda Electronic Information Co., Ltd.
The flowchart in Figure 5 can be converted into a C language program in the VJC1.6 environment. For details, please refer to the use of VJC1.6.
Programs compiled in the VJC1.6 environment, whether flowcharts or C language programs, can be directly downloaded to the flash memory or EEPROM of the microcontroller, which is why this programming and development method is popular. However, this method is currently only used in the program development of intelligent robots with microcontrollers as the core. There is no such graphical programming environment specifically used for microcontroller development. I believe that this method will appear in the near future.
Figure 5 Dual motor start and stop control partial flow chart
Conclusion
The function implemented by the microcontroller system here is equivalent to a programmable controller system, and the programming language is a flowchart language. It can be seen that some microcontroller systems can be slightly expanded to become a fully functional programmable controller that can use flowchart programming, C language programming and assembly language programming, thus keeping pace with existing programmable controllers in the field of industrial control.
|