Commit 35331f7f authored by Philip Hozier's avatar Philip Hozier
Browse files

week 10 UPDATE 8/5

parent 56f075d3
Pipeline #229328 passed with stages
in 1 minute and 50 seconds
......@@ -354,11 +354,168 @@ I thought i had overcome the bad luck and all the possible problems you could ha
See [week 4](../week4/ "Week 4") for more milling problems.
*UPDATE*
**Adding serial pins to the design**
I was wrong in the assumption that 'communication' tracks could be used between different protocols. Especially a Rx UPDI line could be used as a serial Rx line if assigned in the embedded programming.
**SPI or I2C**
With my knowledge at the time (or lack of networking and communication protocols to be exact), I didn't know that the sensor would need special pins for communicating. I thought serial output would be enough. It spoke in SPI or I2C, which I was advised to wait for that teaching week before i go down that rabbit-hole. which meant, unbeknownst to me, I was going to fail that week whatever i tried.
With my knowledge at the time (or lack of networking and communication protocols to be exact), I didn't know that the sensor would need special pins for communicating. I thought serial output would be enough. It spoke in SPI or I2C, which I was advised to wait for that teaching week before i go down that rabbit-hole. Which meant, unbeknownst to me, I was going to fail that week whatever i tried.
---
## UPDATE - A WORKING SENSOR - Week 14
---
Together with the 'Controller' board i made in week 13 for [Networking and Communications](../week13/ "Networking and Communications week 13"), I attempted to make a new version of the sensor from which I could plug in to the I2C communication pins.
- Board design
![Individual Assignment](../week10/kicad2-1.jpg "KiCad2 1")
This new design wouldn't need an IC on the same board, so the bigger chip (ATtiny 1614) on the controller board would do the main part of the work and be able to hold the library needed for I2C communication.
I researched the use of this sensor by other students in the Fab Academy's past, and found some that directly copied Neil's board using a ATtiny45. Only a couple I found had tried to do this with the sensor on a board separate from the IC. [Ilias Bartolini](http://fab.academany.org/2018/labs/barcelona/students/ilias-bartolini/2018/04/05/week10-input-devices.html#input-test-board "Ilias Bartolini")
[Esteban Martín Gimenez](http://archive.fabacademy.org/archives/2017/fablabbcn/students/271/project/week-13.html "Esteban Martín Gimenez").
But nobody had ported the sensor to the new generation of ATtiny chips yet. So I would be the first to use it in combination with a ATtiny 1614 (ATtiny412 might not have enough memory to hold much more than the needed library - see issues [Networking and Communications](../week13/ "Networking and Communications week 13"))
So i made a list of all the components that the different circuits had in common to make the basic design. Somethings I was unsure about, one circuit used 2 Mosfet transistors for some reason (not explained in the documentation), and an extra capacitor to smooth the power for the sensor (the control board already has one).
A check with Henk, and I would just have to make it to see if it worked.
![Individual Assignment](../week10/kicad2-2.jpg "KiCad2 2")
An easy routing as it was so small and few components.
- **Production**
A quick mill, and solder and it was done! No not really. The modified footprint of the sensor had allowed the small tracks to be milled, but the challenge would always be soldering the sensor in the right place.
I thinly tinned the tracks on the board, and added a 'bubble' of solder onto the tiny pins of the sensor. Then i very patiently positioned the sensor over the tracks, getting it in the middle of all the tracks from every angle. Then with the hot air gun, I delicately held the sensor in position and heated the areas around the sensor. When the solder was hot enough i saw it flow along the tracks and now it was a gamble if all pins had connected to the tracks.
- **Testing**
- *Continuity testing*
For the components i could test i did, but there was no way to test if the sensor had connected to the tracks properly, other than it not falling of the board.
- *I2C scanning*
The easiest test to do was to scan the I2C bus and see if an address would come back, acknowledging it could make communication with the sensor.
#include <Adafruit_I2CDevice.h>
Adafruit_I2CDevice i2c_dev = Adafruit_I2CDevice(0x10);
void setup() {
// Initialize serial port
while (!Serial) {
delay(10);
}
Serial.begin(9600);
}
void loop() {
Serial.println("I2C address detection test");
// Loop throuth all possible i2c addresses
for (char i = 0; i < 127; i++) {
// Send address
Adafruit_I2CDevice i2c_dev = Adafruit_I2CDevice(i);
// If response on address, print address
if (i2c_dev.begin()) {
Serial.print("Device found at 0x");
Serial.println(i2c_dev.address(), HEX);
}
}
// Wait 5 seconds, then rescan
delay(5000);
}
![Individual Assignment](../week10/I2C-scan.jpg "I2C scan results")
And the sensor is alive!!!!! It wants to speak. :)
- *Serial output*
So the next step was to see if it was saying anything now I knew it was able to communicate. I downloaded the arduino files from [Ilias Abrtolini](http://fab.academany.org/2018/labs/barcelona/students/ilias-bartolini/2018/04/05/week10-input-devices.html#input-test-board "Ilias Bartolini"), and just throw it on the controller board to see what would happen. The code is mostly in C, which i didn't quite understand. The Hex address in the code for the sensor was the same, i wasn't sure about assigning the pin variables for PB3 and PB4 as these for the ATtiny45. Maybe it would give me a 'helpful' error if it didn't work so i tried it anyway.
#include <Wire.h>
#define BUFFER_SIZE 25
#define ADXL343_ADDRESS (0x53) // I2C ADXL343 ALT Address
#define ADXL343_REG_DATAX0 (0x32) // X-axis data 0
#define ADXL343_REG_DATAY0 (0x34) // Y-axis data 0
#define ADXL343_REG_DATAZ0 (0x36) // Z-axis data 0
int i = 0;
int pb3, pb4;
char buffer[10];
uint8_t adxl343WriteRegister(uint8_t reg, uint8_t value) {
Wire.beginTransmission(ADXL343_ADDRESS);
Wire.write((uint8_t)reg);
Wire.write((uint8_t)value);
Wire.endTransmission();
}
uint8_t adxl343ReadRegister(uint8_t reg) {
Wire.beginTransmission(ADXL343_ADDRESS);
Wire.write((uint8_t)reg);
Wire.endTransmission();
Wire.requestFrom(ADXL343_ADDRESS, 1);
return Wire.read();
}
int16_t adxl343ReadWord(uint8_t reg) {
Wire.beginTransmission(ADXL343_ADDRESS);
Wire.write((uint8_t)reg);
Wire.endTransmission();
Wire.requestFrom(ADXL343_ADDRESS, 2);
return (uint16_t)(Wire.read() | (Wire.read() << 8));
}
void setup() {
delay(2000);
Serial.begin(9600);
Serial.flush();
Serial.print("hello_serial: starting\n");
Wire.begin();
uint8_t deviceId = adxl343ReadRegister(0x00);
Serial.print(" deviceId: ");
Serial.println(deviceId);
adxl343WriteRegister(0x2D,0x08); // POWER_CTL register
adxl343WriteRegister(0x31,0x08); // Full res register
i = 0;
}
void loop() {
//_delay_ms(500);
delay(500);
i++;
int16_t x = adxl343ReadWord(ADXL343_REG_DATAX0);
int16_t y = adxl343ReadWord(ADXL343_REG_DATAY0);
int16_t z = adxl343ReadWord(ADXL343_REG_DATAZ0);
Serial.print("x: ");
Serial.print(x);
Serial.print("\ty: ");
Serial.print(y);
Serial.print("\tz: ");
Serial.println(z);
}
![Individual Assignment](../week10/sensor-output.jpg "Sensor output results")
Success!!!! Now to try and visualise this serial data [Week 14](../week14/ "Week 14")
---
## CONCLUSION
......@@ -376,4 +533,12 @@ Getting it to work is something i still need to work on!
| [Traces](../week10/3-axis-accelerometer-F_Cu_500.png "Traces") | The traces for milling. |
| [Interior](../week10/3-axis-accelerometer-Edge_Cuts_500.png "Interior") | The interior for milling. |
| [ATtiny412 datasheet](../week10/Attiny212-412_datasheet.pdf "ATtiny412 datasheet") | ATtiny412 datasheet. |
| [ADXL343 Accelerometer Datasheet](../week10/ADXL343-3Axis_Accelerometer-Datasheet.pdf "Accelerometer-Datasheet") | Accelerometer Datasheet. |
\ No newline at end of file
| [ADXL343 Accelerometer Datasheet](../week10/ADXL343-3Axis_Accelerometer-Datasheet.pdf "Accelerometer-Datasheet") | Accelerometer Datasheet. |
### ATTEMPT 2
| **FILE** | **DESCRIPTION** |
|---|----|
| [Traces](../week10/3-axis-accelerometer2-F_Cu.png "Traces") | The traces for milling. |
| [Interior](../week10/3-axis-accelerometer2-Edge_Cuts.png "Interior") | The interior for milling. |
| [KiCad](../week10/3-axis-accelerometer 2.zip "KiCad files") | The KiCad files. |
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment