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

졸업작품 의뢰가 필요하신분은 아래 주소로 와서 의뢰해주세요

간단한 질문 댓글 환영합니다.

#스태퍼드라이버#StepperMotorDriver#DCMotorDriver

http://instructables.tistory.com/64


Favicon of search.naver.com [L293D 최대전압]

Favicon of search.naver.com [L298]

L298N과열

Bing

[l298n 과열] :: 모터에서 소모하고 남은 전류가 역으로 모터드라이버에 흘러들어가 정체되면 이런 현상이 발생합니다. (rectifier를 써야합니다.) (댓글 주세요)








L293D Motor Driver Datasheet


l293.pdf


Vcc1은 논리연산을 위한 5V전압

Vcc2는 Motor파워를 위한 4.5V~36V

(5V모터를 돌릴때는 합쳐도 된다.)

(5V보다 큰 모터를 돌릴때는 반드시 구분지어서 연결시킬것)

1.Features

.Wide Supply-Voltage Range

.Separate Input-Logic Supply

.Internal ESD Protection (정전기 방지)

.High-Noise-Immunity Inputs

.Output Current 1A per Channel (600mA for L293D)

.Peak Output Current 2A per Channel (1.2A for L293D)

.Output Clamp Diodes for Inductive Transient Suppression (L293D)


2.Applications (응용분야)

.Stepper Motor Drivers

.DC Motor Drivers

.Latching Relay Drivers


3.Description

The L293 and L293D devices are quadruple high current half-H drivers.

The L293 is designed to provide bidirectional drive currents of up to 1A at voltages from 4.5V to 36V.

The L293D is designed to provide bidirectional dirive currents of up to 600mA at voltages from 4.5V to 36V.

Both devices are designed to drive inductive loads such as relays, solenoids, DC and bipolar stepper motors,

as well as other high-current /high-voltage loads in positive-supply applications.

Each output is complete totem-pole drive circuit,

with a Darlington transistor sink and a pseudo-Darlington source.

Drivers are enabled in pairs, with drivers 1 and 2 enabled by 1,2EN and drivers 3 and 4 enabled by 3,4EN.

The L293 and L293D are characterized for operation from 0℃ to 70℃


.

.

.

6.1 Absolute Maximum Ratings

칩전체에 공급전압은 36V를 허용한다.

입력전압 최대 7V 까지

L293D의 경우 600mA까지 허용된다. (Motor를 동작시키기전에 부하전류를 반드시 체크할것)

L293B의 경우 1A 까지 허용된다. (=L293B can handle 1 amp)

L298N의 경우 2A 까지 허용된다. (=It can handle 2 amps per motor)

Calculating Motor Driver Power Dissipation (LINK)


Stresses beyond those listed under Absolute Maximum Ratings may cause permanent damage to the device.

These are stress ratings only, which do not imply functional operation of the device at these or any other conditions beyond those indicated under Recommended Operating Conditions. Exposure to absolute-maximum-rated conditions for extended periods may affect device reliability.  

All voltage values are with respect to the network ground terminal.

========================================================


▼H브릿지 원리



http://www.ermicro.com/blog/?p=423

▲기본 브릿지 회로 + NPN만 사용한 브릿지 회로

Controlling your DC motor direction

we only can turn the DC motor in one direction if we want to change the direction than we also have to change the DC motor voltage polarity. 

The other way to work around this condition is to use the relay to switch the DC motor’s voltage polarity, but using this method means the DC motor will always ON and we can not control the DC motor speed using digital signal or known as the PWM (Pulse Width Modulation).

The best and popular way to solve this issue is to use the H-bridge circuit:


When we apply current (IB1) to the TR1 and TR2 transistors, IB2=0 to the TR3 and TR4 transistors, then TR1 and TR4 transistors will be turned ON, TR2 and TR3 will be turned OFF; this will cause the current to start flow through TR1 transistor, passing the DC motor and going into the TR4 transistor (blue color). 

왼쪽위 IB1에 전류를 적용하고, 오른쪽위 IB2에 전류를 적용하면 (TR의 Base에 전원인가)

then TR1과 TR4가 will be Turned ON 된다.

and TR2와 TR3이 will be Turned OFF된다.

When we apply current (IB2) to the TR3 and TR4 transistors, 

IB1=0 to the TR1 and TR2 transistors, 

then the TR3 and TR2 transistors will be ON while TR1 and TR4 transistors will be turned OFF; this will cause the current to flow through TR3, passing the DC motor in reverse polarity and going into the TR2 transistor (red color).

By not applying current to both IB1 and IB2 all the transistors will be turned OFF.


Again by applying the Ohm’s law 

we could easily calculate the RB1 and RB2 on this following circuit 

옴의 법칙을 적용해서 저항값 RB1, RB2를 계산한다.

(Updated! Thanks for the nice discussion and correction from the All About Circuits Forum discussion here

in order for this circuit to work you have to put a resistor on each of the TIP 120 Darlington transistors base terminal):


hFE : 전류이득 (링크) or Amplification factor of a Transistor.

IC= hFEIB=βIB

1mA가 fed되면 into the Base of a TR에

그리고 it has a hFE of 100,

collector current will be 100mA.

이득이 100이면, Collector에 1mA 공급시, Collector Current가 100mA를 끌어당긴다.

(전류이득이 너무크면 과열될 수도 있다.)

hFE의 범위는 대체로 10~500 이다.


The above H-Bridge circuit use 5 Volt supply and DC motor with 5 Volt and 1 A maximum operating current rating; assuming the TIP120 Darlington transistor hFE is 1000, the RB1 and RB2 resistors could be calculated as follow:

▼계산공식

IB = IC / hFE = 1 A / 1000 = 0.001 A, for each of the transistor base current
RB1a,b = (VPORT – VBE) / IB = (4.2 – 1.4) / 0.001 = 2800 Ohm, use 2K2 Ohm resistor

Diode 개당 감소전압 -0.7V * 2개거쳐감 = -1.4V

RB2a,b = (VPORT – VBE) / IB = (4.2 – 1.4) / 0.001 = 2800 Ohm, use 2K2 Ohm resistor
P = (VPORT – VBE) x IB = (4.2 – 1.4) x 0.001 = 0.0028 watt, use 0.25 Watt resistor for RB1 and RB2

1/4W 2K2저항을 사용하면 된다.

To test the TIP 120 Darlington transistors H-Bridge circuit above 

I used this following circuit using Atmel AVR ATTiny13 microcontroller as shown on this following picture:

=========================================================

http://letsmakerobots.com/node/32208

▲바이폴라 스테핑 모터 예시


회전방향 바꾸고자할때

청흑적녹 (CW)

흑청녹적 (CCW)


==========================================================

http://www.talkingelectronics.com/projects/BasicElectronics-1A/BasicElectronics-1A_Page2.html


Arduino 적용

모터 토크 재는방법 (LINK)

위 방법을 통해 모터의 소모전류를 체크한다.

위 DataSheet에서 알 수 있듯이 순간 Peak Output 전류는 2A까지 허용하고, 

Continuous Output전류는 600mA까지 허용한다고 명시되있다.

여기서 중요한건 Continuous Output Current이다

(Peak Current는 정방향↔역방향으로 방향전환시 일시적으로 발생한다.)

모터 소모전류가 600mA를 넘어간다면 다른 Motor로 교체하거나 다른 Motor Driver로 교체해주면 된다.

이렇게 맞춰줬다면

회로도를 설계한다.

Sound Sensor에서 Arduino로 연결된 Signal선을 통해 소리값을 감지한다.

Arduino에서는 그 기준값을 설정해주고 그 값을 넘어가면 출력을 내보내도록 코딩한다.

그 출력과 연결된 L293D의 핀번호는 2,7번 핀에 해당한다.

(2번출력이 발생할때는 CW, 7번출력이 발생할때는 CCW가 된다.)

L293D MotorDriver하나로 두개의 모터를 제어할 수 있다.

여기선 하나만 사용하도록 그렸다.

그러므로 EN1에만 5V전원공급을 했다.

Vcc1(Logic)은 논리전압에 해당한다. 여기 5V를 인가해야만 Arduino→L293D 연결이 가능하다.

Vcc2(Outter Voltage)는 외부전압에 해당한다.

이걸 인가해줘야 L293D→Motor로 전류가 흘러가서 모터가 동작하게된다.

Vcc2에는 최대 36V까지 인가해줄수 있고, Motor에 역시 32V를 적용시킬 수 있다.

★파란색 선은 옵션인데, 사용할 Motor가 5V용이라면 Arduino에 쓰이는 5V를 끌어와도 된다.

하지만 이때는 반드시 Rectifier를 사용해야한다.

그 이유는 모터에서 소모하고 남은 전류가 파란색선을 타고 역으로 흘러가서 Arduino에 정체되기 때문이다.

점점 뜨거워지다가 망가지는 불상사를 방지하기 위해서 이 부품이 반드시 필요하다.

Rectifer를 사용하기 싫다면 완전히 독립된 전류원을 사용해야한다.





모멘텀휠에 적용했을때 회로도








▼구매 (인제대 학생들을 위한 자료)

https://electronicshobbyists.com/controlling-dc-motors-arduino-arduino-l298n-tutorial/

사용법 ::

양쪽에 모터를 연결한다. (극성은 상관없지만 돌아가는 방향을 보고 결정한다.)

 

 Input1

 Input2

 Input3

 Input4

 

 정방향

 High

 Low

 High

 Low 정방향
 역방향

 Low

 High 

 Low 

 High  역방향
 Break

 High

 High 

 High

 High

 Break

Input1 + Input2 = MotorA를 담당한다. (둘다 High일때 둘다 Low일때는 Break가 된다.)

Input3 + Input4 = MotorB를 담당한다.

그림상에서...

Power Pins가 두개 있는데 왼쪽은 5V~35V까지 허용되며 Motor를 동작시키기 위한 전압니다.

오른쪽의 5V는 Logic Voltage(=논리전압)으로 IC를 활성화시키기위한 전압니다. 

(EnableA & B에 함께 인가 되는 전압이다.)

Non Repetive (t=100us) : 전원을 인가하고 100us시간동안은 3A 출력발생 (Load에 어떤게 연결될지에 따라서 3A에서 감쇠곡선을 그릴 전망이다.) (Load가 작으면 완만한 곡선을 그릴 수도 있다.)

Repetive (80% on -20% off; ton = 10ms) == (-20%손실되고 남은 80%효율; ton은 막켜고나서 생긴 딜레이, 즉 10ms동안 -20%손샐이 생긴다는 뜻) == (이 과정을 반복할땐 2.5A 출력까지 감당된다는 뜻이다.)

DC Operation :: 2A (★DC모터의 소모전류가 2A인 경우까지 견딘다는 뜻이다.)



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


졸업작품 의뢰는 ▶LINk 로 와주세요



http://320volt.com/en/op-ampli-sicaklik-anahtari-fan-kontrol/

▲코드 안쓴것


▼검색 키워드들

Favicon of m.search.naver.com [op-amp 마이너스 전원]

Favicon of m.search.naver.com [듀얼 싱글 op amp]

Favicon of m.search.naver.com [op-amp different]




OP_Amp_applications.pdf

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


op amps for everyone.pdf

53쪽

Chapter 4

Single-Supply Op Amp Design Techniques

The previous chapter assumed that all op amps were powered from dual or split supplies,

and this is not the case in today's world of portable, battery-powered equipment. 

이전 쳅터는 가정했다. that 모든 OP Amp들은 전원공급된다. from 듀얼 or 개별

When op amps are powered from dual supplies (see Figure 4–1), 

the supplies are normally equal in magnitude, 

opposing in polarity, and the center tap of the supplies is connected

to ground. 

Any input sources connected to ground 

are automatically referenced to the center of the supply voltage,

so the output voltage is automatically referenced to ground.

When op amp가 전원공급됬을때 from 듀얼 서플라이들로부터

그 서플라이들은 보통 같다. in 크기면에서

반대로 in 극성면에서, and the 센터 탭 of the 서플라이들은 연결되있다.

to GND로.

어느 입력 소스들 연결되있는 to GND에

은 자동으로 참조된다. to the 센터에 of the 서플라이 전압의,

so the 출력전압은 자동으로 참조된다. to GND에.




Single-supply systems do not have the convenient ground reference 

that dual-supply systems have, 

thus biasing must be employed 

to ensure that the output voltage swings between

the correct voltages.

싱글-공급 시스템들은 do not 갖고있지않다. the convenient group reference를

that 듀얼공급 시스템들이 갖고있는

따라서 바이어싱은 must be 이용되야만한다.

to 확인하기위해 that the 출력전압으

(Voltage Output Swings : 얼마나 근접하게 op-amp 출력이 driven되는가에 대한 수치이다. )

☞링크

Input sources connected to ground 

are actually connected to a supply rail in single-supply systems.

This is analogous to connecting a dual-supply input

to the minus power rail. 

This requirement for biasing the op amp inputs to achieve the desired

output voltage swing complicates single-supply designs.


When the signal source is not referenced to ground (see Figure 4–2), 

the voltage difference

between ground and the reference voltage is amplified along with the signal. 

Unless the reference voltage was inserted as a bias voltage, 

and such is not the case when the input signal is connected to ground, 

the reference voltage must be stripped from the signal

so that the op amp can provide maximum dynamic range.



An input bias voltage is used to eliminate the reference voltage when it must not appear

in the output voltage (see Figure 4–3). 

The voltage, VREF, is in both input circuits, 

hence it is named a common-mode voltage.

Voltage feedback op amps reject common-mode

voltages because their input circuit is constructed with a differential amplifier (chosen because

it has natural common-mode voltage rejection capabilities).

(Reference Voltage가 반전, 비반전 입력에 모두 들어가서 상쇄되었다.)

(그래서 공식에서 Vref가 빠져있다.)


When signal sources are referenced to ground, single-supply op amp circuits exhibit a

large input common-mode voltage. Figure 4–4 shows a single-supply op amp circuit that

has its input voltage referenced to ground. The input voltage is not referenced to the midpoint

of the supplies like it would be in a split-supply application, rather it is referenced to

the lower power supply rail. This circuit does not operate when the input voltage is positive

because the output voltage would have to go to a negative voltage, hard to do with a positive

supply. It operates marginally with small negative input voltages because most op

amps do not function well when the inputs are connected to the supply rails.

The constant requirement to account for inputs connected to ground or different reference

voltages makes it difficult to design single-supply op amp circuits. Unless otherwise specified,

all op amp circuits discussed in this chapter are single-supply circuits. The singlesupply

may be wired with the negative or positive lead connected to ground, but as long

as the supply polarity is correct, the wiring does not affect circuit operation.

Use of a single-supply limits the polarity of the output voltage. When the supply voltage

VCC = 10 V, the output voltage is limited to the range 0 ≤ Vout ≤ 10. This limitation precludes

negative output voltages when the circuit has a positive supply voltage, but it does not

preclude negative input voltages when the circuit has a positive supply voltage. As long

as the voltage on the op amp input leads does not become negative, the circuit can handle

negative input voltages.

Beware of working with negative (positive) input voltages when the op amp is powered

from a positive (negative) supply because op amp inputs are highly susceptible to reverse

voltage breakdown. Also, insure that all possible start-up conditions do not reverse bias

the op amp inputs when the input and supply voltage are opposite polarity.


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

75쪽

Chapter 5

Feedback and Stability Theory

======================================================================================

http://www.instructables.com/answers/whats-the-difference-between-12V-and-GND/

▲마이너스 전압과 GND의 차이점에 대한 질문

what's the difference between -12V and GND?



Re-design의 댓글

In some circuits negative is the same as ground, 

but in some circuits ground = 0 volts 

and in other parts of the circuit 

there is a negative voltage that is below ground.

몇몇 회로들에서 네거티브는 같다. as GND로,

but in 몇몇 회로들에선 GND=0V이다.

and in 다른 부품들에서 of the 회로의

there is a 네거티브 전압이 있다. that is 내려가는 GND아래로.

If you connect a voltmeter between ground (0 volts) and -12 volts 

it will read a difference of 12 volts, with the ground being most positive.

만약 네가 연결하면 a 테스터기를 between GND 와 -12V 사이에

이건 읽어들일것이다. a 차이를 of 12V의, with GND는 most positive가 되며.

Electrical parts work because of a difference in potiential.

Many don't care which way the difference is (light bulb) 

and some work in reverse (dc motor) 

and some won't work at all or are destroyed.

전자 부품들은 동작한다. because of a 전위차 때문에.

많은것들은 신경쓰지않는다. which 방법이 the difference 인지(전등)

and 몇몇은 동작한다. in 역으로 (예컨데 DC모터)

and 몇몇은 동작하지않을것이다. 전혀 or 파괴될것이다.


IT's a hard concept to explain and goes much more into detail 

than what I have just explained 

but google "negative voltage" if you wish to learn more.

IT는 어려운 개념이다. to 설명하는데 and 접근한다. much more into 자세히

than 뭘 내가 이미 just설명했는지

but 검색한다. "네거티브 전압"을 if 네가 좀더 배우길 원하면.


https://www.elcircuit.com/2016/09/headphone-amplifier-circuit-using-tl074.html

4 채널 증폭기를 이용한 HeadSet 설계

TL074CN 사용 (MCP6004로 대체가능)


'졸업작품 > OP AMP' 카테고리의 다른 글

성균관대 3학년용  (4) 2016.12.15
Posted by ElectricShock
:
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.


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



http://www.atmel.com/images/doc2467.pdf


▲NewTC 제품 핀아웃

글씨가 너무작아서 안보여서 이거 참고하시면 납땜하실때 편합니다.




▼아래 제품 정보

Reset왼쪽에 D1 (1N4148)

Push버튼 왼쪽에 D2

PA0 PA1각각 D4,D3 (for simple test)

DC Jack 왼쪽에 있는 Blue Button으로 On/Off시킬 수 있다.

Xtal왼편의 Jumper를 위/아래로 선택할 수 있다.

(Built-In Xtal은 8MHz이고, 따로 연결할수 있도록 아래칸은 비어있다.)


▼PCB작업시 필요한 회로(★)

AVR-H128-schematic.pdf


▼ATmega128 Pinout(=핀아웃)



--------왓취독타이머---------------------------------------------------------------

WDTCR :: -    -    -    WDCE    WDE    WDP2    WDP1    WDP0

void WDT_off(void)

{

/* Reset WDT*/

__watchdog_reset();

/* Write logical one to WDCE and WDE */

WDTCR |= (1<<WDCE) | (1<<WDE);  //WatchDog Change Enable와 WatchDog Enable

//두개 비트를 1로 Set시킨다.

/* Turn off WDT */

WDTCR = 0x00;                    //싹다 Reset시킴

}

--------인터럽트-------------------------------------------------------------------------

void Move_interrupts(void)

{

/* Enable change of interrupt vectors */

MCUCR = (1<<IVCE);

/* Move interrupts to boot flash section */

MCUCR = (1<<IVSEL);

}

-------▼69쪽-----풀업------------------------------------------------------------------------

unsigned char i;

...

/* Define pull-ups and set outputs high */

/* Define directions for port pins */

PORTB = (1<<PB7)|(1<<PB6)|(1<<PB1)|(1<<PB0);

DDRB = (1<<DDB3)|(1<<DDB2)|(1<<DDB1)|(1<<DDB0);

/* Insert nop for synchronization*/

__no_operation();

/* Read port pins */

i = PINB;

...

-----▼111쪽----16비트 타이머카운터--------------------------------------------------

The main features are: 

• True 16-bit Design (i.e.,Allows 16-bit PWM) 

• Three Independent Output Compare Units 

• Double Buffered Output Compare Registers 

• One Input Capture Unit 

• Input Capture Noise Canceler 

• Clear Timer on Compare Match (Auto Reload) 

• Glitch-free, Phase Correct Pulse width Modulator (PWM) 

• Variable PWM Period • Frequency Generator 

• External Event Counter 

• Ten Independent Interrupt Sources (TOV1, OCF1A, OCF1B, OCF1C, ICF1, TOV3, OCF3A, OCF3B, OCF3C, and ICF3)


Note that in Atmel® AVR® ATmega103 compatibility mode, 

only one 16-bit Timer/Counter is available (Timer/Counter1). 

Also note that in ATmega103 compatibility mode, the Timer/Counter1 

has two Compare Registers (Compare A and Compare B) only.

기억해라. that in Atmel AVR에서 ATmega103은 호환성 모드,

only 하나 16-bit Timer/Counter만 이용가능하다.

또한 기억해라. that in ATmega103 호환성 모드, the Timer/Counter1은 

갖고있다. 두개 비교 레지스터들을(Compare A and Compare B).

Most register and bit references in this section 

are written in general form. 

A lower case “n” replaces the Timer/Counter number, 

and a lower case “x” replaces the Output Compare unit channel. 

However, when using the register or bit defines in a program, 

the precise form must be used i.e., TCNT1 

for accessing Timer/Counter1 counter value and so on. 

A simplified block diagram of the 16-bit Timer/Counter 

is shown in Figure 46. 

For the actual placement of I/O pins, 

refer to “Pin Configurations” on page 2. 

CPU accessible I/O Registers, including I/O bits and I/O pins, 

are shown in bold. 

The device-specific I/O Register and bit locations 

are listed in the “16-bit Timer/Counter Register Description”

on page 132.

대부분의 레지스터 and 비트 참조들 in this 섹션의

은 씌였다. in 일반적인 폼으로.

소문자 n은 대체한다. the Timer/Counter 넘버를,

and 소문자 x는 대체한다. the 출력 비교 유닛 채널을.

However, when 사용할때 the 레지스터를 of 비트 정의들을 in a 프로그램에서,

the 정확한 폼은 must be 사용되어야한다. i.e., TCNT1

for 접근하기위해 Timer/Counter1 카운터 벨류에 and so on.

A 간략화된 블록 다이어그램 of the 16-bit Timer/Counter

은 보인다. in 그림 46에서.

For the 실제 배치를 위해 of I/O 핀들의,

참조해라 to "핀 구성"을 on 페이지 2의.

CPU 접근가능한 I/O Register들, 포함하며 I/O 비트들을 and I/O 핀들을

은 보인다. in 굵은 글씨로.

The 디바이스 특성 I/O Register and 위치들

은 리스트되있다. the "16비트 타이머/카운터 레지스터 설명"

on 페이지 132에.


Table 30. Port B Pins Alternate Functions

 Port Pin

 Alternate Functions

 PB7

 OC2/OC1C(1) (Output Compare and PWM Output for Timer/Counter2 or Output Compare and PWM Output C for Timer/Counter1)

 PB6

  OC1B (Output Compare and PWM Output B for Timer/Counter1)

 PB5

 OC1A (Output Compare and PWM Output A for Timer/Counter1)

 PB4

 OC0 (Output Compare and PWM Output for Timer/Counter0)

 PB3

 MISO (SPI Bus Master Input/Slave Output)

 PB2

 MOSI (SPI Bus Master Output/Slave Input)

 PB1

  SCK (SPI Bus Serial Clock)

 PB0 SS (SPI Slave Select input)


Table 39. Port E Pins Alternate Functions

 Port Pin

 Alternate Function

 PE7

 INT7/ICP3(1) (External Interrupt 7 Input or Timer/Counter3 Input Capture Pin)

 PE6

  INT6/ T3(1) (External Interrupt 6 Input or Timer/Counter3 Clock Input)

 PE5

 INT5/OC3C(1) (External Interrupt 5 Input or Output Compare and PWM Output C for Timer/Counter3)

 PE4

 INT4/OC3B(1) (External Interrupt4 Input or Output Compare and PWM Output B for Timer/Counter3)

 PE3

 AIN1/OC3A (1) (Analog Comparator Negative Input or Output Compare and PWM Output A for Timer/Counter3)

 PE2

 AIN0/XCK0(1) (Analog Comparator Positive Input or USART0 external clock input/output)

 PE1

  PDO/TXD0 (Programming Data Output or UART0 Transmit Pin)

 PE0

 PDI/RXD0 (Programming Data Input or UART0 Receive Pin)

------112쪽--------------------------------------------------------------------------------

The Timer/Counter (TCNTn), 

Output Compare Registers (OCRnA/B/C), 

and 

Input Capture Register (ICRn) are all 16-bit registers. 

Special procedures must be followed 

when accessing the 16- bit registers. 

특별 절차들은 must be 따라야만 한다.

when 접근할때 the 16비트 레지스터들에.

These procedures are described in the section “Accessing 16-bit Registers” on page 114. 

The Timer/Counter Control Registers (TCCRnA/B/C) 

are 8-bit registers 

and 

have no CPU access restrictions.

예) ▼

TCCR1A |= (1<<COM1A1) | (1<<COM1B1) | (1<<WGM11);    //Non Inverted PWM

TCCR1B |= (1<<WGM13) | (1<<WGM12) ! (1<<CS11) | (1<<CS10)     

//PRESCALER=64 MODE 14(FAST PWM)

Interrupt requests (shorten as Int.Req.) signals are all visible 

in the Timer Interrupt Flag Register (TIFR) 

and 

Extended Timer Interrupt Flag Register (ETIFR). 

All interrupts are individually masked with the Timer Interrupt Mask Register (TIMSK) 

and Extended Timer Interrupt Mask Register (ETIMSK). (E)TIFR and (E)TIMSK are not shown in the figure since these registers are shared by other timer units. 

The Timer/Counter can be clocked internally, via the prescaler

or by an external clock source 

on the Tn pin.

타이머/카운터는 생성된다. prescale 혹은 외부 클락에 의해.

The Clock Select logic block controls which clock source and edge the Timer/Counter uses                                             to increment (or decrement) its value.

The Timer/Counter is inactive when no clock source is selected.

The output from the clock select logic is referred to as the timer clock (clkTn).

The double buffered Output Compare Registers (OCRnA/B/C) are compared with the Timer/Counter value at all time.

The result of the compare can be used by the waveform generator to generate a PWM or variable frequency output on the Output Compare Pin (OCnA/B/C).


▼PWM출력 (=교류) (=Alternate Functions)

ATmega8OCR1A는 ATmega128OC1A와 같다.



-----▼114쪽--Temporary Register-----------------------------------------------------

unsigned int i; 

... 

/* Set TCNTn to 0x01FF */ 

TCNTn = 0x1FF; 

/* Read TCNTn into i */ 

i = TCNTn; 

...

-------▼인터럽트------------------------------------------------------------------------

It is important to notice that accessing 16-bit registers are atomic operations.

atomic operation : 쪼갤 수 없는 연산자

If an interrupt occurs between the two instructions accessing the 16-bit register, 

and the interrupt code updates the temporary register 

by accessing the same or any other of the 16-bit Timer Registers, 

then the result of the access outside the interrupt will be corrupted. 

Therefore, when both the main code and the interrupt code update the temporary register, 

the main code must disable the interrupts during the 16-bit access.

메인코드 & 인터럽트코드가 업데이트할때 임시레지스터를,

그 메인코드는 반드시 disable시켜야한다. the 인터럽트를 during the 16비트 접근동안

unsigned int TIM16_ReadTCNTn( void ) 

unsigned char sreg; 

unsigned int i; 

/* Save global interrupt flag */ 

sreg = SREG; 

/* Disable interrupts */ 

__disable_interrupt(); 

/* Read TCNTn into i */ 

i = TCNTn; 

/* Restore global interrupt flag */ 

SREG = sreg; 

return i; 

}

---------▼116쪽----atomic write------------------------------------------------------

The following code examples show how to do an atomic write of the TCNTn Register contents. Writing any of the OCRnA/B/C or ICRn Registers can be done 

by using the same principle.

따라오는 코드 예제들은 보여준다. how to 하는법 atomic 쓰기 of the TCNTn 레지스터 컨텥츠들의.

쓰기 어떤걸 of the OCRnA/B/C의 or ICRn 레지스터들 can be 완성될수있다. 

by 사용함으로써 the 같은 원리를.


void TIM16_WriteTCNTn( unsigned int i ) 

unsigned char sreg; 

unsigned int i; 

/* Save global interrupt flag */ 

sreg = SREG; 

/* Disable interrupts */ 

__disable_interrupt(); 

/* Set TCNTn to i */ 

TCNTn = i; 

/* Restore global interrupt flag */ 

SREG = sreg; 

}

-------▼SPI통신 Master코드--------------------------------------------------------------

void SPI_MasterInit(void)

{

/* Set MOSI and SCK output, all others input */

DDR_SPI = (1<<DD_MOSI)|(1<<DD_SCK);

/* Enable SPI, Master, set clock rate fck/16 */

SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);

}

void SPI_MasterTransmit(char cData)

{

/* Start transmission */

SPDR = cData;

/* Wait for transmission complete */

while(!(SPSR & (1<<SPIF)))

;

}

-----▼SPI통신 Slave코드-----------------------------------------------------------------

void SPI_SlaveInit(void)

{

/* Set MISO output, all others input */

DDR_SPI = (1<<DD_MISO);

/* Enable SPI */

SPCR = (1<<SPE);

}

char SPI_SlaveReceive(void)

{

/* Wait for reception complete */

while(!(SPSR & (1<<SPIF)))

;

/* Return data register */

return SPDR;

}

------▼134쪽---------------------------------------------------------------------------------

●Bit 1:0 – WGMn1:0: Waveform Generation Mode


------▼176쪽 USART통신 Initialization-----------------------------------------------------

#define FOSC 1843200// Clock Speed

#define BAUD 9600

#define MYUBRR FOSC/16/BAUD-1

void main( void )

{

...

USART_Init ( MYUBRR );

...

}

void USART_Init( unsigned int ubrr )

{

/* Set baud rate */

UBRRH = (unsigned char)(ubrr>>8);

UBRRL = (unsigned char)ubrr;

/* Enable receiver and transmitter */

UCSRB = (1<<RXEN)|(1<<TXEN);

/* Set frame format: 8data, 2stop bit */

UCSRC = (1<<USBS)|(3<<UCSZ0);

}

----▼데이터전송 5~8개 데이터 비트--------------------------------------------------------

void USART_Transmit( unsigned char data )

{

/* Wait for empty transmit buffer */

while ( !( UCSRA & (1<<UDRE)) )

;

/* Put data into buffer, sends the data */

UDR = data;

}

-------▼데이터전송 9개 데이터 비트--------------------------------------------------------

void USART_Transmit( unsigned int data )

{

/* Wait for empty transmit buffer */

while ( !( UCSRA & (1<<UDRE)) )

;

/* Copy 9th bit to TXB8 */

UCSRB &= ~(1<<TXB8);

if ( data & 0x0100 )

UCSRB |= (1<<TXB8);

/* Put data into buffer, sends the data */

UDR = data;

}

----▼데이터수신 5~8개 데이터 비트------------------------------------------------------

unsigned char USART_Receive( void )

{

/* Wait for data to be received */

while ( !(UCSRA & (1<<RXC)) )

;

/* Get and return received data from buffer */

return UDR;

}

--------▼데이터수신 9개 데이터 비트-------------------------------------------------------

unsigned int USART_Receive( void ) 

unsigned char status, resh, resl; 

/* Wait for data to be received */ 

while ( !(UCSRA & (11<<RXC)))

/* Get status and 9th bit, then data */ 

/* from buffer */ 

status = UCSRA; 

resh = UCSRB; 

resl = UDR; 

/* If error, return -1 */

if ( status & (1<<FE)|(1<<DOR)|(1<<UPE) )

return -1;

/* Filter the 9th bit, then return */

resh = (resh >> 1) & 0x01; 

return ((resh << 8) | resl); 

}

----▼183쪽 Flushing the Receive Buffer-------------------------------------------------

void USART_Flush( void )

{

unsigned char dummy;

while ( UCSRA & (1<<RXC) ) dummy = UDR;

}

-----▼192쪽 USART Baud Rate Registers – UBRRnL and UBRRnH----------------------------



• Bit 11:0 – UBRRn11:0: USARTn Baud Rate Register 

This is a 12-bit register which contains the USARTn baud rate. 

The UBRRnH contains the four most significant bits, 

and the UBRRnL contains the eight least significant bits of the USARTn baud rate. 

Ongoing transmissions by the transmitter and receiver 

will be corrupted if the baud rate is changed.

진행하는 전송들 by the 송수신부에의해

은 will be 손상된다. if the 보드 레이트가 바뀌면.

Writing UBRRnL will trigger an immediate update of the baud rate prescaler.

쓰기 UBRRnL은 will 트리거할것이다. 즉시 업데이트를 of the 보드 레이트 프리스케일러의

------▼211쪽 TWI---------------------------------------------------------------------

TWCR = (1<<TWINT)|(1<<TWSTA)| (1<<TWEN)

while (!(TWCR & (1<<TWINT))) ;

if ((TWSR & 0xF8) != START) ERROR();

TWDR = SLA_W;

TWCR = (1<<TWINT) | (1<<TWEN);

while (!(TWCR & (1<<TWINT))) ;

if ((TWSR & 0xF8) != MT_SLA_ACK) ERROR();

TWDR = DATA;

TWCR = (1<<TWINT) | (1<<TWEN);

while (!(TWCR & (1<<TWINT))) ;

if ((TWSR & 0xF8) != MT_DATA_ACK) ERROR();

TWCR = (1<<TWINT)|(1<<TWEN)| (1<<TWSTO);



------▼244쪽 ADCSRA---------------------------------------------------------------------

ADCSRA : ADC Control and Status Register A  이다.

ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); 의 형태로 주로 사용한다.

ADEN : ADC Enable Bit (필수로 1로 Set 시켜야한다.)

ADSC : ADC Start Conversion

In Single Conversion mode,

write this bit to one to start each conversion.

In Free Running mode,

write this bit to one to start the first conversion.

The first conversion 

after ADSC has been written

after the ADC has been enabled, or if ADSC is written at the same time as the ADC is enabled,

will take 25 ADC clock cycles instead of the normal 13.

This first conversion performs initialization of the ADC.

'AVR > ATmega128 Datasheet' 카테고리의 다른 글

ATMEL042(93C56)  (0) 2018.07.03
JMOD-128-1  (0) 2016.08.13
GS-128B (거상인 제품) ㅁ  (0) 2016.04.20
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)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백