Connection Between the Components
The Arduino UNO contains an ATmega328 microcontroller, a 16 MHz, 8-bit RISC microcontroller that supports about 300,000 lines of code per second and provides sufficient inputs and outputs for many applications. It has 32 KB of Flash Memory, of which 0.5 KB is used by the bootloader. The board can be programmed via a USB interface; the program is stored in the microcontroller's internal EEPROM (1KB). A standardized pinout allows connecting a variety of add-on modules called shields.
Arduino UNO has a 3.3-volt regulator, a 5-volt regulator, and a USB input. There's a reset switch that lets the user reset the microcontroller and start the program over. It has a USB interface chip that connects USB to the microcontroller's serial input pins. It has a set of 14 digital I/O pins that provide 5 volts (0 or 5 volts), and 6 analog input pins that accept 0 to 5-volt inputs. That's where the sensors are connected. There is also access to a 3.3-volt and a 5-volt supply from the board itself.
Useful Features for our project:
It is an easy USB interface. This allows USB interfacing, as it's a common, convenient serial device.
It has a number of hardware features like digital I/O, PWM, timers, external and internal interrupts, and multiple sleep modes.
It has a 16 MHz clock, which is fast enough for most applications.
It has 32 KB of flash memory for storing the code.
Use of Arduino UNO in the control of the project
Generation of PWM signals from Arduino UNO: Using the analogWrite function. The two things the function needs to run are a pin/variable and a value to set the duty cycle. The value given to this function must be between 0 and 255 (8-bit). A duty cycle of 100% occurs if the value is set at 255, and a value of 0 gives a duty cycle of 0%. The board has built-in PWM circuits on pins 3, 5, 6, 9, 10, and 11. An example command for PWM signal generation is analogWrite(9, 128), which sets a 50% duty cycle on pin 9.
Serial communication between the computer and Arduino: The Arduino must continuously communicate with the computer as the values (such as Setpoint, PID parameters, Kp, Ki, and Kd) in the graphical user interface change. Moreover, the processed data from the Arduino must be sent back to the computer GUI for plotting the required data. The two LEDs near the USB connector blink when data is transmitted: RX blinks when the Arduino is receiving data, and TX blinks when the Arduino is transmitting data.
Read the analog value from the feedback sensor (IR sensor): Arduino must read the analog value from the feedback sensor (IR sensor in our case) to process it and find the actual position. As discussed, Arduino has 6 analog input pins that accept 0-5-volt input.
L298N motor driver is a dual H-bridge motor controller and is typically used to control the speed and direction of the motor. An H-bridge is a circuit that can drive a current in either polarity and be controlled by pulse width modulation (PWM) signals.
L298N motor driver module pinouts
DC motor 1 "+"
DC motor 1 "-"
12V jumper - remove this if using a supply voltage greater than 12V DC. This enables power to the on-board 5V regulator
Vcc Port: Connect the motor supply voltage here, maximum of 35V DC. Remove the 12V jumper if the Supply Voltage is greater than 12V DC
GND: Ground pin
5V output with the 12V jumper in place, ideal for powering your Arduino (etc.).
DC motor 1 enable jumper. Remove jumper for connecting to PWM output, for DC motor speed control
IN1: Input Pin 1 for DC motor 1
IN2: Input Pin 1 for DC motor 1
IN3: Input Pin 1 for DC motor 2
IN4: Input Pin 1 for DC motor 2
DC motor 2 enable jumper. Remove jumper for connecting to PWM output, for DC motor speed control
DC motor 2 "+"
DC motor 2 "-"
Motor direction is controlled by sending a HIGH or LOW signal to the driver. For example, a HIGH to IN1 and a LOW to IN2 will cause the motor to turn in one direction, and a LOW to IN1 and a HIGH to IN2 will cause it to turn in the other direction. However, the motors' speed is controlled by a PWM signal from a digital pin on the Arduino, connected to the driver's enable pin.
Therefore, for controlling a single motor, three digital output pins on the Arduino are required, one of which needs to be a PWM pin.
In our project, digital pins D2 and D4 on the Arduino are connected to the module pins IN1 and IN2, respectively, and D9 to the ENA pin (after removing the jumper).
The motor used in the project is a simple geared permanent magnet brushed DC motor.
Power supply used is Keysight (U8002A) single output DC power supply 0-30V, 5A. The setting for constant 9-volt supply is done in the setup.
It is made of high quality nylon material, with good toughness and thus is used as tendon wire.
Spring is used for the measurement of the force. The stiffness of the spring used is approximately equal to 20 N/m. So, by calculating the displacement of spring, corresponding force can be calculated.
IR stands for infrared. These are light-based sensors, one is the transmitter (photo LED) and the other is the receiver (photo transistor).
The emitter emits infrared radiation and the receiver acquires radiation. The potential difference at the receiving end is proportional to the size of the received light. As receiver comes to the transmitter, intensity of the light increases, hence the voltage difference also increases. We can calibrate this apparatus with original distances.
We used a photodiode (TIL 38) as transmitter and a phototransistor (TIL 81) as receiver.
IR Sensor Circuit (Electronic Circuit) Development
The IR pair is located on the leadscrew and slider-nut mechanism as shown in Figure below. We further calibrated this apparatus with original distances for our experimental setup.
The schematic diagram of the electronic components used is shown in the above Figure.
The microcontroller (Arduino UNO) is connected to the IR circuit and motor driver. The enable pin (ENA) of the motor driver is connected to the digital pin (Pin 5) of the Arduino. Input pin 1 (IN1) and input pin 2 (IN2) are connected to digital pins 2 and 4 of the Arduino, respectively. The DC motor is connected to the motor driver's output pins 1 and 2 (OUT1 and OUT2). A power supply (9-12V) is connected to the Vcc port of the motor driver. A 5V supply to the IR circuit is given from the Arduino itself. The voltage output signal from the IR circuit is read by the Arduino through the analog pin (A0). All the connections are grounded commonly.