Input Devices
Hall Effect Sensor to read water meters
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.
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:- 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
- If autorouting, do not move the boundaries of the dimension/board closer. Autoroute with the default size and then move the boundaries in.
- To get the best cut with a 1/32bit, set the border line in dimension layer in Eagle to the width of 0.4mm.
Milling
Programming
- I used an Arduino Uno to program the board.
- 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.
- 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
- 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.
- Water Flow Meter
- 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
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 BlinkPinToo Fail
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
Code is linked here