Input Devices


Group Project

Individual Project


Learning outcomes:


Have you:

Week workflow

Study Neil's input boards → Decide what type of imput → Design Schematic/Boad → Mill the board→ solder components → debug → edit and publish website


Tools used


Software Used


Files

  1. Eagle files
  2. G-code files
  3. Code files

Group Assignment

Go to group assignment page


Individual Project

This week I will be testing a thermistor. Since I am building an incubator I will be needing to measure and control temperature.

The thermistor I chose is the B57560G0104, after reading its data-sheet I learned that at 25 degrees Celsius it has an resistance of 100K.

The way the thermistor works is by decreasing its resistance as the temperature increases. Because the IC on its ADC pin reads voltage not resistance we need to set a voltage divider in other to derive its resistance.

I will connect the Thermistor in series with the resistor that will be connected to VCC. One end of the thermistor will be connected to ground and the other that is in series.

Hero shot of my board and temperature sensor


References

As done on week 6 I started by reviewing Neil's boards. The one I would be redesigning is the visible light input board.

Professor Neil's light board


Experimenting with an Arduino

My objective with this experiment was to understand and test the thermistor and the code. I got it working but the temperature was not really accurate. Off course I am not using accurate instruments to calibrate the thermistor so I never know what is not correct so I ended up boiling water so I would know at least the temperature needed to be around 100 degrees Celsius.

Boiling water with soldering iron. thermistor inserted on the liquid.

detail of thermistor and temperature probe together.

Programming the Attiny with a USBasp

Programer USBasp on a ATtiny45

In the video below I show the programming taking place.

High res video on Youtube


Experiment with the board I designed

Hero shot of my board and temperature sensor


Designing the PCB

The attiny45 datashet here

Because I normally program with Arduino IDE it's quite useful to have not only the data-sheet but also a diagram that converts the pins from one programing platform to the other.

On a quick look we can determine that there are 4 Arduino analog pins. They all have a analog to digital converter (ADC0, ADC1 ADC2, ADC3), so they could also be used as digital pins together with pins 1, 0 and 2.

For this assignment I will need 1 analog pin and 2 digital pins. The analog pin I will connect the thermistor and the digital pins are for the serial communication.

The board will have a header for the ISP programmer, 2 headers in the sides so all pins can be used and tested as needed as well as a led just to show there is power coming in.

Autodesk Eagle is the weapon of choice. but I will be creating the G-code with pcb-gcode addin.

Resistor calculations

In order to calculate the resistor values, I examined the following Datasheets and the calculations/observations I made:

Green LED

datasheet extraction

resistor calculation

Bellow is how my schematics looks like:

Schematics of with Attiny45

The thermistor board

On my thermistor board I used:

  1. Vishay Dale NTHS1206N01N1003KE NTC 100KOHM 3964K 1206, datasheet here.
  2. And a 100k resistor as a pull-down resistor

The way the a NTC thermistor works is as the temperature raises the resistance reduces and vice-versa, so we need to find out the resistance.

We will then have to use a resistor to help us calculate the voltage drop. The IC used the ATtiny45 doen't measure resistance so in order to calculate the resistance of the thermistor we'll have to use a known resistor and measure the voltage coming and calculate the voltage drop between the thermistor and the 100k resistor. The formula I used in the program is this: RT = ((VCC*R-R*VRT)/VRT)

Attiny45 input devices board

Schematics of thermistor board

Thermistor board design

Code for the attiny45

I used 3 sets of code for this assignment.

  1. software serial sources: source1 source2
  2. Because I could not use regular hardware serial on the attiny it was necessary to include a library to make this function available:
                    #include "SoftwareSerial.h"
                    SoftwareSerial Monitor(1, 0);
    
                    void setup() 
                    {
    
                    Monitor.begin(9600);
    
                    pinMode(0, OUTPUT);
                    pinMode(1, INPUT);
                    }
                    

    also when you whant to print something you need to do it in a different way:

                    Monitor.println(whatever you what to print here);
                    
  3. temperature collection with Arduino
  4. The code I used for the experiments with Arduino I found on the Arduino's project hub How Easy Is It to Use a Thermistor?! authored by Marcazzan_M:

    //Thermometer with thermistor
    
    /*thermistor parameters:
     * RT0: 10 000 Ω
     * B: 3977 K +- 0.75%
     * T0:  25 C
     * +- 5%
     */
    
    //These values are in the datasheet
    #define RT0 10000   // Ω
    #define B 3977      // K
    //--------------------------------------
    
    
    #define VCC 5    //Supply voltage
    #define R 10000  //R=10KΩ
    
    //Variables
    float RT, VR, ln, TX, T0, VRT;
    
    void setup() {
      Serial.begin(9600);
      T0 = 25 + 273.15;                 //Temperature T0 from datasheet, conversion from Celsius to kelvin
    }
    
    void loop() {
      VRT = analogRead(A0);              //Acquisition analog value of VRT
      VRT = (5.00 / 1023.00) * VRT;      //Conversion to voltage
      VR = VCC - VRT;
      RT = VRT / (VR / R);               //Resistance of RT
    
      ln = log(RT / RT0);
      TX = (1 / ((ln / B) + (1 / T0))); //Temperature from thermistor
    
      TX = TX - 273.15;                 //Conversion to Celsius
    
      Serial.print("Temperature:");
      Serial.print("\t");
      Serial.print(TX);
      Serial.print("C\t\t");
      Serial.print(TX + 273.15);        //Conversion to Kelvin
      Serial.print("K\t\t");
      Serial.print((TX * 1.8) + 32);    //Conversion to Fahrenheit
      Serial.println("F");
      delay(500);
    
    }
                    
  5. My version on the code contains both the software serial and also part of Marcazzan's code as the attiny would not compile with both the software serial and the log calculations. The code had to then be limited to only 4k after compilation.
  6. the code here

    #include "SoftwareSerial.h"
    #define VCC 5    //Supply voltage
    #define R 100000  //R=100KΩ
    
    float RT,VRT,VR;
    
    SoftwareSerial Monitor(1, 0);
    
    void setup() {
    
    Monitor.begin(9600);
    
    pinMode(0, OUTPUT);
    pinMode(1, INPUT);
    }
    
    void loop() {
    VRT = analogRead(3);              //Acquisition analog value of VRT
    VRT = (5.00 / 1023.00) * VRT;      //Conversion to voltage
    VR = VCC - VRT;
    RT = ((VCC*R-R*VRT)/VRT);               //Resistance of RT
    
       // Monitor.println("Voltage Read:");
       // Monitor.print(VRT,10);
       // Monitor.println("Voltage drop:");
       // Monitor.print(VR,10);
       Monitor.print("Resistance:");
       Monitor.println(RT);
       
      delay(1000);
    }
                    

    Aso his formula of finding the resistance did not work for me I suspect it is because I use a NTC thermistor, so I had to modify the formula and it looks like this now:

                    RT = ((VCC*R-R*VRT)/VRT);               //Resistance of RT
                    

Designing and making the PCB

Since I modified my work-flow I decided to update it. Now It contains the usage of PCB-Gcode ULP and Autoleveller software usage.


Autodesk Eagle Design

With the schematics ready click on:

  1. SCH/BRD this will open a dialog
  2. On the dialog click on yes in other to place the components next to what will be the board space.

With the components placed next to the square that represents the board, the board will be resized later.

Typing "move" then "pressing enter" alows you to click on each component and drag it to insid the board.

Here I started dragging the attiny45 inside the board limits. Again, clicking each component won't require typing "move" again, unless "esc" is pressed or another command.

Here all components are dragged and the superior limits are being dragged and resized with the command "move" ass well. Another way of moving components is typing "info" and then left clicking the component, this will allow typing the coordinates of the element instead of dragging.

The command "rotate" will alow you to turn the component to the ideal orientation routing the wires is more eficient. The yellow lines represent the connections created in the schematics part.

Here I am creating a contour with the command polygon, when its closed it will open a dialog box.

After the polygon is finished the dialog will open typing "GND" connects the polygon to ground.

Typing ratsnest of clicking its icon will fill up the hole board area with the ground layer so now either by typing autoroute or the net command the components can be connected.

Now before routing the components go to edit --> design rules and there the distances between each element can be defined.

In the tab sizes define the minimum with of wire. On my experience 0.2mm works great.

The tab clearance sets the distance between each element of the pcb I am sing currently 0.3mm on all Signals.

Now with all design rules set typing autorouter or clicking its icon will start the process of connecting each component.

An important setting is clicking on the dialog box labeled bottom and selecting N/A if not desired two sides. Then pressing willl start the process.

Next chose one of the option and then click on evaluate or end job in order to go back to the board layout.

I circled in yellow to show the bottom layer of the board in blue. I do not want this so I will reset the board in the next step.

Here you can see the effect of the command "ratsnest". This command will basically fill up all the spaces not occupied by a via with the ground element.

Because I want autorouter do it over I typed "ripup" and then I selected all so all routes are undone.

And redo the autoroute process.

Here the route is done but not yet with ratsnet.

Here ratsnest is applied.

In here I moved the components around in oder to shrink the board a bit. This is basically done with the command "move" If you what to move numerous components select them and type group then type "move"and right click them to move the hole group.


Ratsnest dilemma

Bellow you can see a board with and without ratsnest.

The first board has ratsnest on. Its a bit more cluttered. One advantage is thermal, having a greater copper surface glows for cooling of the board as well as larger conductivity specially in 2 sided boards as one side can be ground and the other side can be for VCC making almost all surfaces for power transfer. The second board looks cleaner.

I currently prefer making boards without ratsnest, because manual soldering can be imprecise and short circuits are easy to happen and the ratsnest feature can increase that.

The thick light blue contour drawn with the layer "milling" is used by the ULP pcb-gcode to create a G-code milling contour, the software will use that to create the limits and the cut can be used to detach the board from the copper stock. The thickness of the polygon will define the milling bit size.


Board BOM

qty Location Digikey or MouserPart number Manufacture Part # Description
1 U1 ATTINY45V-10SU-ND ATTINY45V-10SUR IC MCU 8BIT 4KB FLASH 8SOIC
2 R1 311-10.0KFRCT-ND RC1206FR-0710KL RES SMD 10K OHM 1% 1/4W 1206
1 R2 311-100FRCT-ND RC1206FR-07100RL RES SMD 100 OHM 1% 1/4W 1206
1 D3 160-1169-1-ND LTST-C150GKT LED GREEN CLEAR 1206 SMD
1 C1 445-1423-1-ND C3216X7R1H105K160AB CAP CER 1UF 50V X7R 1206
1 FTDI 6 pin header
2 Headers 1X4P

PCB-Gcode

A while back I started using the User Language Programs(ULP) called PCB-Gcode its a great program alows many settings that I discovered in part reading the documentation and in part with trial and error.

Bellow I show how I setup it for a smooth G-code creation.

  1. Click file
  2. then Run ULP
  3. then click pcb-gcode-setup

The settings that I customized are:

  1. I chose to generate only top outlines and top drills: -the first is the generation of the board G-code to cut off the board from the stock. -the second is the holes the board might have. the thickness of the mill bit or drill is chosen in the machine tab
  2. here we can set the board thickness, my boards are separated well with 1.72mm cut. and the "num Slices" I chose to do 6, these will mean the board will be cut off in 6 passes.
  3. Spot drill holes are light markings made while eching the via and all features of the board design, it serves the purpose of alignment of the drill bit that can be used to drill the hole and prevent the bit heat from sliding on the board. My choice is 0.055mm the same I have for etching.
  4. Isolation was one of the most important settings. This settings might make your computer slow down a lot if the maximum is set to hight, what works for me is: -minimum 0.0254mm (default); maximum 1.5mm; step size 0.05mm. The last one together with maximum will ensure 30 passes that will make sure there is no coper in between the traces and they are sufficiently isolated reducing the risks of shorts.These numbers could be an exaggeration but it is working very well and I am obtaining gorgeous boards. In the future I might reduce it or increase the step size.

In the Machine tab there are settings like: depth of cuts, unit, feed rates and tool diameter are chosen.

  1. - Z high is set to 12.7 (default), this setting should allow clearance for fixtures that could be in the way; -Z up is the clearance from the board when moving from location to location; -Z down is the depth of the cut. This number is very important in my case because I use a 10 degree V bit if I go too deep I cut more than I should and if to shallow I cut less. Of course 10 degrees is not too steep and is more forgiving than a depth mistake with a more steep etching bit; - the drill depth is the depth of the thought hole s, and it should be generally a bit higher than the thickness of the blank pcb to account for imperfections; Drill dwell is the pause between each hole, it allows for cool down of the drill bit, I leave it default.
  2. Here I set the unit as mm
  3. All my etching feedrates are default
  4. The tool diameter I use is 0.1 mm

The G-code style tab is used to chose the post processor. I use Mach3.

Here is the visualization of the G-code provided by the ULP, arrow can be used to move around the image as well as plus minus signs.

4 files get generated

  1. *.bot.mill.gcode: it is the bottom milling (contour), I do not use this file.
  2. *.top.drill.gcode: is the G-code for the holes
  3. *.top.mill.gcode: is the file for the top layer contour, these file will allow detaching the pcb.
  4. Finally *.top.etch.gcode is the G-code of the etching of the pcb containing all the features designed.

Bellow is the thermistor board isolation visualization.


Autoleveller

Autoleveller is a great software. By probing the blank pcb and then using the file generated to adjust the depth of cut of the G-code, it ensures the milling machine will follow the relief of the blank pcb. I start Autoleveller runing its executable, there is no instalation needed on linux. Next click File and then Original G-code File (OFG): this will alow loading the original G-code in the program.

Click in the original G-code.

Click yes so the settings will be based on the file loaded

Next click on Generate PFG on the botom right of the window, this will create a G-code with a set of instructions, it will: -first probe the Z 0; -second probe several points in the area of the board; - tird it will ask for a location in other to save the raw file, that will later be used to create the autoleveled G-code.

This is the PFG file being saved. Next load this G-code to the cnc and follow the intructions on the G-code area.

Now its the time to attach the blank PCB to the CNC bed. I am no longer using double sided tape as its not as effective as the fixtures, also there is the need to clean up the leftover tape later.

In my cnc I have machined a pocket prior so the board has a fixed location, that helps immobilizing the blank.

In the CNC with the PFG loaded follow the instruction on the screen by attaching the probe.

Here I am attaching the probe to the surface of the board and the the alligator clip to the mill bit.

This video shows the probing process.

With the probing done save the raw file and take it to Autoleveller and load it.

Load the raw probe file back into the autoleveller.

Last save the adjusted G-code by clicking Autolevel on the bottom right of the screen. Save the file and take it to the CNC for the milling process to begin.

Machining process videos

Slow motion video of etching (milling) process.

The final result is here, sometimes I use sandpaper 1000 grit to give it a better finishing.

Now I am going to show the boarder being cut.

Milling the board boarders

The results

Thermistor board just before soldering.

thermistor board after soldering and cleaning with isopropil alcohol.

Attiny45 board plus the thermistor board ready for work.

Foot notes

avrdude -Cavrdude.conf -v -pattiny45 -cusbasp -Pusb -e -Uefuse:w:0xff:m -Uhfuse:w:0xdf:m -Ulfuse:w:0xe2:m

serial monitor : https://www.youtube.com/watch?v=9CX4i6rMXS8

attiny fan controler project: http://www.robotroom.com/DualFan.html

reads temp with arduino and ntc thermistor https://circuitdigest.com/microcontroller-projects/arduino-thermistor-interfacing-code-circuit

setup arduino 022: http://highlowtech.org/?p=1229

reflow oven project: http://pleasantsoftware.com/developer/3d/reflow/

pul up resistor (RES SMD 10K OHM 1% 1/4W 1206) from RST to VCC

decoupling capacitor (CAP CER 1UF 50V X7R 1206) from VCC to GND to reduce noise