embeded/raspberry pi2015. 10. 16. 09:46

데이터 시트상으로는 PWM 1과 PWM 2 채널 독립적으로

모드를 설정하여 사용이 가능해야 하나...

wiringPi에서는 편의상.. 걍 묶어 버렸다!!!!


wiringPi/wiringPi $ vi wiringPi.c

void pwmSetMode (int mode)

{

  if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO))

  {

    if (mode == PWM_MODE_MS)

      *(pwm + PWM_CONTROL) = PWM0_ENABLE | PWM1_ENABLE | PWM0_MS_MODE | PWM1_MS_MODE ;

    else

      *(pwm + PWM_CONTROL) = PWM0_ENABLE | PWM1_ENABLE ;

  }

}


void pwmSetRange (unsigned int range)

{

  if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO))

  {

    *(pwm + PWM0_RANGE) = range ; delayMicroseconds (10) ;

    *(pwm + PWM1_RANGE) = range ; delayMicroseconds (10) ;

  }

}


void pwmSetClock (int divisor)

{

  uint32_t pwm_control ;

  divisor &= 4095 ;


  if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO))

  {

    if (wiringPiDebug)

      printf ("Setting to: %d. Current: 0x%08X\n", divisor, *(clk + PWMCLK_DIV)) ;


    pwm_control = *(pwm + PWM_CONTROL) ;                // preserve PWM_CONTROL


// We need to stop PWM prior to stopping PWM clock in MS mode otherwise BUSY

// stays high.


    *(pwm + PWM_CONTROL) = 0 ;                          // Stop PWM


// Stop PWM clock before changing divisor. The delay after this does need to

// this big (95uS occasionally fails, 100uS OK), it's almost as though the BUSY

// flag is not working properly in balanced mode. Without the delay when DIV is

// adjusted the clock sometimes switches to very slow, once slow further DIV

// adjustments do nothing and it's difficult to get out of this mode.


    *(clk + PWMCLK_CNTL) = BCM_PASSWORD | 0x01 ;        // Stop PWM Clock

      delayMicroseconds (110) ;                 // prevents clock going sloooow


    while ((*(clk + PWMCLK_CNTL) & 0x80) != 0)  // Wait for clock to be !BUSY

      delayMicroseconds (1) ;


    *(clk + PWMCLK_DIV)  = BCM_PASSWORD | (divisor << 12) ;


    *(clk + PWMCLK_CNTL) = BCM_PASSWORD | 0x11 ;        // Start PWM clock

    *(pwm + PWM_CONTROL) = pwm_control ;                // restore PWM_CONTROL


    if (wiringPiDebug)

      printf ("Set     to: %d. Now    : 0x%08X\n", divisor, *(clk + PWMCLK_DIV)) ;

  }

}




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

라즈베리 파이 CLCD 라이브러리  (0) 2015.11.03
bcm2835 pwm 데이터시트  (0) 2015.10.16
라즈베리 파이 GPIO 유틸 PWM  (0) 2015.10.14
DHT-11 DHT-22 RHT-03  (0) 2015.10.14
dSPIN_raspi / L6470 / sparkfun  (0) 2015.10.12
Posted by 구차니

오랫만에 홈페이지 갔더니

이상한 요금제가 있어서 114 센터 전화하고 물어봐서 변경!

그대로라고 하더니 음성이 조금 더 싸지고 기본료도 싸지고!

그런데 이런 중요한(!) 정보는 좀 지들이 알려줘야 하는거 아냐!?!?

이제 사라진 4500원 짜리 요금제에서 다른걸로 바꾸라고 해줘야지!!! 버럭



기존은 반값기본요금제로 9000->4500원(VAT별도)

음성 1.8 / 문자 15 / 데이터 20.48


에서


후불1500 (1500 VAT별도)

음성 1.5 / 문자 15 / 데이터 20.48 로 더 나아진 서비스가 되려나?



'개소리 왈왈 > 모바일 생활' 카테고리의 다른 글

다음달은 5천원을 목표로!!  (0) 2015.11.13
smardi GAM.r  (0) 2015.10.24
디펜스 성공!  (0) 2015.05.15
드디어!! 약정 할부 끝? ㅋㅋ  (0) 2015.03.16
안드로이드 asec / apk  (0) 2015.02.15
Posted by 구차니
embeded/raspberry pi2015. 10. 14. 22:44

1024 로 설정되면

30 ~ 110 범위로 180도를 오가는지라 해상도가 낮아졌는데

100으로 설정하고 range를 키워주면 상당부분 해소 될듯

기존의 80/180=2.25도에서 320/180=0.56도로 4배 정도 해상도가 향상된다.


$ gpio mode 1 pwm

$ gpio pwm-ms


$ gpio pwmc 400

$ gpio pwmr 1024

$ gpio pwm 1 30

$ gpio pwm 1 70

$ gpio pwm 1 110 


$ gpio pwmc 200

$ gpio pwmr 2048

$ gpio pwm 1 60

$ gpio pwm 1 140

$ gpio pwm 1 220


$ gpio pwmc 100

$ gpio pwmr 4096

$ gpio pwm 1 120

$ gpio pwm 1 280

$ gpio pwm 1 440



2015/06/22 - [개소리 왈왈/라즈베리 파이(rpi)] - 라즈베리 파이 2 PWM-MS 모드 servo 제어


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

bcm2835 pwm 데이터시트  (0) 2015.10.16
wiringpi pwm 라이브러리 분석?  (0) 2015.10.16
DHT-11 DHT-22 RHT-03  (0) 2015.10.14
dSPIN_raspi / L6470 / sparkfun  (0) 2015.10.12
라즈베리 파이 홈페이지 내용 업데이트 - pi 2b  (0) 2015.10.09
Posted by 구차니
Programming/openCV2015. 10. 14. 21:38

tpos + ((matchLoc.x - 160) * 60 / (180/60) /  320);



해놓고는 왜 이게 대충 근사로 되는지 모르겠네 -_-

일단.. 서보 모터는 180도 움직일 수 있고
이 값이 30~110 까지로 설정이 되지만 trackbar에서는 0~100으로 설정되니 일단 패스

카메라 하나의 시야각은 60도로 근사하고
화면상에 보이는 각도는0~100중 0~33으로 가정하여
계산을 한다
그리고 화면 해상도(클릭 범위)는 0~319로 320 범위로 생각

그러면 클릭 위치를 중심점에서 부터 빼서
(matchLoc.x - (320 / 2)) / 320 로 중심점을 계산하고
음의 방향이 될지 양의 방향이 될지 계산한다.


현재 화면의 화각은 60도로

전체 범위(0~100) 에서 1/3 사이즈로 계산한다.

/ (180 / 60)



전체 수식으로는

현재 화면에서의 비율 * 화면 하나의 각도 * 화면 하나의 서보에 대한 비율


 ( 현재 점 - 중심점 )                                     카메라 영상 각도(60')

----------------------- *  카메라 영상 각도(60') * ----------------------------

카메라 영상폭(320px)                                     서보 이동 각도(180')



이 되려나?

하고 나니 나도 헷갈리네.. ㅠㅠ




---------------

일단은 백업..

한쪽 버전


$ cat cv.cpp

#include <opencv2/core/core.hpp>

#include <opencv2/highgui/highgui.hpp>

#include <opencv2/imgproc/imgproc.hpp>

#include <iostream>


#include <wiringPi.h>


#define MIN_POS 30

#define MAX_POS 110


using namespace cv;

using namespace std;


bool bMouse = true;

Point mpos(160,120);


void CallBackFunc(int event, int x, int y, int flags, void* userdata)

{


        switch(event)

        {

        default:

                break;


        case EVENT_LBUTTONDOWN:

                cout << "EVENT_LBUTTONDOWN" << endl;

                cout << "pos (" << x << "," << y << ")" << endl;

                mpos.x = x;

                mpos.y = y;

                bMouse = true;

                break;

        case EVENT_LBUTTONUP:

                cout << "EVENT_LBUTTONUP" << endl;

                break;

        case EVENT_RBUTTONDOWN:

                cout << "EVENT_RBUTTONDOWN" << endl;

                bMouse = true;

                break;

        }

}


void init_wiringpi()

{

        if(wiringPiSetup() == -1) exit(0);


        pinMode(1, PWM_OUTPUT);

        pwmSetMode(PWM_MODE_MS);

        pwmSetRange(1024);

        pwmSetClock(400);


        pinMode(23, PWM_OUTPUT);

        pwmSetMode(PWM_MODE_MS);

        pwmSetRange(1024);

        pwmSetClock(400);


        pwmWrite(1,     MIN_POS + (MAX_POS - MIN_POS) / 2);

        pwmWrite(23,    MIN_POS + (MAX_POS - MIN_POS) / 2);

}


void setPWM_1(int val)

{

        pwmWrite(23, val);

}


void setPWM_2(int val)

{

        pwmWrite(1, val);

}



void on_trackbar_1(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

        setPWM_1(val);


        cout << "pos 1 [" << pos << ":" << val << "]" << endl;

}


void on_trackbar_2(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

        setPWM_2(val);


        cout << "pos 2 [" << pos << ":" << val << "]" << endl;

}


void on_trackbar_3(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

//      setPWM_1(val);

//      setPWM_2(val);


        setTrackbarPos("track 1", "cam 1", pos);

        setTrackbarPos("track 2", "cam 2", pos);


        cout << "pos 3 [" << pos << ":" << val << "]" << endl;

}


int main(int argc, char** argv)

{

        // opencv 2 style

        VideoCapture cap(0);

        int pos[2];


        init_wiringpi();


        if(!cap.isOpened())

        {

                cout << "No camera detected" << endl;

                return -1;

        }

        else

        {

                cout << "In capture ..." << endl;

                cap.set(CV_CAP_PROP_FRAME_WIDTH, 320);

                cap.set(CV_CAP_PROP_FRAME_HEIGHT, 240);

        }

/*

        VideoCapture cap2(1);

        if(!cap2.isOpened())

        {

                cout << "No camera detected" << endl;

                return -1;

        }

        else

        {

                cout << "In capture ..." << endl;

                cap2.set(CV_CAP_PROP_FRAME_WIDTH, 320);

                cap2.set(CV_CAP_PROP_FRAME_HEIGHT, 240);

        }

*/

        namedWindow("cam 1", WINDOW_AUTOSIZE );

//      namedWindow("cam 2", WINDOW_AUTOSIZE );

        namedWindow("control", WINDOW_AUTOSIZE );

        namedWindow("crop", WINDOW_AUTOSIZE );


        createTrackbar("track 1", "cam 1", &pos[0], 100, on_trackbar_1 );

//      createTrackbar("track 2", "cam 2", &pos[1], 100, on_trackbar_2 );

//      createTrackbar("track 3", "control", &pos[0], 100, on_trackbar_3 );


        setTrackbarPos("track 1", "cam 1", 50);

//      setTrackbarPos("track 2", "cam 2", 50);

//      setTrackbarPos("track 3", "control", 50);


        setMouseCallback("cam 1", CallBackFunc, NULL);


        Mat frame;

        Mat result;

        Mat tMat;

        Mat crop;


        double minVal;

        double maxVal;

        Point minLoc;

        Point maxLoc;

        Point matchLoc;


        for(;;)

        {


                Point pt[2];

                if(!cap.read(frame)) break;

                        pt[0].x = 150;

                        pt[0].y = 110;

                        pt[1].x = pt[0].x + 20;

                        pt[1].y = pt[0].y + 20;


                if(bMouse)

                {

                        tMat = frame.clone();

                        crop = Mat(tMat, Rect(mpos.x - 10, mpos.y - 10, 20, 20));

                        imshow("crop", crop);

                }


                matchTemplate( frame, crop, result, CV_TM_SQDIFF );

                normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );

                minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );

                matchLoc = minLoc;

                cout << "matchLoc : " << matchLoc << endl;


                rectangle(frame, pt[0], pt[1], Scalar(0,0,0),2);

                rectangle(frame, Point(mpos.x - 10, mpos.y - 10), Point(mpos.x + 10, mpos.y + 10), Scalar(0,0,255),2);

                rectangle(frame, matchLoc, Point( matchLoc.x + 20 , matchLoc.y + 20 ), Scalar(0,255,0), 2);

#define SERVO_ANG       180

#define CAM_FOV         60

                if(bMouse)

                {

                        int tpos = getTrackbarPos("track 1", "cam 1");

//                      int value = tpos + (matchLoc.x - 160) * 3 * 2/ 100;

//                      int value = tpos + (100 / (SERVO_ANG / CAM_FOV)) * (matchLoc.x / 320) ;

                        int value = tpos + ((matchLoc.x - 160) * 60 / 3 /  320);

                        cout << "---- calc : " <<  value << endl;

                        setTrackbarPos("track 1", "cam 1", value);

                        bMouse = false;

                }


                imshow("cam 1", frame);

/*

                if(!cap2.read(frame)) break;

                rectangle(frame, pt[0], pt[1], Scalar(0,0,0),2);


                matchTemplate( frame, crop, result, CV_TM_SQDIFF );

                normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );

                minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );

                matchLoc = minLoc;

                cout << "matchLoc : " << matchLoc << endl;


                rectangle(frame, matchLoc, Point( matchLoc.x + 20 , matchLoc.y + 20 ), Scalar(0,255,0), 2);

                        imshow("cam 2", frame);

*/

                if(waitKey(30) >= 0) break;

        }


        return 0;

} 



두쪽 버전

$ cat cv.cpp

#include <opencv2/core/core.hpp>

#include <opencv2/highgui/highgui.hpp>

#include <opencv2/imgproc/imgproc.hpp>

#include <iostream>


#include <wiringPi.h>


#define MIN_POS 30

#define MAX_POS 110


using namespace cv;

using namespace std;


bool bMouse = true;

Point mpos(160,120);


void CallBackFunc(int event, int x, int y, int flags, void* userdata)

{


        switch(event)

        {

        default:

                break;


        case EVENT_LBUTTONDOWN:

                cout << "EVENT_LBUTTONDOWN" << endl;

                cout << "pos (" << x << "," << y << ")" << endl;

                mpos.x = x;

                mpos.y = y;

                bMouse = true;

                break;

        case EVENT_LBUTTONUP:

                cout << "EVENT_LBUTTONUP" << endl;

                break;

        case EVENT_RBUTTONDOWN:

                cout << "EVENT_RBUTTONDOWN" << endl;

                bMouse = true;

                break;

        }

}


void init_wiringpi()

{

        if(wiringPiSetup() == -1) exit(0);


        pinMode(1, PWM_OUTPUT);

        pwmSetMode(PWM_MODE_MS);

        pwmSetRange(1024);

        pwmSetClock(400);


        pinMode(23, PWM_OUTPUT);

        pwmSetMode(PWM_MODE_MS);

        pwmSetRange(1024);

        pwmSetClock(400);


        pwmWrite(1,     MIN_POS + (MAX_POS - MIN_POS) / 2);

        pwmWrite(23,    MIN_POS + (MAX_POS - MIN_POS) / 2);

}


void setPWM_1(int val)

{

        pwmWrite(23, val);

}


void setPWM_2(int val)

{

        pwmWrite(1, val);

}



void on_trackbar_1(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

        setPWM_1(val);


        cout << "pos 1 [" << pos << ":" << val << "]" << endl;

}


void on_trackbar_2(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

        setPWM_2(val);


        cout << "pos 2 [" << pos << ":" << val << "]" << endl;

}


void on_trackbar_3(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

        setPWM_1(val);

        setPWM_2(val);


        setTrackbarPos("track 1", "cam 1", pos);

        setTrackbarPos("track 2", "cam 2", pos);


        cout << "pos 3 [" << pos << ":" << val << "]" << endl;

}


int main(int argc, char** argv)

{

        // opencv 2 style

        VideoCapture cap(0);

        int pos[2];


        init_wiringpi();


        if(!cap.isOpened())

        {

                cout << "No camera detected" << endl;

                return -1;

        }

        else

        {

                cout << "In capture ..." << endl;

                cap.set(CV_CAP_PROP_FRAME_WIDTH, 320);

                cap.set(CV_CAP_PROP_FRAME_HEIGHT, 240);

        }


        VideoCapture cap2(1);

        if(!cap2.isOpened())

        {

                cout << "No camera detected" << endl;

                return -1;

        }

        else

        {

                cout << "In capture ..." << endl;

                cap2.set(CV_CAP_PROP_FRAME_WIDTH, 320);

                cap2.set(CV_CAP_PROP_FRAME_HEIGHT, 240);

        }


        namedWindow("cam 1", WINDOW_AUTOSIZE );

        namedWindow("cam 2", WINDOW_AUTOSIZE );

        namedWindow("control", WINDOW_AUTOSIZE );

        namedWindow("crop", WINDOW_AUTOSIZE );


        createTrackbar("track 1", "cam 1", &pos[0], 100, on_trackbar_1 );

        createTrackbar("track 2", "cam 2", &pos[1], 100, on_trackbar_2 );

        createTrackbar("track 3", "control", &pos[0], 100, on_trackbar_3 );


        setTrackbarPos("track 1", "cam 1", 50);

        setTrackbarPos("track 2", "cam 2", 50);

        setTrackbarPos("track 3", "control", 50);


        setMouseCallback("cam 1", CallBackFunc, NULL);


        Mat frame;

        Mat result;

        Mat tMat;

        Mat crop;


        double minVal;

        double maxVal;

        Point minLoc;

        Point maxLoc;

        Point matchLoc;


        for(;;)

        {


                Point pt[2];

                if(!cap.read(frame)) break;

                        pt[0].x = 150;

                        pt[0].y = 110;

                        pt[1].x = pt[0].x + 20;

                        pt[1].y = pt[0].y + 20;


                if(bMouse)

                {

                        tMat = frame.clone();

                        crop = Mat(tMat, Rect(mpos.x - 10, mpos.y - 10, 20, 20));

                        imshow("crop", crop);

                }


                matchTemplate( frame, crop, result, CV_TM_SQDIFF );

                normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );

                minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );

                matchLoc = minLoc;

                cout << "matchLoc : " << matchLoc << endl;


                rectangle(frame, pt[0], pt[1], Scalar(0,0,0),2);

                rectangle(frame, Point(mpos.x - 10, mpos.y - 10), Point(mpos.x + 10, mpos.y + 10), Scalar(0,0,255),2);

                rectangle(frame, matchLoc, Point( matchLoc.x + 20 , matchLoc.y + 20 ), Scalar(0,255,0), 2);

#define SERVO_ANG       180

#define CAM_FOV         60

                if(bMouse)

                {

                        int tpos = getTrackbarPos("track 1", "cam 1");

                        int value = tpos + ((matchLoc.x - 160) * 60 / 3 /  320);

                        cout << "---- calc : " <<  value << endl;

                        setTrackbarPos("track 1", "cam 1", value);

                }


                imshow("cam 1", frame);


                if(!cap2.read(frame)) break;

                rectangle(frame, pt[0], pt[1], Scalar(0,0,0),2);


                matchTemplate( frame, crop, result, CV_TM_SQDIFF );

                normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );

                minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );

                matchLoc = minLoc;

                cout << "matchLoc : " << matchLoc << endl;


                rectangle(frame, matchLoc, Point( matchLoc.x + 20 , matchLoc.y + 20 ), Scalar(0,255,0), 2);

                if(bMouse)

                {

                        int tpos = getTrackbarPos("track 2", "cam 2");

                        int value = tpos + ((matchLoc.x - 160) * 60 / 3 /  320);

                        cout << "---- calc : " <<  value << endl;

                        setTrackbarPos("track 2", "cam 2", value);

                        bMouse = false;

                }

                imshow("cam 2", frame);


                if(waitKey(30) >= 0) break;

        }


        return 0;

} 


'Programming > openCV' 카테고리의 다른 글

opencv 카메라 왜곡 수정  (0) 2015.10.20
opencv sift surf  (0) 2015.10.20
openCV + openMP 합치는게 잘 안되네?  (0) 2015.10.11
opencv 마우스 이벤트와 빠르게 그리기  (0) 2015.10.05
opencv 마우스 이벤트 관련 2  (0) 2015.10.05
Posted by 구차니
파일방2015. 10. 14. 16:22

지인이 쓰는데 좋아 보이길래..


[링크 : http://www.desktopcal.com/]

'파일방' 카테고리의 다른 글

playonlinux - 플레이온 리눅스  (0) 2016.02.02
hfs - HTTP file server  (0) 2015.11.23
라즈베리 파이 오디오 스트리밍 관련 문서  (0) 2015.09.18
HelpNDoc  (0) 2015.07.29
goahead 웹 서버  (0) 2015.07.19
Posted by 구차니
하드웨어/모터(motor)2015. 10. 14. 16:01

[링크 : http://www-stud.uni-due.de/~sbadpras/...-in-daisy-chain-mode/소스코드

[링크 : https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/slave-select-ss] SPI daisy chain

[링크 : http://www.st.com/.../application_note/DM00039787.pdf]


하나랑 통신할때는 비트 단위로 보낸다면...

Daisy chain 시에는 바이트 단위로 묶인 순서의 반대대로(먼 순서 부터) 보낸다.

[링크 : http://www.st.com/.../datasheet/CD00255075.pdf]


ti stellarisware에서 32bit 단위로 하면 최대 4대 까지 가능하려나?

어떻게 될지 모르겠네...


---

비교는 해봐야겠다.. 데이지 체인용으로 수정한 코드라는데..

[링크 : http://www.deathbylogic.com/2015/01/daisy-chaining-multiple-autodrivers/]

[링크 : https://github.com/DeathByLogic/L6470-AutoDriver/tree/daisy_chain]

Posted by 구차니
embeded/raspberry pi2015. 10. 14. 13:14

온도/습도 센서 인데..

검색하다 보니 차이가 있... 다?


DHT11

Ultra low cost

3 to 5V power and I/O

2.5mA max current use during conversion (while requesting data)

Good for 20-80% humidity readings with 5% accuracy

Good for 0-50°C temperature readings ±2°C accuracy

No more than 1 Hz sampling rate (once every second)

Body size 15.5mm x 12mm x 5.5mm

4 pins with 0.1" spacing


DHT22

Low cost

3 to 5V power and I/O

2.5mA max current use during conversion (while requesting data)

Good for 0-100% humidity readings with 2-5% accuracy

Good for -40 to 125°C temperature readings ±0.5°C accuracy

No more than 0.5 Hz sampling rate (once every 2 seconds)

Body size 15.1mm x 25mm x 7.7mm

4 pins with 0.1" spacing

[링크 : https://learn.adafruit.com/dht/overview]


[링크 : http://cdn.sparkfun.com/datasheets/Sensors/Weather/RHT03.pdf]


RHT03 (also known by DHT-22)

[링크 : https://www.sparkfun.com/products/10167]


AM2302가 DHT22 대응인 듯

그냥 .. DHT11만 보더라도 상당히 불안정하게 값이 읽혀온다.

[링크 : http://www.kandrsmith.org/RJS/Misc/calib_dht22_dht11_sht71.html] 벤치마크?



아무튼.. DHT-11은 저가형에 정밀하지 못한 녀석

DHT-22/RHT03은 정밀한 녀석으로 결론...

Posted by 구차니
Linux API/linux2015. 10. 13. 16:09


ITIMER_REAL

decrements in real time, and delivers SIGALRM upon expiration.

실시간으로 감소하고 만료시 SIGALRM을 전송한다.


ITIMER_VIRTUAL

decrements only when the process is executing, and delivers SIGVTALRM upon expiration.

프로세스가 실행중잉 동안만 감소하고 만료시 SIGVTALRM을 전송한다.


ITIMER_PROF

decrements both when the process executes and when the system is executing on behalf of the process. Coupled with ITIMER_VIRTUAL, this timer is usually used to profile the time spent by the application in user and kernel space. SIGPROF is delivered upon expiration.

프로세스가 실행중이거나 시스템이 프로세스 대신 작동하는 동안에도 감소한다. ITIMER_VITUAL과 결합하여 유저 시간과 커널 시간을 프로파일링 하는데 사용된다. SIGPROF가 만료시 전송한다.


Timer values are defined by the following structures:

struct itimerval {

    struct timeval it_interval; /* next value */

    struct timeval it_value;    /* current value */

};


struct timeval {

    time_t      tv_sec;         /* seconds */

    suseconds_t tv_usec;        /* microseconds */

};


The function getitimer() fills the structure pointed to by curr_value with the current setting for the timer specified by which (one of ITIMER_REAL, ITIMER_VIRTUAL, or ITIMER_PROF). The element it_value is set to the amount of time remaining on the timer, or zero if the timer is disabled. Similarly, it_interval is set to the reset value.

it_value 값은 타이머의 남은 값을 설정하거나 타이머를 사용하지 않기 위해 0으로 설정한다. 유사하게 it_interval는 초기화 값을 설정한다.

The function setitimer() sets the specified timer to the value in new_value. If old_value is non-NULL, the old value of the timer is stored there.


Timers decrement from it_value to zero, generate a signal, and reset to it_interval. A timer which is set to zero (it_value is zero or the timer expires and it_interval is zero) stops.

it_value로 부터 0으로 타이머가 감소하고, 시그널을 생성하고, it_interval로 초기화 한다. 타이머가 0으로 설정되면 정지한다(it_value가 0이거나 타이머가 만료되고 it_interval이 0일 경우)


Both tv_sec and tv_usec are significant in determining the duration of a timer.


Timers will never expire before the requested time, but may expire some (short) time afterward, which depends on the system timer resolution and on the system load; see time(7). (But see BUGS below.) Upon expiration, a signal will be generated and the timer reset. If the timer expires while the process is active (always true for ITIMER_VIRTUAL) the signal will be delivered immediately when generated. Otherwise the delivery will be offset by a small time dependent on the system loading.

[링크 : http://linux.die.net/man/2/setitimer]


그래서 둘다 설정하지 않으면 멈추는 거구나..

다만. it_value의 값은 초기 1회에 대한 타이머이고

it_interval의 값은 2회 부터의 값에 대한 타이머가 된다.

timer.it_value.tv_sec = 0;

timer.it_value.tv_usec = 250000;

timer.it_interval.tv_sec = 0;

timer.it_interval.tv_usec = 250000;


[링크 : http://linuxspot.tistory.com/28] 


[링크 : https://kldp.org/node/132754]

[링크 : http://manofpro.tistory.com/290]

[링크 : http://forum.falinux.com/zbxe/index.php?document_srl=413903]


[링크 : http://www.joinc.co.kr/modules/moniwiki/wiki.php/article/Timesr_in_Linux]

'Linux API > linux' 카테고리의 다른 글

select()  (0) 2015.10.26
mmap / ioremap  (0) 2015.10.21
리눅스 모듈 - 세마포어 / 뮤텍스  (0) 2015.10.21
linux kernel module module_init() 매크로  (0) 2015.10.21
clock_gettime  (0) 2015.08.09
Posted by 구차니
embeded/Cortex-M3 Ti2015. 10. 13. 11:47

lm3s617외에 같은 클래스에서도 동일한 녀석으로 쓸수 있으려나?
코드를 보니.. 메인을 장악해버려서 다른 프로그램의 하위 시스템으로 넣기에는 엄청난 수정이 필요 할지도..


[링크 : http://www.ti.com/lit/ug/spmu026a/spmu026a.pdf] Stellaris® Stepper Motor Reference Design Kit

[링크 : http://www.ti.com/lit/ds/symlink/lm3s617.pdf] LM3S617

[링크 : http://www.ti.com/product/LM3S617/description]

    [링크 : http://www.ti.com/tool/sw-rdk-stepper-gui]

    [링크 : http://www.ti.com/tool/sw-rdk-stepper]

'embeded > Cortex-M3 Ti' 카테고리의 다른 글

lm3s1607 / lm3s811 비교  (0) 2015.11.03
bitband 고찰..  (0) 2015.10.23
lm3s spi / ssi  (0) 2015.10.06
lm3s stellarisware SPI  (0) 2015.10.05
cortex-m3 ROM direct call  (0) 2015.09.25
Posted by 구차니
이론 관련/전기 전자2015. 10. 13. 10:55

linux/os의 PID가 아님

 

P: Proportinal(비례) 

I: Integral(적분) 

D: Differential(미분) 

 

 

[링크 : https://ko.wikipedia.org/wiki/PID_제어기]

[링크 : http://www.ktechno.co.kr/pictech/motor05.html]

 

소스구현

[링크 : http://enginius.tistory.com/46]

[링크 : http://magicom9.tistory.com/3]

 

+

2022.04.01

[링크 : https://throwexception.tistory.com/851]

 

'이론 관련 > 전기 전자' 카테고리의 다른 글

디지털 서보(?)  (0) 2015.11.24
DMOS?  (0) 2015.10.20
전류제어  (0) 2015.09.11
디지털 필터 - FIR / IIR  (0) 2015.01.23
역률이 모야?  (2) 2011.08.04
Posted by 구차니