336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

작품 의뢰는 instructables.tistory.com/64로 방문해주세요.



<부품리스트>

JMOD-128-1 (ATMega128) 27500원

http://www.ds-parts.co.kr/goods_detail.php?goodsIdx=19118

16x2 LCD

Piezo Disk

HC-06 BlueTooth Module

Buzzer

ServoMotor (HS-311)



ㅂㅅㄱ(=ㅊㅈㄷ)

Photo Interrupter는 발광부 수광부로 나뉜다.

발광부는 220Ω을 거쳐서 LED를 동작시키고, Photo Interrupter 중간에 편지가 지나가는지 유무를 감지하는 부분은 반대쪽의 수광부이다.

편지로 인해 수광부가 차단됬다면 Low값이 ATmega128로 들어간다.

10K 저항은 Pull-Down저항으로써 수광부에서 빛을 감지하여 Vcc의 전류가 Emitter로 흘러나갈때 GND로 빠져나가는 전류손실을 차단하기 위해 사용했다.

10K이상의 전류를 사용할 수록 좋다.

이렇게 하면 출력 전류가 10K전류를 피해서 NOT Gate를 향해 흘러간다.


값을 반전시켜서 High값이 들어갈때 Photo Interrupter의 Event로 적용하기위해서 NOT Gate(=7404)를 사용했다.

Piezo Disk에 충역을 주게되면 LOW값이 ATmega128로 전달되게끔 회로를 설계했다.

위의 두 Events는 Bluetooth를 통해 BlueTerm에 표시된다.

Servo제어는 Bluetooth를 통해 제어되도록 회로를 설계했다.

Servo의 PWM은 각도를 제어하는데 쓰인다.

Pulse Width  Modulation의 약자로 한세트의 Frequency를 보내줘야 특정각도에서 멈춘다.

만약 90도 → 180도 → 0도 이런 식으로 각도를 바꿔가면서 동작을 하면

그 각도들 사이에서 Delay를 적용하면 된다.

Delay없이 각도를 바꿔주면 불안정하게 흔들리는 현상이 발생한다.

부품리스트

JMOD-128-1 (ATMega128) 27500원

http://www.ds-parts.co.kr/goods_detail.php?goodsIdx=19118

Servo Motor HS-311 (12000원)

http://www.ds-parts.co.kr/goods_detail.php?goodsIdx=2742

Photo Interrupter (500원)

http://www.ds-parts.co.kr/goods_detail.php?goodsIdx=5735

7404 NOT Gate

Piezo Disk Vibrator (100원)

블루투스 (6600원)

http://www.ds-parts.co.kr/goods_detail.php?goodsIdx=18248

http://robot.co.kr/front/php/product.php?product_no=2812&main_cate_no=&display_group=

카세트 플페이어 홈플러스 (31900원)

Naver

[카셋트회로도] :: 누군가 이 키워드로 검색해 왔는데 따로 적을까 하다가 수요가 적을듯해서 여기에 부록마냥 끄적여 봤습니다.

[카세트 회로설명]





AVR Studio 사용법 링크▼

http://instructables.tistory.com/406

Posted by ElectricShock
:
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.


1. POT을 이용한 구성

POT을 돌려서 저항값을 낮출수록 message과 배경의 경계가 모호해진다.

pull-up저항에 해당한다.

RW는 Vss와 합쳐준다.

▶3번+5번핀을 Jumper로 연결후, 그 3번핀을 POT의 middle pin에 연결 (POT양단은 Vcc, GND)

▶POT의 middle pin을 3번에 연결하고 RW핀을 GND에 Direct로 연결한다. 

(만능기판으로 구현할때는 이게 좀더 잘되긴하다.)

2. Vss와 Vee사이에 1K 저항을 연결하여 고정시켜준다.

BreadBoard에 이와같이 구현했더니 별 문제없이 잘 동작한다.

3. RW를 Vss와 합쳐줬다는 점은 1.의 방법을 참조했다.

Posted by ElectricShock
:
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

http://www.gnu.org/savannah-checkouts/non-gnu/avr-libc/user-manual/group__avr__stdio.html

우선 #include<stdio.h> 가 선언되어있어야 한다.


http://www.avrfreaks.net/forum/how-use-printf-uart

timojaask의 링크를 주목


https://www.sparkfun.com/tutorials/105

SparkFun의 Tutorial

AVR GCC Compiling

Sorry for the confusion. 

When these tutorials were written and photographed, 

we used the ATmega8. 

We now carry the newer ATmega168. 

You will find all ATmega168 information in the following pages, 

but the pictures will show an ATmega8.

I know very little about the ins and outs of the AVR-GCC compiler. 

난 알고있다. 매우조금 about the 입력들 and 출력들을 of the AVR-GCC 컴파일러의.

I've learned a few basics that helped me along the way, 

but when you run up against a jam, google and AVRfreaks.net are your friend.

First, we did the blinky. 

Open this code in PN2 and make sure you can compile it. 

Click on Tools->Make All. The window in the bottom screen should say 'Process Exit Code: 0' meaning the compilation was successful. If not, there should be a line number listing of the problem line of code. Be sure to check above and below the indicated line for problems.

In the second example C file called basic-out-atmega168.c (basic-out.c for the ATmega8), 

I've inserted a handful of functions and lines of code. First of the black magic:


#define FOSC 16000000
#define BAUD 9600
#define MYUBRR FOSC/16/BAUD-1    //MYUBRR을 선언하기위해 FOSC, BAUD를 선언


What is all this noise at the top of the file? 

This is a series of defines that calculates the MYUBRR variable with the correct number. 

Since serial communication depends on the fact that we will be transmitting and receiving at 9600 bits per second, it's crucial to tell the ATmega168 what bit rate to set. 

Because the ATmega168 is dictated by the oscillator that it is using, 

we must correctly calculate what value we need to load into the ATmega168 hardware so that the ATmega168 sends the serial pulses at the correct rate with a given oscillator type. 

In our case, 

we are using a 16MHz oscillator so we can setup the define statement as shown. MYUBRR is calculated at compile time and is loaded successfully into the hardware UART during run time.


The UBRR value calculation in Lecture 5 could be more accurate with the following macro:

#define MYUBRR (((((FOSC * 10) / (16L * BAUD)) + 5) / 10) - 1)

There is also pretty useful web form for UBRR calculation:

http://www.wormfood.net/avrbaudcalc.php

▲BaudRate 계산기

여기 맞춰서 Bit를 설정해주면 된다.


static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE);


This line creates a buffer for the printf statement to post to.

이 라인은 만들어낸다. a buffer를 for the printf statement를 to 포스트하기위해

I'd rather not explain it, simply because I don't understand it. 

When I am working on a new coding project I never start from a blank page, 

I *always* start from a known working program and slowly bring in bits of other projects to get the code I need, writing bits along the way. 

Please start from this printf example and build away. 

The purpose here is to get your printing string to the terminal window.

여기 프로젝트는 to 얻기위함이다. 네 printing string을 to the 터미널 윈도우에.


Checkout the ioinit() function. You'll notice some new commands.

UCSR0B = (1<<RXEN0)|(1<<TXEN0);       //기본적으로 RX,TX가 Enable상태가 되야한다.


This is the really funky, but very practical, method of setting bits on the AVR series. RXEN0 is defined in some file as '5'. 1<<RXEN0 translates to 'shift a 1 to the left by 5 spaces'.  

This is handy because you don't need to remember specifically where the RX enable bit resides, 

you only need to know to set (or not set) the RXEN0 bit by using this bit command. Same goes for TX enable. Using the example code above, these two bits (RXEN0 and TXEN0) get set and loaded into UCSR0B register, enabling the TX and RX hardware on the ATmega168. 

Finally, we see the very comfortable line of code:


printf("Test it! x = %d", x);


What did you say? This is not a comfortable line of C code for you? Ok - printf is somewhat of a universal function to pass serial strings and variables to the outside world. The line of code above will pass the string "Test it! x =" to the serial port and it should display on the terminal window. After that, the %d gets converted to an actual decimal number so that whatever digital number is currently stored in the variable x gets printed to the terminal screen. So what? This simple printf statement allows you to print variable contents and see what's going on within your C program.

Time to load the basic-out-atmega168.c file onto your breadboard. Open up PN2, compile basic_out-atmega168.c. Power up your board, click on Tools->[WinAVR] Program from within Programmer's Notepad. The code should now be loaded onto your ATmega168. If WinAVR throws a verification error, try again. Open up the terminal window at 9600bps if you don't already have it open.

basic-out-atmega168.c


코드상에서 필수 추가해야할 것들

static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE);

여기  파라미터에 대한 선언이 없으므로

static int uart_putchar(char c, FILE *stream);

함수 printf를 초기화시키기위해 ▼아래 작업이 필요하다.

stdout = &mystdout;    //Required for printf init

'졸업작품 > 우편함(bluetooth+Servo+LCD+SmartPhone)' 카테고리의 다른 글

2-1 관련코드  (3) 2016.10.27
4.회로도  (7) 2016.10.27
1.충격센서 (Piezo Disk Vibration Sensor)  (0) 2016.10.15
Posted by ElectricShock
:

BLOG main image
잡동사니들(지극히 개인취향인...) (다른글에도 댓글 부탁해요♥) You May Leave English Messages on GuestBook. by ElectricShock

공지사항

카테고리

분류 전체보기 (782)
MiDi (2)
Programming(=프로그래밍) (3)
Animation (4)
Blender (3D Graphic Program.. (10)
Blendtuts.com (Series) (1)
Blender 기초 팁들 (2)
Processing (디지털미디어과) (2)
Music (1)
Books in the world (0)
Communication(CAN, UART, et.. (12)
MCU Examples (PIC 기반) (7)
Transistor (1)
Mikro C Pro (11)
Mikro Pascal (1)
Proton IDE (0)
Robot (0)
Swift 3D (1)
Dummies Series (1)
All about Hacking (0)
제2 외국어 (1)
PIC 해외서적들 (3)
AVR (25)
PIC (MikroC) (MPLAB) (4)
Assembly (2)
ARM (3)
Arduino (26)
PSpice (1)
Proteus ISIS (14)
CodeVision (2)
FPGA (15)
MPLAB (24)
PCB (the Procedure) (15)
3D Printer (5)
PICKIT3 (6)
Matlab (11)
RaspBerry PI (15)
BeagleBone (1)
Android Studio (17)
졸업작품 (172)
Korea History (0)
Issue(사회) (73)
Multimeter 리뷰 (1)
Oscilloscope (1)
A (34)
B (19)
J (6)
C (32)
P (12)
T (37)
H (12)
I (12)
M (44)
R (5)
E (5)
F (2)
D (9)
O (2)
L (7)
S (9)
W (2)
V (6)
G (14)
Visual C++ or Visual Studio (2)
Android App Development (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백