The invention discloses a mechanical and electrical integrated excavator and a control method, including a monitoring processor, a memory, a watchdog, a display screen, a voice alarm, a photoelectric isolation circuit, a high-speed photoelectric isolation circuit, a counter, a filter, and a communication circuit Connection, the monitoring processor is connected with the memory, watchdog, display screen, voice alarm, counter, filter, communication circuit, the photoelectric isolation circuit is connected with the filter, and the high-speed photoelectric isolation circuit is connected with the counter; it also includes motion control The output of the arm inclination sensor, the arm inclination sensor, the bucket inclination sensor, the arm inclination sensor, the bucket inclination sensor, and the bucket inclination sensor are connected to the input of the motion controller, and the motion controller communicates with the monitoring processor through the communication circuit connected. The mechatronics excavator can realize the automatic excavation control of the predetermined trajectory, and has the advantages of high control precision, accurate positioning and low energy consumption.