06.4 Implementation
Model and Prints
Electronics and Code
The system is controller using Arduino UNO microcontroller. The use of a microcontroller is necessary to connect to the motor controller to adapt the power given to the motors. Further, in the future it could be use to integrate other sensors and/or connect to the devices via ethernet, WiFi, Bluetooth.
The motor controller is connected to the Arduino with the IN1, IN2, IN3, IN4 that control the forward/reverse configuration of each motor. Respectively IN1 and IN2 for the first motor, and IN3 and IN4 for the second one. The power to each motor is controller with the connection ENA and ENB for the first and second motor. Finally, the motor controller gives power with 5V and GND connection to Arduino. The motor controller is powered with an external 24V power supply connected to an outlet.
IN1 is connected to 8 pin on Arduino
IN2 is connected to 7 pin on Arduino
IN3 is connected to 5 pin on Arduino
IN4 is connected to 4 pin on Arduino
ENA is connected to 9 pin on Arduino
ENB is connected to 3 pin on Arduino
Following the code to define the pins on Arduino:
const int enA = 9; // PWM Pin for Speed
const int in1 = 8; // Direction Pin 1
const int in2 = 7; // Direction Pin 2
const int enB = 3; // PWM Pin for Speed
const int in3 = 5; // Direction Pin 1
const int in4 = 4; // Direction Pin 2The motors are 2 DC 24V 600RPM gear motor with high torque. The speed is controller with the motor controller to perform the cut of the vegetable.
The speed can be controlled using a function as the following:
void runMotor(int motor, int speed, int direction, int durationMs) {
setMotorState(motor, speed, direction);
delay(durationMs);
stopMotor(motor);
}
void stopMotor(int motor) {
setMotorState(motor, 0, STOP);
}
void setMotorState(int motor, int speed, int direction) {
int pin1, pin2, pinPWM;
if (motor == MOTOR_A) {
pinPWM = enA; pin1 = in1; pin2 = in2;
} else {
pinPWM = enB; pin1 = in3; pin2 = in4;
}
speed = constrain(speed, 0, 255);
if (direction == FORWARD) {
digitalWrite(pin1, HIGH);
digitalWrite(pin2, LOW);
} else if (direction == BACKWARD) {
digitalWrite(pin1, LOW);
digitalWrite(pin2, HIGH);
} else {
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
speed = 0;
}
analogWrite(pinPWM, speed);
}The system works with a continuous movement of the blade and an intermittent motion of the conveyor belt. By changing for how long the conveyor moves it is possible to change the slice thickness.