1. Assignment:
SELECT SENSORS:
In this assigment I tried to select senors that I will use in my final proyect. It does, that the first was know to do my dino-robot, initially, It should follow a line untile it reachs an object and stand. According to the research I did for my final proyect (which you can see HERE) and focusing especially on the project of a student of FabAcademy of 2016 - Carlos Andres Moreno Molina. I will use two types of sensores:
- SONAR: It will cause the robot detects an object when it is in front of it by means of the sound as shown in the class video
- PHOTOTRANSISTOR: It will cause the robot diferentiate between changes of light, in my case as it has to be a little more detailed I must use the phototransistor with a led as shown in the class video
DATA SHEET INFORMATION:
Once I had decided the sensors needed the specific choice of these and the information I would find in the datasheet.
- SONAR HC-SR04 : the same as seen in the class example, I quickly found the datasheet, which surprised me that it only had 3 pages, much less than the datasheet of the microcontrollers we had seen. HERE the datasheet link.
The information I used mainly was, what was each of the pins? because I didn't quite understand that it was "TRIG" and "ECHO"
And how far away could the signal read. All this is shown in the following table.
- PHOTOTRANSISTOR PT15-21C/TR8 : The inventory offered 3 types of phototransistors I decided on the second one that looked a lot like the PT15-21B / TR8 but with a transparent coating instead of black.
My guru explained to me that this transistor acts as a variable resistor so that you need a fixed resistance and the pin between these two resistors to collect the potential difference and thus read the sensor data. HERE the datasheet link.
What struck me most about these datasheets were the soldier specifications.
DESIGN THE PCB:
The design of the schematic is done in Eagle, which seemed much simpler than the output board. In inputs you just need to put components apart from the sensors themselves, the microcontroller and the connections to program.
List of components:
- ATmega168
- FTDI header
- 3 pin x1
- Xtal 8Mhz
- Led azul
- Res 100 Omh
- 2 Res 10 KOmh
- Cap 1 µF
- Cap 0.1 µF
- Sonar HC-SR04
- Phototransistor PT15-21C / TR8
One of the elements that give me most problems is the ISP connector, especially when creating the traces, so I decided to use 3 pads for: MISO, MOSI and SCK and loose pads for RESET, GND and VCC. Finally, this is the schematic.
The design of the traces for the PCB I made in Eagle from the schematic, its structure is quite simpler than the one made in outputs, I hardly had problems, for example, with the cutting rules.
IMAGE EDIT:
In order for the milling machine can realize the circuit, first the engraving with a 1/64 milling cutter, and second the cut with the 1/32 milling cutter we need the file in PNG format. Eagle allows exporting the model in black and white.
To prepare the model correctly use Inkscape, where I put a white border so that later the cut is made at this edge. One of the problems that arose to me was the cut of the holes for the pads because to have the numbers in the center doesn't leave enough the hole so that between the strawberry. To solve what I did was to put Inkscape circles one by one.
At the time of milling and soldering I had no problems leaving me a pretty plate.
For this week I can only program the sonar, but for the final project I will use the other sensor that is the phototransistor, to see how it works you can go to week 17.
PROGRAMMING
const int EchoPin = 18; const int TriggerPin = 19; const int LedPin = 13; void setup() { Serial.begin(9600); pinMode(LedPin, OUTPUT); pinMode(TriggerPin, OUTPUT); pinMode(EchoPin, INPUT); } void loop() { int cm = ping(TriggerPin, EchoPin); Serial.print("Distancia: "); Serial.println(cm); delay(1000); } int ping(int TriggerPin, int EchoPin) { long duration, distanceCm; digitalWrite(TriggerPin, LOW); delayMicroseconds(4); digitalWrite(TriggerPin, HIGH); delayMicroseconds(10); digitalWrite(TriggerPin, LOW); duration = pulseIn(EchoPin, HIGH); distanceCm = duration * 10 / 292/ 2; return distanceCm; }