embeded/raspberry pi2015. 9. 28. 12:56

pwm 클럭은 채널 1/2에 동일하게 들어가는 듯?


데이터 시트 141p

PWM clock source and frequency is controlled in CPRMAN. 


데이터 시트 138p

채널은 2개 이지만 연결 가능한 GPIO는 여러개로 보인다.

 GPIO가 여러개 라고 해도 동시에 활성화 가능한건 2채널이려나?


+

40번 이후 부터는 compute module에서나 쓸수 있을테고

라즈베리 파이 2에서는

좌/우 로 2개씩 총 4개의 핀이지만 2개의 채널이니까 12,13번 핀을 나란히 써주는 것도 무난 할 듯?

 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+

 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |

 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+

 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |

 |   2 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5V      |     |     |

 |   3 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |

 |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |

 |     |     |      0v |      |   |  9 || 10 | 1 | ALT0 | RxD     | 16  | 15  |

 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |

 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |

 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |

 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |

 |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |

 |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |

 |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 1 | IN   | CE0     | 10  | 8   |

 |     |     |      0v |      |   | 25 || 26 | 1 | IN   | CE1     | 11  | 7   |

 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |

 |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |

 |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |

 |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |

 |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |

 |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |

 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |

 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+

 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |

 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+



+


클럭관련해서는 PWM 쪽이 아닌 상위에서 넣어준다.

[링크 : http://www.farnell.com/datasheets/1521578.pdf]



---


wiring pi 상으로는 ABC 정렬도 아닌거 같고..

그냥 초기화 해야 하는 순서대로

Mode / Range / Clock 순인것 같다.

PWM Control


PWM can not be controlled when running in Sys mode.

  • pwmSetMode (int mode) ;

The PWM generator can run in 2 modes – “balanced” and “mark:space”. The mark:space mode is traditional, however the default mode in the Pi is “balanced”. You can switch modes by supplying the parameter: PWM_MODE_BAL or PWM_MODE_MS.

  • pwmSetRange (unsigned int range) ;

This sets the range register in the PWM generator. The default is 1024.

  • pwmSetClock (int divisor) ;

This sets the divisor for the PWM clock.

To understand more about the PWM system, you’ll need to read the Broadcom ARM peripherals manual.

[링크 : https://projects.drogon.net/raspberry-pi/wiringpi/functions/] 


Posted by 구차니
embeded/raspberry pi2015. 9. 28. 08:29


void pinMode (int pin, int mode) ;

This sets the mode of a pin to either INPUT, OUTPUT, or PWM_OUTPUT. Note that only wiringPi pin 1 (BCM_GPIO 18) supports PWM output.


void pwmWrite (int pin, int value) ;

Writes the value to the PWM register for the given pin. The value must be between 0 and 1024. (Again, note that only pin 1 (BCM_GPIO 18) supports PWM)


pwmSetMode (int mode) ;

The PWM generator can run in 2 modes – “balanced” and “mark:space”. The mark:space mode is traditional, however the default mode in the Pi is “balanced”. You can switch modes by supplying the parameter: PWM_MODE_BAL or PWM_MODE_MS.


pwmSetRange (unsigned int range) ;

This sets the range register in the PWM generator. The default is 1024.


pwmSetClock (int divisor) ;

This sets the divisor for the PWM clock.


[링크 : https://projects.drogon.net/raspberry-pi/wiringpi/functions/]


LED PWM 예제 - c언어 / wiring pi

[링크 : https://learn.sparkfun.com/tutorials/raspberry-gpio/c-wiringpi-example]


python / pwm 2 ch 예제

[링크 : http://electronut.in/controlling-two-servos-with-hardware-pwm-on-the-raspberry-pi-model-a/]

Posted by 구차니
embeded/raspberry pi2015. 9. 24. 10:35

그래도 너무 이것저것 하는 기분이라..

잠시 접어두고 블로그나 해야하려나..

끄응...




Posted by 구차니
embeded/raspberry pi2015. 9. 22. 10:27

jack 해보겠다고 하는데 안되서 보니

어!??!?!?!?!?



/proc/asound/card0 $ ls -al

합계 0

dr-xr-xr-x  4 root root 0  9월 22 10:03 .

dr-xr-xr-x  5 root root 0  9월 22 10:01 ..

-r--r--r--  1 root root 0  9월 22 10:25 id

dr-xr-xr-x 10 root root 0  9월 22 10:25 pcm0p

dr-xr-xr-x  3 root root 0  9월 22 10:25 pcm1p 



생각해보니.. 3.5 파이 잭에도

오디오(L/R) / composite 비디오 인거지..

L/R/Mic 가 아니었네 -ㅁ-?!?!?

Posted by 구차니
embeded/raspberry pi2015. 9. 22. 07:33



[링크 : http://qjackctl.sourceforge.net/]


$ sudo apt-get isntall qjackctl



setup에서 Setting을 보면

Frame/Period, Sample Rate, Period/Buffer를 설정함에 따라 Latency가 자동으로 계산되어 나온다





근데.. 라즈베리는 마이크가 없잖아? 안될거야 ㅠㅠ


네트워크로 할 경우에는 netone이나 netJack을 쓰면 된다고 한다.

[링크 : https://ccrma.stanford.edu/book/export/html/2835]

[링크 : http://jackaudio.org/faq/netjack.html]

[링크 : https://github.com/jackaudio/jackaudio.github.com/wiki]

    [링크 : https://github.com/jackaudio/jackaudio.github.com/wiki/WalkThrough_User_NetJack2]

----

[링크 : https://help.ubuntu.com/community/HowToJACKConfiguration]

[링크 : https://help.ubuntu.com/community/What%20is%20JACK]


[링크 : http://jackaudio.org/faq/pulseaudio_and_jack.html]

[링크 : http://jackaudio.org/faq/jack_on_windows.html]

[링크 : http://jackaudio.org/files/docs/html/index.html]


[링크 : http://www.youtube.com/watch?v=fMz6fDGBnA4]

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

Posted by 구차니
embeded/raspberry pi2015. 9. 21. 13:23

또.. gst-launch가 보이다니 ㄷㄷ


JACK

[링크 : http://wiki.linuxaudio.org/wiki/raspberrypi]


gstreamer

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




---

그나저나.. 영 안되네 -_-

$ sudo apt-cache search jackd

ebumeter - Loudness measurement according to EBU-R128

jackd - JACK Audio Connection Kit (default server package)

jackd1 - JACK Audio Connection Kit (server and example clients)

jackd2 - JACK Audio Connection Kit (server and example clients)

libjack-jackd2-0 - JACK Audio Connection Kit (libraries)

libjack-jackd2-dev - JACK Audio Connection Kit (development files)

pulseaudio - PulseAudio sound server

pulseaudio-module-jack - jackd modules for PulseAudio sound server

pulseaudio-module-jack-dbg - jackd modules for PulseAudio sound server (debugging symbols)

tuxguitar-jack - tuxguitar plugin for sound playback using JACKD

xjadeo - Video player with JACK sync


pi@raspberrypi ~ $ sudo apt-get install jackd

패키지 목록을 읽는 중입니다... 완료

의존성 트리를 만드는 중입니다

상태 정보를 읽는 중입니다... 완료

jackd 패키지는 이미 최신 버전입니다.

jackd 패키지 수동설치로 지정합니다.

0개 업그레이드, 0개 새로 설치, 0개 제거 및 38개 업그레이드 안 함.

pi@raspberrypi ~ $ sudo apt-get install jackd2

패키지 목록을 읽는 중입니다... 완료

의존성 트리를 만드는 중입니다

상태 정보를 읽는 중입니다... 완료

jackd2 패키지는 이미 최신 버전입니다.

jackd2 패키지 수동설치로 지정합니다.

0개 업그레이드, 0개 새로 설치, 0개 제거 및 38개 업그레이드 안 함.



$ DISPLAY=:0.0 jackd -dalsa

jackdmp 1.9.9

Copyright 2001-2005 Paul Davis and others.

Copyright 2004-2012 Grame.

jackdmp comes with ABSOLUTELY NO WARRANTY

This is free software, and you are welcome to redistribute it

under certain conditions; see the file COPYING for details

JACK server starting in realtime mode with priority 10

control device hw:0

control device hw:0

audio_reservation_init

Acquire audio card Audio0

creating alsa driver ... hw:0|hw:0|1024|2|48000|0|0|nomon|swmeter|-|32bit

control device hw:0

ALSA: Cannot open PCM device alsa_pcm for capture. Falling back to playback-only mode

configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods

ALSA: final selected sample format for playback: 16bit little-endian

ALSA: use 2 periods for playback





Posted by 구차니
embeded/raspberry pi2015. 9. 21. 13:22

기술적으로는 무언가 다른 내용이 있을것 같으나..

일단 라즈베리 에서는 GPU의 동적 메모리 할당으로 보면 된다.


CMA - DYNAMIC MEMORY SPLIT

The firmware and kernel as of 19th November 2012 supports CMA (Contiguous Memory Allocator), which means the memory split between CPU and GPU is managed dynamically at runtime. However this is not officially supported.


You can find an example config.txt here.


CMA_LWM

When the GPU has less than cma_lwm (low-water mark) megabytes of memory available, it will request some from the CPU.

cma_lwm 보다 적은 양을 GPU에서 가지고 있을 때, CPU로 부터 (메모리를) 요청한다.


CMA_HWM

When the GPU has more than cma_hwm (high-water mark) megabytes of memory available, it will release some to the CPU.

cma_hwm 보다 큰 것을 GPU에서 가지고 있을 때, CPU에게 (메모리를) 놓아준다.


The following options need to be in cmdline.txt for CMA to work:


coherent_pool=6M smsc95xx.turbo_mode=N


[링크 : https://www.raspberrypi.org/documentation/configuration/config-txt.md]

[링크 : http://elinux.org/RPiconfig#CMA_-_dynamic_memory_split]


영어라 읽다가 귀차니즘으로 포기

[링크 : https://en.wikipedia.org/wiki/High-water_mark_(computer_security)]

[링크 : https://en.wikipedia.org/wiki/Watermark_(data_synchronization)]



원래 찾던건.. 오디오 스트리밍을 낮은 지연시간으로 하는건데..

갑자기 네트워크를 USB 1.1로 돌리고 막 쑈를 하면서 찾은거.. ㄷㄷ

[링크 : http://wiki.linuxaudio.org/wiki/raspberrypi]

Posted by 구차니
embeded/raspberry pi2015. 9. 20. 18:28

패키지 설치

$ sudo apt-get update

$ sudo apt-get install gstreamer1.0 gstreamer1.0-omx


server

$ raspivid -t 0 -w 1280 -h 720 -fps 30 -hf -b 2000000 -n -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=192.168.219.148 port=5000


client

$ gst-launch-1.0 -v tcpclientsrc host=192.168.219.148 port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false


라즈베리 2B -> B

성능 차이도 있긴 하지만.. CPU 점유율이 상당히 낮다 (라즈베리 2B)

top - 18:37:16 up 39 min,  3 users,  load average: 0.12, 0.38, 0.31

Tasks: 108 total,   1 running, 107 sleeping,   0 stopped,   0 zombie

%Cpu(s):  2.7 us,  0.4 sy,  0.0 ni, 96.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st

KiB Mem:    884384 total,   492260 used,   392124 free,    29196 buffers

KiB Swap:   102396 total,        0 used,   102396 free,   377976 cached


  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND

 6214 pi        20   0 42812  13m 6260 S  22.1  1.5   0:21.53 gst-launch-1.0

반면.. 클라이언트는 성능이 꾸져서 인가.. cpu가 하늘을 찌른다 .. ㄷㄷㄷ(라즈베리 B)

top - 18:37:31 up 19 min,  2 users,  load average: 1.10, 0.98, 0.66

Tasks:  67 total,   1 running,  66 sleeping,   0 stopped,   0 zombie

%Cpu(s): 89.1 us,  2.6 sy,  0.0 ni,  7.9 id,  0.0 wa,  0.0 hi,  0.3 si,  0.0 st

KiB Mem:    445804 total,   406424 used,    39380 free,    27972 buffers

KiB Swap:   102396 total,        0 used,   102396 free,   327912 cached


  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND

 6411 pi        20   0 99.2m  23m  12m S  89.3  5.5   1:41.95 gst-launch-1.0 


현재 상황으로는... 2b -> b 로는 스트리밍이 전혀 안되는 상황..

옵션이 문제인가..


라즈베리 B -> 2B

라즈베리 B.. 보내는 쪽은 낮네

 top - 19:00:28 up 18 min,  2 users,  load average: 0.06, 0.13, 0.13

Tasks:  68 total,   1 running,  67 sleeping,   0 stopped,   0 zombie

%Cpu(s):  5.0 us,  3.7 sy,  0.0 ni, 90.3 id,  0.0 wa,  0.0 hi,  1.0 si,  0.0 st

KiB Mem:    380780 total,    68340 used,   312440 free,    10220 buffers

KiB Swap:   102396 total,        0 used,   102396 free,    29628 cached


  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND

 2325 pi        20   0 38028 9004 6220 S   5.9  2.4   1:03.73 gst-launch-1.0


라즈베리 2B.. 받는 쪽은 하늘을 찌른다. ㄷㄷㄷ

top - 19:00:32 up 17 min,  2 users,  load average: 2.44, 2.46, 1.71

Tasks: 106 total,   1 running, 105 sleeping,   0 stopped,   0 zombie

%Cpu(s): 49.4 us,  5.5 sy,  0.0 ni, 44.9 id,  0.0 wa,  0.0 hi,  0.2 si,  0.0 st

KiB Mem:    884384 total,   218004 used,   666380 free,    17676 buffers

KiB Swap:   102396 total,        0 used,   102396 free,    92048 cached


  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND

 2543 pi        20   0  158m  48m  12m S 168.8  5.6  27:10.75 gst-launch-1.0 






Posted by 구차니
embeded/raspberry pi2015. 9. 19. 11:26

5ch를 도전했으나..

USB 카메라 2개가 안 붙어서 2개만.. ㅠㅠ



320x240x15p 에서는 대략.. 3Mb 정도 대역폭

머.. USB 2.0에 주고 받고 네트워크 하면 대충 커버는 가능한 듯..


문제는 의외로 CPU를 많이 먹는 다는 점?


아무튼.. iftop  이라는 좋은 녀석도 발견하고..

[링크 : http://blog.naver.com/parkjy76/30155747342]

Posted by 구차니
embeded/raspberry pi2015. 9. 17. 11:49

yuv는 raw 데이터니까 포맷과 이미지 크기는 수동으로 잡아 주어야 한다.

음.. yuv랑 jpg랑 화질 차이는 모르겠네..



raspistill로 촬영


특이하게도.. raspistill로 받아오니 EXIF 정보가 들어오네?


[링크 : http://sourceforge.net/projects/raw-yuvplayer/]


그나저나.yuv나 jpg나 둘다 시간은 거의 동일하네

raspistill은 raspiyuv로 받고 yuv to jpg로 변환하는 건가?(1초 차이!)


pi@raspberrypi ~/src $ date; raspiyuv -o img3.yuv;date

2015. 09. 17. (목) 11:41:19 KST

2015. 09. 17. (목) 11:41:25 KST


pi@raspberrypi ~/src $ date; raspistill -o img.jpg;date

2015. 09. 17. (목) 11:42:15 KST

2015. 09. 17. (목) 11:42:21 KST


pi@raspberrypi ~/src $ ls -alh

합계 25M

drwxr-xr-x  3 pi pi 4.0K  9월 17 11:42 .

drwxr-xr-x 13 pi pi 4.0K  9월 17 11:38 ..

-rw-r--r--  1 pi pi 2.5M  9월 17 11:42 img.jpg

-rw-r--r--  1 pi pi 7.3M  9월 17 11:41 img3.yuv 


저장되는 해상도 상관없이 무조건 full 영상 해상도로 받아와서 처리하는 느낌?

$ date; raspiyuv -o img3.yuv -w 1920 -h 1080 ;date

2015. 09. 17. (목) 11:51:55 KST

2015. 09. 17. (목) 11:52:01 KST 





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

라즈베리 파이 gstreamer 시도  (2) 2015.09.20
라즈베리 파이 motion / 3ch..  (0) 2015.09.19
라즈베리 파이 RAW output  (0) 2015.09.16
라즈베리 파이 rpi-cam-web-interface  (0) 2015.09.16
라즈베리 파이 PWM 채널  (0) 2015.09.16
Posted by 구차니