KUWTP Ep. 25 | 1st October 2024 | Coding our servo motor + Pet food code
Skibidi Toilet Mad Lit. In lieu of how time flies and we are now halfway into Semester 1, we use some Gen Alpha slangs in a bid to remain young and relevant in pop culture. Anyways! We are finally back after a 1 month hiatus due to midterms. After a such a long break from MnT, we gaslit ourselves and forgot how to piece our 3D printed parts together HAHAHAHA but we got back to the MnT grind quickly.
Today we focussed on coding our servo motor and generating the code that takes into account a dog’s body composition and nutritional value of a specific kibble before recommending the suggested mass of kibble to be fed and dispensing it automatically. We are pleased to announced we successfully completed both in a day which is a massive achievement. Regarding the servo motor code, we struggled with getting the code to work for our continuous servo motor. In literature, the command servo.write(90) stops the motor from running while values from 0 to 90 controls the speed of the servo motor with 0 being the fastest rotation. However, while running the code, we realised that this was in fact not calibrated for our servo motor as a servo.write(90) causes our servo motor to turn at a slow rate while servo.write(0) causes our servo motor to stop turning. To troubleshoot this, we simply generated a simple code on arduino to manually cross-check the value of the angle in servo.write(angle) and its corresponding speed.
This code allows us to key in integer values between 0 and 180 and quickly check its corresponding rotation speed. A few minutes of experimenting (Fig. 1) with different values allowed us to determine that for counter clockwise rotation, an angle of 103 corresponds to fastest revolution rate, an angle of 96 corresponds to the slowest possible revolution rate while angle of 95 returns to motor to the neutral position and stops the rotation.
After troubleshooting our servo.write() parameters, we updated our code and tested it out again. To our delight, the code now works perfectly A quick run through of our code – it enables the user to input 3 commands (tare, calibrate and dispense). The tare function offsets the current weight on the weighing scale and sets it to 0. This is crucial in taring the pet food bowl. The calibrate function ensures that the weighing scale is properly initialized. We calibrated the scale against a 100g known mass (Fig. 2) as the mass of pet food to be dispensed is approximately 100g hence the mass used for calibration should be close to the target mass to ensure accuracy and precision of the weighing scale. The dispense function allows the user to key in the desired mass of kibble to be dispensed, after which it is automatically dispensed and stops when the right amount has been dispensed. To minimise the probability of more food being dispensed, we programmed the motor to slow down drastically when approaching the target value at different increments. In total, the speed of the servo motor slows down 3 times, when the difference between desired and actual mass is between 50 and 20, between 20 and 10, and less than 1o.
After celebrating the success of our servo motor, we also brainstormed and finalized on how we will be integrating our pet weighing scale and food dispenser together. The conclusion would be to purchase a plywood and some metal structures to create a contraption where the food dispenser and weighing scale are back to back (Fig. 3). We will also be adding a feature to the weighing scale, where it will look like a dog bed so dogs will be more willing to stand on the scale.
We have also attached a video below featuring the success of our servo motor for you to celebrate our success with us, as well as our servo motor and pet food code ◡̈
Arduino Continuous Servo Motor Code: arduino servo motor code
Pet Food Code: pet food code