Skip to content

9. Input Devices

This week built on top of the knowledge gathered from the last assignment, so be sure to check that out beforehand.

In order to prepare a component for my final project I designed and fabricated a simple daughterboard that reads the values of a hall effect sensor with an ATTiny412.

These values need to be transported to the mainboard later down the line so included some pin headers for programming and an I2C connection.

I once again teamed up with Anna, Kerstin and Lars, the other students from HRW FabLab, to measure the analog and digital outputs of a vibration sensor and a photo diode for our group assignment.

You can find our page right here.

Design in KiCAD

I’ll be honest, even though this week essentially revolves around the same things as the last one, I struggled a lot with the design.

For some reason Honeywell, who manufactured the SS59ET hall effect sensor I am using, didn’t think of including a sample circuit or any other useful information in their datasheet.

Feel free to take a closer look yourself.

Anyways the only resource with an example I could find was this article on hackaday and even there the information I needed was hidden barely visible in a select few frames of the linked video.

This is what I am talking about:

If you can’t read anything, I am terribly sorry about the quality but this is what I worked with, which probably explains some things that occured later down the line.

Anyways I opened up KiCAD and got to work on the schematic.

I added the symbols for the ATTiny412, the sensor, resistors, capacitors and some pin headers and began connecting the components.

You can find the symbol, footprint and 3D model for the hall effect sensor right here.

The single pin header labeled J1 is only going to be used to program the ATTiny412 via UPDI while the other four pins are for 3.3V, GND and an I2C connection.

With that done I transformed the schematic into a PCB:

Remember how last week trying to solder on the pin headers robbed me of my last two braincells?

To prevent another catastrophic soldering experience I enlarged the pads a little bit by selecting them and hitting E on my keyboard to edit them.

I changed the pad shape to Circular and the diameter to 2.2mm.

The other steps were business as usual.

Arrange the components, connect them with traces, set up the ground planes and give the board an outline.

Make sure to run the design rule checker and redo everything like three times.

When I was done I exported the gerber files which you can find in the Download section at the bottom of this page along with the KiCAD project file.

Production and soldering

The production process for my PCB was also pretty much the same as last week.

I used the LPKF ProtoMat S63 again and was delighted to see that some problems that occured over the weekend had been fixed.

Apparently the spoilboard was so worn out that it had potholes.

When turning on the vacuum, the FR4 sheet would get bent down into the holes ever so slightly that the milling tool lost contact to the surface resulting in something like this:

After swapping out a worn tool we also didn’t readjust the cutting depth of the new one, which didn’t necessarily help either.

Thankfully we have competent people around to help us.

So anyways, I started milling.

After initial cleanup and filing off the tabs as usual, I started carefully applying solder paste for all the SMD components.

I then placed the compontents onto their pads.

After that I started preheating our reflow oven and followed the on-screen instructions.

The oven beeped (a little too loudly for my taste) to let me know that I can insert my PCB.

For some reason the solder paste didn’t really melt but rather dried out.

I checked the continuity with a multimeter and everything looked fine but the solder joints seemed kind of brittle so I went ahead and redid them with a soldering iron.

While I was at it I also attached the pin headers which worked much better than last week.

Maybe it is just because of the fancy new Omnifixo third hand but I’ll take any improvement over last week’s disaster.

Programming the ATTiny412

With the hardware part done I started up the Arduino IDE where I first had to do some setup.

If you haven’t noticed until now, the ATTiny412 doesn’t come with a USB port so how do you program it?

I actually already answered that question in the design section, but for those who only skimmed over the text: UPDI

UPDI stands for Unified Program and Debug Interface and is used for exactly what the name says with only one wire on small package AVR devices.

A single wire still doesn’t make a USB connection, but there are solutions to that.

I could have either gone with a dedicated UPDI programmer such as the UPDI friend from Adafruit or program an existing Arduino to behave as one.

I chose the latter option which is why I had to add http://drazzy.com/package_drazzy.com_index.json to the additional boards manager URLs in the IDE’s preferences menu.

After that I installed the megaTinyCore by Spence Konde via the Boards Manager.

The last setup step was to download Spence Konde’s jtag2updi sketch and open it in the IDE.

Don’t worry if you see no code in the jtag2updi.ino file, it is supposed to be that way.

I connected an Arduino Uno to my computer and uploaded the sketch which essentially transforms it into a programmer.

For it to work properly though and not get flashed itself when uploading sketches for the ATTiny412, I had to add a 10 µF capacitor that went from RESET to GND.

By default pin 6 is the one used for UPDI programming so I connected that to my new board’s UPDI pin as well as 3.3V and GND.

I then connected an LED to the Attiny’s pin 2 and prepared a basic blink sketch:

void setup() {
  pinMode(2, OUTPUT);
}

void loop() {
  digitalWrite(2, HIGH);
  delay(1000);
  digitalWrite(2, LOW);
  delay(1000);
}

Using for example PA1 to set up the pins does not work, which I found kind of counterintuitive.

You have to enter one of the numbers circled in red:

To get ready to upload the sketch I had to go to Tools and select the ATTiny412 board from the megaTinyCore library despite an Arduino Uno being connected.

After that I set the Programmer in the Tools menu to jtag2updi.

With all that done I was finally able to upload the sketch.

The error message avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description pops up everytime I upload code to the Attiny but it can safely be ignored.

Since that worked flawlessly, I prepared another sketch to test the hall effect sensor:

void setup() {
  pinMode(2, OUTPUT);
  pinMode(0, INPUT);
}

void loop() {
  int hall = analogRead(0);
      hall = map(hall, 0, 1023, -100, 100);
      analogWrite(2, hall);
}

It reads the sensor’s values and maps them in a way that doesn’t under or overpower the LED but still makes the changes visible.

Or at least I hoped that it does.

For some reason the LED was just constantly powered, no matter where I placed a magnet in relation to the sensor.

I measured the sensor’s output with a multimeter and found that it was pretty much exactly the input voltage.

This hall effect sensor should usually cut the input in half when no magnetic field is detected so I thought it was dead.

After desoldering it and powering it without the PCB it worked without any problems so I got to thinking and eventually stumbled across one of last week’s lost braincells.

I guess connecting the pin for the sensor values to the input voltage via a resistor didn’t work quite as expected.

Maybe a bigger resistor would have helped but I simply removed the one I had and, would you look at that, it works.

I think that’s it from me for now, stay hydrated folks!

Downloads

gerbers.zip

KiCAD.zip