Input Devices

Hall Effect Sensor to read water meters

RGB of input sensor on
Hero Image - Hall Effect Sensor in Action

Status - Success

The Why of my Input Device

My final project involves working with water. Typically, water flow is measured with water meters which use rotors with mounted magnets. Im using this opportnity to MIX an input and output device, where the colour of an RGB LED changes based on magentic field.


Design process

I started by looking and analysing all the designs. I realised to combine an input and output device, I would have to change from the ATTiny 45 to Attiny 44 as it has 14 pins as compared to 8 of the 45.

Pinout of Attiny 45


Pinout of Attiny 44


Pinout conversion of Attiny 45 to 44

So I made this excel sheet, based on these pin out diagrams from the datasheets. It has a space in the column "Connected to" to map the pin connections to make programming easier.
Then I mapped the pins in the reference board design in the Schedule here from input devices and here from output devices to complete my PCB design.

PCB Design

I had a few new understandings in terms of PCB design this week:
  1. Getting a well spaced Autorouted board is an challenge, esp if we use values from the Fabmodules.dru file. Instead, change values of Width to X and gap to X
  2. If autorouting, do not move the boundaries of the dimension/board closer. Autoroute with the default size and then move the boundaries in.
  3. To get the best cut with a 1/32bit, set the border line in dimension layer in Eagle to the width of 0.4mm.

1. Schematic of my board - input is Magnetometer and Output is RGB LED


2. Status of the ERC check


3. Schematic to board


4. Beginning the Layout of the board


5. Version 1 of my board layout with airwires to indicate the pin connections (unoptimised as yet)


6. Optimised airwires post RATSNEST


7. Defining the Width and spacing to ensure a clean autoroute which will pass the FabAcademy DRC (Design Rule Check)


8. How an incomplete Autoroute shows airwires


9. How the Autorouter shows completion percentages, with 100% showing that all connections are possible, and lower percentages showing increasing number of unconnected pins like shown above


10. Final look of the board traces - this has an error. The component in Fab Library has different pin layout than what the Datasheet has


11. The outer cut of the board. Making the width of this line as 0.04 gets a perfect cut. Only we need to be cognisant to leave some space between the board's outer cut and traces insdie, else have a chance of cutting the traces themselves

Milling


Sidekick image - Milling in slow motion
During Milling, I learnt a new thing. When sticking the PCB on to the base board, put a paper and then press the PCB in once, this avoids fingerprints and smudges. Gives a great looking PCB!
Inner traces milling with the 1/64 bit


Outer cut with the 1/32 bit


Milled board

Programming


Sidekick image - Prgramming the board using an Arduino Uno with the old wiring
  1. I used an Arduino Uno to program the board.
  2. Using the "ArduinoasISP" example code, I programmed the Arduino Uno to be the programmer board. This meant that in the future I could use the Arduino Uno's port address and upload the code for the Attiny44 there.
  3. Step 1 to programming my board was to test the LEDs. This would let me know if the Attiny was alright post my soldering and if the LEDs were functioning. I did this using this Code This was a pass. The pins I had to use were Pins 10, 8, and 9
  4. Step 2 was to get reading from the Sensor. Here I started facing the first of the issues:
    9a. Using this code, I tried to get the LED to blink according to the returned values. However, the values did not change irrespective of the proximity to the magent.
    9b. Since I had designed the board to not have an FTDI output, i took the sensor off the board and realised that the wiring was different. I temporarily rewired it using hookup wires like this to see if there was any improvement

    To ensure I had an understanding of the exact sensor output, I plugged it into the Arduino Uno as shown below, and did an analogRead and Serial.print of the values. I didn't get any values, hence, for now declaring this as a fail.

At this point, I decided to give this board on more shot, which I did and on my inabaility to get it to respond again, dropped it for the time being and focussed on getting sensors to work with a working modification of the SatshaKit board.


Chapter 2: The SatshaKit Adventure

With the final project in mind, I needed a common board to work across Input and Output devices and Networking weeks. Few others in the Lab Avishek Das, Chandni Chabbra, Siddarth Arya had worked on the SatshaKit and gotten it to work. I tried adding these Input devices and testing the SatshaKit before adding a Output device and network interface.

  1. Water Flow Meter
  2. Ultrasonic Distance Sensor

Mods in the Kit

Since I wanted a common board which could work for Input, Output, Networking and Interface week, I took the SatshaKit files off Jakob Nilson's page on the advice of Avishek Das, Chandni Chabbra and Siddarth Arya and added some extra power and ground pins and made provision for an ESP8266-12e module.

Programming and Setting up the Board

To run the PinToo Board as an Arduino Uno clone, we first took an Arduino Uno (Mega in my case) and uploaded the ArduinoISP example code with some small changes, namely:
1. Enable old wiring as shown below

Changes - Uncomment line 81, "#define USE_OLD_WIRING". Select Arduino Uno or Mega, and wire according the the code in line 73, 85, 86, 87.
2. Select port of the Arduino and upload. Once done, Select "Arduino As ISP" as shown in the above image, and select "Burn Bootloader" as shown in the image below
If succesful, you will find the Verbose mode outputting the below message:
avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Program Files
(x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

Using Port : COM10
Using Programmer : stk500v1
Overriding Baud Rate : 19200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : STK500
Description : Atmel STK500 Version 1.x firmware
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/optiboot/optiboot_atmega328.hex"
avrdude: writing flash (32768 bytes):

Writing | ################################################## | 100% -0.00s

avrdude: 32768 bytes of flash written
avrdude: verifying flash memory against C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/optiboot/optiboot_atmega328.hex: avrdude: load data flash data from input file C:\Program Files
(x86)\Arduino\hardware\arduino\avr/bootloaders/optiboot/optiboot_atmega328.hex: avrdude: input file C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/optiboot/optiboot_atmega328.hex contains 32768 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% -0.00s

avrdude: verifying ...
avrdude: 32768 bytes of flash verified
avrdude: reading input file "0x0F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0F:
avrdude: load data lock data from input file 0x0F:
avrdude: input file 0x0F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude done. Thank you.

Water Flow Meter

Using an off the shelf Seasonic YF-S201 flow sensor, which works on the principle of the Hall effect sensor, I connected the Data pin of the Flow sensor to the Pin-Too board's Digital Pin 2 (as ATMega-328P has 2 hardware interrupts - Digital Pins 2 and 3). The flow sensor code I took from the internet (Didn't believe in reinventing the wheel) by Arvind Sanjeev of DIYhacking.com. I changed the calibration from 4.5 to 6.5 as suggested in the Datasheet here and uploaded it on the Pin-Too board to complete this assignment.

Media

PinToo Blink

PinToo Fail


Data on serial port

Errors

Wrong Labelling of my power extension on the Pin-Too - this meant that the sensor was not getting power to work. After I used a multimeter and diagnosed the issue, it was fixed and data was seen on serial monitor.

Files


Screenshot of my Board - Pin-Too with future provisions

Code is linked here