For this week assignment, we had to make a board that could read a sensor and show the value in the computer for example.
I my case, I chose to read distance with a ultrasonic sensor.
More precisely, with a HC-SR04, a very simple sensor that work with two digital pin,
one that make the sensor send a "pulse" and the other one that we have to ear to know in how much time the sound come back.
This sounds very well, but by experience I know that this kind of sensor doesn't work well when there is a liquid because I think that the dissipate the the sound.
Finally, the microcontroller make this operation,
distance=time x SpeedOfSound / 2.
For my board, I decided to make a pinout that was compatible with the sensor, to be able to solder it directly on the board changing the pin headers from through holes to superficials pin headers.
The board is in essential, a Fab Echo Board, but with the ability to read the sensor and with two more digital pins that could be use for a buzzer or for two LEDs as in my case.
Next to the two digital pins I added a ground and a 5V output to be able to connect it to a protoboard or with a cable to another board.
For the routing process, I used as a width 14 and used as you can see some 0 home resistors as "jumpers".
As always, you have to change the routing that you do while you generate the nc code in the fab modules because it is only like that,
that you can see if connexions are to near and will be connected in the milling process.
Finally to export it to fab modules, I choose PNG format, and 1500 dpi.
As always, I used the fab modules to generate my Gcode for the roland, because in my opinion it is the most easy way to generate it.
What is interesting of the fab modules is that you can see the trajectory of the end-mill and see if the connexions are going to be incorrect.
In this case, even after many tries, I have not been able to correct the small connexion between the 0 ohm resistors and the path that goes through.
To correct that, with a cutter, I cut it once the board has been made.
As parameters, as always, 3000 dpi, 4500 rpm, coolant off, number of offsets 4, and cut depth 0.16mm.
It is the first time that I change the offset parameter and I have been very happy with that,
because it makes the space between the paths and the rest of the cooper more important, so the risk of a short is much less.
Download Traces: Traces
Download Outline: Outline
For the milling process, as always, I used a 1/64 end mill, I used some double tape to stick the board to the rolland and as a good advice, I usually clean the zone where I am going to stick the board with some alcohol and also the back of the board to make sure that the force made by the end-mill during the milling process don't make the board move because in this case it would make the paths less precise.
The process took a bit more time than usual because of the the offset of 4. However, as you can see the result have been quite good. In the top right hand corner, you can see that the copper was a bit strange but with a cuter, all this copper has been removed and the result of the board has been nearly perfect.
For the outline, I used a 1/32 end-mill. This part of the process, is always a headache because there is an important risk that because of the force made by the end-mill, the board start to rotate around it. It is for this reason that even if I know that it is dangerous, I decided to apply some pressure on the board during this part of the process, as well as reducing the plunge speed to 1 mm/s instead of 2 mm/s.
After all the milling process, I removed the borders with the help of a clamp and I tried to remove the double tape, which has been very difficult because the one that we have in the lab is very sticky and I had to use lot of alcohol and a cuter to remove the whole thing. Finally as I mentioned before, with a cuter I removed all the imperfections.
Once the board finished, it is a good practice to take your board design and double check everything because once soldered, it will be very difficult to check all the details and you will probably lost hours trying to troubleshoot something, most the time simple to resolve. You can also use a multimeter in continuity mode to check the connexions.
The soldering process has been very easy, it took me around 20 minutes to solder the whole thing. However, it has been much harder to desolder the pin headers from the ultrasonic sensor to resolder some superficial pin headers. It is like that, that I learnt that it is easier to solder something rather than having to desolder it because it this case, there were tin in both sides of the sensor connector.
To test if all the conexions were correct after the soldering process, I made three things. The first one is to check continuity with my multimeter, the second one is to see if I can upload a sketch into my board. Finally the last test, is to check if all the outputs works. For that, I made a very simple circuit with a LED in serie with a resistor, which I will switch on with each of the digital pins available. In this case, everything worked great from the first try.
To test my new board with the sensor, I decided to first use a protoboard because I was not sure if the sensor worked well. After some connexions done, everything looked fine and it was time to upload some code. In this case, as you can see, I connected directly a LED to the digital output using a current limiting resistor (you can calculate it here: LED Resistor Calculator) and at the other side connecting it to the ground. What is much more obvious but important to say is that, I connected the FTDI cable because it is thank to this cable that you will receive the information from the sensor in the serial monitor or in the serial plotter. When you have to program your board, you have to connect it to the programmer with the SPI cable. Please make sure to do not connect it in the wrong side because it will cause a short and you will receive an error message in your computer telling you that you are asking to much power in the USB port.
For my code, I decided to use the NewPing library and the SoftwareSerial library because the NewPing code was for some reason much more precise than the code that I did myself earlier.
In the case of the SoftwareSerial, it is for the communication between the microcontroller and the computer because in this case the ATTiny44 doesn't have a Hardware Serial.
Please have care using this library, when you declare the name of your Serial communication (ex: SoftwareSerial mySerial (rxpin,txpin);)
don't use "Serial" as the name of it because it could cause a conflict with the Serial command and you will lose a lot of time trying to debug.
The difference between the two code that you can download, is that in one case it make it easy to read the distance in the serial monitor and in the other case, it only output the value (number) to make it possible to see the data in the serial plotter.
Code: Serial Monitor Output
Code: Serial Plotter Output
As always, here it is very important to choose your board which is in my case the ATtiny44, for the clock, to choose 1 Mhz, Otherwise when you will want to see the data through the Serial Monitor it will not work (I really don't understand why because if it is because the resonator doesn't work or because I have not soldered it well, if I choose external clock, in the arduino, the board should not work) but it does. To test that it works with the resonator, I used the LEDS and the protoboard that you saw earlier. Finally your programmer and you are good to go.
As you can see, in the serial monitor, you are able to see the data that the sensor reads (or at least the result of the calculation made with the data taken by the sensor). To read the data, make sure that you select the correct baudrate because otherwise you will only have data that is simply impossible to understand.
To finish the board, I had to solder the sensor to the board, which sounds very easy but it has been a very frustrating part of the process, because I had to change the through hole pin headers of the sensor by SMDs pin headers, and to desolder those pins. The desolder process, has been very long, and difficult because the pins had tin in both sides of the board, when trying to soldered it, the copper of my board started to separate a bit from the board because the sensor was a bit heavy for the width of my routing. So yes, it worked but it has been a very frustrating process. The JP6 connector was simply two digital Pins that the ATTiny44 had with a 5V output and a GND, and I thought that it could be useful to put them there in case I could need them one day. In this case I used the connector with three jumpers (Two digital and GND) wires that you see connected to a protoboard to switch on a red and green led in case the distance between the board and the obstacle are at more than 20cm (red) or less (green).
For this week group assignment, we had to see how was a digital signal, and how was an analog signal (in a graphical way) is. As we can see in the oscilloscope, the analog is basically a signal that goes from 5 to 0V or 0 to 5V (it depends of the logic level of your microcontroller, it could have a 3,3V logic level). The signal could have a sinusoidal shape or a more linear one as mine. Finally, the digital signal is basically 1 or 0, which is 5V or 0V in electronics (once again it depends of the logic level of your micrcontroller). A digital signal, if switched very fast, is called a square signal because the on, off process makes squares because it goes up and down. If this square signal is controlled in the time, it is a PWM signal.