Munzir Alradi
ع
Munzir Alradi
Home About Services Work Blog Tutorials Contact Light Tunnel العربية
Electronics

Reading Sensors: What Your Input Device Actually Reports

Adding sensors to a board of my own design, then measuring the difference between the datasheet and the bench.

2021 5 min read 29 photos 6 videos Written during Fab Academy · Week 11
The finished ATtiny45 board with its headers soldered on

for this week assignment we have been asked to go deeper into electronic, specifically this week we will focus on input devices, and we should test it on a board that we designed, so as start i will make a new board to work with this week and i will planned a head so i can use it also for Output device

Designing New Board

as i have already explained the process in more details in electronic Design Week i will not put full details here again , just i will add the main steps

I will use ATtiny45 on this assignment

ATtiny25/45/85 pinout, the chip this board is built around
  • to Design my board i used Kicad open source software.

    KiCad, the open source tool I drew the board in

Add component

  • ATtiny45
  • ISPSMD header
  • capacitor
  • led
  • 2 * Resistor
  • FTDI header
  • 4 * 2 pin header
  • 3 pin male header
All the components dropped onto the schematic sheet before wiring

connect them to Attinu45s

The same schematic once everything is wired to the ATtiny45

check the connection with design rule

Running the Electrical Rules Checker from the schematic toolbar

after Checked the design rule i found there were no problem in the connection

Annotate schematic symbol

The Annotate Schematic dialog, numbering every symbol on the sheet

Assign foot print

in this step you can see the foot print for each component and make sure that you have choose the correct one

Assign Footprints, one fab footprint against each symbol in the list

Generate Netlist

Generating the netlist from the Pcbnew tab of the Netlist dialog

load netlist in PCB layout

from the pcb layout top bar click load netlist, then choose the one you saved in the past steps.

Frames 01–02

    Loading the saved netlist file in Pcbnew, then Update PCB
    The footprints land in the layout, still joined by ratsnest lines

Adjust Trace Thinkness and Clearance

next is to adjust the setup from file –» board setting — »> Net classes

Net Classes in Board Setup: clearance and track width at 0.4 mm

connect Traces to components foot-print

this seams to be one of the tsaks that east most of the time, every time i design a new board i take most of the time finding the best way to route the traces, i had to delete the FTDI header since i will use ISP programmer , and deleted the LEDs i will use it outside the board.

after that i ended up with this design

The finished routing inside an octagonal board outline

fill it with copper to connect the grounds

The copper pour filled in, tying the ground pads together

export the deign

now export it as svg ,

Frames 01–02

    Exporting the layout as SVG from the File menu
    The Export SVG File dialog, with the copper and board-outline layers ticked

generate a tool-path

i used mods To generate the tool psth for the desing in order to prepare it to cut it with Roland- SRM20

The mods module chain with my traces loaded, set for the SRM-20

Mill it with SRM-20

after that send the file to the printer to start milling it , you can refer to my assignment electronic production for more information about the exact steps to cut the machine

Frames 01–02

    VPanel for the SRM-20, where the origin is set before cutting
    Adding the toolpath file to the Cut list and pressing Output

Milling Result

The milled board held up in hand, before any parts are soldered
  • now its time to solder

Soldering Result

The same board after soldering the ATtiny45, headers and passives

lets run the programmer i will use Arduino as ISP

Frames 01–02

    Opening the ArduinoISP example from File, Examples in the Arduino IDE
    The ArduinoISP sketch open, ready to upload to the Arduino Uno

connect isp with arduino

  • Connect pin 13 from Arduino = pin 7 in Attiny 45 = SCK ISP
  • Connect pin 12 from Arduino = pin 6 in Attiny 45 = MISO ISP
  • Connect pin 11 from Arduino = pin 5 in Attiny 45 = MOSI ISP
  • Connect pin 10 from Arduino = pin 1 in Attiny 45 = RESET ISP
  • Connect pin 5v from Arduino = pin 8 in Attiny 45 = VCC ISP
  • Connect pin GND from Arduino = pin 4 in Attiny 45 = GND ISP

Frames 01–03

    Jumper wires going into digital pins 10 to 13 on the Uno
    The ribbon of jumpers running from the Uno down to my board
    The two boards wired together, power taken from the Uno POWER header

if you dont know how to upload the program follow my steps that i have explained in Embedded Programming upload the first example

Push button

one of the most important input devices is the push button, its important that you know how its connected and how to make use of it

How the push button is wired inside: pins 1-3 and 2-4 joined

the push button we are using have internal connection pin 1 -3 connected also 2,4 make sure to have it tested before going further, you can do that by simply connecting one side to 5v and the other side to led, you can also do the test with multimeter, but since the bread board is front of me i found this way is faster

input pull down

i have added 10K resistor going to the ground to make sure that the reading is sooth

Breadboard diagram of the button wired to the Uno, with its 10K pull-down

input button to enable led

the program is simple , if the button is pressed , turn on an LED otherwise keep it off

you can download the code from here

LDR

LDR It stands for Light Dependent Resistor or Photoresistor, which is a passive electronic component, basically a resistor which has a resistance that varies depending of the light intensity.

The light dependent resistor, its zig-zag track on a red disc

to connect it with our board we need to connect one leg to input and wit 5k resistor pullup , the other side to ground as shwing here

The wiring drawn out: supply at the top, the pull-up resistor, then the LDR down to ground

with same function of the least program we can read analog signal, if the reading is more than specific value turn on an LED other wise keep it off.

but first lets connect it with Arduino to see the value that i will depends on, i will use ready example in Arduino , ” analog read serial ”

depending of this Value i can say that if the value is less then 200 its mean dark , and if its more its mean there is alight, so will write my program this way, and upload it to my board

you can download the code from here

push button serial

next i wanted to test the serial communication to read the value of my sensors in arduino serial monitor,

i found that serial function will not work directly, so i hade to use software serial and here is the result

Download


The Fab Academy brief

Group assignment:

  • Probe an input device(s)’s analog and digital signals
  • Document your work (in a group or individually)

Individual assignment:

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

Type to search