Back to Projects AS220 Labs

Fab Academy 2014

Embedded Programming
This week's assignment was to mill a board and program it to do something. I had designed an upgraded version of my face board from the electronics design week (this version included a pilot light for power indication), but I was really interested to try something with one of the sensors. Most people seemed to be working with buttons on their board (that had been set up in the previous week), but I didn't have a button so I decided to try and make a daughter board that could work off of my face board.

Shawn started off with his usual breakdown lecture. We reviewed binary, hexadecimal, assembly, and machine code before getting into some of the basics of programming. I've got some experience with some basic programming tasks, and I felt a lot more comfortable here than I did in some of the electronics classes (although I am definitely getting more confident as making the daughter board later this week proved to be a breeze). One valuable lesson from Shawn was how to input a variable into a function. It seems silly, but I've never really understood this and ended up making a lot of my functions work with no inputs. He suggested that we work in the Arduino IDE, and begin with an example that we modify. I had already set up the basic blink program in my electronics design week, so I decided to start from there.


Shawn reviews function structures

I was least familiar with the Hall effect sensor (or even what the Hall effect was), so I decided to start there. I checked the input devices page of the fab academy site, and got the datasheet for the sensor. From there, I designed a quick daughter board in Eagle with a 4 pin header to connect back to my face board. This was pretty easy, all I had to do was be careful with the 3 input for the sensor to make sure they were properly aligned.


schematic for the board in Eagle


image in Eagle prior to exporting for milling

The board was small, and milled easily. This was my first time using the Modela totally unsupervised, and I'm proud to say it went very smoothly. I remembered to keep my photoshop exports at 1000 dpi to avoid the problem I'd had in the past where my .png files suddenly balloon to 10x their original size on the Modela. The fab modules had also been update with a nice GUI and the ability to abort from inside the software, although I didn't need that... this time.


milling out the daughter board

I headed back upstairs to start programming. Before I got started, I enabled verbose output (the text box below your sketch that shows exactly what's going on. This can be turned on from the 'Preferences' menu here:


verbose mode setting

Below you can see my code for the hall effect sensor. This was a modified version of the AnalogReadSerial example provided. Notice that I imported the SoftwareSerial library. I'm actually not sure why we had to do this (I do remember Shawn telling us to, and unfortunately this is a backdated documentation so it's not fresh in my mind). It may have to do with using the ATTiny rather than an Arduino, but I will check it out and update. You'll see that code adheres to the basic Arduino structure of have 3 main parts,

  • declaring global variables
  • setup function - this runs once at the beginning of the program
  • loop function - this loops over and over

code for Hall Effect sensor

Finally, I hooked my board up and checked the serial output. It seemed to be spitting out 3 digit numbers that looked vaguely related to magnetic fields. However, to be honest, I couldn't really be sure. I checked at home with several different magnets (and live wires checking for current), and it always seemed like a slightly mystical connection.

UPDATE: 2 weeks later as I was preparing for the input devices week (where I wanted to start with this as a test again, I realized that I was actually reading a floating pin (thanks Shawn!). I've updated the code (correct version posted here), and the sensor works great!


sensor hooked up to face board.