{"id":13084,"date":"2025-11-20T19:18:13","date_gmt":"2025-11-20T18:18:13","guid":{"rendered":"https:\/\/dronesonen.usn.no\/?p=13084"},"modified":"2025-11-20T19:28:49","modified_gmt":"2025-11-20T18:28:49","slug":"autobalance-week-13","status":"publish","type":"post","link":"https:\/\/dronesonen.usn.no\/?p=13084","title":{"rendered":"AutoBalance Week 13:"},"content":{"rendered":"\n<p><strong>Meron<\/strong> :<\/p>\n\n\n\n<p>This week I worked on simulation testing in SolidWorks to find out how much weight our motorcycle frame can handle during balancing. Since our prototype includes several components such as the balancing motor, electronic systems and the spinning wheel, it was important to understand how the structure behaves under load. I have run several simulation tets with different loads, but I found the 10 kg test to be the most relevant for our design. This test shows the realistic limit for our prototype and gives us confidence that the structure is strong enough. I used plastic as material choice in simulation since our motorcycle parts are printed in 3 D which makes it important to understand how the material reacts under stress.<\/p>\n\n\n\n<p>The first image shows the von mises stress, where the maximum stress is 18.52 MPA far below the materials yield strength of 103.65 meaning the part is safe.<\/p>\n\n\n\n<p>The second image shows displacement with a maximum deformation of only 1.77mm which is acceptable.<\/p>\n\n\n\n<p>The third image shows the factor of safety (FOS) which is above 5 confirming that the frame is stable and secure.<\/p>\n\n\n\n<p>Simulation is a very important part of our project . it helps us predict mechanical performance before building saving both material and time . for me as a mechanical engineering student this is valuable because it connects theory and practice allowing me to understand how design decisions affect the real performance of the motorcycle.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"630\" height=\"279\" src=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-128.png\" alt=\"\" class=\"wp-image-13091\" style=\"width:474px;height:auto\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-128.png 630w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-128-300x133.png 300w\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"638\" height=\"288\" src=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-129.png\" alt=\"\" class=\"wp-image-13092\" style=\"width:485px;height:auto\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-129.png 638w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-129-300x135.png 300w\" sizes=\"auto, (max-width: 638px) 100vw, 638px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"321\" height=\"631\" src=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-130.png\" alt=\"\" class=\"wp-image-13093\" style=\"width:260px;height:auto\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-130.png 321w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-130-153x300.png 153w\" sizes=\"auto, (max-width: 321px) 100vw, 321px\" \/><\/figure>\n\n\n\n<p><strong>Salim &amp; Muhammed \u00d8:<\/strong> This week we met and combined our code from last week. We set everything up, but we realized we had the wrong sensor. We were using the ADXL345, which only provides accelerometer data. &nbsp;In addition we tried to get readings from the sensor without soldering it, not knowing it won\u2019t work, therefore we decided to wait for the MPU6050, which we will receive next week. We need the gyroscope as well, which we had discussed in the previous weeks.<\/p>\n\n\n\n<p>We charged the new battery we received and discussed how we will test all the components on a bicycle now that we have all the parts we need. We also agreed on which balancing wheel we will use for testing. From there, we can observe how much the system changes.<\/p>\n\n\n\n<p>In addition we have determined how to mount the sensor on the motorcycle, since doing this, we will be needed to change the code because the imu sensors axes. In the previous week we used the X axis, but now we will be using the Y axis, since it will be responsible for left and right. <\/p>\n\n\n\n<p>Furthermore we tested the system with the received battery and can confirm that it performs optimally for our purpose. The battery did not come with any cabels to connect to the system therefore we needed to find a way to connect it to our system. Our approach was by connecting alligator clips to the cables used to charge the battery, and then connecting it to our system with dupont cables. &nbsp;The batteries weight is enough to counter measure the weight of the motor, so it can be placed to achieve a balanced motorcycle.<\/p>\n\n\n\n<p>we also changed minor things in our code amoung other things the complementary filter since it was wrong.<\/p>\n\n\n\n<p>Our updated code:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;Wire.h&gt;\n#include &lt;MPU6050.h&gt;\n\nMPU6050 imu;\n\n\/\/ Filter og kontrollvariabler\nfloat angle = 0;\nfloat angleNOW = 0;\nfloat gyroChange = 0;\nfloat offset = 0;    \/\/ offset for gyroX\nfloat a = 0.98;      \/\/ komplement\u00e6rfilter vekting (kan justeres)\nunsigned long timeLast;\n\n\/\/ PID-lignende parametre\nfloat X1 = 25.0;\nfloat X2 = 0.9;\n\n\/\/ Motorpinner (PWM-PIN for ENA)\nint MotorENA = 5;     \/\/ PWM pin (m\u00e5 v\u00e6re PWM!)\nint MotorIN1 = A0;\nint MotorIN2 = A1;\n\nvoid setup() {\n\n  Serial.begin(9600);\n  Wire.begin();\n  imu.initialize();\n\n  Serial.println(\"Hold motorsykkelen rolig for kalibrering...\");\n  delay(2000);\n\n  long sum = 0;\n  int samples = 200;\n  for (int i = 0; i &lt; samples; i++) {\n    int16_t accX, accY, accZ, gyroX, gyroY, gyroZ;\n    imu.getMotion6(&amp;accX, &amp;accY, &amp;accZ, &amp;gyroX, &amp;gyroY, &amp;gyroZ);\n    sum += gyroX;\n    delay(5);\n  }\n  offset = sum \/ (float)samples;\n\n  Serial.print(\"GyroX offset = \");\n  Serial.println(offset);\n\n  pinMode(MotorENA, OUTPUT);\n  pinMode(MotorIN1, OUTPUT);\n  pinMode(MotorIN2, OUTPUT);\n\n  timeLast = millis();\n}\n\n\nvoid setMotorSpeed(int speed) {\n\n  \/\/ Begrens verdi\n  speed = constrain(speed, -255, 255);\n\n  if (speed &gt;= 0) {\n    \/\/ Motor fremover\n    digitalWrite(MotorIN1, HIGH);\n    digitalWrite(MotorIN2, LOW);\n    analogWrite(MotorENA, speed);\n  } else {\n    \/\/ Motor bakover\n    digitalWrite(MotorIN1, LOW);\n    digitalWrite(MotorIN2, HIGH);\n    analogWrite(MotorENA, -speed); \/\/ positiv PWM\n  }\n}\n\n\nvoid loop() {\n\n  int16_t accX, accY, accZ, gyroX, gyroY, gyroZ;\n  imu.getMotion6(&amp;accX, &amp;accY, &amp;accZ, &amp;gyroX, &amp;gyroY, &amp;gyroZ);\n\n  float dt = (millis() - timeLast) \/ 1000.0;\n  timeLast = millis();\n\n  angleNOW = atan2((float)accY, (float)accZ) * 180.0 \/ PI;\n\n  gyroChange = ((float)gyroX - offset) \/ 131.0;   \/\/ deg\/s\n\n  angle = a * (angle + gyroChange * dt) + (1 - a) * angleNOW;\n\n  int pwm = -constrain(X1 * angle + X2 * gyroChange, -255, 255);  \n\n  setMotorSpeed(pwm);\n\n  \/\/ Debug\n  Serial.print(\"Angle: \");\n  Serial.print(angle);\n  Serial.print(\" | gyro: \");\n  Serial.print(gyroChange);\n  Serial.print(\" | PWM: \");\n  Serial.println(pwm);\n}\n<\/code><\/pre>\n\n\n\n<p><br><\/p>\n\n\n\n<p>Picture of the connected components:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"369\" height=\"492\" src=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-16.jpeg\" alt=\"\" class=\"wp-image-13087\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-16.jpeg 369w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-16-225x300.jpeg 225w\" sizes=\"auto, (max-width: 369px) 100vw, 369px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"368\" height=\"491\" src=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-19.jpeg\" alt=\"\" class=\"wp-image-13089\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-19.jpeg 368w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-19-225x300.jpeg 225w\" sizes=\"auto, (max-width: 368px) 100vw, 368px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"356\" height=\"475\" src=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-18.jpeg\" alt=\"\" class=\"wp-image-13086\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-18.jpeg 356w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-18-225x300.jpeg 225w\" sizes=\"auto, (max-width: 356px) 100vw, 356px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"357\" height=\"476\" src=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-17.jpeg\" alt=\"\" class=\"wp-image-13085\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-17.jpeg 357w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-17-225x300.jpeg 225w\" sizes=\"auto, (max-width: 357px) 100vw, 357px\" \/><\/figure>\n\n\n\n<p><strong>Muhammed \u00d8:<\/strong><br>this week I worked on developing a wiring diagram for our system. The ground symbol indicates a common reference point. This ensures that all signals use the same reference voltages.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"752\" height=\"473\" src=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-127.png\" alt=\"\" class=\"wp-image-13088\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-127.png 752w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/11\/image-127-300x189.png 300w\" sizes=\"auto, (max-width: 752px) 100vw, 752px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Mohammed A:<\/strong><\/p>\n\n\n\n<p>I worked in solidworks to build a front and back wheel with inmind to make everything look slimmer and better, and put as much weight in the senter as much as possible, front wheel rotat at 120 degres. I am in the making of suspentions at home and in the workshop. In addition I working on the back wheel to have Tron wheel look alike, It give a chalange to have the belt outside or connected throuth the insdie of the wheel. In the week I&#8217;ll work on FEM analysis to see accumulation of vibration, where most of the load and stress accumulates. While we are talking about FEM analysis, I looked into topoligy to build a much stronger bike that can withstand the stress and vibraton. Side note, I am trying to get in contact with the K\u00e5re, if we have time to build a chastity of the bike using the labs materials.<br><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Meron : This week I worked on simulation testing in SolidWorks to find out how much weight our motorcycle frame can handle during balancing. Since our prototype includes several components such as the balancing motor, electronic systems and the spinning wheel, it was important to understand how the structure behaves under load. I have run [&hellip;]<\/p>\n","protected":false},"author":112,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13084","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts\/13084","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/users\/112"}],"replies":[{"embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13084"}],"version-history":[{"count":3,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts\/13084\/revisions"}],"predecessor-version":[{"id":13096,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts\/13084\/revisions\/13096"}],"wp:attachment":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}