'개소리 왈왈 > 자전거' 카테고리의 다른 글
서울 자전거 대행진 흰색?!?! (0) | 2016.04.21 |
---|---|
아 몰랑 일단 신청 ㅋ (0) | 2016.04.05 |
아.. 놔.. 망할 에어로 시트 포스트 (0) | 2016.03.23 |
자전거 셋팅... 완...료는 아니고 (0) | 2016.01.10 |
자전거 청소 끝 (0) | 2016.01.09 |
서울 자전거 대행진 흰색?!?! (0) | 2016.04.21 |
---|---|
아 몰랑 일단 신청 ㅋ (0) | 2016.04.05 |
아.. 놔.. 망할 에어로 시트 포스트 (0) | 2016.03.23 |
자전거 셋팅... 완...료는 아니고 (0) | 2016.01.10 |
자전거 청소 끝 (0) | 2016.01.09 |
음.. 우리나라가 미친듯 비싸게 파는걸려나..
The MPU-6050 is not expensive, especially given the fact that it combines both an accelerometer and a gyro.
[링크 : http://playground.arduino.cc/Main/MPU-6050]
어라.. 3.3V 짜리인 i2c 장비를 레벨 쉬프트 하지 않고 쓸수가 있나보네?
[링크 : http://playground.arduino.cc/Main/I2CBi-directionalLevelShifter]
avrdude: stk500_getsync() attempt 1 of 10: not in sync (0) | 2016.04.06 |
---|---|
아두이노 - 라즈베리 i2c 연결 (0) | 2016.04.06 |
아두이노 나노 내장 온도센서 (0) | 2016.03.31 |
어?!?! 아두이노 sprintf() %f가 안돼? (0) | 2016.03.31 |
가속도계 각도 계산.. (2) | 2016.03.31 |
temperature = (ADCW - 324.31) / 1.22
[링크 : http://playground.arduino.cc/Main/InternalTemperatureSensor]
[링크 : http://www.atmel.com/images/...328p_datasheet_complete.pdf]
아두이노 - 라즈베리 i2c 연결 (0) | 2016.04.06 |
---|---|
아두이노 level shift / MPU-6050 (0) | 2016.04.01 |
어?!?! 아두이노 sprintf() %f가 안돼? (0) | 2016.03.31 |
가속도계 각도 계산.. (2) | 2016.03.31 |
아두이노 nano + ADXL345 (0) | 2016.03.31 |
엥? winavr에서도 안되었던가??
급 멘붕 ㄷㄷ
char *dtostrf(double val, signed char width, unsigned char prec, char *s) Use this method to convert it to a C-Style string and then use sprintf, eg: char str_temp[6]; /* 4 is mininum width, 2 is precision; float value is copied onto str_temp*/ dtostrf(temp, 4, 2, str_temp); sprintf(temperature,"%s F", str_temp); |
[링크 : http://stackoverflow.com/questions/27651012/arduino-sprintf-float-not-formatting]
[링크 : http://forum.arduino.cc/index.php?topic=175478.0]
아두이노 level shift / MPU-6050 (0) | 2016.04.01 |
---|---|
아두이노 나노 내장 온도센서 (0) | 2016.03.31 |
가속도계 각도 계산.. (2) | 2016.03.31 |
아두이노 nano + ADXL345 (0) | 2016.03.31 |
ADXL345 소스 분석 및 아두이노 용으로 변환 (0) | 2016.03.30 |
초코렛이나 구매하려고 로이스 홈페이지 갔다가
약도 위에 빨갛게 떠서 먼가해서 봤더니... 헐?!?
회사 홈페이지도 같은 지도 쓰니 언넝 수정을 해야지...
크아아앙 지름신님 ㅠㅠ 살려주세요 젭라 ㅠㅠ (0) | 2016.04.28 |
---|---|
포지션 : 잡캐? (0) | 2016.04.25 |
po지름wer!!! (0) | 2016.03.24 |
망할 locky... cryptowall 계열... (0) | 2016.03.17 |
망할 locky 랜섬웨어 -_- (3) | 2016.03.16 |
먼가 깨알 같은 top은 안되요의 압박
bash를 실행하면
우분투쪽 시스템을 끌어오는게 아닌데도 불구하고..
UNIX subsystem을 통해 바로 bash를 통해 elf(unix) 쪽 파일을 바로 실행도 가능하고..
먼가.. 맥을 잡아버릴려는 느낌인거 같기도 하고
머하는 짓인가 싶기도 하고.. ㄷㄷ
[링크 : https://sec.ch9.ms/sessions/build/2016/P488.mp4]
[링크 : http://techcrunch.com/.../be-very-afraid-hell-has-frozen-over-bash-is-coming-to-windows-10/]
[링크 : http://www.clien.net/cs2/bbs/board.php?bo_table=news&wr_id=2146552]
메모장 F5 단축키.. (0) | 2016.08.10 |
---|---|
win7 자격 증명 저장관련 (0) | 2016.06.23 |
그래픽 카드 성능 향상...?? system.ini irq (0) | 2016.02.16 |
win7 starter / home premium 메모리 사용량 (0) | 2015.11.08 |
win7 starter? (0) | 2015.11.07 |
필터는 나중에 적용하고..
걍.. atan()만 쓰면 끝나나?
double x_angle = -atan((double)ay/(double)az)*180.0 / 3.1416;
[링크 : http://hs36.tistory.com/19]
[링크 : http://pinkwink.kr/73]
[링크 : http://mechaworld.tistory.com/11]
+
2016/04/06 - [이론 관련] - 가속도계로 각도계산하기
아두이노 나노 내장 온도센서 (0) | 2016.03.31 |
---|---|
어?!?! 아두이노 sprintf() %f가 안돼? (0) | 2016.03.31 |
아두이노 nano + ADXL345 (0) | 2016.03.31 |
ADXL345 소스 분석 및 아두이노 용으로 변환 (0) | 2016.03.30 |
아두이노 나노 pinout / atmega328p (0) | 2016.03.30 |
음.. 이제 좀 마음에 들게 되긴했는데..
각도를 어떻게 받고. 어떤 각도를 계산해야 하려나..
#include <avr/io.h> #include <Wire.h> #define I2C_ID 0x53 // ADXL-345 void setup() { // put your setup code here, to run once: Serial.begin(115200); Wire.begin(); // adxl345 initialize // power setting Wire.beginTransmission(I2C_ID); Wire.write(byte(0x2d)); Wire.write(byte(0x18)); Wire.endTransmission(); // range setting Wire.beginTransmission(I2C_ID); Wire.write(byte(0x31)); Wire.write(byte(0x09)); Wire.endTransmission(); } void loop() { // put your main code here, to run repeatedly: char str[30]; char data[6]; unsigned char idx = 0; short acc_x; short acc_y; short acc_z; // data request Wire.beginTransmission(I2C_ID); Wire.write(byte(0x32)); Wire.endTransmission(); Wire.requestFrom(0x53, 6); idx = 0; while (Wire.available()) data[idx++] = Wire.read(); acc_x = (data[1] << 8) | data[0]; acc_y = (data[3] << 8) | data[2]; acc_z = (data[5] << 8) | data[4]; sprintf(str,"x:%6d y:%6d z:%6d",acc_x, acc_y, acc_z); Serial.println(str); delay(100); } |
FULL_RES 끄고(10bit output / 0~1023) +-16g로 출력
#include <avr/io.h> #include <math.h> #include <Wire.h> #define I2C_ID 0x53 // ADXL-345 void setup() { // put your setup code here, to run once: Serial.begin(115200); Wire.begin(); // adxl345 initialize // power setting Wire.beginTransmission(I2C_ID); Wire.write(byte(0x2d)); Wire.write(byte(0x18)); Wire.endTransmission(); // range setting Wire.beginTransmission(I2C_ID); Wire.write(byte(0x31)); Wire.write(byte(0x03)); Wire.endTransmission(); } void loop() { // put your main code here, to run repeatedly: char str[30]; char data[6]; unsigned char idx = 0; short acc_x; short acc_y; short acc_z; double deg_x; double deg_y; // data request Wire.beginTransmission(I2C_ID); Wire.write(byte(0x32)); Wire.endTransmission(); Wire.requestFrom(0x53, 6); idx = 0; while (Wire.available()) data[idx++] = Wire.read(); acc_x = (data[1] << 8) | data[0]; acc_y = (data[3] << 8) | data[2]; acc_z = (data[5] << 8) | data[4]; if(acc_z == 0) { deg_x = 0.0; deg_y = 0.0; } else { deg_x = atan((double)acc_x / (double)acc_z) * 57.2957; deg_y = atan((double)acc_y / (double)acc_z) * 57.2957; } sprintf(str,"x:%6d y:%6d z:%6d",acc_x, acc_y, acc_z); Serial.println(str); sprintf(str,"x:%d y:%d",(short)deg_x, (short)deg_y); Serial.println(str); delay(100); } |
#include <avr/io.h> #include <math.h> #include <Wire.h> #define I2C_ID 0x53 // ADXL-345 void setup() { // put your setup code here, to run once: Serial.begin(115200); Wire.begin(); // adxl345 initialize // power setting Wire.beginTransmission(I2C_ID); Wire.write(byte(0x2d)); Wire.write(byte(0x18)); Wire.endTransmission(); // range setting Wire.beginTransmission(I2C_ID); Wire.write(byte(0x31)); Wire.write(byte(0x02)); Wire.endTransmission(); } void loop() { // put your main code here, to run repeatedly: char str[30]; char str_x[15]; char str_y[15]; char data[6]; unsigned char idx = 0; short acc_x; short acc_y; short acc_z; double deg_x; double deg_y; // data request Wire.beginTransmission(I2C_ID); Wire.write(byte(0x32)); Wire.endTransmission(); Wire.requestFrom(0x53, 6); idx = 0; while (Wire.available()) data[idx++] = Wire.read(); acc_x = (data[1] << 8) | data[0]; acc_y = (data[3] << 8) | data[2]; acc_z = (data[5] << 8) | data[4]; if(acc_z == 0) { deg_x = 0.0; deg_y = 0.0; } else { deg_x = atan((double)acc_x / (double)acc_z) * 57.2957; deg_y = atan((double)acc_y / (double)acc_z) * 57.2957; } sprintf(str,"x:%6d y:%6d z:%6d",acc_x, acc_y, acc_z); Serial.println(str); dtostrf(deg_x, 4,2, str_x); dtostrf(deg_y, 4,2, str_y); sprintf(str,"x:%s y:%s",str_x, str_y); Serial.println(str); delay(100); } |
어?!?! 아두이노 sprintf() %f가 안돼? (0) | 2016.03.31 |
---|---|
가속도계 각도 계산.. (2) | 2016.03.31 |
ADXL345 소스 분석 및 아두이노 용으로 변환 (0) | 2016.03.30 |
아두이노 나노 pinout / atmega328p (0) | 2016.03.30 |
아두이노 avr 헤더사용하기 / PUD (0) | 2016.03.30 |
음.. 이래서 input인데 값이 다른 칩에서 변경하지 못했던건가?
(Hi-Z / tri-state)
Input으로 사용할 시에는 해당 회로에서 들어오는 값을 갱신하지 못하는 상태로 만들어 Output을 고저항(Hi-Z)으로 두어 Input되는 값이 변형되는 일이 없도록 하고, Output으로 사용할 시에는 상태를 갱신할 수 있도록 한다.
패럿(farad) / 암페어(ampere) 변환 (0) | 2016.04.14 |
---|---|
genlock (0) | 2016.04.05 |
solid state (0) | 2016.01.17 |
디지털 서보(?) (0) | 2015.11.24 |
DMOS? (0) | 2015.10.20 |
이걸 한번... 아두이노 용으로 변환해서 해봐야지..
일단 0x53이고
파워업 리셋시 센서 작동하지 않으므로
Rate는 0x0A(1010b)로 설정되어 100Hz 표준 i2c 속도의 출력 속도에 맞춰 지는건가?
0x2d 레지스터에 0x18을 넣어
AUTO_SLEEP 과 Measure를 설정해 값을 측정하도록 한다.
AUTO_SLEEP은 좀더 봐야 할 듯
0x31에서는 측정할 가속도의 범위를 설정하는데
기본값은 0x00으로 Range +-2g를 측정하게 된다.
+
2016.03.31
FULL_RES=1의 경우 무조건 4mg=1 로 계산되고 Range에 영향을 받아 출력되는 범위가 달라진다.
예를 들어 +2g로 Range 설정시 256으로 출력되며 1g(4mg*256=1024mg=1g) 흔들어서나오는 값이
+-512를 넘지 못한다(512*4=2048=2g)
FULL_RES=0의 경우 Range를 0x03으로 하면 8g이고 32값이 나오게 된다(1g에 대한 값)
즉, 최대 범위에 대해서 0~1023으로 scaling된 값이 나오게 된다.
+
그리고는 0x32~0x37까지 6바이트에 대해서 x,y,z 축에 대한 값을 받아 온다.
DATAX0이 LSB쪽
DATAX1이 MSB쪽이다.
#include <stdio.h> #include <stdlib.h> #include <linux/i2c-dev.h> #include <fcntl.h> #include <string.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <iostream> int main(int argc, char **argv) { printf("**** ADXL435 example program ****\n"); int fd; // File descrition char *fileName = "/dev/i2c-1"; // Name of the port we will be using int address = 0x53; // Address of the SRF02 shifted right one bit char buf[6]; // Buffer for data being read/ written on the i2c bus short x,y,z; if ((fd = open(fileName, O_RDWR)) < 0) { // Open port for reading and writing printf("Failed to open i2c port\n"); exit(1); } if (ioctl(fd, I2C_SLAVE, address) < 0) { // Set the port options and set the address of the device we wish to speak to printf("Unable to get bus access to talk to slave\n"); exit(1); } buf[0] = 0x2d; // Commands for performing a ranging buf[1] = 0x18; if ((write(fd, buf, 2)) != 2) { // Write commands to the i2c port printf("Error writing to i2c slave\n"); exit(1); } buf[0] = 0x31; // Commands for performing a ranging buf[1] = 0x09; if ((write(fd, buf, 2)) != 2) { // Write commands to the i2c port printf("Error writing to i2c slave\n"); exit(1); } // This sleep waits for the ping to come back while(true){ buf[0] = 0x32; // This is the register we wish to read from if ((write(fd, buf, 1)) != 1) { // Send the register to read from printf("Error writing to i2c slave\n"); exit(1); } usleep(1000); memset(&buf,0,sizeof(buf)); if (read(fd, buf, 6) != 6) { // Read back data into buf[] printf("Unable to read from slave\n"); exit(1); } else { x=y=z=0; // memset(&buf,0,sizeof(buf)); x = ((short)buf[1]<<8) | (short) buf[0]; y = ((short)buf[3]<<8) | (short) buf[2]; z = ((short)buf[5]<<8) | (short) buf[4]; std::cout<<"x:"<<x<<"\ty:"<<y<<"\tz:"<<z<<std::endl; } } return 0; } |
2015/08/24 - [개소리 왈왈/라즈베리 파이(rpi)] - 라즈베리 파이 i2c ADXL345 3축 가속도 센서
값이 바뀌긴 한데 수치만으로는 헷갈리네..
|
|
먼가 값은 나온다.
A4 -> SDA
A5 -> SCL
5V -> VCC
GND -> GND
이렇게 4줄 연결 하고 끝
이제 이걸.. 수학 공식을 이용해서 각도로 계산을 어떻게 한다냐...
가속도계 각도 계산.. (2) | 2016.03.31 |
---|---|
아두이노 nano + ADXL345 (0) | 2016.03.31 |
아두이노 나노 pinout / atmega328p (0) | 2016.03.30 |
아두이노 avr 헤더사용하기 / PUD (0) | 2016.03.30 |
아두이노 / avr bootloader (0) | 2016.03.30 |