Segwa balance car DIY, teach you to play with urban transport

"Segway" (English: Segway) is an electric-powered, self-balancing personal transport vehicle. It is a kind of "Segway" for urban transport. It is impressive. The travel tool, which occupies less than one square meter, rides on the image like a skateboard, and hands are liberated, but it can change the position of the center of gravity only by body movement, and then move forward and backward, turn the brakes and so on. The traditional means of transportation can not be moved at will, and most of the energy must be placed in the direction and speed of control, and "Segway" does not require special control devices, all of which are completed by the body, and thus obtained The alias of "Balanced Car". The Segway "balance car looks magical, but have you found out that its principle is actually very simple? Thanks to the latest technology, key parts can be bought directly on Taobao, and the control program can also be written by itself. It’s very simple to have your own balance car.

Inverted pendulum and robot

Segwa balance car DIY, teach you to play with urban transport

The balance problem of "Segway" is actually a multi-level inverted pendulum problem. When a person holds the bottom of a bamboo pole by hand so that it does not fall vertically in the air, this is a model of a one-stage inverted pendulum system. If the first bamboo pole is hinged to other bamboo poles, or the bamboo pole itself has a certain elasticity (comparable to the large living body with bones and joints on the "Segway"), it becomes a multi-level inverted pendulum.

Many people have played games with their hands on bamboo poles. The most impressive thing is that it is a static and unstable system. The cup on the table can stand on its own, and when the center of gravity falls in the bottom of the cup, it will not fall even if there is a small disturbance. However, most of the time in the palm of the hand, the center of gravity projection is not at the point of contact, so that the bamboo raft remains relatively unmoved by the dynamic adjustment - which side of the bamboo raft is poured, the hand will quickly go to which side, let the center of gravity return to the point of contact. This is the dynamic balancing process that is done by the human eye, the brain and the human hand.

The human brain has an inherent advantage in dealing with such problems, because the human walking process is essentially a process of continuous decline, and it must rely on the real-time extension of the support foot to shift the center of gravity to ensure the dynamic balance of the upright travel. It is very difficult for robots to do this. It is necessary to comprehensively solve the linear problems, robustness problems, stabilization problems, follow-up problems and tracking problems in the dynamic control process. So in the humanoid robots that have been seen so far, There are a lot of people who can walk stiffly, but they can jump up and down like a real person.

Segwa balance car DIY, teach you to play with urban transport

Two police officers patrol the "Segway" single police patrol car

The principle of dynamic balance of Segway is the same as that of the inverted pendulum. The uppermost passenger is used as the swing arm, and then the wheel is controlled to maintain the center of gravity of the system to make the passenger stand upright. When the driver changes his or her body's angle forward or backward, the "Segway" will advance or retreat according to the direction of the tilt, and the speed is proportional to the degree of inclination of the driver's body to maintain balance. One of the clever design here is to balance the passenger sensing and control - "Segway" forward or backward to maintain balance, but also achieve the purpose of advancing or retreating according to the passenger's intention. In the end, skilled drivers can walk in the same direction as before, and indulge their hands and minds. This feature makes Segway particularly suitable for patrols and police patrols.

Mechanical part

Segwa balance car DIY, teach you to play with urban transport

The mechanical mechanism of the design includes a simple independent suspension. The cushioning part directly uses the shock absorber of the bicycle (the spring needs to be replaced), and the body is not very compact, mainly for being able to be disassembled and folded, and is convenient for retracting and transporting. (It should be noted that the structure has been submitted for patent application, please do not use it for commercial purposes.) The whole machine material is very simple, two independently driven wheels + motor drive board + body angle sensor + turning sensor + battery + one loaded these The box of things. The two wheels, the motor and the shock absorber are all finished products from Taobao. Sheet metal and machine parts are processed separately.

Here are some pictures to make, detailed part drawings are listed at the end.

Overall shape

Segwa balance car DIY, teach you to play with urban transport

DIY's own "Segway"

Like human walking, the control of Segway also requires sensors and actuators. It relies on MEMS technology to manufacture precision solid-state gyroscopes and accelerometers to sense the rotation, speed and tilt of the car body, high-speed microprocessors to calculate sensor data, and drive the hub motor to complete forward/reverse/differential turn. Beyond the circuit, in order to change it from a pendulum in the lab to a practical scooter, you need to prepare the necessary structural parts and accessories.

Structural details

Segwa balance car DIY, teach you to play with urban transport

Motor mounting section

The motor is an excellent motor, 250W, 24v / good quality, not recommended.

Assembly process

Segwa balance car DIY, teach you to play with urban transport

Lithium battery compartment

Segwa balance car DIY, teach you to play with urban transport

The original design was a lead-acid battery, and the latter friend provided me with a lithium battery for free. I would like to thank you again.

Overall installation

Segwa balance car DIY, teach you to play with urban transport

Segwa balance car DIY, teach you to play with urban transport

Circuit part

The main control adopts ATMEGA_32 of AVR, the motor is driven by H-bridge, and the components are IR2184 and IRF1405. The sensor uses IDG300 and ADXL335, and the current sensor is ACS755. There are also some small peripheral functions that are optional, not detailed.

Control drive PCB diagram

Segwa balance car DIY, teach you to play with urban transport

Sensor PCB diagram

Segwa balance car DIY, teach you to play with urban transport

PCB empty board

Segwa balance car DIY, teach you to play with urban transport

What you need to pay attention to welding is - don't be too sloppy. First solder low-profile components, then solder large ones!

Welding is basically completed

Segwa balance car DIY, teach you to play with urban transport

Connected motor test

Segwa balance car DIY, teach you to play with urban transport

Body angle acquisition

The selected sensor is an analog output, so it is only necessary to use the AD of the single-chip microcomputer to collect the data and calculate the angle value. It should be noted that the directly used data after the acquisition will be very bad. It is necessary to perform the filtering calculation again to obtain an accurate, timely, and anti-disturbing true angle data. In the speed regulation process, the serial port can be used to output data and assist debugging. Here is the simple PID control wheel speed, if you don't remember, Baidu look. It takes a little time to debug the parameters. At the beginning, the parameters are too large, otherwise it is dangerous to shake! In addition, you need to set the function of excessive angle stop. The steering data is obtained by collecting the steering potentiometer, and the collected data is filtered and processed. Setting an invalid dead zone in the middle of the turn is also to prevent malfunction.

heat sink:

Segwa balance car DIY, teach you to play with urban transport

Remote control and voice module

Segwa balance car DIY, teach you to play with urban transport

Control program part

The quality of the shell users is very high, here are some key parts. Some personally considered useful code is attached at the end.

flow chart

Segwa balance car DIY, teach you to play with urban transport

remote control

Segwa balance car DIY, teach you to play with urban transport

The hardware originally used 18b20, it is regrettable that this part of the program is not tuned, the possible reason 1: the system must have multiple interrupts, and the interrupt service program is more, thus disrupting the 18b20 timing, plus no oscilloscope, and thus no communication . Possible cause 2: IQ problem. After trying to debug for nearly 2 hours, the analog temperature chip LM35D was used instead, and the voltage was directly divided by the resistor. The rest can be played freely.

Friendly reminder: This car has certain dangers. It does not rule out falling and losing control. It is good to play on the open space. If you plan to use it for work, please buy insurance for yourself!

19mm Key Switches

19mm key switches, ie, key switch lock, is gradually increase market share with its Diverse functions, accurate operation and Wide range of applications

This 19MM Key Switches could have 3 position key switch, 4 Position key Switch, which means it could have stronger power to support industrial and other bigger equipment. The exclusive technology of reset functions, multi-position rotation angles are not available in all walks of life,only we can have the technique to realize these.


3 postion key switch


As for the quality, this 19Mm Key Switches have via UL authentication. In terms of green environmental protection, we adhere to the concept of sustainable development from the procurement of raw materials to the shipment of finished products. Meanwhile, we have professional environmentalist in charging of  the whole production system, ROHS environmental protection  providing PPAP report for our customers.

At present, our company's power key switches matching detection equipment is roughly as follows:ROHS testing machine, projector, life testing machine, push-pull testing machine, secondary element microscope, power testing machine, salt spray testing machine, etc.

With a sound quality control system and reliable detection equipment, we has created a globally reliable power key switch and has become a trusted producer of electrical key switches.

19MM Key Switches

19Mm Key Switches,4 Position Slide Switch,19Mm Push Button Key Switch,19Mm 3 Position Key Switch

YESWITCH ELECTRONICS CO., LTD. , https://www.yeswitches.com