Joao Wilbert
How to Make (almost) Anything 2019

Week 8: Input Devices

For this week I did two exercises, one was to design a board to sense piezoelectric thin film and digitize the signal and get the input into an Python script. This is my first time using the ATTINY to process the sensor signal with the ADC, I spent some time reading through the datasheet.

Files: | piezoInput.c | piezoInput.c.hex | piezoInput.out

For this week assignment I decided to create a board using the ATTINY as a ADC for input of two piezo vibration sensors in thin film format. This was my first foray into starting my final project. The idea was to test what could I sense using a piezoelectric sensor and wether I could get high enough sampling rate for my final project of creating sheet microphones with piezo sensor.

I first designed a board to input two piezos, the idea was to use no amplification or filtering, just input the piezoelectric sensor directly into the ADV of the microccontroller. The approach is to check wether I need some pre amplification and also to learn how to use the ATTINY ADC as a potential candidate for my final project.

Here is a side by side of the board component and traces. I layoutted the board on Eagle and added two pads for connecting the electrodes to the ATTINY44SU. My idea was to use the AVRDude programmer to program the board to get the piezo input. I added inputs for two sensors connecting to two pins into the ATTINY. Based on previous experience I added two protection diodes to protect the ATTINY pins from high voltages that could be generated by the sensor.

I used mods to upload my board, and used the 1/64 mill for traces and 1/32 mill for the outline. This board was very straightforward to do design and build, I managed to populate it without having to use any bridge resistors.

I milled the board on the SRM20, the milling went well, with no issues during the milling, the board milled with traces in good quality.

I milled and stuffed the board with no problem, but when teting the board on the oscilloscope I realized that the voltage input from the piezo was being significantly dropped by the protection didoes, I then checked the datasheet on the ATTINY and realized that it already included protection diodes, given this fact I decided to remove the input diodes from my board.

On the ATTINY44SU I enabled the ADC by shifting the register for PA1 which was the pin where my sensor was connected to. I then started a loop that gets the analog signal and converts to a value between 0-1024. To send the data to a remote host PC I used the FTDI cable and send the data over serial by packing the int from the analog input into a high and a low byte. The code below turns on the ADC, defines a prescaling to the output values, initiates a conversion and packs the conversion into a high and a low byte to be sent via serial.

I used FTDI to read the values from the microcontroller over serial. On Python I used pyserial to open a serial interface with the board over USB (using the FTDI cable), I then read in the high and low byte (as a group of 2) and convert them to an integer. The code below implements a signature that counts 1,2,3 to read the byte to make sure we are getting the high and low byte in the correct order.

I then print the value to the serial monitor. One thing I couldn't understand was why the midlevel of the sensor was at 512? Could this be to do with biasing the sensor? I tried changing the reference voltage on the ATTINY to 1.1v but this had no effect on the value. This experiment was to check wether I needed to do any signal conditioning to my final circuit project.

Altough I am not using an attiny for my final project this was a good and successful exercise on how to sample the raw signal from the piezoelectric sensor, since I am going to be working with audio I might consider designing an analog signal to condition the signal on the sensor prior to sampling it with the microcontroller.

In parallel with this exercise I also did some more sensor paper exploration with another input device, the documentation can be found in paper exercises page.