Input Devices

 

This week our task was to create a circuit with a microcontroller on it that takes an input.  I decided to use a Hall Effect sensor this sensor measures a magnetic field. 

 

Board Creation

 

To create the board I based my design off of Neil’s on the website.  I used eagle to draw the schematic and it transferred it to the board layout side to lay out the board.  I used a ground plane to help with routing. 

e1

e2

The next step was to cut the board out and then populate it.  To do this I had to use eagle to export a Gerber file so my LPFK could cut the board.  The hardest part was looking through the box of parts to find the right components.

c1

Programing

 

To program I used Neil’s code and the python file to see if it was working.  After that I went into understanding some of the code. 

 

The first part of the main function is setting up the Analog to Digital Converter. 

at1

 

We shift a one into MUX1 to enable ADC2 on PB4 and also set the voltage reference to VCC by setting REF2:0 to all zeros. 

 

The next part is to take a 100 reading and store the values and then breaks up the data to send it over the serial interface to the python script. 

at2

at3

The last part is the python program.  This program take the serial data rebuild the ADC accumulated value and then take the average. 

j1

To compile the code the make file was used with the following syntax

 

Make –f hello.mag.45.make

 

This compiled the code in to a hex file for flashing.

w1

The next step was to flash the code to the micro.

 

Make –f hello.mag.45.make  program-usbtiny

w2

The last part was to run the python code.  The only hard thing I had with this was how to run it.  It was asking for a serial port and I had to find out where the FTDI cable was installed to.

I found this out by using dmesg | grep tty  I found out that it was on /dev/ttyUSB0  after adding that to the end of the python the code ran fine. 

w3

The below are screen captures of the value changing when a magnet is placed by the sensor.

w4

c2

w5

Files


schematic

Board

C File

Make File

python File




Back