windows 8 사용중 AVRISP MK-II 드라이버 문제 발생.

학습/AVR 2012. 10. 31. 15:49 Posted by 보노보노보노

윈도우 8 설치후 드라이버 설치 문제가 발생하였다.

 

" 이 하드웨어에 대한 장치 드라이버를 로드할 수 없습니다. 드라이버가 손상되었거나 누락된 것 같습니다. (코드 39)"

아래와 같이 오류 메세지가 나타나며 드라이버 설지가 되지않았다.

해결 방안:

ATMEL 사 홈페이지에서 서비스팩을 설치 한 결과 이상 없이 인식되었다.

- 인식 결과 -

 

Atmel Studio 6.0 Service Pack 1 : http://www.atmel.com/Images/as6installer-stable-servicepack1-6.0.1938.exe

 

 

 

SRF-10,08 구동

학습/AVR 2010. 12. 16. 14:16 Posted by 보노보노보노

 




IHLAB-128보드 로 제작하였음.

SRF-08과 SRF-10은 같은 TWI(I2C)방식으로 제어방식이 동일함.


동작 순서 : setup_TWI() -> startRanging(주소) -> 65ms 이상 대기    -> getRange(주소)  순으로 되어있으며,
                   TWI 초기화  ->   거리감지 시작    -> 측정시간동안 대기 -> 거리얻어오기         순서이다..

주소는 초기 0xE0로 설정되어있지만 변경하여서 0xE2 ~ 0xEA까지로 바꾸었다.

새제품일 경우는 조소에 0xE0로 하여  Test 하변 된다.

 
참고자료 : http://www.robot-electronics.co.uk/htm/srf10tech.htm

사용법은 압축파일의 소스에 설명.





- 하이퍼 터미널 Test 화면 -



- 보드상의 LCD 출력-




- 초음파 센서 장착 사진  -





임베디드 리눅스에서 시리얼 접근

카테고리 없음 2010. 6. 12. 04:01 Posted by 보노보노보노
#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <termios.h>
#include <stdlib.h>

struct termios tio; // 터미널 구조체

int main(int argc, char *argv[]) {
	int fd, result; //fd 파일 디스크립터, result : 파일 RW 결과값
	long baud = B38400; //통신속도
	unsigned char buf; // 데이터 받을 buf -> unsigned를 안붙이면 값이 이상하게 나온다.
	char sBuffer[7]={0x02, 0x03, 0x49, 0x56, 0x00, 0x03, 0x1C}; // 보낼 데이터 (현재 뚜리가 사용하고 있는 키트의 정의된 프로토콜 형식


	if((fd = open("/dev/ttyS0", O_RDWR|O_NDELAY|O_NOCTTY)) < 0) { // READ, WRITE로 Serial0 포트 열기
		exit(1);
	}

	////////////////// 보낼 옵션 설정

	tio.c_cflag = baud|CS8|CREAD|CLOCAL; // baud 통신 속도, CS8 (8bit, No Parity, 1 Stop Bit)설정
	// CREAD 문자 수신가능하게 함, CLOCAL, Local Connection 모뎀제어 안함..
	//처음엔 CRTSCTS를 같이 c_cflag에 줬었다. 그래서 정상적으로 작동이 안되서 상당히 얘를 먹었다.
	// CRCTSCTS는 하드웨어 흐름제어, 직렬 케이블의 모든 선이 연결되어 있을 때 사용 -> 보통 모든선을 다 안쓰므로. ^^
	tio.c_cflag &= ~HUPCL;
	tio.c_lflag = 0;  // Local Mode 설정
	tio.c_iflag = IGNPAR; // Parity 오류가 있는 문자 무시
	tio.c_oflag = 0; // 출력처리 설정 0이면 아무것도 안함

	///////////////// 옵션 설정 끝 (물론 추가적인 옵션도 많이 있으나 찾아보기 바란다.)

	tcflush(fd, TCIFLUSH); // 설정을 초기화
	tcsetattr(fd, TCSANOW, &tio); // tio 터미널 구조체의 속정으로 설정을 적용시킨다.
	
	fcntl(fd, F_SETFL, FNDELAY); // 열려있는 파일 제어를 위해 사용

	result = write(fd, sBuffer, 7); // 실제적으로 시리얼로 데이터를 보낸다. sBuffer값의 7개만 시리얼0으로 보낸다.

	if(result < 0) { // 에러냐?
		printf("write error\n");
		close(fd); 
		exit(1);
	}

	usleep(1000); // 쉬고

	while(1) { // 데이터 받는 부분.. 오는거 계속 출력한다. 주구장창.. ^^
		if((result = read(fd, &buf, 1)) > 0) {
			printf("%02x ", buf);
			fflush(stdout); // 뿌려주3.
		}
		
	}

	close(fd); // 끝내기 닫고
}

[출처] 리눅스 C 시리얼|작성자 호팔


[API] Window를 항상 맨위에 보이게 하기

학습/C 2010. 4. 2. 20:09 Posted by 보노보노보노

//--- External Function에 다음과 같이 선언하시고
Function Long SetWindowPos (Long hwnd ,Long  hWndInsertAfter ,Long  x ,Long  y ,Long  cx ,Long  cy ,Long  wFlags ) Library "user32"

//--- 다음과 같이 기술합니다.
Constant Long HWND_TOPMOST = -1                  //맨위로 설정할때
Constant Long HWND_NOTOPMOST = -2            // 설정을 해제할때
Constant Long SWP_NOSIZE = 1

SetWindowPos (Handle(W_NAME), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE)
[이 게시물은 사랑니님에 의해 2009-08-02 15:38:47 PowerBuilder에서 이동 됨]
[출처] IT.DevInfo ∽ 힘든 IT개발자들의 즐거운 공유(ITDI.co.kr) - http://wss02.ivyro.net/onuri/bbs/board.php?bo_table=02_2&wr_id=68



Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const HWND_TOP = 0
Private Const HWND_BOTTOM = 1
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2

Function EnabledAlwaysOnTop(hwnd As Long) As Long
EnabledAlwaysOnTop = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
End Function


Function DisabledAlwaysOnTop(hwnd As Long) As Long
    DisabledAlwaysOnTop = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
End Function

 

'사용법은
call EnabledAlwaysOnTop(form1.hwnd)
[출처] 항상위(Allways on TOP) 표현 API|작성자 곱단이


http://blog.naver.com/seamusic00?Redirect=Log&logNo=120014901361





 

WAV 포맷

카테고리 없음 2009. 11. 26. 12:56 Posted by 보노보노보노

멀티미디어 파일들을 읽기 위해서는 대부분 복잡한 포맷형식 때문에 이미 만들어진 라이브러리들을 통하여 읽는 것이 일반적이다. 하지만 PCM형식의 WAV파일은 비교적 간단하기 때문에 손쉽게 읽을 수 있을 것이라 생각된다.

WAV파일의 DFT변환을 위해 WAV파일의 저장된 내용을 읽을 필요가 있었는데.. 실제 음파의 값들을 읽을수 있는 라이브러리를 찾다가 직접 WAV파일을 읽는 프로그램을 작성하더라도 큰 어려움이 없을 것같아 만들어 보았다.

우선  PCM WAV파일의 포맷부터 보자..

 

이름

형식

Chunk Head

Chunk ID

4 Bytes ASCII String

“RIFF” - MS에서 사용하는 멀티미디어를 저장하는 포맷으로 항상RIFF라 생각하면 됩니다.

Chunk Size

4 Bytes Little Endian

전체파일의 총 길입니다.

Format

4 Bytes ASCII String

“WAVE” - WAV파일일 경우

Sub Chunk 1

Sub Chunk 1 ID

4 Bytes ASCII String

“fmt “ - WAV파일일 경우

Sub Chunk 1 Size

4 Bytes Little Endian

Sub Chunk1의 길이

Audio Format

2 Bytes Little Endian

1 – PCM

Number of Channels

2 Bytes Little Endian

1 – Mono

2 – Stereo

Sample Rate

4 Bytes Little Endian

8000, 22000, 44000…… 등등

Byte Rate

4 Bytes Little Endian

(Sample Rate) *  (Number of Channels) * (Bit Per Samples) / 8

Block Align

2 Bytes Little Endian

(Number of Channels) * (Bit Per Samples) / 8

Bit Per Sample

2 Bytes Little Endian

또는 16

Extra Pram Size(선택적)

2 Bytes Little Endian

PCM의 경우는 사용하지 않음

Extra Pram(선택적)

N Bytes

확장 옵션을 위해

Sub Chunk 2

Sub Chunk 2 ID

4 Bytes ASCII String

“data”

Sub Chunk 2 Size

4 Bytes Little Endian

Sub Chunk 2의 크기

Data

N Bytes

실제 사운드 데이터

스테레오의 경우 좌 샘플 하나 우 샘플 하나씩 번갈아 가며 저장됨.


PCM의 경우 압축을 사용하지 않으므로 매우 간단하게 읽을 수 있다.

수치 값들은 모두 Little Endian으로 저장되며 모두 Unsigned 값들이다. 실수만 하지 않는 다면 간단하게 읽을 수 있을 것이다.

이곳으로 가면 조금더 자세한 WAV형식에 대한 설명을 볼 수 있습니다.
http://ccrma.stanford.edu/courses/422/projects/WaveFormat/

C#으로 작성해 보았으며 PCM형식의 WAV파일들의 값을읽습니다. 아 그리고 아래 소스는 실행가능 한 코드가 아니고 프로그램의 일부입니다..

또한 스트레오의 필요가 없어서 스트레오의 경우 모노로 바꾸어 읽어 버립니다..

연산자 오버로딩

카테고리 없음 2009. 11. 20. 12:08 Posted by 보노보노보노

/* 09-11-20 FRI Obj_*/
#include<iostream>
using namespace std;

class Complex
{
 private :
   double real;
   double image;
 public:
   Complex(double r=0,double i=0);
   void ShowComplex();
   void ShowComplex(char);
   void SetReal(double r);
   void SetImage(double i);
   double GetReal();
   double GetImage();
   void ReFresh(double r, double i);
   Complex operator+(Complex B);
   Complex operator-(Complex B);
   Complex operator*(Complex B);
   Complex operator/(Complex B);
   void OPer(char op, Complex a, Complex b);
};

Complex::Complex(double r, double i){
 real = r;  image = i;  }


void Complex::OPer(char op, Complex a, Complex b){
 if(op=='+'){
  real = a.GetReal() +  b.GetReal();
  image = a.GetImage() + b.GetImage();
 }else if(op=='-'){
  real = a.GetReal() - b.GetReal();
  image = a.GetImage() - b.GetImage();
 }
}


void Complex::ReFresh(double r, double i){
 real = r; image = i; }

void Complex::SetReal(double r)  { real = r;   }
void Complex::SetImage(double i) { image = i;  }

 

double Complex::GetReal() {  return real;  }
double Complex::GetImage() {  return image; }

void Complex::ShowComplex(){
 cout<<"("<< real <<" + "<< image <<" i )"<<endl;  }

void Complex::ShowComplex(char ch){
 cout<<"("<< real <<" "<<ch<<" "<< image <<" i )"<<endl;  }

Complex  Complex::operator+(Complex B)
{
 Complex Temp;
 Temp.SetReal(B.GetReal() +  this->GetReal());
 Temp.SetImage(B.GetImage() + this->GetImage());

 return Temp;
}
Complex  Complex::operator-(Complex B)
{
 Complex Temp;
 Temp.SetReal( this->GetReal() - B.GetReal() );
 Temp.SetImage(this->GetImage() - B.GetImage());

 return Temp;
}
Complex  Complex::operator*(Complex B)
{
 Complex Temp;
 Temp.SetReal((B.GetReal() *  this->GetReal()) - (B.GetImage()*this->GetImage() ) );
 Temp.SetImage((B.GetReal() * this->GetImage()) + (this->GetReal() * B.GetImage()) );

 return Temp;
}
Complex  Complex::operator/(Complex B)
{
 double a,b,c,d;
 Complex Temp;
 
 a=this->GetReal();
 b=this->GetImage();
 c=B.GetReal();
 d=B.GetImage();
 
 
 Temp.SetReal( ((a*c)-(b*d))/((c*c)+(d*d)) );
 Temp.SetImage( (a*d-c*b) / ( c*c+d+d) );
 return Temp;
}


void main()
{
 Complex x(10,20);
 Complex y(20,5);
 Complex z;

 cout<<"x = ";  x.ShowComplex();
 cout<<"y = ";  y.ShowComplex();
 cout<<"z = ";  z.ShowComplex();
 cout<<endl;
 /*z.ReFresh( x.GetReal() + y.GetReal(),
    x.GetImage() + y.GetImage()
    );
 */
 cout<<"OPER : *"<<endl;
 z=x*y;
 x.ShowComplex();
 y.ShowComplex();
 z.ShowComplex(); 
 cout<<endl;
 
 cout<<"OPER : /"<<endl;
 z=x/y;
 x.ShowComplex();
 y.ShowComplex();

}



 

객체지향 - Class

카테고리 없음 2009. 11. 6. 12:22 Posted by 보노보노보노

/* 09-11-06 FRI Obj_*/
#include<iostream>
using namespace std;

class Complex
{
 private :
   int real;
   int image;
 public:
   Complex(int r=0,int i=0);
   void ShowComplex();
   void SetReal(int r);
   void SetImage(int i);
   int  GetReal();
   int  GetImage();
   void ReFresh(int r, int i);

   void OPer(char op, Complex a, Complex b);
};

Complex::Complex(int r, int i){
 real = r;  image = i;  }


void Complex::OPer(char op, Complex a, Complex b){
 if(op=='+'){
  real = a.GetReal() +  b.GetReal();
  image = a.GetImage() + b.GetImage();
 }else if(op=='-'){
  real = a.GetReal() - b.GetReal();
  image = a.GetImage() - b.GetImage();
 }
}

void Complex::ReFresh(int r, int i){
 real = r; image = i; }

void Complex::SetReal(int r)  { real = r;   }
void Complex::SetImage(int i) { image = i;  }

int Complex::GetReal() {  return real;  }
int Complex::GetImage() {  return image; }

void Complex::ShowComplex(){
 cout<<"("<< real <<" + "<< image <<" i )"<<endl;  }


void main()
{
 Complex x(10,20);
 Complex y(20,5);
 Complex z;

 cout<<"x = ";  x.ShowComplex();
 cout<<"y = ";  y.ShowComplex();
 cout<<"z = ";  z.ShowComplex();
 cout<<endl;
 /*z.ReFresh( x.GetReal() + y.GetReal(),
    x.GetImage() + y.GetImage()
    );
 */

 z.OPer('+',x,y);
 cout<<"x + y = ";  z.ShowComplex();

 z.OPer('-',x,y);
 cout<<"x - y = ";  z.ShowComplex();

}



 

글리치(glich)

학습 2009. 5. 3. 20:31 Posted by 보노보노보노

글리치(Glitch)

 불필요한 부분에 발생하는 노이즈 펄스로 인해 일어나는 컴퓨터의 일시적인 오동작. 잘못된 출력이나 시스템 충돌을 일으키는 원인이 된다. 글리치가 하드웨어적인 문제인 데 비해, 소프트웨어적인 문제로 오동작이 일어나는 것을 버그라고 한다.



얼굴인식을 통한 UI구현

UI & GUI 2009. 4. 5. 03:40 Posted by 보노보노보노
faceAPI : 웹캠으로 얼굴인식을 하여, 얼굴이 화면에 가까이 오면, 3차원 오브젝트와 가까워지고, 얼굴과 멀어지면, 오브젝트도 멀어진다. 또한, 얼굴을 좌우로 이동하면, 오브젝트도 따라서 움직인다.












 닌텐도 wii모콘 끝에 달려있는 적외선 카메라를 모니터에 달고, 기존 TV위에 설치하던 LED 센서를 모자에 달아, 얼굴을 쉽게 추적하게 한 프로토타입... 위의 데모와 거의 유사한 형태이다. 제작은 카네기 멜른의 Johnny Chung Lee... 참고로 위모트는 1024x768 해상도의 적외선 카메라가 달려있고, 100Hz로 4점 트래킹이 가능하며, 100Hz로 동작하는 +/-3g 8비트 3축 가속센서(accelerometer)가 포함되어 있다.




휴대폰이나 PC에는 이미 나를 찍는 카메라가 달려있기 때문에, 향후, 휴대폰이나 PC등에서 위의 3차원 기술등이 적용된 어플리케이션, 게임들을 쉽게 볼 수 있을 것이다.

출처 : 몬스터 디자인그룹
http://monsterdesign.tistory.com/850


FT232 가지고 놀기 Part.2

프로젝트/FTDI 2009. 2. 26. 19:18 Posted by 보노보노보노

이것은 USB로 PC와 시리얼 로 접속한뒤 블루투스나 Rs-232로 데이터를 전송하는 모듈이다.

모듈은 내부 핀설정을 통해 블루투스에서 받은 데이터를 RS-232C로 전송하거나

RS-232로 받은 데이터를 블루투스로 보내는 어답터 역활을 수행하기도 한다.
흰색부분이 3pin RS-232신호핀이다.

위의 점퍼로 설정이 가능 한데, 저 점퍼를 세로로 하면 BT-RE232C 통신이 가능하다.