Control and Hardware Implementation
Table of contents
Control Flowchart
The flowchart displays a general working of the control aspect of our project where Visual Feedback is ensured to turn the knob of the potentiometer resulting in the change in direction of the servo motor.
Apart from this, handheld transformation also took place wherein we pulled the rack while driving on the pinion to provide sufficient torque for the transformation to take place and it was noted that the system would actually work when chosen with the right motor providing more than sufficient torque.
Servo Motor Working
Servo motors are often used for positioning tasks. A servo motor comprises of a Sawtooth Shaft, Potentiometer, Gearbox, DC Motor and an IC chip.
- Connection of the Three wires
- Brown: GND
- Red: VCC – Requires voltage between 4.8V – 7.2V
- Orange: PWM or Control Signal
- Periodic time of 20ms aka 1/20 = 50Hz
- Duty Cycle of 1-2ms
- An ‘On’ time of 1ms represents -90o position.
- 1.5ms represents 0o position. Sawtooth shaft Gearbox Potentiometer DC Motor
- 2ms represents 90o position.
- Structure
- 4 different size gears that decrease the original RPM usually from 3000RPM to 50-100 RPM, thereby increasing the torque.
- A potentiometer is present inside the servo.
- Potentiometer creates a voltage divider that outputs a variable voltage according to the position of the motor shaft and acts as feedback for the utilized control IC (KC5188)
- The IC constantly compares the potentiometer voltage aka the current states to the intended position of the PWM signal aka the Target States and then activates an integrated H bridge which lets the motor drive in either direction to achieve a difference of 0 between the two signals.
Potentiometer Working
Potentiometer is often termed as Potmeter which is a three terminal analog device.
- A manually adjustable variable resistor by turning the top of the potmeter.
- 3 terminals
- Two Fixed Terminal: connected to both ends of the resistive element for establishing an electrical resistance.
- Variable Terminal: connected to the sliding contact or wiper, attached to a rotary knob
- The wiper will run across the resistive element resulting in making good electrical contact.
- Working Principle
- If we connect the 2 fixed terminal ends of the potentiometer to a multimeter, it displays the maximum resistance of the potentiometer
- Potentiometer acting as Voltage Divider
- DC Motor – Potentiometer – Power Supply
- Here we use potentiometer for motor speed control
- Higher Resistance config, more voltage will pass thus increasing the speed of the DC motor and vice versa
Connections
Code:
#include Servo myservo; // create servo object to control a servo
int potpin = A5; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup() {
Serial.begin(9600); // setup serial
myservo.attach(6); // attaches the servo on pin 9 to the servo object
}
void loop() { // Servo knob demo
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
Serial.print(val); Serial.print(" ");
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
Serial.print(val); Serial.println();
delay(10);
}