WEEK11: INPUT DEVICES

ASSIGNMENTS:

 

Individual assignment

  • Measure something: add a sensor to a microcontroller board that you have designed and read it

   Group assignment

  • Measure the analog levels and digital signals in an input device

DESIGNING BOARD FOR FINAL PROJECT

  • Input devices week assignment is to measure something with microcontroller and sensor, and my final project also consists sensor, so I have decided to design board for my final project and use the same for this week's assignment
  • So first task to design board for final project is to list down what are the operations required to be performed by board and control of those.
  • My final project is fundamentally to melt plastic and extrude it into filament of 1.75mm   diameter. This will required heater to melt plastic and temperature sensor to measure the temperature, also the motor to extrude plastic filament from pipe by means of augur screw-pipe mechanism.
  • So, basically 2 types of control I will require, heater temperature, motor rotation to control right flow-rate extrusion.
  • I have referred such project done by open source community. Very good references I have got to understand this mechanism and work-flow are as follow.
  • Felfil Evo
  • Filastruder project on instructable
  • Filament factory by Ianmcmill
  • Stephano Paradiso from FabLab Torino

STEP01: Listing down components and sketch the circuit on paper

  • As I got clarity about operations and controls I understood what components I will require. List of components are as below.
  • Very good tutorial on interfacing circuit is given here which I referred.
No. Item Name Particular Quantity Description
1 Microcontroller Atmega 328P-AU 1 I used 328P because I am planning for further development of this project by connecting this with delta printer or desktop robot at my lab. I think attiny44 might also work just to extrude filament as that have 2 pwm pins as well, but 44 has limited i/o pins.
2 Mosfets Mosfet N-CH 3 To have control of cartridge heater temperature
3 Resistor for mosfet 1k Ohm 3 To switch between different values
4 LED Green 3 Interfacing circuit requirement
5 Resistor for LED 499.9k Ohm 3
6 Diode 3.3V 3
7 Crystal 16MHz 1 To use as external clock for computation
8 Capacitor 22uF 2 Interfacing circuit with Crystal
9 ISP header 6 pin 1 To program board with FabISP
10 FTDI header 6 pin 1 To program board for serial communication (Rx-Tx)
11 Switch Button switch 1 For Reset
12 Resistor for switch 10k 1 Switch resistor
13 Voltage regulator 5V LM1117 1 To convert voltage between 5V and 12V
14 Capacitor 10uF 2 Interfacing with voltage regulator
15 LED Green 1
16 Resistor 499 Ohm 1
17 Temperature sensor 100k NTC thermsitor 1 I wanted to measure temperature in range above 200 degree celcius, so I have to use 100k NTC
18 Resistor 10k Ohm 1 To connect with thermistor
19 2 pin header 2 pin 4 1 for thermistor, 3 for cartridge heaters
20 Motor driver L293D IC 1 To run and control DC motor
21 DC jack 12V pin 1 To connect 12V dc convertor
  • Next thing I have to do is to make connections  and sketch general circuit diagram on paper.

STEP02: Understanding Micro-controller ADC operation for 328P

  • Basically, for this week I am going to use Thermistor as input device, and thermistor uses ADC module of micro-controller, below is how it works.
  •  
  • Micro-controllers basically understands digital data as in form of 0 and 1 directly, if we need to interpret some non digital data, we required to convert analog data into digital, and that can be done by ADC module in MCU.
  • Atmega 328 MCU have 8 ADC (6 in PDIP package) input channel.
  • Apart from 8 ADC channels available on pins, there are also three internal channels that can be selected with multiplexer decoder. These are: temperature sensor-channel 8, band gap reference-1.1V and GND-0V.
  • Detailed study documentation is done on ADC in Atmega 328P datasheet, from page number 305.
  • ADC conversion happens in 3 phase or way. In single conversion micro-controller conversion starts and then stops, while in free it is constantly converting.
  • ADC Prescaler
  • The ADC needs a clock pulse to do its conversion. This clock generated by system clock by dividing it to get smaller frequency.
  • At higher frequency the conversion is fast while a lower frequency the conversion is more accurate.
  • So the Prescaler is provided to produces acceptable frequency for ADC from any system clock frequency.
  • ADC Channels
  • The ADC in ATmega32 has 8 channels that means one can take samples from eight different terminal.
  • And can connect up to 8 different sensors and get their values separately.
  • ADC Registers
  • The registers related to any particular peripheral module(like ADC, Timer, USART etc.) provides the communication link between the CPU and that peripheral.
  • One can configure the ADC according to need using these registers, and also get the conversion result using appropriate registers. The ADC has only four registers.
  • ADC Multiplexer Selection Register – ADMUX : For selecting the reference voltage and the input channel.
  • ADC Control and Status Register A – ADCSRA : As the name says it has the status of ADC and is also use for controlling it.
  • The ADC Data Register – ADCL and ADCH : The final result of conversion.

Measuring temperature:

  • Selecting the Temperature sensor channel by writing ADMUX.MUX[3:0] to '1000' enables the temperature sensor. The internal 1.1V voltage reference must
  • also be selected for the ADC voltage reference source in the temperature sensor measurement
  • Atmega 328P has Port C alternative function pins available for ADC

STEP03: Working with Eagle

  • Once I got to know about circuit flow and components I start making schematic in Eagle.
  • Most of the general components listed above I have found from fab and sparkfun libraries.
  • I have started to make connection by referring Satshakit, where I learned programmable pins, connection and placement with Atmega 328P.
  • Once I understand programmable pins, I have connected it with respective pins of ISP and FTDI header.
  • Secondly, thermistor has to be connected with analog pin of microcontroller. So, accordingly I connected thermistor to 23rd Pin of IC.
  • 3 mosfets and its interfacing circuit I have connected with IC pin number 9,11 and 12.
  • Accordingly I have connected rest of the components to make circuit.
  • I have started to make connection by referring Satshakit, where I learned programmable pins, connection and placement with Atmega 328P.
  • Accordingly I have connected rest of the components to make circuit.
  • Mistake I have made by connecting Vcc to input of regulator and output to 12V. This have realized after milling board. So I went back to schematic and correct it.
  • Corrected final schematic
  • It took me very long time to make all connections right as Autorouting was giving only 80% results. so I have made connections manually with 12 and 10 mil lines.
  • Once board designed properly, I have exported design as monochrome png image file from Eagle.
  • After this I have go fabmodules  and check my file fo to  traces intersection.
  • Here I have check with back and forth between Eagle and fabmodules around 5 to 7 times to get right result.
  • Once done I have generated 3 different files for 3 different milling. a) Traces without border, 2) Holes drilling, and 3) boundary cutting in GIMP

STEP04 Milling PCB board

  • I have took board with enough size to accommodate to milling of 7*7 cm. I have made my board ready with double sided tape.
  • For milling traces I have used 1/64th inch of  milling bit. For drilling holes 1/32th inch endmill and for cutting 1/16th inch of 2 flute endmill I have used.
  • As my lab's model MDX-20 was very old and  bed alignment totally has been disturbed, I have milled almost 4 to 5 different boards to get right result.
  • In modela half of area was aligned so it could mill small board such as FabISP, but it create milling problem in bigger bead. After lots of iteration to make it align with water-level guage I got almost right result of milling my board.
  • Model MDX-20 alignment problem, I have tried 5 times to mill board. One trace pass was taking around 70 minute.
  • After leveling machine base with water-level gauge, I could able to mill one proper board, and went on to soldering after that.
  • After leveling machine base with water-level gauge, I could able to mill one proper board, and went on to soldering all the components.
  • After soldering I have check connectivity by multimeter and it came out fine after one pin re-soldering.

STEP05: Programming Fila-X board with FabISP

  • For programming I have to connect my board with FabISP, by connecting all six programmable pins.
  • Once connected, I want to program it to sense temperature by thermistor, this will require to read certain values by Rx and Tx pins of board.
  • In order to find out right boud value I have write program to print hello. After certain trial and error I have got right value as 9600.
  • Once done, I wrote program for 100k NTC thermistor and uploaded in board.
  • Once program uploaded successfully, I have connected thermistor in 2 pin header.
  • As thermistor runs on 5V, I need not to apply 12V supply.
  • After connecting thermistor I have tested temperature value by soldering iron heat, which can be seen in below video that, values are increasing as temperature rises due to closeness of soldering iron.
  • Once done, I wrote program for 100k NTC thermistor and uploaded in board.
  • Once program uploaded successfully, I have connected thermistor in 2 pin header.
  • Testing temperature value sensing by 100k thermistor.
  • In below video that, values are increasing as temperature rises due to closeness of soldering iron.

Original design and program files

 

  • All the original Eagle design files, milling files, and programming files are attached here as package including program files.

INDIVIDUAL CONTRIBUTION TO GROUP WORK

 

  • Input devices group work we have tested input sensor such as LDR and it's function generator analog graph on Oscilloscope.
  • In this week, assignment was completely new to us so we all sit together and work in group how to measure value of input sensor on oscilloscope.

For detailed documentation on input sensor value on oscilloscope is done on lab website

Go to Week 12

Go to Weekly work page

2018 | Tanvir Khorajiya