embeded/raspberry pi2015. 9. 3. 09:13

생각해보니.. 음속은 기온에 비례하는데

공식으로는 대충


음속 = (331.3 + 0.606 * 섭씨) m/s

0도에서 약 331m인데

실온이면 약 18도 로 잡고(10.908m/s) 342.208m/s

근사치로 340 정도 잡으면 될거 같긴한데


[링크 : https://en.wikipedia.org/wiki/Speed_of_sound]


어짜피 DHT-11 온도/습도 센서가 있으니까..

이걸로 온도 잰걸로 음속을 환산해주면 좀더 정확해지려나? +_+


[링크 : http://eleparts.co.kr/EPXF6C83]

[링크 : http://eleparts.co.kr/EPXF43N9]


Posted by 구차니
embeded/raspberry pi2015. 9. 2. 16:23


CPU의 시리얼 번호를 기반으로 MAC을 생성 하는 듯?

그나저나.. BogoMIPS가 멋대로 바뀌네? ㄷㄷㄷ


타이머로 변경되면서 클럭 변경되면 다르게 나오려나?

$ cat /proc/cpuinfo

processor       : 0

model name      : ARMv7 Processor rev 5 (v7l)

BogoMIPS        : 38.40

Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm

CPU implementer : 0x41

CPU architecture: 7

CPU variant     : 0x0

CPU part        : 0xc07

CPU revision    : 5 


$ cat /proc/cpuinfo

processor       : 3

model name      : ARMv7 Processor rev 5 (v7l)

BogoMIPS        : 57.60

Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm

CPU implementer : 0x41

CPU architecture: 7

CPU variant     : 0x0

CPU part        : 0xc07

CPU revision    : 5


Hardware        : BCM2709

Revision        : a21041

Serial          : 00000000a37ce24e


$ sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq; cat /proc/cpuinfo

900000

processor       : 0

model name      : ARMv7 Processor rev 5 (v7l)

BogoMIPS        : 57.60

Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm

CPU implementer : 0x41

CPU architecture: 7

CPU variant     : 0x0

CPU part        : 0xc07

CPU revision    : 5


$ sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq; cat /proc/cpuinfo

600000

processor       : 0

model name      : ARMv7 Processor rev 5 (v7l)

BogoMIPS        : 38.40

Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm

CPU implementer : 0x41

CPU architecture: 7

CPU variant     : 0x0

CPU part        : 0xc07

CPU revision    : 5


---

라즈 B


# cat /proc/cpuinfo

processor       : 0

model name      : ARMv6-compatible processor rev 7 (v6l)

Features        : half thumb fastmult vfp edsp java tls

CPU implementer : 0x41

CPU architecture: 7

CPU variant     : 0x0

CPU part        : 0xb76

CPU revision    : 7


Hardware        : BCM2708

Revision        : 000e

Serial          : 0000000055593a15


# ifconfig

eth0      Link encap:Ethernet  HWaddr B8:27:EB:59:3A:15

---



$ ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:7c:e2:4e
          inet addr:192.168.10.23  Bcast:192.168.10.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1685 errors:0 dropped:2 overruns:0 frame:0
          TX packets:358 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:107201 (104.6 KiB)  TX bytes:52547 (51.3 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1104 (1.0 KiB)  TX bytes:1104 (1.0 KiB)


$ cat /sys/class/net/eth0/address

b8:27:eb:7c:e2:4e


[링크 : http://www.robert-drummond.com/2013/05/23/how-to-find-the-mac-address-of-your-raspberry-pi/]

Posted by 구차니
embeded/raspberry pi2015. 8. 27. 08:24

자유낙하 실험... 은 아니고

가방에 넣어 두었는데

가방이 떨어지면서 먼가 불쾌한 철퍽 하는 소리..

꺼내보니 액정까진 아니고 액정 보호유리가 깨지고..

켜보니... ㅠㅠ


터치 축 틀어짐 -_-!!!!

캘리브레이션 한다고 될진 모르겠지만 끄아아아아 ㅠㅠ



사요나라

바이바이

잘가

ㅠㅠ





그러니 다시 사야하나? ㅠㅠ

[링크 : http://eleparts.co.kr/EPXDR9TM]

Posted by 구차니
embeded/raspberry pi2015. 8. 24. 15:47

아두이노랑은 이렇게 하라는데

일단.. I2C로 할거니까.. 저렇게 위에 4개 선을 연결하면 어찌어찌 라즈베리에서도 사용가능 할 듯



장치 ID는 0xE5 고정

ADXL345

REGISTER DEFINITIONS

Register 0x00—DEVID (Read Only)

The DEVID register holds a fixed device ID code of 0xE5 (345 octal). 



데이터는 X/Y/Z축 LSB / MSB 순으로 들어 있다.


Register 0x32 to Register 0x37—DATAX0, DATAX1, DATAY0, DATAY1, DATAZ0, DATAZ1 (Read Only)

 These six bytes (Register 0x32 to Register 0x37) are eight bits each and hold the output data for each axis. Register 0x32 and Register 0x33 hold the output data for the x-axis, Register 0x34 and Register 0x35 hold the output data for the y-axis, and Register 0x36 and Register 0x37 hold the output data for the z-axis. The output data is twos complement, with DATAx0 as the least significant byte and DATAx1 as the most significant byte, where x represent X, Y, or Z. The DATA_FORMAT register (Address 0x31) controls the format of the data. It is recommended that a multiple-byte read of all registers be performed to prevent a change in data between reads of sequential registers



I 2 C

 With CS tied high to VDD I/O, the ADXL345 is in I2 C mode, requiring a simple 2-wire connection, as shown in Figure 40. The ADXL345 conforms to the UM10204 I 2 C-Bus Specification and User Manual, Rev. 03—19 June 2007, available from NXP Semiconductors. It supports standard (100 kHz) and fast (400 kHz) data transfer modes if the bus parameters given in Table 11 and Table 12 are met. Single- or multiple-byte reads/writes are supported, as shown in Figure 41. With the ALT ADDRESS pin high, the 7-bit I 2 C address for the device is 0x1D, followed by the R/W bit. This translates to 0x3A for a write and 0x3B for a read. An alternate I2 C address of 0x53 (followed by the R/W bit) can be chosen by grounding the ALT ADDRESS pin (Pin 12). This translates to 0xA6 for a write and 0xA7 for a read. There are no internal pull-up or pull-down resistors for any unused pins; therefore, there is no known state or default state for the CS or ALT ADDRESS pin if left floating or unconnected. It is required that the CS pin be connected to VDD I/O and that the ALT ADDRESS pin be connected to either VDD I/O or GND when using I2 C


[링크 : http://eleparts.co.kr/data/design/product_file/SENSOR/G_SENSOR/data/ADXL345.pdf]


---





---

pi@raspberrypi /boot/overlays $ dmesg | grep i2c

[    3.862054] bcm2708_i2c_init_pinmode(1,2)

[    3.863939] bcm2708_i2c_init_pinmode(1,3)

[    3.866020] bcm2708_i2c 3f804000.i2c: BSC1 Controller at 0x3f804000 (irq 79) (baudrate 100000)


pi@raspberrypi /boot/overlays $ lsmod | grep i2c

i2c_bcm2708             4990  0


pi@raspberrypi /boot/overlays $ insmod i2c-dev

Error: could not load module i2c-dev: No such file or directory


pi@raspberrypi /boot/overlays $ sudo vi /etc/modules

i2c-dev

i2c-bcm2708


pi@raspberrypi ~ $ lsmod | grep i2c

i2c_dev                 6027  0

i2c_bcm2708             4990  0


pi@raspberrypi ~ $ i2cdetect -y 1

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00:          -- -- -- -- -- -- -- -- -- -- -- -- --

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

50: -- -- -- 53 -- -- -- -- -- -- -- -- -- -- -- --

60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

70: -- -- -- -- -- -- -- --

pi@raspberrypi ~ $ i2cdetect -y 0

Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory


pi@raspberrypi ~ $ i2cdetect -l

i2c-1   i2c             3f804000.i2c                            I2C adapter


pi@raspberrypi ~ $ i2cdetect -F 1

Functionalities implemented by /dev/i2c-1:

I2C                              yes

SMBus Quick Command              yes

SMBus Send Byte                  yes

SMBus Receive Byte               yes

SMBus Write Byte                 yes

SMBus Read Byte                  yes

SMBus Write Word                 yes

SMBus Read Word                  yes

SMBus Process Call               yes

SMBus Block Write                yes

SMBus Block Read                 no

SMBus Block Process Call         no

SMBus PEC                        yes

I2C Block Write                  yes

I2C Block Read                   yes


pi@raspberrypi ~ $ lsmod | grep -i i2c

i2c_dev                 6027  0

i2c_bcm2708             4990  0



insmod가 아니라 modprobe ...


pi@raspberrypi ~ $ sudo modprobe i2c_dev

pi@raspberrypi ~ $ lsmod | grep i2c

i2c_dev                 6027  0

i2c_bcm2708             4990  0


[링크 : http://raspberrypi.stackexchange.com/.../how-to-make-raspbian-load-the-i2c-dev-module-on-boot-up]



---





#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;

} 



Posted by 구차니
embeded/raspberry pi2015. 8. 24. 15:30


raspi-config 면 기본 설정을 될테고..

나머지는 간단한(?) 테스트용 유틸리티 설치?


$ sudo apt-get install i2c-tools libi2c-dev python-smbus

$ sudo i2cdetect -y 1

[링크 : http://www.rasplay.org/?p=6409]

[링크 : https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c]


예제코드 / 스켈레톤 코드

char *fileName = "/dev/i2c-0";

fd = open(fileName, O_RDWR);

ioctl(fd, I2C_SLAVE, address);

write(fd, buf, 1);

read(fd, buf, 2); 

[링크 : http://www.robot-electronics.co.uk/files/rpi_sd21.c]

    [링크 : http://www.robot-electronics.co.uk/htm/raspberry_pi_examples.htm]


pi@raspberrypi ~ $ i2cdetect

Error: No i2c-bus specified!

Usage: i2cdetect [-y] [-a] [-q|-r] I2CBUS [FIRST LAST]

       i2cdetect -F I2CBUS

       i2cdetect -l

  I2CBUS is an integer or an I2C bus name

  If provided, FIRST and LAST limit the probing range. 


활성화 시키지 않으면 이런 에러가 발생한다.

pi@raspberrypi ~ $ i2cdetect -y 1

Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory 


근데..

전에 처럼 또.. 연결 안하고 안켜면 활성화도 안되는 기분?

pi@raspberrypi ~ $ sudo i2cdetect -y 1

Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory


pi@raspberrypi ~ $ dmesg | grep i2c

[    3.872815] bcm2708_i2c_init_pinmode(1,2)

[    3.874707] bcm2708_i2c_init_pinmode(1,3)

[    3.877782] bcm2708_i2c 3f804000.i2c: BSC1 Controller at 0x3f804000 (irq 79) (baudrate 100000) 



Posted by 구차니
embeded/raspberry pi2015. 8. 23. 22:16

머.. fbtft 였나..

fb를 쓰는거니 당연히 되는 걸로 생각이 되긴 해야 하지만..

사이즈나 속도 면에서 무슨 제약이 걸려서 안되는게 아닐까 싶기도?

아무튼 되는거 보면 왜 놀라운걸까 ㅋㅋ




Posted by 구차니
embeded/raspberry pi2015. 8. 23. 16:01

음.. 다시 봤더니 뭔가 수정된 기분?

아무튼.. 나중에 다시 한번 바닥 부터 만들어 봐야지...

rootfs에 dtb 관련해서 추가되는게 은근 좀 있는 듯...


$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs

$ mkdir mnt/fat32

$ mkdir mnt/ext4

$ sudo mount /dev/sdb1 mnt/fat32

$ sudo mount /dev/sdb2 mnt/ext4

$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install

$ sudo cp mnt/fat32/$KERNEL.img mnt/fat32/$KERNEL-backup.img

$ sudo scripts/mkknlimg arch/arm/boot/zImage mnt/fat32/$KERNEL.img

$ sudo cp arch/arm/boot/dts/*.dtb mnt/fat32/

$ sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/fat32/overlays/

$ sudo cp arch/arm/boot/dts/overlays/README mnt/fat32/overlays/

$ sudo umount mnt/fat32

$ sudo umount mnt/ext4


[링크 : https://www.raspberrypi.org/documentation/linux/kernel/building.md]


스크립트를 통해서 zImage 파일이 어떻게든 변경되나 보다..

$ sudo ./scripts/mkknlimg arch/arm/boot/zImage ~/KERNEL.img

Version: Linux version 4.1.6-v7+ (minimonk@devmini) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) ) #1 SMP PREEMPT Tue Aug 18 23:54:39 KST 2015

DT: y

283x: n


$ ls -al ~/KERNEL.img

-rw-r--r-- 1 root root 4031680  8월 23 16:19 /home/minimonk/KERNEL.img


$ file ~/KERNEL.img

/home/minimonk/KERNEL.img: Linux kernel ARM boot executable zImage (little-endian)


$ diff arch/arm/boot/zImage ~/KERNEL.img

Binary files arch/arm/boot/zImage and /home/minimonk/KERNEL.img differ  



2015/04/16 - [개소리 왈왈/라즈베리 파이(rpi)] - 라즈베리 파이 2 커널모듈 빌드

'embeded > raspberry pi' 카테고리의 다른 글

라즈베리 파이 i2c 사용하기  (0) 2015.08.24
라즈베리 파이 SPI LCD도.. openGL은 되네?  (0) 2015.08.23
라즈베리 카메라 관련  (0) 2015.08.21
motion는 쓸만한게 아니었나..  (0) 2015.08.21
MMAL motion 로그  (0) 2015.08.20
Posted by 구차니
embeded/raspberry pi2015. 8. 21. 14:37

나만 잘 안되나..

v4l2나 motion 관련해서 보는데 끄응...

일단 기본 문서들 조사중..



raspistill - Capturing still photographs with the camera module

raspiyuv - Capturing still photographs and generating raw unprocessed image files

raspivid - Capturing video with the camera module

[링크 : https://www.raspberrypi.org/documentation/usage/camera/raspicam/README.md]



$ sudo apt-get install python-picamera 

[링크 : https://www.raspberrypi.org/documentation/usage/camera/python/README.md]

[링크 : http://picamera.readthedocs.org/] pythin picamera API


module has a five megapixel fixed-focus camera that supports 1080p30, 720p60 and VGA90 video modes, as well as stills capture. It attaches via a 15cm ribbon cable to the CSI port on the Raspberry Pi.

[링크 : https://www.raspberrypi.org/products/camera-module/]

'embeded > raspberry pi' 카테고리의 다른 글

라즈베리 파이 SPI LCD도.. openGL은 되네?  (0) 2015.08.23
라즈베리 파이 빌드.. 다시?  (0) 2015.08.23
motion는 쓸만한게 아니었나..  (0) 2015.08.21
MMAL motion 로그  (0) 2015.08.20
MMAL motion  (0) 2015.08.19
Posted by 구차니
embeded/raspberry pi2015. 8. 21. 12:46

MMAL motion으로 돌리면

cpu 하나 100% 쳐묵쳐묵 하고 있고

framerate를 30으로 해줘도 1프레임도 안나와서

찾아보니.. 이거뭐..


v4l2 official driver 해도 시궁창이던데...

그냥 MMAL / CSI를 포기해야 하나


아니 그래서 사람들이 이거 관련 글이 별로 없었던 건가?


[링크 : https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=62945]

'embeded > raspberry pi' 카테고리의 다른 글

라즈베리 파이 빌드.. 다시?  (0) 2015.08.23
라즈베리 카메라 관련  (0) 2015.08.21
MMAL motion 로그  (0) 2015.08.20
MMAL motion  (0) 2015.08.19
라즈베리 파이 터치 LCD(3.5인치 waveshare) evtest  (0) 2015.08.19
Posted by 구차니
embeded/raspberry pi2015. 8. 20. 09:58


로그를 보니.. 2프레임이 머니.. 2프레임이 -_-

[1978205048] [NTC] [ALL] [Aug 19 22:48:49] motion_startup: Using log type (ALL) log level (WRN)

[1] [ALR] [VID] [Aug 19 22:48:49] mmalcam_start: MMAL Camera thread starting... for camera (vc.ril.camera) of 1024 x 576 at 2 fps

[1] [ALR] [VID] [Aug 19 22:48:49] mmalcam_start: MMAL Camera using video capture

[1] [ALR] [VID] [Aug 19 22:55:37] MMAL Camera cleanup 


아마도.. 여기 설정에 영향을 받는거 같은데..

프레임 바꾸고 해봐야겠다.

# Maximum number of frames to be captured per second.

# Valid range: 2-100. Default: 100 (almost no limit).

framerate 1


############################################################

# OpenMax/MMAL camera support for Raspberry Pi

############################################################

mmalcam_name vc.ril.camera


요건 카메라 장착 안하고 MMAL motion 실행파일 구동할때의 에러

조금은 속아주고 돌아갈줄 알았더니..췟

[1] [ERR] [VID] [Aug 20 09:54:36] Failed to create MMAL camera component create_camera_component 



'embeded > raspberry pi' 카테고리의 다른 글

라즈베리 카메라 관련  (0) 2015.08.21
motion는 쓸만한게 아니었나..  (0) 2015.08.21
MMAL motion  (0) 2015.08.19
라즈베리 파이 터치 LCD(3.5인치 waveshare) evtest  (0) 2015.08.19
wayland 설정  (0) 2015.08.19
Posted by 구차니