2020/02/21

STM32 Analog-to-digital converters(ADCs)

single channel/single conversion
scan channel/single conversion
single channel/continuous conversion
scan channel/continuous conversion

Datasheet
Three 12-bit analog-to-digital converters are embedded and each ADC shares up to 16 external channels, performing conversions in the single-shot or scan mode. In scan mode, automatic conversion is performed on a selected group of analog inputs.

Additional logic functions embedded in the ADC interface allow:
- Simultaneous sample and hold
- Interleaved sample and hold

The ADC can be served by the DMA controller. An analog watchdog feature allows very precise monitoring of the converted voltage of one, some or all selected channels. An interrupt is generated when the converted voltage is outside the programmed thresholds.

To synchronize A/D conversion and timers, the ADCs could be triggered by any of TIM1, TIM2, TIM3, TIM4, TIM5, or TIM8 timer.


RM0090 Chapter 13 Analog-to-digital converter (ADC)

13.1 ADC introduction
The 12-bit ADC is a successive approximation analog-to-digital converter. It has up to 19 multiplexed channels allowing it to measure signals from 16 external sources, two internal sources, and the Vbat channel. The A/D conversion of the channels can be performed in single, continuous, scan or discontinuous mode. The result of the ADC is stored into a left or right-aligned 16-bit data register.

The analog watchdog feature allows the application to detect if the input voltage goes beyond the user-defined, higher or lower thresholds.

13.2 ADC main features
- 12-bit, 10-bit, 8-bit or 6 bit configurable resolution
- Interrupt generation at the end of conversion, end of injected conversion, and in case of analog watchdog or overrun events
- Single and continuous conversion modes
- Scan mode for automatic conversion of channel 0 to channel 'n'
- Data alignment with in-built data coherency
- Channel-wise programmable sampling time
- External trigger option with configurable polarity for both regular and injected conversions
- Discontinuous mode
- Dual/Triple mode (on devices with 2 ADCs or more)
- Configurable DMA data storage in Dual/Triple ADC mode
- Configurable delay between conversions in Dual/Triple interleaved mode
- ADC conversion type (refer to the datasheets)
- ADC supply requirements: 2.4V to 3.6V at full speed and down to 1.8V at slower speed
- ADC input range: Vref- <= Vin <= Vref+
- DMA request generation during regular channel conversion

13.3 ADC functional description
13.3.1 ADC on-off control
The ADC is powered on by setting the ADON bit in the ADC_CR2 register. When the ADON bit is set for the first time, it wakes up the ADC from the Power-down mode.

Conversion starts when either the SWSTART or the JSWSTART bit is set.

You can stop conversion and put the ADC in power down mode by clearing the ADON bit. In this mode the ADC consumes almost no power (only a few uA).

13.3.2 ADC clock
The ADC features two clock schemes:
- Clock for the analog circuitry: ADCCLK, common to all ADCs

- Clock for the digital interface (used for registers read/write access)


13.3.3 Channel selection
There are 16 multiplexed channels. It is possible to organize the conversions in two groups: regular and injected. A group consists of a sequence of conversions that can be done on any channel and in any order.

- A regular group

- An injected group

13.3.4 Single conversion mode



AN4073 Application note
How to improve ADC accuracy when using STM32F2xx and STM32F4xx microcontrollers

The purpose of this application note is to show how to improve the accuracy of A/D conversions for applications using the STM32F2xx and STM32F4xx microcontrollers.

It also explains the firmware methodology, which can be applied to reduce the ADC error and gives some general tips on writing firmware for better ADC accuracy.

Please note that the data provided with this application note is for reference only, measured in a lab under typical conditions (unless specified otherwise) and not tested in production.

1. Overview of parameters impacting the ADC accuracy

The accuracy of an analog to digital conversion has an impact on the overall system quality and efficiency. To improve the accuracy, you need to understand the errors associated with the ADC and the parameters affecting them.
전체적인 시스템 품질과 효율성이 ADC의 정확도에 영향을 미친다. 정확도를 개선하려면 ADC에 연관된 문제점과 거기 관계된 파라미터에 대한 이해가 필요하다.

The ADC, itself, cannot ensure the accuracy of results. It depends on your overall system design. For this reason, you need to do some careful preparation before starting your development.
ADC 자체는 정확도와 상관없고 시스템의 전체적인 디자인에 관련이 있다. 그러므로 개발을 시작하기 전에 세심한 주의를 기울여야한다.

Many parameters impact the ADC accuracy, depending on the application. Some of these factors are: PCB layout, voltage source, I/O switching and analog source impedance.
PCB 아트웍, 전압소스, 입출력 스위칭 신호와 아날로그 임피던스 등 많은 요소가 ADC 정확도에 영향을 미치는 요소이다.

For more details about ADC errors, please refer to AN2834: How to get the best ADC accuracy in STM32F10xxx devices and AN3137: A/D converter on STM8L devices application notes.

2. Firmware techniques for improving the conversion accuracy

2.1 Averaging
Averaging is a simple technique where you sample an analog input several times and take the average of the results. This technique is helpful to eliminate the effect of noise on the analog input or a wrong conversion.
여러번 샘플값을 얻어서 평균내는 간단한 방법이 있다. 노이즈나 잘못 변환된 값을 제거하는데 도움이 된다.

2.1.1 Averaging of N ADC samples
When this method is used, it is better to collect the samples in multiples of 2(N should be a multiple of 2). This makes it more efficient to compute the average because you can do the division by right-shifting the sum of the converted values. This saves CPU time and code memory needed to execute a division algorithm (in Cortex-Mx, this takes 1 CPU cycle)




















This averaging technique is used to measure the voltage on one analog input pin. A total of N conversions is considered and the average is calculated. This is done in a loop in the firmware.
샘플 수집은 2의 지수승으로 하는것이 좋다. 평균값 계산시 오른쪽 비트 시프트 만으로 나눗셈 연산이 되므로 CPU 타임과 코드 메모리를 절약할 수 있다.
이 방법은 하나의 아날로그 전압 측정에 유용하다. N번의 변환과 평균값 계산을 펌웨어에서 루프로 진행한다.

Total conversion time = (number of samples * ADC conversion time) + computation time.
Computation time = time taken to read the results, add them together and calculate the average by dividing the total by the number of samples.

There is a trade-off between the total conversion time and the number of samples used to average, depending on the analog signal variations and the time available for computation.
총 작업시간 = (샘플 수 * 변환시간) + 계산시간
계산시간 = 샘플을 읽고,그 샘플을 모두 더하고 평균내는데 걸리는 시간
총 작업시간과 샘플 수 사이에 균형을 맞춰야한다.

2.1.2 Averaging of N-X ADC samples
This method is based on taking N ADC samples, sorting them from the highest to the lowest value (or the reverse) and deleting the dispersed X samples.
이 방법은 N ADC 샘플 추출 기반으로 최대, 최소값을 정렬한 후 튀는 값들을 제거하는 방식이다.

It is recommended to choose N and X as multiples of 2.
N과 X는 2의 지수값으로 정하는걸 추천한다.

This averaging method is more efficient than the previous one, as it deletes the most dispersed values which could impact the average, and it gives a good trade-off between the execution time and the conversion accuracy.
이 방식이 평균값에 영향을 미치는 튀는 값들을 제거하기 때문에 이전 방식보다 더 효과적이다.

N번 샘플 수집 -> 크기 순으로 정렬 -> X/2개의 상위 샘플 제거, X/2개의 하위 샘플 제거 -> 남은 샘플 평균값 계산


2.2 Additional recommendation
ADC conversion results are the ratio of the input voltage to the reference voltage. If there is noise in the reference voltage, then the results may not be accurate. Both hardware and firmware design are responsible for reducing the noise.

The execution of code generates some non-negligible noise on the internal power supply network of the microcontroller. To filter this noise, the Vdda(or Vref) and VSSA analog supply pins are available on the microcontroller package; You can connect a capacitor filter to these power supply pins to filter a high frequency noise.

Here are some general firmware design tips for reducing system noise in order to achieve a better ADC conversion accuracy:
1. Avoid starting transmission on any communication peripheral just before starting the ADC conversion. The toggling of the I/Os may create some noise in the supply voltage.
2. Avoid toggling high-sink I/Os which cause noise ripple in the power supply.
3. Avoid toggling digital outputs on the same I/O port as the A/D input is being converted. This can introduce switching noise into the analog inputs.
4. It is recommended to configure the STM32F2/F4 ART with data cache + instruction cache enable and to disable the prefetch. This will avoid extra CPU accesses to the Flash memory causing an additional noise which can significantly decrease the ADC accuracy in some applications.

오 N sampling, N-X sampling 소스도 있네


































2020/02/20

Kivy garden Graph widget

The Graph widget is a widget for displaying plots.
It supports drawing multiple plot with different colors on the Graph. It also supports a title, ticks, labeled ticks, grids and a log or linear representation on both the x and y axis, independently.































To display a plot. First create a graph which will function as a "canvas" for the plots. Then create plot objects e.g. MeshLinePlot and add them to the graph.

To create a graph with x-axis between 0-100, y-axis between -1 to 1, x and y labels of and X and Y, respectively, x major and minor ticks every 25, 5 units, respectively, y major ticks every 1 units, full x and y grids and with a red line plot containing a sine wave on this range:

1
2
3
4
5
6
7
8
9
from math import sin
from kivy.garden.graph import Graph, MeshLinePlot
graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5,
x_ticks_major=25, y_ticks_major=1,
y_grid_label=True, x_grid_label=True, padding=5,
x_grid=True, y_grid=True, xmin=-0, xmax=100, ymin=-1, ymax=1)
plot = MeshLinePlot(color=[1001])
plot.points = [(x, sin(x / 10.)) for x in range(0101)]
graph.add_plot(plot)
cs

The MeshLinePlot plot is a particular plot which draws a set of points using a mesh object. The points are given as a list of tuples, with each tuple being a (x, y) coordinate in the graph's units.

You can create different types of plots other than MeshLinePlot by inheriting from the Plot class and implementing the required functions. The Graph object provides a "canvas" to which a Plot's instructions are added. The plot object is responsible for updating these instructions to show within the bounding box of the graph the proper plot. The Graph notifies the Plot when it needs to be redrawn due to changes. See MeshLinePlot class for how it is done.

2020/02/14

STM32F439ZIT 기본 Firmware

Board Name : STM32-144-DUI
Board Version : 0.0.1
Code : Greig
MCU : STM32F439ZIT6

전원, MCU 및 주변회로, USB-to-Serial 만 수납하여 펌웨어 테스트 진행함.




































0. 준비사항
0.1 STM32CubeMX 설치 및 업데이트
0.2 STM32CubeProgrammer 설치 및 업데이트
0.3 STM32CubeIDE 설치 및 업데이트


1. STM32CubeMX
STM32CubeMX를 사용해서 프로젝트를 생성한다.

1.1 MCU Selector



















1.2 Project Settings
























1.3 Pinout & Configuration
1.3.1 RCC Configuration
























1.3.2 USART3 Configuration

























1.3.3 Clock Configuration
























1.3.4 Generate Code


2. STM32CubeIDE
2.1 Project Import




































2.2 Test Build













OK 문제없음.



3. Communication with Host PC
3.1 Protocol Format
- Host PC to MCU : "명령어" + i개의 "cmd_arg" + "\r"
    *. 명령어 : 대문자 알파벳
    *. i개의 cmd_arg : 숫자
    *. \r : Carriage Return
- MCU to Host PC : "명령어" + i개의 "cmd_arg" + "\r\n" + j개의 "rtn_arg" + "\r\n>"
    *. 명령어 : 대문자 알파벳
    *. i개의 cmd_arg : 숫자
    *. \r : Carriage Return
    *. \n : Line Feed
    *. j개의 rtn_arg : 숫자 또는 대소문자 알파벳
    *. > : 응답 문장의 종료

예를 들어 LED를 ON 하려면
Host to MCU로 "LED 0 1\r" 이렇게 명령을 보내고
MCU to Host로 "LED 0 1\r\nLED"LED Num-0 ON\r\n" 이렇게 응답을 받게 된다.

간단한 통신 테스트용 앱을 만들어보자.(Python + Kivy)






























COM 포트 연결되면 "VER\r"이란 명령어가 날아가고 보드의 버전 정보를 읽어오도록 해보자.
뿅뿅





























OK 굳.

2020/01/29

40V/3A 부스트 방식 전류 컨트롤러

TPS61500 High-Brightness, LED Driver with Integrated 3A, 40V Power Switch

Feature
- 2.9-Vto 18-VInputVoltageRange
- 3-A, 40-VInternalPowerSwitch
  –  Four3-W LEDsFrom5-V Input
  –  Eight3-W LEDsFrom12-VInput
- High-Efficiency Power Conversion : Up to 93%
- Frequency Set by External Resistor : 200 kHz to2.2 MHz
- User-Defined Soft Start Into Full Load
- Programmable Overvoltage Protection
- Analog and Pure PWM Brightness Dimming
- 14-Pin HTSSOP Package With PowerPAD™


Description
The TPS61500 is a monolithic switching regulator with integrated 3-A, 40-V power switch. It is an ideal driver for high brightness 1-W or 3-W LED.
The device has a wide input voltage range to support application with input voltage from multi-cell batteries or regulated 5-V or 12-V power rails.
The LED current is set with an external sensor resistor R3, and the feedback voltage that
is regulated to 200 mV by current mode PWM(pulse width modulation) control loop, as
shown in Typical Application Circuit. The device supports analog and pure PWM dimming methods for LED brightness control. Connecting a capacitor to the DIMC pin configures the device to be used for analog dimming, and the LED current varies proportional to the duty cycle of an external PWM signal. Floating the DIMC pin configures the device for pure PWM dimming with the average LED current being the PWM signal's duty cycle times a set LED current. The device features a  programmable soft-start function to limit inrush current during start-up, and it has other built-in protection features, such as pulse-by-pulse overcurrent limit, overvoltage protection, and thermal shutdown. The TPS61500 is available in 14-pin HTSSOP package with PowerPAD.

60W 스텝다운 방식의 전류 컨트롤러

40V 3A 스텝-다운방식 단방향 전류 제어기

The AL8843 is a hysteresis mode DC-DC step-down converter, designed for driving single or multiple series connected LEDs efficiently from a voltage source higher than the LED voltage.
The device can operate from an input supply between 4.5V and 40V and provide an externally adjustable output current up to 3A.
Depending upon supply voltage and external components, this converter can provide up to 60W of output power.

The AL8843 integrates the power switch and a high-side output current sensing circuit, which uses an external resistor to set the nominal average output current.

Dimming can be realized by applying an external control signal to the CTRL pin. The CTRL pin will accept either a DC voltage signal or a PWM signal.

The soft-start time can be adjusted by an external capacitor from the CTRL pin to Ground. Applying a voltage of 0.3V or lower to the CTRL pin will shut down the power switch.


Features
- Wide Input Voltage Range: 4.5V to 40V
- Output Currentup to 3A
 
- Internal 40V NDMOS Switch
- Typical 4% Output Current Accuracy
- Single Pin for On/Off and Brightness Control by DC Voltage or PWM Signal
- Recommended Analog Dimming Range: 10% to 100%
- Soft-Start- High Efficiency (Up to 97%) 
- LED Short Protection
- Inherent Open-Circuit LED Protection
- Over Temperature Protection (OTP)
- Up to 1MHz Switching Frequency 
- SO-8EP Packages Available in Green Molding Compound (No Br, Sb)
- Totally Lead-Free & Fully RoHSCompliant (Notes 1 & 2)
- Halogen and Antimony Free. “Green” Device (Note 3)

Applications
- LED Retrofit for Low Voltage Halogen 
- Low Voltage Industrial Lighting 
- LED Backlighting- Illuminated Signs 
- External Driver with Multiple Channels

2020/01/21

부품 목록화 작업중

1. 폰으로 사진찍어서 구글 포토에 업로드
2. 구글 포토에 부품 앨범 생성
3. 사진에 comment 추가할 수 있는지 확인중


2020/01/01

전압, 전류, 저항, 그리고 옴의 법칙

원문
https://learn.sparkfun.com/tutorials/voltage-current-resistance-and-ohms-law/all

Electricity Basics


When beginning to explore the world of electricity and electronics, it is vital to start by understanding the basics of voltage, current, and resistance. These are the three basic building blocks required to manipulate and utilize electricity. At first, these concepts can be difficult to understand because we cannot "see" them. One cannot see with the naked eye the energy flowing through a wire or the voltage of a battery sitting on a table. Even the lightning in the sky, while visible, is not truly the energy exchange happening from the clouds to the earth, but a reaction in the air to the energy passing through it. In order to detect this energy transfer, we must use measurement tools such as multimeters, spectrum analyzers, and oscilloscopes to visualize what is happening with the charge in a system. Fear not, however, this tutorial will give you the basic understanding of voltage, current, and resistance and how the three relate to each other.
전자와 전기를 이해하기 위해서는 전압, 전류, 저항에 대한 기본적인 이해가 필요하다.  이것들은 눈에 보이는게 아니므로 이해하기 난감하다. 아무도 맨눈으로 배터리에서 와이어를 통해 에너지가 흐르는걸 볼 수 없다. 눈에 보이는 번개라해도 엄밀히 말하면 구름과 지구의 에너지 교환이 아니라 그 사이에 에너지가 흘러가면서 발생하는 현상일 뿐이다. 그러므로 에너지 흐름을 측정하려면 시스템의 전하 상태를 시각화 해주는 멀티미터나 스펙트럼 애널라이저, 오실로스코프 등을 사용해야한다. 여기서는 전압, 전류, 저항에 대한 기본적인 이해와 이 세가지가 어떻게 연관되어 있는지를 살펴볼 것이다. 

Covered in this Tutorial
- How electrical charge relates to voltage, current, and resistance.
- What voltage, current, and resistance are.
- What Ohm's Law is and how to use it to understand electricity.
- A simple experiment to demonstrate these concepts.
- 전하(charge)는 전압, 전류, 저항과 어떤 관계인가
- 전압, 전류, 저항은 무엇인가
- 옴의 법칙?? 그리고 어찌 사용하는것인가
- 이론에 대한 간단한 실험


Electrical Charge
Electricity is the movement of electrons. Electrons create charge, which we can harness to do work. Your lightbulb, your stereo, your phone, etc., are all harnessing the movement of the electrons in order to do work. They all operate using the same basic power source: the movement of electrons.
전기는 전자의 흐름이다. 전자는 전하를 발생시키는 실제 일꾼이라고 볼수있다. 전구나 스테레오, 폰 등은 전자의 흐름에 의해 동작한다. 전자기기는 모두 다 전자의 흐름에 의해 동작한다.

The three basic principles for this tutorial can be explained using electrons, or more specifically, the charge they create:
- Voltage is the difference in charge between two points.
- Current is the rate at which charge is flowing.
- Resistance is a material's tendency to resist the flow of charge (current).
세가지 기본 규칙은 전자 또는 전자가 생성하는 전하에 의해 설명된다.
- 전압은 두 지점간의 전하의 차이다.
- 전류는 전하가 흐르는 비율이다.
- 저항은 전하의 흐름을 방해하는 물질의 성분이다.

So, when we talk about these values, we're really describing the movement of charge, and thus, the behavior of electrons. A circuit is a closed loop that allows charge to move from one place to another. Components in the circuit allow us to control this charge and use it to do work.
자, 이 세가지에 대해 이야기하기에 앞서 전하의 흐름과 전자의 특성에 대해 이야기해보자. 회로는 전하가 흐르기 위한 폐루프이다. 회로의 소자는 전하를 컨트롤하고 특정 작업을 할 수 있게 해준다.

Georg Ohm was a Bavarian scientist who studied electricity. Ohm starts by describing a unit of resistance that is defined by current and voltage. So, let's start with voltage and go from there.
게오르크 옴은 전기를 연구한 학자였고 전류와 전압에 의해 정의되는 저항의 단위에 대한 업적을 남겼다. 자 이제 전압에 대해 이야기해 보자.

Voltage
We define voltage as the amount of potential energy between two points on a circuit. One point has more charge than another. This difference in charge between the two points is called voltage. It is measured in volts, which, technically, is the potential energy difference between two points that will impart one joule of energy per coulomb of charge that passes through it (don't panic if this makes no sense, all will be explained). The unit "volt" is named after the Italian physicist Alessandro Volta who invented what is considered the first chemical battery. Voltage is represented in equations and schematics by the letter "V".
전압은 보통 회로상 두 포인트 사이의 전기적 위치 에너지(potential energy) 차이로 정의한다. 두 포인트 중 어느 하나가 더 높은 전하(electric charge)를 가지고 있다. 두 포인트의 높은 전하와 낮은 전하의 차이를 전압(voltage)라고 한다. volts로 측정되며, 두 포인트의 전위차는 그 사이를 통과하는 전하의 joule/coulomb으로 알려져있다. volt는 최초로 화학 전지를 개발한 이탈리아 물리학자 안레산드로 볼타의 이름이다. Voltage는 수식이나 회로도에서 V로 표기된다.

1V = 1J/1C

1줄은 1뉴턴의 힘으로 물체를 1미터 이동하였을때 한 일이나 이에 필요한 에너지다.
1J=1N1m
1J=1C1V
전기 에너지에서의 1J는 1V에 1A가 1초동안 흘렀을 때의 에너지이다.


1쿨롬은 전류 1A가 1초 동안 흘렀을 때 이동한 전하의 양이다. 즉, 단위시간 당의 전하의 양이다.
1C=1A×1s


When describing voltage, current, and resistance, a common analogy is a water tank. In this analogy, charge is represented by the water amount, voltage is represented by the water pressure, and current is represented by the water flow. So for this analogy, remember:
* Water = Charge
* Pressure = Voltage
* Flow = Current
Consider a water tank at a certain height above the ground. At the bottom of this tank there is a hose.
전압, 전류, 저항을 설명할때 보통 물탱크에 비유해서 설명한다. 전하는 물의 양, 전압은 수압, 전류는 물의 흐름으로 설명할 수 있다.
- Water = Charge
- Pressure = Voltage
- Flow = Current
지상의 어떠한 높이를 가진 물탱크를 가정하자. 이 물탱크의 아래에는 호스가 달려있다.

























The pressure at the end of the hose can represent voltage. The water in the tank represents charge. The more water in the tank, the higher the charge, the more pressure is measured at the end of the hose.
호스 끝의 압력이 전압을 의미한다. 탱크속의 물은 전하를 의미한다. 탱크속에 물이 더 있다면, 더 높은 전하를 가진것이고 더 높은 압력이 측정될 것이다.

We can think of this tank as a battery, a place where we store a certain amount of energy and then release it. If we drain our tank a certain amount, the pressure created at the end of the hose goes down. We can think of this as decreasing voltage, like when a flashlight gets dimmer as the batteries run down. There is also a decrease in the amount of water that will flow through the hose. Less pressure means less water is flowing, which brings us to current.
이 물탱크를 임의의 용량을 가진 배터리라고 생각하자. 
물탱크의 호스를 열어놓으면 수압에 의해 물이 흘러 나갈것이고 수압은 점차 줄어든다.
이것은 배터리의 전압이 떨어져서 전등의 불빛이 점점 어두워지는것에 비유할 수 있다.
호스로 빠져나간만큼 물이 줄어드는데 낮은 압력은 적은 물이 흐르고 있다는 뜻이고 자연스레 전류 설명으로 넘어가보자.

Current
We can think of the amount of water flowing through the hose from the tank as current. The higher the pressure, the higher the flow, and vice-versa. With water, we would measure the volume of the water flowing through the hose over a certain period of time. With electricity, we measure the amount of charge flowing through the circuit over a period of time. Current is measured in Amperes (usually just referred to as "Amps"). An ampere is defined as 6.241*10^18 electrons (1 Coulomb) per second passing through a point in a circuit. Amps are represented in equations by the letter "I".
호스를 통해 흘러나온 물의 양을 전류라고 생각할 수 있다. 압력이 높으면 많이 흐를것이고 반대도 마찬가지. 특정 시간 호스를 통해 흘러나온 물의 양을 측정하는것처럼 특정 시간 회로를 흘러간 전하량을 측정하자. 전류는 암페어로 측정되며 1암페어는 초당 1쿨롱(6.241*10^18 electrons) 이 흘렀음을 의미한다. 암페어는 l로 표현된다.

Let's say now that we have two tanks, each with a hose coming from the bottom. Each tank has the exact same amount of water, but the hose on one tank is narrower than the hose on the other.
이제 두개의 물탱크가 있고, 동일한 물의 양이 있으며, 호스의 굵기만 다르다고 가정해보자.

























We measure the same amount of pressure at the end of either hose, but when the water begins to flow, the flow rate of the water in the tank with the narrower hose will be less than the flow rate of the water in the tank with the wider hose. In electrical terms, the current through the narrower hose is less than the current through the wider hose. If we want the flow to be the same through both hoses, we have to increase the amount of water (charge) in the tank with the narrower hose.
각각 동일한 양의 물이 들어있지만 탱크를 열어두면 좁은 호스쪽이 물이 적게 흐른다. 전기적 관점에서 좁은 호스가 전류가 적게 흐른다. 동일한 양의 물이 흐르게 하려면 좁은 호스쪽의 물의 양을 늘려야한다. 


























This increases the pressure (voltage) at the end of the narrower hose, pushing more water through the tank. This is analogous to an increase in voltage that causes an increase in current.
좁은 호스쪽의 압력을 늘리면 물이 더 많이 빠져나간다. 마찬가지로 전압을 증가시키면 전류가 증가한다.

Now we're starting to see the relationship between voltage and current. But there is a third factor to be considered here: the width of the hose. In this analogy, the width of the hose is the resistance. This means we need to add another term to our model:
지금까지 전압과 전류의 관계를 알아보았다. 그런데 호스의 굵기라는 또 하나의 고려사항이 있다. 호스의 굵기가 저항을 의미한다. 물과 전기의 관계 설정에 용어를 추가하자.

- Water = Charge (measured in Coulombs)
- Pressure = Voltage (measured in Volts)
- Flow = Current (measured in Amperes, or "Amps" for short)
- Hose Width = Resistance

Resistance

Consider again our two water tanks, one with a narrow pipe and one with a wide pipe.
동일하게 좁은 호스와 넓은 호스를 가진 동일 사이즈의 물탱크를 가정하자.

























It stands to reason that we can't fit as much volume through a narrow pipe than a wider one at the same pressure. This is resistance. The narrow pipe "resists" the flow of water through it even though the water is at the same pressure as the tank with the wider pipe.
이 그림이 동일한 압력에 좁은 호스쪽이 더 적은 물이 흐르는 이유를 보여준다. 이것이 저항을 의미한다. 좁은 호스쪽은 넓은 호스쪽과 같은 압력이지만 물의 흐름에 방해가 있다.























In electrical terms, this is represented by two circuits with equal voltages and different resistances. The circuit with the higher resistance will allow less charge to flow, meaning the circuit with higher resistance has less current flowing through it.
전기적으로 보면 위 그림은 동일한 전압에 다른 저항이 걸려있는것으로 표현된다.
높은 저항이 걸린쪽은 전하가 적게 이동하고, 전류가 적게 흐른다는것을 의미한다.

This brings us back to Georg Ohm. Ohm defines the unit of resistance of "1 Ohm" as the resistance between two points in a conductor where the application of 1 volt will push 1 ampere, or 6.241×10^18 electrons. This value is usually represented in schematics with the greek letter "Ω", which is called omega, and pronounced "ohm".
게오르크 옴은 1옴을 1V의 전압에 1A 전류를 흘리는 저항으로 정의했다. 이 값은 회로상에 그리스 문자 Ω으로 표시되며 옴이라고 발음한다.

Ohm's Law
Combining the elements of voltage, current, and resistance, Ohm developed the formula:
V = IR
전압, 전류, 저항으로 옴은 이런 공식을 발견했다.
V = IR

Where
- V = Voltage in volts
- I = Current in amps
- R = Resistance in ohms

This is called Ohm's law. Let's say, for example, that we have a circuit with the potential of 1 volt, a current of 1 amp, and resistance of 1 ohm. Using Ohm's Law we can say:

1V = 1A · 1Ω
이걸 옴의 법칙이라고 부른다. 
어떤 회로에서 1옴의 저항에 1V 전압이 걸리고 1A가 흐르는걸 옴의 법칙으로 쓰자면:
1V = 1A · 1Ω
가 된다.

Let's say this represents our tank with a wide hose. The amount of water in the tank is defined as 1 volt and the "narrowness" (resistance to flow) of the hose is defined as 1 ohm. Using Ohms Law, this gives us a flow (current) of 1 amp.
넓은 호스 물탱크를 옴의 법칙으로 표현해보자. 탱크의 물의 양을 1V로, 호스의 협소함의 정도를 1옴으로 정의하자. 옴의 법칙에 따르면 1A가 흐르게 된다.

Using this analogy, let's now look at the tank with the narrow hose. Because the hose is narrower, its resistance to flow is higher. Let's define this resistance as 2 ohms. The amount of water in the tank is the same as the other tank, so, using Ohm's Law, our equation for the tank with the narrow hose is
1V = ?A · 2Ω
좁은 호스 물탱크는 저항이 더 높다. 그러니 2옴으로 하자. 물의 양은 같으니 전압은 동일하다. 옴의 법칙을 적용하면
1V = ?A · 2Ω
가 된다.

But what is the current? Because the resistance is greater, and the voltage is the same, this gives us a current value of 0.5 amps:
1V = 0.5A · 2Ω
전류는?? 동일 전압에 저항이 더 크니  계산해보자.
1V = 0.5A · 2Ω
0.5A 다.

























So, the current is lower in the tank with higher resistance. Now we can see that if we know two of the values for Ohm's law, we can solve for the third. Let's demonstrate this with an experiment.
높은 저항을 가진 탱크는 전류가 낮다. 이제 전압, 전류, 저항 중 두가지 값을 알면 나머지 하나는 옴의 법칙에 의해 바로 알 수 있다. 간단한 실험으로 확인해보자.

An Ohm's Law Experiment
For this experiment, we want to use a 9 volt battery to power an LED. LEDs are fragile and can only have a certain amount of current flowing through them before they burn out. In the documentation for an LED, there will always be a "current rating". This is the maximum amount of current that can flow through the particular LED before it burns out.
이 실험에서 LED를 구동하기 위해 9볼트 전압을 사용한다. LED는 허용 전류 이상으로 전류가 흐르게 되면 파손된다. LED 스펙에 current rating이라고 하여 명시되어있다. 

Materials Required
In order to perform the experiments listed at the end of the tutorial, you will need:

- A multimeter
- A 9-Volt battery
- A 560-Ohm resistor(or the next closest value)
- An LED
실험을 위해 아래 품목이 필요하다.
- 멀티미터
- 9볼트 배터리(건전지)
- 560옴 저항(없으면 제일 근접한 값)
- LED

NOTE: LEDs are what's known as a "non-ohmic" devices. This means that the equation for the current flowing through the LED itself is not as simple as V=IR. The LED introduces something called a "voltage drop" into the circuit, thus changing the amount of current running through it. However, in this experiment we are simply trying to protect the LED from over-current, so we will neglect the current characteristics of the LED and choose the resistor value using Ohm's Law in order to be sure that the current through the LED is safely under 20mA.
NOTE : LED는 옴의 법칙에 들어맞는 소자는 아니다. LED를 흐르는 전류는 V=IR에 일치하지 않는다. LED에 발생되는 열에 의해 저항값이 변화되고 그에따라 전압과 전류가 계속 달라지게 된다. 그러나 이 실험에서 그런 전류 특성은 배제하고 LED 전류를 20mA로 설정하기 위해 저항값을 선택했다.


For this example, we have a 9 volt battery and a red LED with a current rating of 20 milliamps, or 0.020 amps. To be safe, we'd rather not drive the LED at its maximum current but rather its suggested current, which is listed on its datasheet as 18mA, or 0.018 amps. If we simply connect the LED directly to the battery, the values for Ohm's law look like this:
V = I ·
therefore:
I = V / R
and since we have no resistance yet:
I = 9V / 0R

이 실험에서 9볼트 배터리에 LED를 연결하여 20mA를 흘리게 해야한다. 안전을 위해 18mA만 흐르게 하자. LED와 배터리를 다이렉트로 연결했을때 옴의 법칙에 따르면 아래와 같다:
V = I · 
그러므로
I = V / R
근데 저항값이 없네...

I = 9V / 0R

Dividing by zero gives us infinite current! Well, not infinite in practice, but as much current as the battery can deliver. Since we do NOT want that much current flowing through our LED, we're going to need a resistor. Our circuit should look like this:
0으로 나누면 무한대의 전류라는 이야긴데 실제로 무한대는 아니고 과전류로 소자가 모두 상해버린다. 이걸 원치는 않으니 저항을 끼워넣자.




















We can use Ohm's Law in the exact same way to determine the resistor value that will give us the desired current value:
V = I · R
therefore:
R = V/I
plugging in our values:
R = 9V/0.018A
solving for resistance:
R = 500Ω
전압과 전류를 아니까 저항값을 계산할 수 있다.
V = I · R
그러니까
R = V/I
값을 대입해보자
R = 9V/0.018A
계산하면
R = 500Ω

So, we need a resistor value of around 500 ohms to keep the current through the LED under the maximum current rating.
LED 전류 제어용으로 500옴이 필요하다.














500 ohms is not a common value for off-the-shelf resistors, so this device uses a 560 ohm resistor in its place. Here's what our device looks like all put together.
근데 500옴은 흔히 쓰는 용량이 아니다. 저항용량은 로그 단위로 되어 있으니까. 560옴을 쓰자.

























Success! We've chosen a resistor value that is high enough to keep the current through the LED below its maximum rating, but low enough that the current is sufficient to keep the LED nice and bright.
성공~~. 저항은 과전류를 막아줄만큼 충분히 용량이 크며, 적당한 밝기를 유지할만큼 충분히 작은 용량이다.

This LED/current-limiting resistor example is a common occurrence in hobby electronics. You'll often need to use Ohm's Law to change the amount of current flowing through the circuit. Another example of this implementation is seen in the LilyPad LED boards.
취미전자쪽에서 LED 전류제어용 저항을 흔히 볼 수 있다. 저항값을 바꿔서 전류를 변경 할 수 있다. 다른 예제로 LilyPad LED보드의 구성은 이렇다.

























With this setup, instead of having to choose the resistor for the LED, the resistor is already on-board with the LED so the current-limiting is accomplished without having to add a resistor by hand.
전류제어용 저항이 내장되어 있어서 그냥 연결만 해주면 되는듯하다.

Current Limiting Before or After the LED?
To make things a little more complicated, you can place the current limiting resistor on either side of the LED, and it will work just the same!

Many folks learning electronics for the first time struggle with the idea that a current limiting resistor can live on either side of the LED and the circuit will still function as usual.

Imagine a river in a continuous loop, an infinite, circular, flowing river. If we were to place a dam in it, the entire river would stop flowing, not just one side. Now imagine we place a water wheel in the river which slows the flow of the river. It wouldn't matter where in the circle the water wheel is placed, it will still slow the flow on the entire river.

This is an oversimplification, as the current limiting resistor cannot be placed anywhere in the circuit; it can be placed on either side of the LED to perform its function.

For a more scientific answer, we turn to Kirchoff's Voltage Law. It is because of this law that the current limiting resistor can go on either side of the LED and still have the same effect. For more info and some practice problems using KVL, visit this website.
전류제한용 저항을 LED 앞에 두느냐 뒤에 두느냐??
동일하다.