Home About Me Weekly Projects Final Project

Input Devices


COUNTDOWN





Assignments



For this week we had to mill a new PCB and use input devices. Input devices are anything that can feed the microcontroller data which in turn is used for various other actions (Outputs).

We had two assignments this week, a group assignment and an individual assignment.

Group Assignment


For the group assignment we had to measure analog levels and digital signals in an input device. This task is pretty straight forward and since we are only two students in the lab we both completed the assignment together.

Analog and Digital Signals in an input device

The assignment this week was to Measure the analog levels and digital signals in an input device. So our idea was to compare two sensors that would achieve the same job, or solve the same problem. One of them is digital and the other is analog.

We choose to use two sensors that measure:

  1. The UltraSonic Sensor (HC-SR04): Digital Sensor
  2. The Infrared Sensor (SHARP 2Y0A21): Analog Sensor

In order to use the sensors, we first checked the datasheets of the ultrasonic and the infrared sensors.

Testing the Ultrasonic Sensor

So the ultrasonic Sensor is considered to be a digital sensor because the microcontroller reads a digital signal from it. How the Ultrasonic mainly works, is by emitting an ultrasound at 40000 Hz which travels through the air and if there is an object or obstacle on its path, it will bounce back to the module. Considering the travel time and the speed of the sound you can calculate the distance.

The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The GND and VCC pins of the module need to be connected to the GND and the 5V pins on the Arduino Board respectively. Lastly the trig and echo pins to any Digital I/O pin on the Arduino Board.

In order to generate the ultrasound you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound wave traveled.

Testing IR Distance Sensor

The distance sensor produced by Sharp is a popular and relatively low cost solution for measuring distance. In this test we will use the 2YOA21 model and the characteristics of this sensor are:

  1. Minimum Measuring Distance = 10cm
  2. Maximum Measuring Distance = 80cm
  3. Infrared Proximity Sensor
  4. Analog output inversely proportional to distance
  5. Sensor is Ratiometric
  6. Operating Supply Voltage = 4.5V to 5.5V
  7. Average Supply Current – Typical = 30mA
  8. Response Time = 38 ± 10ms

The IR distance sensor is connected to a voltage supply, and connected to an analog input to the micro-controller. The microcontroller reads an analog signal, which is technically a value of voltage between 0 and 5V. Based on the value recieved you can deduce the distance between the sensor and an obstacle.

Comparing Results

Concerning the Ultrasonic Distance Measuring sensor, you can easily read the information from it on the Serial Monitor, as the signal received from it, is a digital signal, which is converted directly with the help of the existing libraries into the measurements and numbers we need.

However, on the other hand, with the InfraRed Sharp Distance sensor, it is a bit harder to get data from it, because you need to calibrate it first. The IR sensor sends analog data to the Arduino Board, which is technically a variation of the voltage. Thus, what you can read on the serial monitor is a variation in voltage. To convert that into readable information, we should check the values we read with respect to various set distances and calibrate accordingly.

The video represents how the signal is sent and received from and to the arduino board. The signal received at the ECHO signal by the arduino board is a digital signal that represents the variation in distance. On the other hand, the picture represents how the signal is received from the IR sensor. It is mainly a voltage level that variates according to the distance.



You can check the full assignment by clicking on the following link:

Group Assignment

Individual Assignment


For the individual assignment we had to measure the signals of at least one input device by adding it to a microcontroller. That would in turn be added to a PCB.

Since this week is followed by Output week, I decided to mill my PCB to include the output devices I was gonna use. Because I am using these weeks to further experiment on something related to my final project, the outputs in my case are water pumps, and therefore had 2 relays as outputs.

Find the steps taken below:

  1. First a brief list of the tools needed/used:


  2. Before going on manufacturing my PCB, I wanted to test the input devices on the arduino. I tried 2 main inputs
  3. Now that the input sensors have been identified, it is time to mill the new PCB to handle these two sensors. Since I was looking for effeciency, I had additional pins sketched to be able to add a relay module that would be further explained in the Output as it is part of my final project.
  4. To design the new PCB, I followed the design of the Satchakit which uses an ATMEGA328p and know I need 4 Signal pins for the inputs and outputs and their respective VCC and GND.
  5. Now we need to identify which components should be taken into consideration to have a functional PCB
  6. Now coming to the actual design of the PCB, I used the Eagle software which had a final design that is shown below:


  7. Schematic

    Schematic

  8. Once the design is complete, Export the file in PNG format and open it on GIMP which is used to generate the inner and outer traces to mill the PCB. The inner traces should look like the following:


  9. PNG Gimp

  10. Once the GIMP photos have been generated, inner and outer traces. Go to Fabmodules to generate the .rml code for the specific milling machine that would be used (Roland MDX-40 in this case). To know exactly how to do so go through the previous weeks to know the exact step by step process.
    PCB milling steps
  11. Once the PCB is milled it is time to move on to the next step, Soldering.
  12. Now that the PCB is ready, the next step is to program it.
  13. Now that the PCB is programmable, time to start experimenting with a few inputs.



  14. And last but not least Happy milling and Coding.



Downloads



Eagle .brd file

Eagle .sch Schematic file

Crash Sensor Arduino Code

Ultrasonic Sensor Arduino Code