How to make a segway with your own hands. DIY Segway Collection of mechanical parts


This article will consider the creation of a self-balancing vehicle, or simply a Segway. Almost all materials for creating this device easy to get.

The device itself is a platform on which the driver stands. By tilting the torso, two electric motors through a chain of circuits and microcontrollers responsible for balancing.

Materials:


-XBee wireless control module.
- Arduino microcontroller
-batteries
- InvenSense MPU-6050 sensor on the “GY-521” module,
- wooden blocks
-button
-two wheels
and other things indicated in the article and in the photographs.

Step one: Determine the required characteristics and design the system.

When creating this device, the author tried to make it fit into such parameters as:
- flotation and power needed to move freely even on gravel
-batteries of sufficient capacity to provide at least one hour of continuous operation of the device
- provide the possibility of wireless control, as well as fixing data on the operation of the device on an SD card for troubleshooting and troubleshooting.

In addition, it is desirable that the cost of creating such a device be less than ordering the original off-road hoverboard.

According to the diagram below, you can see the electrical circuit diagram of a self-balancing vehicle.


The following image shows the drive system of the scooter.


The choice of a microcontroller to control Segway systems is diverse, the author Arduino system most preferred because of its price ranges. Suitable controllers such as Arduino Uno, Arduino Nano or you can take the ATmega 328 to use as a standalone chip.

To power a dual bridge motor control circuit, a supply voltage of 24 V is required, this voltage is easily achieved by connecting 12 V car batteries in series.

The system is designed so that power is supplied to the motors only while the start button is pressed, so for a quick stop, just release it. In this case, the Arduino platform must maintain serial communication with both the bridge control circuit of the motors and with the wireless control module.

Tilt parameters are measured using the InvenSense MPU-6050 sensor on the “GY-521” module, which processes acceleration and carries the functions of a gyroscope. The sensor was located on two separate expansion boards. The l2c bus communicates with the Arduino microcontroller. Moreover, the tilt sensor with address 0x68 was programmed in such a way as to poll every 20 ms and provide an interrupt to the Arduino microcontroller. The other sensor has address 0x69 and is pulled directly to the Arduino.

When the user stands on the platform of the scooter, the load limit switch is activated, which activates the algorithm mode for balancing the Segway.

Step two: Creating the body of the hoverboard and installing the main elements.


After determining the basic concept of the gyro scooter operation scheme, the author proceeded to the direct assembly of its body and the installation of the main parts. The main material was wooden planks and bars. The tree weighs little, which will positively affect the duration of the battery charge, in addition, wood is easily processed and is an insulator. A box was made from these boards, in which batteries, motors and microcircuits will be installed. Thus, a U-shaped wood detail, on which wheels and engines are attached by means of bolts.

The transmission of engine power to the wheels will be due to gearing. When laying the main components in the body of the Segway, it is very important to ensure that the weight is distributed evenly when bringing the Segway to a working upright position. Therefore, if you do not take into account the distribution of weight from heavy batteries, then the work of balancing the device will be difficult.

IN this case the author placed the batteries at the back, so as to compensate for the weight of the engine, which is located in the center of the device body. The electronic components of the device were stowed in place between the engine and the batteries. For later testing, a temporary start button was also attached to the handle of the Segway.

Step Three: Wiring Diagram.



According to the above diagram, all the wires in the Segway case were carried out. Also, in accordance with the table below, all the outputs of the Arduino microcontroller were connected to the bridge motor control circuit, as well as to the balancing sensors.


The following diagram shows the tilt sensor installed horizontally, while the control sensor was installed vertically along the Y-axis.



Step four: Testing and configuring the device.


After carrying out the previous stages, the author received a Segway model for testing.

When conducting testing, it is important to take into account such factors as the safety of the testing area, as well as protective equipment in the form of protective shields and a helmet for the driver.

hoverboard inside

Main details

What is a gyroscope made of? If you look from the side, the gyro scooter is an interesting device. The first is a work platform or board. It is on it that a person gets up and, trying to keep balance, drives, rides or falls. On the sides of the platform there are two wheels, it is they that give us the opportunity to ride and move forward or backward.

First, let's deal with the platform. The working platform is divided into two parts, the right and left side. Just right and left foot. This was done in order to be able to turn right or left, just by pressing the toe on these platforms.

How is a gyro scooter?

mini segway device

wheels

There are two wheels on the sides. Usually hoverboards come in 4 types, and they differ in the class and size of the wheels. The first class of hoverboards is a children's hoverboard with 4.5 inch wheels. Small size wheels makes the hoverboard very uncomfortable and not passable in some sections of the road.

The next class is the 6.5 inch hoverboard. It already has a larger wheel diameter, but everything is also designed only for driving on flat surfaces. The 8 inch gyroscooter is the golden mean among all gyroboards. He has optimal size wheels that can drive on almost any road.

And the biggest is the SUV of all mini-segways - a 10-inch hoverboard. This is a model that has interesting feature, in addition to large wheels, these wheels have a chamber system. That is, the wheels are inflatable, they have a smoother ride, and such hoverboards are more wear-resistant than smaller prototypes.

Frame

The body of all hoverboards is made of different materials, but with the same feature. Everywhere the case covers the wheels, protecting from splashes, dirt, water, snow and dust. Gyroscooters with small wheels 4.5 and 6 are usually made of ordinary plastic. Since these models are designed to drive on a flat road, and do not develop such high speed, then the engineers decided not to put expensive plastic and thereby not increase the price of the hoverboard.

For a hoverboard with 8 inch wheels, the bodies are made of various materials, both from simple plastic, and from carbon, high-impact magnesium plastic. Such plastic is able to withstand almost any physical impact and shock. Carbon, for example, lightweight material, thus it reduces the load on the electric motors and reduces the rate of battery discharge.

Engines

After you remove the cover, on the sides closer to the wheel you should see the electric motor. Electric motors come in different capacities. The average value among all mini-segways is 700 watts on both wheels. Or 350 watts per wheel. The fact is that the electric motors of the gyroscooters work independently of each other. One wheel can go at one speed and the other at another, or they can move in different directions, one backward, the other forward. Thus, this system gives the gyroscooter controllability.

It becomes more sensitive to turns at high speed. You can also turn around 360 degrees. The higher the power of the engine, the higher the load carried and the higher the speed, but not always. It must be understood that the higher the mass of the load on the platform, the lower the speed and the faster the battery is discharged. Therefore, gyroscooters with powerful engines are more expensive.

Balancing system

The balancing system consists and includes quite a few components. First of all, these are two gyroscopic sensors, which are located on the right and left sides of the platform. If you remove the case cover, you can see two auxiliary boards, it is to them that the gyroscopic sensors are connected. Auxiliary boards help process information and send it to the processor.

Further on the right side you can see the main board, it is there that the 32-bit processor is located and all control and calculation is carried out. There is also a program that reacts to any change in the platform on the right or left.

If the platform leans forward, then the processor, having processed the information, sends a signal to the electric motors that physically hold the board in a level position. But if the platform tilts more with a certain pressure, the wheel immediately starts moving forward or backward.

It must be remembered that in all current hoverboards there must be two auxiliary boards for gyroscopic sensors and one main board, where the processor is located. In older models, there may also be a two-board system, but since the fall of 2015, a change has been made to the standard and now all hoverboards, mini-segways are made with 3 boards.

In Chinese fakes or low-quality hoverboards, there may be one board, the main one. Unfortunately, such a mini-segway has poor handling characteristics. May vibrate or overturn the driver. And then the whole system can fail altogether.

Scheme internal device Controlling a scooter is not as difficult as it seems. The whole system is designed to respond as quickly as possible to any behavior of the platform. The calculation is done in a fraction of a second and with amazing accuracy.

Battery

The power supply system of the hoverboard is powered by two or more batteries. In standard inexpensive models, a battery with a capacity of 4400 mAh is usually installed. The battery is responsible for the operation of the entire system as a whole and providing it with electricity, so the battery must be of high quality and branded. Typically, two brands of batteries are used - these are Samsung and LG.

Batteries also differ in class. There are low-level batteries of classes 1C, 2C. Such batteries are usually put on hoverboards with 4.5 and 6.5 inch wheels. All for the same reason, because these hoverboards are designed for flat roads, flat asphalt, marble or floors.

Gyroscooters with 8-inch wheels usually put batteries of the middle class type 3C, this is a more reliable battery model. It will not turn off during a sudden stop or when hitting a curb or a hole.

Large-wheeled 10-inch models usually have class 5C batteries. This hoverboard is able to ride on almost any road, land, puddles, pits. Therefore, the battery needs to be more reliable.

The basic principle of the hoverboard device is due to balance. With a large weight of the driver, the gyro scooter needs more electricity to carry out maneuvers and movement.

Other

Many hoverboards also have a Bluetooth system and speakers. With it, you can listen to your favorite music and ride with friends. But this system still makes it possible to connect your smartphone to the hoverboard and monitor the state of your vehicle. Can be followed average speed, see how far you have covered. Customize maximum allowable speed and much more.

Many models also have a backlight, it illuminates your path in the dark, and can also flash brightly to the beat of the music. But you need to remember that music and lighting greatly drain the battery. Many generally turn off the backlight to increase the power reserve.

Conclusion

The scooter is designed to be compact and lightweight, yet fast, powerful and durable. The main thing is to buy a hoverboard from trusted suppliers who have all the necessary documentation so that you do not have to disassemble it after an unsuccessful ride.

Hi all brains! In my new brain project, I will create a self-balancing vehicle or Segway with my own hands. For this project you need basic knowledge in electronics and the ability to work manually. All mechanical components can be purchased online or at your local store.

SEGWAY consists of a platform on which they stand in vertical position, and two lateral electric motors driven by batteries. The control controller algorithm ensures a stable position. The movement of the Segway is controlled by the driver by tilting his torso, and a handle to select the direction of movement left / right. Therefore, you will need additional components such as a controller, a motor driver, and an acceleration sensor/gyroscope. Mechanical design made of wood because it has a light weight, electrically isolated and easy to process. Now let's start making a Segway!

Step 1: Main characteristics of the project

In this project, it is required to manufacture a device with the following characteristics:

— Sufficient power and stability for driving on the street, and even on a gravel path;
- 1 hour continuous work
– Total cost up to 500€ euros
- Possibility of wireless control
- Write data to SD card to detect breakdowns

Step 2: System Design

The tilt sensor is mounted horizontally along the x-axis and vertically along the y-axis.

Step 5: Testing and tuning

Please note that the motors must have sufficient power. Check the device in a wide and safe area to avoid injury or damage. It is recommended to wear protective shields and a helmet.

Follow the step by step procedure. Start by programming the Arduino microcontroller (download), then check the communication with the sensors and the control bridge.

The Arduino Terminal can be used to debug code and test functionality. For example, the gain of the PID controller needs to be tuned because it depends on the mechanical and electrical parameters of the motor.

Gain is adjusted according to this procedure:
1. The Kp parameter is for balancing. Increase Kp until the balance becomes unstable, Ki and Kp remain 0. Lower Kp slightly to get a steady state.
2. The Ki parameter is for acceleration/deceleration when tilting. Increase Ki to get proper acceleration to avoid falling when leaning forward, Kp stays at 0. Balance should now be stable.
3. The parameter Kd is used to compensate for switching on and return to a stable position.

In the Terminal program, you can execute various "?" commands.
? - Help with team selection
p,i,d [integer] — Set/Get PID gain, value from 0 to 255
r [integer value] – forced increase in motor speed, value from -127 to 127
v - software version
With the "p" command you get access to the Kp parameter. The "p 10" command allows you to set Kp to a value of 10.

After power is applied to the Arduino, the sensors are initialized and enter the standby state. When the push button is pressed, a control signal is transmitted to the SEGWAY controller, which is in a vertical position, which is ready to activate the motors to move forward or backward, depending on the initial position. From this point on, the button must be kept pressed constantly, otherwise the motors will turn off and the controller will go into a standby state. After reaching the vertical position, the controller waits for the “Driver in Place” load limit switch signal, which is usually pressed with the foot when the driver is on the platform. After that, the balancing algorithm starts and the motors are activated forward or backward in order to remain in an upright position. Leaning forward creates translational motion forward and vice versa. Being in an inclined position leads to an acceleration of movement. Leaning in the opposite direction results in slower speed. Use the handle to move left and right.

Step 6: Demo

See below video finished device and thanks for your attention!

Is it really possible to make such a complex device as a Segway yourself? It turns out you can. If you apply enough diligence and use special knowledge. What did a young engineer named Petter Forsberg, who graduated Swedish Chalmers University of Technology with a degree in Automation and Mechatronics.

In addition to knowledge and skills, he still had to need a lot of money, you say. Yes, money was needed, but not much, about 300 euros, to purchase a certain set of parts and equipment. The result of his efforts is in this video:

Mechanics

Motors, wheels, chains, gears and batteries were taken from two inexpensive Chinese electric scooters. Engines allow you to provide 24V, 300W, 2750 rpm.

The transmission is carried out from the small gear on the motor to the large gear on the steering wheel. The ratio is about 6:1, a high ratio is preferable to get better torque and lower top speed. The transmission on the 12" wheel was based on a freewheel mechanism, so the necessary modifications had to be made to allow the wheel to be driven in both directions.

The basis of the platform is a fixed axle on which both wheels must rotate. The axle is mounted with three aluminum blocks, which are fixed with 5mm set screws.

To be able to turn when driving a Segway by tilting the steering column to the left and right, a drawing was made required part in the SolidWorks program, after which it was made on a CNC machine. The machine program was written using CAMBAM. The same method was used to produce the electronics box and assemble the emergency brake unit.

The steering wheel of the future Segway is a conventional bicycle handlebar, the tube of which is attached to a 25 mm steel hollow pipe. To keep the steering column centered and create some force to feedback two steel springs were involved. The steering wheel also has an emergency button, which is connected to a standard relay from the car and can reduce engine power.

For power supply, two 12V 12Ah lead batteries are used, which are used for 24V motors.

Electronics

All printed circuit boards were made specifically for this development. The main board takes care of the calculations, collects data from sensors such as a gyroscope (ADXRS614), an accelerometer (ADXL203) and a trim pot, based on which it is able to determine which direction you want to turn.

Main processor AVR ATmega168. Connection with a laptop is made via Bluetooth using the RN-41. Two H-bridges convert the control signals from the main board into force for the motors. Each H-bridge has an ATmega168, communication between the boards is via UART. All electronics run on a separate battery (LiPo 7.4V 900mAh).

In order to have easy access to charging the batteries, for programming the main board, changing the parameters of the control loop, a small box was made with the necessary connectors, an electronics power switch and a trimmer potentiometer on the top side.

Software

The microcontroller software mainly consists of a filter for the gyroscope and accelerometer and a PD control loop. Two filters were taken for the test: Kalman and Complemenatry. It turned out that their performance was very similar, but the Complemenatry filter requires less computation, so it was chosen to be used. Java applications have also been written so that you can see all the values ​​​​of sensors and control signals, battery status, etc.

The technical side of creating a Segway with your own hands in this video:

Let's talk about how you can use Arduino to create a robot that balances like a Segway.

Segway from English. Segway is a two-wheeled standing vehicle equipped with an electric drive. They are also called gyroscooters or electric scooters.

Have you ever wondered how a Segway works? In this tutorial we will try to show you how to make an Arduino robot that balances itself just like a Segway.

In order to balance the robot, the motors must counteract the fall of the robot. This action requires feedback and corrective elements. Feedback element - , which provides both acceleration and rotation in all three axes (). The Arduino uses this to know the robot's current orientation. The corrective element is the combination of engine and wheel.

The end result should be something like this:

Robot scheme

L298N Motor Driver Module:

DC Gear Motor with Wheel:

A self-balancing robot is essentially an inverted pendulum. It can be better balanced if the center of mass is higher relative to the wheel axles. A higher center of mass means a higher mass moment of inertia, which corresponds to a lower angular acceleration (slower fall). That's why we put the battery pack on top. However, the height of the robot was chosen based on the availability of materials 🙂

The completed version of the self-balancing robot can be seen in the figure above. At the top are six Ni-Cd batteries to power the PCB. Between motors, a 9-volt battery is used for the motor driver.

Theory

In control theory, holding some variable (in this case the position of the robot) requires a special controller called a PID (Proportional Integral Derivative). Each of these parameters has a "gain", commonly referred to as Kp, Ki and Kd. The PID provides a correction between the desired value (or input) and the actual value (or output). The difference between input and output is called "error".

The PID controller reduces the error to the smallest possible value by constantly adjusting the output. In our self-balancing Arduino robot the input (which is the desired slope in degrees) is set by the software. The MPU6050 reads the robot's current tilt and feeds it into a PID algorithm that performs calculations to control the motor and keep the robot upright.

The PID requires that the Kp, Ki and Kd values ​​be set to optimal values. Engineers use software, such as MATLAB, to automatically calculate these values. Unfortunately, we can't use MATLAB in our case because it will complicate the project even more. Instead, we will tune the PID values. Here's how to do it:

  1. Set Kp, Ki and Kd to zero.
  2. Adjust Kp. Too little Kp will cause the robot to fall because the fix is ​​not enough. Too much Kp makes the robot go wild back and forth. A good Kp will make the robot lean back and forth quite a bit (or oscillate a bit).
  3. Once Kp is set, adjust Kd. good value Kd will reduce the oscillations until the robot is almost stable. Also, a proper Kd will keep the robot even if pushed.
  4. Finally, install Ki. When turned on, the robot will oscillate even if Kp and Kd are set, but will stabilize over time. The correct Ki value will shorten the time required for the robot to stabilize.

The behavior of the robot can be seen below in the video:

Arduino code for a self-balancing robot

We needed four external libraries to create our robot. The PID library makes it easy to calculate P, I and D values. The LMotorController library is used to control two motors with the L298N module. The I2Cdev library and the MPU6050_6_Axis_MotionApps20 library are designed to read data from the MPU6050. You can download the code including libraries in this repository.

#include #include #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif #define MIN_ABS_SPEED 20 MPU6050 mpu; // MPU control/status vars bool dmpReady = false; // set true if DMP init was successful uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU uint8_t devStatus; // return status after each device operation (0 = success, !0 = error) uint16_t packetSize; // expected DMP packet size (default is 42 bytes) uint16_t fifoCount; // count of all bytes currently in FIFO uint8_t fifoBuffer; // FIFO storage buffer // orientation/motion vars Quaternion q; // quaternion container VectorFloat gravity; // gravity vector float ypr; // yaw/pitch/roll container and gravity vector //PID double originalSetpoint = 173; double setpoint = originalSetpoint; double movingAngleOffset = 0.1; double input, output; //adjust these values ​​to fit your own design double Kp = 50; double Kd = 1.4; double Ki = 60; PID pid(&input, &output, &setpoint, Kp, Ki, Kd, ​​DIRECT); double motorSpeedFactorLeft = 0.6; double motorSpeedFactorRight = 0.5; //MOTOR CONTROLLER int ENA = 5; int IN1 = 6; int IN2 = 7; int IN3 = 8; int IN4 = 9; int ENB = 10; LMotorController motorController(ENA, IN1, IN2, ENB, IN3, IN4, motorSpeedFactorLeft, motorSpeedFactorRight); volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high void dmpDataReady() ( mpuInterrupt = true; ) void setup() ( // join I2C bus (I2Cdev library doesn't do this automatically) #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin( ); TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz) #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif mpu.initialize(); devStatus = mpu.dmpInitialize(); // supply your own gyro offsets here, scaled for min sensitivity mpu.setXGyroOffset(220); mpu.setYGyroOffset(76); mpu.setZGyroOffset(-85); mpu.setZAccelOffset(1788); // 1688 factory default for my test chip // make sure it worked (returns 0 if so) if (devStatus == 0) ( // turn on the DMP, now that it's ready mpu.setDMPEnabled(true); // enable Arduino interrupt detection attachInterrupt(0 , dmpDataReady, RISING); mpuIntStatus = mpu.getIntStatus(); // set our DMP Ready flag so the main loop() function knows it"s okay to use it dmpReady = true; // get expected DMP packet size for later comparison packetSize = mpu.dmpGetFIFOPacketSize(); //setup PID pid.SetMode(AUTOMATIC); pid.SetSampleTime(10); pid. SetOutputLimits(-255, 255); ) else ( // ERROR! // 1 = initial memory load failed // 2 = DMP configuration updates failed // (if it"s going to break, usually the code will be 1) Serial.print(F("DMP Initialization failed (code ")); Serial.print(devStatus); Serial.println(F(")")); ) ) void loop() ( // if programming failed, don"t try to do anything if (!dmpReady ) return; // wait for MPU interrupt or extra packet(s) available while (!mpuInterrupt && fifoCount< packetSize) { //no mpu data - performing PID calculations and output to motors pid.Compute(); motorController.move(output, MIN_ABS_SPEED); } // reset interrupt flag and get INT_STATUS byte mpuInterrupt = false; mpuIntStatus = mpu.getIntStatus(); // get current FIFO count fifoCount = mpu.getFIFOCount(); // check for overflow (this should never happen unless our code is too inefficient) if ((mpuIntStatus & 0x10) || fifoCount == 1024) { // reset so we can continue cleanly mpu.resetFIFO(); Serial.println(F("FIFO overflow!")); // otherwise, check for DMP data ready interrupt (this should happen frequently) } else if (mpuIntStatus & 0x02) { // wait for correct available data length, should be a VERY short wait while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount(); // read a packet from FIFO mpu.getFIFOBytes(fifoBuffer, packetSize); // track FIFO count here in case there is >1 packet available // (this lets us immediately read more without waiting for an interrupt) fifoCount -= packetSize; mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); input = ypr * 180/M_PI + 180; ) )

Kp, Ki, Kd values ​​may or may not work. If they don't, follow the steps above. Note that the tilt in the code is set to 173 degrees. You can change this value if you like, but note that this is the angle the robot must support. Also, if your motors are too fast, you can adjust the motorSpeedFactorLeft and motorSpeedFactorRight values.

That's all for now. See you.

 
Articles By topic:
Pasta with tuna in creamy sauce Pasta with fresh tuna in creamy sauce
Pasta with tuna in a creamy sauce is a dish from which anyone will swallow their tongue, of course, not just for fun, but because it is insanely delicious. Tuna and pasta are in perfect harmony with each other. Of course, perhaps someone will not like this dish.
Spring rolls with vegetables Vegetable rolls at home
Thus, if you are struggling with the question “what is the difference between sushi and rolls?”, We answer - nothing. A few words about what rolls are. Rolls are not necessarily Japanese cuisine. The recipe for rolls in one form or another is present in many Asian cuisines.
Protection of flora and fauna in international treaties AND human health
The solution of environmental problems, and, consequently, the prospects for the sustainable development of civilization are largely associated with the competent use of renewable resources and various functions of ecosystems, and their management. This direction is the most important way to get
Minimum wage (minimum wage)
The minimum wage is the minimum wage (SMIC), which is approved by the Government of the Russian Federation annually on the basis of the Federal Law "On the Minimum Wage". The minimum wage is calculated for the fully completed monthly work rate.