Sunday, November 14, 2021

Micromouse Design

 1. Introduction

In this project I designed a simple Arduino based micromouse. First, let me explain what a micromouse is. A micromouse is an autonomous robot which is smaller in size than other hobby robots and in general they are built for robotics competitions. Mainly they are used for maze solving. 

When you are designing a simple micromouse robot, mainly you need two gear motors with encoders, IR sensors for object detection, motor driver, a gyro sensor for making it easy to take sharp turns in the arena, the microcontroller and an optional buzzer and a LCD display. For the motors, I used N20 gear motors with encoders. As the IR sensors, I used infrared emitting diodes and infrared detecting diodes. As the motor driver, I used L293D IC and MPU6050 as the gyroscope and finally, Arduino Nano as the microcontroller.

The following figure shows the hierarchical schematic diagram and there after the IR sensor panel, power supply, motor driver, gyro sensor, and other required connections are shown. The IR sensor panel was designed to give a digital output signal to the microcontroller. Here, I have used a linear 5V regulator, but I recommend you to use a switching converter instead of a linear regulator if it is possible.  

Then, using Altium Designer, I created the PCB layout of the micromouse.

2. Schematic Diagram and PCB Layout 


1 / 16
2 / 16
3 / 16
4 / 16
5 / 16
6 / 16
7 / 17
8 / 16
9 / 16
10 / 16
11 / 16
12 / 16
13 / 16
14 / 16
15 / 16
16 / 16

Realtime Object Detection & Tracking

In this project I designed an algorithm for detection and tracking hexagonal nuts on a conveyor belt. Python language with OpenCV image processing library were used to implement the algorithm. Template matching technique was used. 

Let me explain the algorithm. First, we have to include following libraries.

import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt

%matplotlib inline

Then I implemented following function in order to do image preprocessing. First, image thresholding with OTSU is used to get a binary image, then morphological closing operation was done to remove small holes that may be appeared in the image. After that connected component analysis is carried out in order to extract the contours of hexagonal nuts in the image.

def preprocess(im):
    """ Thresholding, closing, and connected component analysis lumped
    """ 

    th, img = cv.threshold(im,0,255,cv.THRESH_BINARY_INV+cv.THRESH_OTSU)
    kernel = np.ones((3,3), dtype = 'uint8')
    closing = cv.morphologyEx(img, cv.MORPH_CLOSE, kernel)
    retval, labels, stats, centroids = cv.connectedComponentsWithStats(closing)

    return retval, labels, stats, centroids 

The following function finds whether a detected nut is a new one or not. For this, two frames are used. The absolute difference between two nuts is measured and compared with a threshold value, to achieve this. The threshold value needs to be found experimentally by considering frame rate, and speed of the conveyor belt.

def is_new(a, b, delta, i):
    
    difference = np.absolute(a - b)
    return (difference[:,i] > delta[i]).all()

The following function is used to get the index of a nut in the previous frame, if that particular nut is not a new one. This is required for tracking the nuts.

def prev_index(a, b, delta, i):
    # Returns the index of the apppearance of the object in the previous frame.
    
    index = -1

    difference = np.absolute(a-b)
    if is_new(a, b, delta, i): return index
    return np.where(difference[:,i]&lt=delta[i])[0]

The following function is used to preprocess the template image. It's similar to preprocessing of images done before.

def preprocess_template(template_img):
    th_t, img_t = cv.threshold(template_img,0,255,cv.THRESH_BINARY_INV+cv.THRESH_OTSU)

    kernel = np.ones((3,3), dtype = 'uint8')
    closing_t = cv.morphologyEx(img_t, cv.MORPH_CLOSE, kernel)

    contours_t, hierarchy_t = cv.findContours(closing_t, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
    return contours_t

The main program is shown below.


cap = cv.VideoCapture(r'conveyor_with_rotation.mp4')
template_img = cv.imread(r'template.png', cv.IMREAD_GRAYSCALE)

contours_t = preprocess_template(template_img)

object_prev_frame = [[0, 0, 0, 0]]
total_nuts = 0
f = 0                               # Number of frames

size = []                           # Size of a frame image
Frames = []                         # Contour plots of Frames

while cap.isOpened(): 
    f += 1
    ret, frame = cap.read()
    
    if not ret:
        print("Can't receive frame (stream end?). Exiting ...")
        break

    frame_gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)           # Converting frames to grayscale
    print_offset = 0

    # 1. Object Detection

    retval, labels, stats, centroids = preprocess(frame_gray)
    belt = ((labels >= 1)*255).astype(np.uint8)
    contours, hierarchy = cv.findContours(belt, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)

    object_current_frame = []
    count = 0
    for cont in contours:
        if (cv.matchShapes(contours_t[0], cont, cv.CONTOURS_MATCH_I1, 0.0) < 0.001):
            count += 1
            M  = cv.moments(cont)
            cx, cy = int(M['m10']/M['m00']), int(M['m01']/M['m00'])
            ca = cv.contourArea(cont)
            object_current_frame.append(np.array([cx, cy, ca, count]))

    # 2. Object Tracking

    im_contours_belt = np.zeros((belt.shape[0],belt.shape[1],3), np.uint8)
    size = im_contours_belt.shape
    conts = cv.drawContours(im_contours_belt, contours, -1, (0,255,0), 2).astype('uint8')

    delta = np.array([15])
    i = np.array([0])
    for nut in object_current_frame:
        if (is_new(object_prev_frame, nut, delta, i)):
            total_nuts += 1
            nut[-1] = total_nuts
        else:
            nut[-1] = object_prev_frame[int(prev_index(object_prev_frame, nut, delta, i))][-1]

        cv.putText(conts,str(int(nut[-1])), (int(nut[0]-20),int(nut[1])+10), cv.FONT_HERSHEY_PLAIN, 4 ,(255,0,255), 3, cv.LINE_AA)
        cv.putText(conts, 'Object {} : {}, {}, {}'.format(nut[-1], nut[0], nut[1], nut[2]), (50, 650 + print_offset*40),cv.FONT_HERSHEY_PLAIN, 2, (255,0,255), 2, cv.LINE_AA)
    
        print_offset += 1
    
    object_prev_frame = object_current_frame

    cv.putText(conts, ('Frame: ' + str(f)), (50,80), cv.FONT_HERSHEY_PLAIN, 2, (255,0,255), 2, cv.LINE_AA)

    Frames.append(conts)
    
    cv.imshow("Contours", conts)
    
    if cv.waitKey(1) == ord('q'):  
        break

cap.release() 
cv.destroyAllWindows() 

You can find the code and required files from this link.

The algorithm was tested using a video clip of a conveyor belt as follows.

Saturday, November 13, 2021

Designing a High Frequency Amplifier

1. The Task

Designing an amplifier to amplify frequencies between 10kHz – 100kHz with a maximum peak-to-peak input voltage of 0.1V using transistors. The amplifier should be able to run a load of 8 Ohms.

2. Introduction

Amplifiers are highly used in the industry. They are widely used to amplify a small signal. Usually, those amplifier modules are available in the market. They are categorized according to their amplification factor (gain), output power, input and output impedance, and bandwidth. When the operating frequency of the amplifier increases, the design becomes more complex.

Our design consists of 3 amplifier stages. In the first stage, we used common-collector amplifier configuration, in the second stage common-emitter configuration and, as the final stage, we used a Darlington pair for power amplification. The reason for using a common collector amplifier as the first stage is, in an amplifier, we need to have a higher input impedance in order to reduce the loading effect. The loading effect is simply, drawing much current from the source by the amplifier. The common-collector configuration gives a fairly high input impedance. The second stage can be considered as the voltage amplification stage. We used a BJT amplifier which operates in common emitter configuration for this. Since the amplifier needs run a load having a small input impedance like 8 ohms, the output of the amplifier should be able to provide enough current. Therefore, power amplification is mandatory to achieve this although we have a significant voltage in no-load conditions. So, we used a Darlington pair which have  significant current gain, as the final stage.

For interconnecting these stage, we used capacitor coupling method. Therefore, we can do DC calculation for each stage separately without considering the effect from other stages. But for AC calculations, we cannot do that. 

3. Design Steps

Stage 01 

As mentioned before, a common collector BJT amplifier is used as the input stage. The circuit diagram is shown below and now let's calculate the resistor values.

Figure 1

For DC analysis, let's assume the following conditions.

1. Vcc = 12V
2. VE = 6V
3. Ic = 1.25mA
4. VBE = 0.7V

\begin{equation}R_{3} = \frac{V_{E}}{I_{E}} \approx \frac{V_{E}}{I_{C}} = \frac{6}{1.25\times 10^{-3}} \approx 4.7k\Omega \end{equation} 

Let's take R1 as 22kOhms. Then, R2 can be found as,

\begin{equation} \frac{R_{2}}{R_{1}+R_{2}}\times V_{CC} = V_{B} \Rightarrow \frac{R_{2}}{R_{2}+22\times 10^{3}} \times 12 = 6 + 0.7 \Rightarrow R_{2} \approx 27k\Omega \end{equation} 

Stage 02

Stage 02 is used for voltage amplification. Therefore, we use the common emitter configuration of a BJT as the second stage The circuitry is shown below.

 

Figure 2

In the above circuit, R7 is used for the thermal stability of the transistor. When the transistor is operating, it's getting heated. Then, it's P-N junction temperature increases. This will increase the thermally generated electron-hole pairs resulting an increase in the collector current. When the collector current increases, the transistor gets much heated and this thing happens indefinitely until the transistor got destroyed. This scenario is called as thermal runaway. 

But, what happens if we put R7 there? When the collector current increases, emitter current increases. Since R7 is there, this will increase the voltage drop across R7 according to Ohm's  law. Voltage drop increases means, voltage at the emitter terminal increases. Since the voltage of the base terminal is approximately constant (voltage divider) this will decrease the base-emitter voltage (VBE). Then, base current reduces and as a result of that, collector current reduces. Therefore, by adding R7 we could stop rising the collector current indefinitely thus achieving thermal stability for the amplifier. 

When you consider the AC signal path (we will discuss this in detail later) a fraction of useful signal power will be dissipated through R7. Therefore, adding R7 will result in a reduction of the amplifier gain. You know capacitors can pass AC signals although the DC signals can't. Therefore, adding a bypass capacitor (C3) parallel to R7 will reduces the AC signal dissipation through R7.

For the calculations in this stage, we need the AC equivalent circuit also which is shown below.


Figure 3
 
In the circuit above, the Ï€-model of a transistor is used as the AC-equivalent of a BJT. 

For calculations, let's assume the following conditions.

1. IC,Q = 15mA
2. VCE,Q = 6V
3. β = 200
4. Av = -200 (Open circuit voltage gain)
5. VBE,Q = 0.7V

Equation for the open circuit voltage gain can be written as,

\begin{equation} A_{V} = \frac{v_{o}}{v_{i}} = \frac{-g_{m}v_{\pi } (r_{0} || R_{6})}{v_{\pi } } = -g_{m} (r_{0}||R_{6}) \approx -g_{m}R_{6} \end{equation}

In the above equation we can neglect r0 since it is a much larger value compared to R6 in general. Now, let's calculate gm. Consider the thermal voltage as 25mV at room temperature.

\begin{equation} g_{m} = \frac{I_{C,Q}}{V_{T}} = \frac{15\times 10^{-3}}{25\times 10^{-3}} = 0.6\Omega ^{-1}\end{equation}

Then, R6 can be obtained as,

 \begin{equation} R_{6} = \frac{-A_{v}}{g_{m}} = \frac{-(-200)}{0.6} \approx 330 \Omega \end{equation} 

For calculating R7 we can write Kirchhoff's  voltage law across CE loop.

 \begin{equation} R_{6}I_{C,Q} + V_{CE,Q} + I_{E,Q}R_{7} = V_{CC} \end{equation} 

\begin{equation} R_{7} \approx \frac{V_{CC} - R_{6}I_{C,Q}-V_{CE,Q}}{I_{C,Q}} = \frac{12 - 330\times 15\times 10^{-3}-6}{15\times 10^{-3}} = 70 \Omega\end{equation}

Now we have to find R4 and R5. Let's take R5 as 5.6kOhms. Since we consider this as a voltage divider in the calculations, take the current across R5 is approximately 6 times the base current. Since we know the collector current at quiescent point (IC,Q) and β, we can find the base current IB as,

\begin{equation} I_{B} = \frac{I_{C,Q}}{\beta } = \frac{15\times 10^{-3}}{200} = 0.075mA \end{equation}

 \begin{equation} I_{R_{5}} = 6\times I_{B} = 0.45mA \end{equation} 

 Now we can find base voltage (VB) as,

 \begin{equation} V_{B} = I_{R_{5}}\times R_{5} = 0.45\times 10^{-3}\times 5.6\times 10^{3} = 2.52V \end{equation} 

 Finally, obtain R4 as,

 \begin{equation} R_{4} \approx \frac{V_{CC}-V_{B}}{I_{R_{5}}} = \frac{12-2.52}{0.45\times 10^{-3}} \approx 21k\Omega \end{equation} 

We calculated all the resistor values in this stage. Now we need to find a suitable value for C3; the emitter-bypass capacitor. In general this capacitor is selected such that, 10 times it's impedance is less than or equal to emitter resistance. That is,

\begin{equation} 10X_{C_{3}} \leqslant R_{7} \end{equation}

We know that, 

\begin{equation} X_{C_{3}} = \frac{1}{2\pi fC_{3}} \end{equation} 

For the frequency 'f' in the above equation we should use the lower cutoff frequency of the amplifier which is 10kHz. It is because here the inequality is based on impedance. Therefore, if we set the inequality for lowest value of frequency, it is always true for the upper cutoff frequency as well since 'f' is in the denominator. So, we can find the minimum value for C3 as,

\begin{equation} C_{3} \geqslant \frac{10}{2\pi fR_{7}} = \frac{10}{2\pi \times 10\times 10^{3}\times 70} = 2.27\mu F \end{equation}

Value of decoupling capacitors is not critical. Purpose of these decoupling capacitors is that, they should pass the AC signals in the desired frequency range and block DC signals. Therefore 470uF will be used as the decoupling capacitor value.

Stage 03

Stage 03 is the power amplification stage. There are various transistor configurations exist for doing this. We will be using a Darlington pair which has a very high current gain. The circuitry for this stage is shown below.

Figure 4

For calculations, let's assume the following conditions.

1. VE,Q = 6V
2. IC,Q = 900mA
3. β2 = 2500

First, let's calculate R10.

\begin{equation} R_{10} = \frac{V_{E,Q}}{I_{C,Q}} = \frac{6}{900\times 10^{-3}} \approx 6.67\Omega \end{equation}

Now let's find R8 and R9. Similar to what we did for the second stage, consider the current through R9 is 6 times the base current (IB). Take R9 as 3.6kOhms. So, IB can be found as,

\begin{equation} I_{B} = \frac{I_{C,Q}}{\beta^{2} } = \frac{900\times 10^{-3}}{2500} = 0.36mA \end{equation} 

\begin{equation} I_{R_{9}} = 6\times I_{B} = 2.16mA \end{equation} 

 Now we can find base voltage (VB) as,

\begin{equation} V_{B} = I_{R_{9}}\times R_{9} = 2.16\times 10^{-3}\times 3.6\times 10^{3} = 7.78V \end{equation}

Finally, obtain R8 as,
 

\begin{equation} R_{8} \approx \frac{V_{CC}-V_{B}}{I_{R_{9}}} = \frac{12-7.78}{2.16\times 10^{-3}} \approx 1.95k\Omega \end{equation} 

Now we have completed the DC analysis and we found all the component values in each stages. The next important step is impedance matching between each amplifier stages. This is necessary for achieving the maximum performance of the amplifier. If impedance is not matched properly, signal reflections may be occurred. 

First, let's calculate the input and output impedance of each stage. Consider the stage 01. The AC equivalent circuit is shown below.


Figure 5
 
\begin{equation} R_{out} = R_{3} || \frac{r\pi +(R_{1}||R_{2})}{\beta +1} \end{equation}
 
\begin{equation} r\pi = \frac{\beta }{g_{m}} = \frac{\beta }{\frac{I_{C,Q}}{V_T}} = \frac{200}{\frac{1.25\times 10^{-3}}{25\times 10^{-3}}} = 4k\Omega \end{equation}
 
 \begin{equation} R_{out} = 4.7\times 10^{3} || \frac{4\times 10^{3} +22\times 10^{3}||27\times 10^{3}}{200 +1} = 78.87\Omega \end{equation} 

Now, let's calculate the input and output impedance of stage 02. The AC equivalent circuit is shown above (Figure 3).

\begin{equation} R_{in} = R_{4} || R_{5} || r_{\pi } = 21\times 10^{3} || 5.6\times 10^{3}|| \frac{200}{0.6} = 309.96\Omega \end{equation} 
\begin{equation} R_{out} = r_{0} || R_{6} \approx R6 = 330\Omega \end{equation}

Then, we need to find the input impedance of stage 03. But, we cannot perform small signal analysis for this. Instead, large signal analysis needs to be performed since we are after the voltage amplification stage. By the time I am doing this project, large signal analysis is out of the scope. Therefore, I am not going to match the impedance between stage 2 and stage 3. This will cause, we are not getting the maximum performance of the amplifier but still we can have a significant performance.

So, in order to match the impedance between stage 1 and stage 2, let's add a series resistor between those stages. The value of the resistor can be calculated as,
\begin{equation} R_{match} = 309.96 - 78.87 \approx 230\Omega \end{equation}

4. Simulation 

The circuit was simulated using NI-Multisim circuit simulator. Simulation schematic is shown below.


Figure 6
 
Our simulation results are shown below.
 
Output waveform for a 10kHz, 100mV peak-to-peak input signal
 
Figure 7
 
The above waveform corresponds to a 10kHz, 100mV peak-to-peak input signal. Red trace corresponds to input signal and for that channel of the oscilloscope, vertical scale is 50mV/division. The green trace corresponds to output signal and for that channel of the oscilloscope, vertical scale is 1V/division. Therefore according to the simulation, we are getting a voltage gain more than 40. 

Output waveform for a 100kHz, 100mV peak-to-peak input signal 
 
Figure 8
 
The above waveform corresponds to a 100kHz, 100mV peak-to-peak input signal. Red trace corresponds to input signal and for that channel of the oscilloscope, vertical scale is 50mV/division. The green trace corresponds to output signal and for that channel of the oscilloscope, vertical scale is 1V/division.

Magnitude Response and Phase Response
 

Figure 9
 
We could obtain a constant magnitude response in the desired frequency range and a linear phase response which are necessary for a good amplifier design.

Friday, November 12, 2021

Flag making Robots - Simulation

 1. Introduction

I have done this project on behalf of a Robotics competition. The task was to simulate the implementation of Sri Lankan national flag out of colored boxes using CoppeliaSim robot simulator, and we have used VREP PRO EDU 3.6.2 (Formally, CoppeliaSim was known as VREP). ABB IRB 4600-40 industrial robots were used as the robot arms. Computer vision techniques were used to identify the location of randomly placed boxes and for detecting color of the boxes. Further, Lua programming language was used to program the robots.

Now, let me explain how we're gonna tackle this task. First, there are cubes in the arena which have different colors (Red, Green, Yellow or Orange), placed in random locations as well as with random orientations. So, our first task is to sort out these boxes in to four bins where actually a bin can contain boxes having the same color. To solve this, we have to do several things. I'll explain how we did it. First, we detected the locations (coordinates) of the boxes using  a vision sensor. Then, using a "suction -pad" mounted on the robot arm, we pick those boxes and place them on a conveyor belt. In order to correct the orientation of the boxes, we used a simple mechanism on the conveyor belt. Then, using another vision sensor, we detect the color and finally those boxes are sorted into corresponding bins. You can learn how to perform these fundamentals with V-REP by going through these video tutorials.



3. GitHub Repository

All the project files can be found in this GitHub repository.

4. Final task simulation


Monday, November 8, 2021

Smart Time Table

1. Problem Definition

Still in most of the government schools in Sri Lanka, the attendance of teachers is marked manually. Usually, in almost-every day, some of them may be absent. So, some other teachers need to be assigned for those periods covered by absent teachers. In most of the schools this is done manually, and it takes a considerable and variable amount of time in each day upon the number of absent teachers. When the updated timetable is prepared, class monitors may have go to the office and check whether there is any such period and inform the respective teachers or there’s a dedicated person in some schools who passes the message for those teachers. 

This method has a lot of problems, and we also have experienced them. 

• In most of the times, class monitor has to inform the respective teacher. For that, first he needs to find where the teacher is, and normally this is done when the corresponding period starts. So, he may have to spend time from the period just for informing the teacher; which is a waste of time of all the students in that class. 

• If a teacher who has a class in the very first period got absent, there is a big problem. Because  assigning teachers may not have been completed by the time the period starts when it is done manually.  Also, some extra time will also be wasted until the message reaches the respective teachers.

2. Objectives of the Project 


• Identifying absent teachers quickly and soon after assigning the available teachers for the periods which should be covered by those teachers who are absent, using an autonomous system. 
• Notifying the respective teachers that they have been assigned to some classes as soon as the system determines the updated timetable. 
• Notifying the respective classes about the updated timetable. 
 
With these, our main objective is to save the valuable time of students as well as teachers by improving the efficiency of inter-personal communication with the aid of IOT. 
 

3. Solution

The following facts collectively describe our complete solution. But as the first stage, we are specially addressing how to deliver the updated timetable for respective  teachers and classes quickly using an IOT based system. Our solution is as follows. 

• Introducing an automated attendance marking system based on fingerprints.
• Designing an algorithm that assigns teachers for the periods of absent teachers automatically within a very small amount of time compared with manual procedure. 
• An IOT based system which automatically sends the message to respective teachers as soon as the above step is completed. 
• An IOT based system that sends the updated time slots with the names of the assigned teachers for the respective classes. 

The following figure shows a functional block diagram of our solution.

First, we get a digital copy of the attendance of teachers and it will be sent to a raspberry pi. Those data will be fed into a computer program which identifies the absent teachers quickly and assigning some other teachers to those periods automatically. Once this is completed, we have the updated timetable for whole school. The program takes a very small time to prepare the updated timetable, compared to manual method. Then by the server LoRa node, which is connected to Raspberry Pi, gets the updated timetables of classes one by one and transmit it to corresponding classroom. By the time the receiver LoRa node at each classroom is turned ON and they are waiting for data. One such transmission takes not more than 10 seconds. So, our system is capable of updating all the devices in the school within few minutes. So, class monitors no longer required to pass the message to teachers, and teachers do not have to wait until they received the message via a class monitor or some other person. Using the MQTT broker, we send the updated timetable data to the node red flow. Then using Twilio Messaging Service, we send the updated timetable to corresponding teachers as an SMS. 
 

4. Hardware Design

 

4.1 Introduction 

We use the client-server architecture here. The server device is located at the main office in the school while the client devices are to be installed at classrooms.When we design such a system we have to consider several factors. In our case, we considered the followings in the hardware design phase.

1. The device at classrooms should be able to drive using batteries, therefore, it should be a low power device. Hence, we need to select technologies and components precisely. Also, there should be a mechanism to automatically turn OFF the client devices when its purpose has been served. 

2.  The communication technology should have the features; a high range, and consumes less amount of power.

3. The server node should have a controller with relatively high computational power and a relatively high memory since it has to run the computer program to assign teachers and send the updated timetable to each and every class.

4.2 Communication Technology 

To establish data communication between server and client devices, we need a communication technology. In this particular application, we need a high range, and low power solution. The mostly used IOT communication technologies with above properties are ZigBee, NB-IOT and LoRa. We have chosen Lora due to several pros such as, long range (can be connected devices up to 10 miles), low power consumption, it uses license free sub gigahertz radio frequency bands (433MHz, 868MHz), availability of data encryption methods, bidirectional communication, ease of use, and finally, availability in the local market. So, we used LoRa module (SX1278) with an antenna to establish data communication between server and client devices.

4.3 Microcontroller Selection

As mentioned above, the server device should have a considerably higher computational power and a memory. Therefore, microcontrollers like Arduino may not be sufficient. Hence, we decided to use a Raspberry Pi. For client devices we do not need a high computational power. Also, it should be low power as well. Therefore, we decided to use an Atmega328P microcontroller for client devices.

4.4 Client Devices PCB design and Component Selection

The Top-level view of the client devices circuit is shown below. 

When it comes to battery, we decided to use AA batteries by considering several options such as the cost, how long it can drive our device without replacing or recharging, whether to use rechargeable batteries or normal batteries, and physical size. Since we design are going to design the circuit such that it consumes a less power, we do not need a battery with a higher capacity. Also, rechargeable batteries are not suited for this environment. Therefore, the ideal solution was using four AA batteries. By using AA-batteries we can reduce the cost a lot at the same time achieving a considerable run time. 

When selecting voltage regulators, we considered what is the required maximum current needed for driving the load and minimum input voltage that should be supplied in order to have a regulated output. A single AA battery has a voltage difference of 1.5V. To power the microcontroller we need 5V therefore, at least 4 such batteries are required. Now, we need a 5V voltage regulator which has a minimum input voltage below 6V. Such voltage regulators are called low-dropout voltage regulators (LDO) and our selection was HT7550 as the 5V LDO which has a minimum input voltage of 5.5V. For LoRa module we need to provide 3.6V. For that we will use HT7536 LDO. The maximum output current of these regulators is 100mA which is less that the required maximum current to drive our load.

As the display we will be using a 20x4 LCD character display. It should be enough for our application because in general no classes may have more than 4 different free periods in a given day. 

We designed an automatic shutdown mechanism as well. It is required because some time after the message receives, the students are aware of their free periods in that day. So, there is no need of displaying it throughout the day. So, we implement our device s.t it automatically shutdowns after a given time-period. 

Altium Designer 2021 was used for Schematic and PCB design. The schematic diagram and PCB designs are shown below.
 




5. Mechanical Design

Mainly the mechanical design part of our project is designing an enclosure for the client device which places in classrooms. SOLIDWORKS 2020 was used as the mechanical design software. As the initial step of  the mechanical design, we came up with few design considerations. 

1. The device should be user friendly, and its appearance should be good enough, because one of the students are the ones who operate it. 

2. The device should be small enough to be kept on a table. 

3. The indications by the device should be clearly visible. 

4. Since the device is battery driven, replacing the batteries should be easily done. 

5. Weight of the device should be small. 

The designed enclosure is shown below.


6.Software Interface

6.1 MQTT 

We used MQTT protocol to communicate between the device and Node-Red flow. After generating updated time tables by Raspberry-Pi, they need to be sent to respective teachers via an SMS. We used MQTT broker as the interconnection of this process.

6.2. Node-RED

We used Node-Red to connect the messenger service with the Raspberry-Pi. The message is sent as a Jason object to the Node-Red flow and then edit it with the relevant order in the flow. Then Twilio SMS pallet is used to send the message to relevant teachers.

7. Demonstration of the Concept


Popular Posts