Sensor Connections: PNP versus NPN and Sourcing versus Sinking

산업자동화에는 24V용 센서가 주로 사용되며, NPN, PNP 두가지 타입이 있습니다. 두가지 타입의 센서는 PLC의 DI(Discrete Input) 모듈의 두가지 타입인 소스방식과 싱크방식에 맞춰서 사용해야 합니다. 

 

Transistor Effects

ON-OFF 형태의 신호를 다루는 전자장치(예를 들어, 입력센서)는 트랜지스터를 내장하고 있습니다. 트랜지스터는 반도체 재질의 소형 릴레이이며, 전류를 흐르거나 차단하는 스위치와 같은 역할을 합니다. 트랜지스터는 약한 신호를 감지후 신호를 증폭하는 역할도 하게 됩니다. 증폭된 신호는 PLC의 입력모듈 또는 기타 장치들로 전달될 수 있습니다. 트랜지스터는 NPN(sourcing), PNP(sinking) 두가지 타입이 있습니다.

 

"P", "N"은 반도체 물질의 종류를 의미하며, "PNP", "NPN"은 이 물질들의 배열순서를 의미합니다. 트랜지스터는 base, collector, emitter로 구성된 3개의 핀을 가지고 있습니다. 

 

PNP versus NPN Switching

산업용 3선식 센서는 대부분 아래와 같은 선으로 구성되어 있습니다.

* +24 Vdc

* 0 Vdc

* 신호선

 

+24 Vdc, 0 Vdc 선은 센서의 구동에 필요한 전원공급용이며, NPN, PNP타입은 신호선이 어떻게 구동될 것인지 결정하게 됩니다.

PNP 타입의 센서는 emitter에 +24 Vdc가 인가되고, collector에 sinking 타입 PLC 모듈과 연결됩니다. 센서가 특정한 물체를 감지하면 base에 전류를 흐르게 하여 emitter-collector간 전류가 흐르게 됩니다. 즉, 신호선쪽으로 +24 Vdc가 인가되고, PLC의 sink 타입 입력모듈 단자를 통해 포토커플러(빛을 이용하여 전류를 흐르게 하는 스위치. 입력모듈이 입력을 확인하는 용도로 사용)를 거친후 0 Vdc로 이어지게 됩니다.

 

 

NPN 타입의 센서는 emitter에 0 Vdc가 인가되고, collector에 source 타입 PLC 모듈과 연결됩니다. 센서가 특정한 물체를 감지하면 base에 전류가 흐르게 하여 collector-emitter간 전류가 흐르게 됩니다. 즉, 신호선쪽으로 0 Vdc가 인가되고, PLC의 source 타입 입력모듈 단자를 통해 포토커플러를 거친후 +24 Vdc로 이어지게 됩니다.

 

Three-Wire Devices and Leakage Current

3선식 센서는 트랜지스터 특성상 누설전류가 발생합니다. 센서가 신호선 스위치를 OFF하고 있음에도 신호선을 통하여 미세하게 전류가 흐르는 현상입니다. 비정상적으로 높은 누설전류는 의도치 않게 PLC의 입력모듈내 포토커플러를 동작시켜 마치 센서가 무언가를 감지한 것처럼 인식하게 만들수 있습니다.

 

Sourcing versus Sinking Circuits

sinking(싱크방식) 입력모듈은 PNP 센서와 사용되며, 입력모듈은 센서 감지시 신호선에 +24 Vdc가 인가되길 기다리고 있습니다.

 

sourcing(소스방식) 입력모듈은 NPN 센서와 사용되며, 입력모듈은 센서 감지시 신호선에 0 Vdc가 인가되길 기다리고 있습니다.

 

 

PLC 기종의 따라 sinking/sourcing를 반대로 표기하는 경우도 있으니, 입력모듈의 결선도는 꼭 확인해 보는 것이 좋습니다.

 

Benefits of PNP versus NPN

PNP 타입의 센서는 케이블 손상시 신호선과 0 Vdc선이 단락될 경우가 있을 수 있습니다. 그 결과로 센서가 손상될 것입니다.

 

NPN 타입의 센서는 케이블 손상시 신호선과 0 Vdc이 단락될 경우가 있을 수 있습니다. 그 결과로 입력모듈에 계속 신호가 들어오는 형태가 되지만 센서가 손상되지는 않습니다.

'ForBeginner' 카테고리의 다른 글

8-7. View  (0) 2021.05.20
8-6. Linked Server (Good, bad and OPENQUERY)  (0) 2021.05.20
2-0. 왜 Sensor의 이해가 필요한가?  (0) 2021.05.19
2-4. 센서와 변환기  (0) 2021.05.19
2-3. Analog & Digital Sensors  (0) 2021.05.19
  • PLC에서 올라온 Sensor의 값이 어떻게 연결 되고 변환 되었는지 알고 있어야 한다. 
  • 현장의 값과 다른 경우, 무엇이 문제인지 알려면 기본적인 지식이 있어야 한다. 
  • PLC Engineer와 원활한 소통을 위해서 Sensor의 이해가 필요하다. 

 

PLC 프로그램을 하다보면

아날로그 입력을 받아 처리하는 경우가 있을 것입니다.

아날로그 입력은 디지털(ON,OFF) 입력과는 달리 연속적인 값을 받아야 하는데요.

대표적으로 압력, 높이, 무게, 온도등이 해당됩니다.

이러한 값을 받아 PLC에서 정확하게 프로그램하기 위해서는

두가지 개념을 이해해야 합니다.

첫째는 스케일(scale) 입니다.

스케일은 범위를 말하는데요.

공학을 공부하거나 현장에서 기계설비를 다루는 사람들은

바늘계기를 가리키며 "풀스케일(full scale)이 얼마인가?"라고 묻곤 합니다.

풀 스케일은 그림에서 보듯이 최대로 표시할 수 있는 범위를 의미합니다.

이처럼 각종 센서들이 유효하게 측정할 수 있는 범위가 어디까지인지

제품사양서를 통해 반드시 확인해야 하는 것입니다.

둘째는 분해능(resolution) 입니다.

센서로부터 입력되는 연속적인 신호(아날로그 신호)를

PLC의 아날로그 입력모듈에서 얼마만큼 작게 쪼개서 표시할 수 있는가를 확인해야 합니다.

분해능이 높을수록 정밀한 값을 표시할 수 있을것입니다.

예를 들어

10bar의 압력을

PLC에서

10개로 쪼갤수 있다면 1bar, 2bar, 3bar와 같이 표시될 것이고,

100개로 쪼갤수 있다면 0.1bar, 0.2bar, 0.3bar와 같이 더 정밀한 값으로 표시할 수 있을 것입니다.

자, 스케일(scale)과 분해능(resolution)을 이해하셨다면

SMC 압력센서와 미쯔비시 PLC 아날로그 입력모듈을 가지고

실제 프로그램까지 작성해보도록 하겠습니다.

압력센서는

PSE564-01 로 선정하였습니다.

아래 사양서를 확인해 보도록 하겠습니다.

위 사양서에서 빨간색 부분을 보시면

센서의 스케일(범위)이 0kPa~500kPa까지이며,

출력이 1~5V 범위라는 것을 알 수 있습니다.

이와같이 센서가 가지는 측정 스케일과 출력신호 스케일을 정확히 파악 하셔아 합니다.

PLC는 FX2N-8AD로 선정하였습니다.

위 사양서에서 빨간색 부분을 보시면

입력범위는 -10V ~ 10V(전체 범위는 20V)이고

분해능은 2가지가 있습니다.

1) 20V를 8000개로 쪼갤수 있는 경우(일반분해능)

2) 20V를 32000개로 쪼갤수 있는 경우(고분해능)

여기서는 일반분해능을 선택하겠습니다

20V를 8000개로 쪼갤경우 2.5mV단위로 표시되게 됩니다.

그런데 센서출력은 1~5V이므로

PLC에서 사용되는 값의 범위는 400~2000이 될 것입니다.

이와같이 PLC의 분해능과 입력범위에 대해서 정확히 파악 하셔야 합니다.

그러면 센서의 스케일과 PLC의 분해능에 따른 입력범위를 가지고 새로운 그래프를 그려보면

PLC 아날로그 입력모듈을 통해 읽혀지는 값이 400이면 현재 압력이 0kPa이고,

2000이라면 500kPa이라는 것을 알수 있습니다.

이 그래프를 계산식으로 표현하면

y = a(x-400) (a는 기울기 또는 gain값으로 500/1600 = 0.3125가 됩니다.)

예제)

x가 1200일때

y = 0.3125 x (1200-400)

= 250

즉, PLC 아날로그 입력값이 1200일때 250kPa이라는 압력값을 얻을수 있습니다.

PLC프로그램은 아래와 같습니다.

빨간색 원을 보면 아날로그 입력값이 1200일때 250으로 계산됩니다.

빨간색 네모를 보면 기울기 0.3125를 곱하지 않고

3125를 곱한 후 10000으로 나누어 주었습니다.

PLC에서 실수형 연산보다는 정수형 연산이 편하기 때문입니다.

 

'ForBeginner' 카테고리의 다른 글

8-6. Linked Server (Good, bad and OPENQUERY)  (0) 2021.05.20
2-5. Sensor와 PLC의 연결  (0) 2021.05.19
2-4. 센서와 변환기  (0) 2021.05.19
2-3. Analog & Digital Sensors  (0) 2021.05.19
2-2. Types of Sensors  (0) 2021.05.18

센서와 변환기의 중요한 차이점 중 하나는 센서가 물리적 변화를 감지 함 주변에서 발생하는 반면 트랜스 듀서는 물리량 또는 비 전기를 다른 신호로 변환합니다. 또는 전기 신호. 센서와 변환기 사이의 다른 차이점은 아래의 비교 차트에서 설명합니다.

트랜스 듀서와 센서는 모두 물리적입니다.물리적 양을 측정하기 위해 전기 및 전자 기기에 사용되는 장치. 센서는 에너지 레벨을 감지하여 디지털 미터로 쉽게 측정 할 수있는 전기 신호로 변경합니다. 트랜스 듀서는 동일한 형태 또는 다른 형태로 에너지를 전달합니다.

내용 : 센서 대 트랜스 듀서

  1. 비교 차트
  2. 정의
  3. 주요 차이점
  4. 결론

 

비교 차트

비교 근거감지기변환기

정의 물리적 변화가 주변에서 발생하고이를 읽을 수있는 양으로 변환 함을 감지합니다. 변환기는 작동 할 때 에너지를 한 형태에서 다른 형태로 변형시키는 장치입니다.
구성 요소 센서 자체 센서 및 신호 컨디셔닝
기능 변경 사항을 감지하고 해당 전기 신호를 유도합니다. 한 형태의 에너지를 다른 형태로 전환.
예제들 근접 센서, 자기 센서, 가속도 센서, 광 센서 등 서미스터, 전위차계, 열전대 등

 

센서의 정의

센서는 물리량 (예 : 열, 빛, 소리 등)을 쉽게 읽을 수있는 신호 (전압, 전류 등)로 측정하는 장치입니다. 교정 후 정확한 판독 값을 제공합니다.

예제들 - 온도계에 사용 된 수은은측정 된 온도는 보정 된 유리 튜브의 도움으로 쉽게 측정 할 수있는 액체의 팽창과 수축으로 이어진다. 열전쌍은 또한 온도를 온도계로 측정 한 출력 전압으로 변환합니다.

센서는 전자 장비에 많은 응용 분야를 가지고 있습니다. 그 중 몇 가지가 아래에 설명되어 있습니다.

  1. 모션 센서는 가정 보안 시스템 및 자동화 도어 시스템에 사용됩니다.
  2. 포토 센서가 적외선 또는 자외선을 감지합니다.
  3. 가속도계 센서는 화면 회전을 감지하기 위해 모바일에 사용됩니다.

변환기의 정의

트랜스 듀서는비 전기 신호의 물리적 속성을 쉽게 측정 할 수있는 전기 신호로 변환합니다. 트랜스 듀서에서의 에너지 변환 과정은 트랜스 덕션 (transduction)으로 알려져 있습니다. 형질 도입은 두 단계로 완료됩니다. 먼저 신호를 감지하고 추가 처리를 위해 신호를 강화합니다.

변환기는 세 가지 주요 구성 요소를 가지고 있습니다. 그것들은 입력 장치, 신호 조절 또는 처리 장치 및 출력 장치입니다.

입력 장치는 측정 량을 수신합니다.비례 아날로그 신호를 컨디셔닝 디바이스로 전송할 수있다. 컨디셔닝 디바이스는 출력 디바이스에 의해 쉽게 받아 들여지는 신호를 수정, 필터링 또는 감쇠합니다.

센서와 변환기의 주요 차이점

다음은 센서와 변환기의 주요 차이점입니다.

  1. 센서는 주변의 물리적 변화를 감지하는 반면 변환기는 한 형태의 에너지를 다른 형태로 변환합니다.
  2. 센서 자체는 센서의 주요 구성 요소이며 센서와 신호 조정은 센서의 주요 구성 요소입니다.
  3. 센서의 주요 기능은 물리적 변화를 감지하는 반면 변환기는 물리적 양을 전기 신호로 변환합니다.
  4. 가속도계, 기압계, 자이로 스코프가 센서의 예이며 서미스터와 열전대는 변환기의 예입니다.

 

결론

센서와 변환기는 둘 다 측정하기 어려운 온도, 변위, 열 등과 같은 물리적 양을 측정하는 데 사용되는 물리적 장치입니다.

산업 모니터링에 관한 다른 Contents도 확인 하세요. 

 

'ForBeginner' 카테고리의 다른 글

2-5. Sensor와 PLC의 연결  (0) 2021.05.19
2-0. 왜 Sensor의 이해가 필요한가?  (0) 2021.05.19
2-3. Analog & Digital Sensors  (0) 2021.05.19
2-2. Types of Sensors  (0) 2021.05.18
8-7. MSSQL(View)  (0) 2021.05.18

Different Types of Sensors – Analog and Digital

 

Sensors have become an integral part of the embedded system. Right from your mobile to security systems installed at home. They are also becoming important for meteorological stations to predict weather parameters like temperature, pressure, humidity, and many more.

To interface any sensor to the microcontroller, you have to know the function of the sensor and different types of sensors used in remote sensing, weather systems, security devices, health equipment etc. But, before going to know about sensors and its types you must know the basic definition of the sensor and its use.

What is a Sensor and How does it Work?

Sensor – Block Diagram

Sensor is a module or chip that observes the changes happening in the physical world and sends the feedback to the microcontroller or microprocessor. Excitation (Power supply) and Grounding must be provided to the sensor for the proper working.

Classification of Sensors

Microcontroller accepts two types of inputs depending up on the type of sensor i.e. analog or digital.

Analog sensor senses the external parameters (wind speed, solar radiation, light intensity etc.) and gives analog voltage as an output. The output voltage may be in the range of 0 to 5V. Logic High is treated as “1” (3.5 to 5V) and Logic Low is indicated by “0” (0 to 3.5 V).

Analog Sensor – Block Diagram

Unlike analog sensor, Digital Sensor produce discrete values (0 and 1’s). Discrete values often called digital (binary) signals in digital communication.

Digital Sensor – Block Diagram

Sensor Selection [Analog or Digital]

To select a sensor it’s important to know about analog and digital circuits. Analog circuits are made up of analog components like resistor, capacitor, Operational amplifiers, diodes and transistors.

 

Whereas digital circuits consist of logic gates and microcontroller chips. Analog signals are much affected by external noise and create errors in the output signal. But digital signals are susceptible to noisy environments and hence digital sensors are preferred over analog ones.

Note: If your application needs better accuracy and throughput go for digital sensors.

Problem with digital sensors:

Digital sensors have low calculation range. For example, digital temperature sensors such as HYT 271 and SHT series have lower temperature range.

But analog temperature sensors (RTD) have higher resolution (positive and negative temperature). This feature makes analog sensors suitable for wide temperature range and stability. The analog output from the sensor is processed by the ADC (Analog to Digital Converter) of the microcontroller.

As discussed above, how sensors are classified and how to select a sensor, now it’s time to know about different sensors in nature and how they are used in the industrial applications.

Types of Sensors

1. Analog Pressure Sensor

Analog Pressure sensors work on the input voltage and against the known pressure value. The output of pressure sensor is analog output voltage (normalized). The units of pressure are psi (pounds per square inch).

Analog pressure Sensors (Barometric)

2. Digital Pressure Sensor

Digital pressure sensor has inbuilt signal processing unit such as ADC that converts the analog input to digital pressure output. Generally, in most of the digital sensors I2c based digital signals are taken out.

 

Some of the applications of the Barometric pressure sensor are:

  • Leak detection in gas pipes and cables
  • Measuring pressure for environmental purpose
  • Radiosonde
  • Tyre pressure monitoring
  • Respiration analytics
  • Industrial and process control
  • Medical devices
  • Airflow monitoring
  • Drones
  • Inhalers
  • Water level measurement

3. Analog Hall effect/Magnetic Sensor (Position Sensor)

The Hall Effect sensor works on the magnetic field. It senses the magnetic field and gives the output voltage. When the magnetic field is positive output voltage increases above the null voltage (no magnetic field and zero current).

Applications of Hall sensor are:

  • GPS positioning
  • Current sensing
  • Speed movement detection
  • Magnetic code decoder
  • Metal detector
  • Controlling motors

4. Load cell (weighing sensors)

Load cells measures and process the weight. There are different types of load cell sensors based on usage of the application. Some of them are:

  1. Beam Load cells (Bending Load cell)

These are suited for normal weight measurement applications and industrial-weight measurement. Applications of beam load cell are

  • To fill the machinery
  • Tank weighing
  • Vehicle Onboard weight
  • Medical equipment
  • Bed weighing
  • To package machinery
  1. Single point Load cell

Single point load cells are used for low weight systems.

Applications:

  • Bench and retail scaling
  • Waste collection
  • Package and filling machinery
  1. Compression Load cell

These are suitable for high weight scaling systems.

Applications:

  • Medical devices
  • Measuring equipment
  • Pump controlling devices
  • Railway weight checkers

5. Temperature Sensor

Analog temperature sensor measures the temperature of the current location based on the resistance in variation. The value of resistance changes with temperature.

 

RTD sensors are best suitable for stability, accuracy and reliability. They comes with wide temperature range.

Applications:

  • To measure water temperature
  • Air temperature measurement
  • Air conditioning
  • Plastics
  • Food processing

6. Reflex Sensor

A simple reflex sensor has transmitter and receiver sections. The transmitter sensor emits a light beam and when an object is detected the receiver captures and process this as changeover signal.

Applications:

  • Monitors flow of material process
  • Level measurement
  • Print and Color detection
  • Inspection of Assembly
  • Sealing cap monitoring
  • Recording level of liquid quantities

7. Fork Sensor

Fork sensors are quite close to the reflex sensor but efficient in picking and detecting very small objects with a size of micrometers (µm).

Applications:

  • Bonding control
  • Placing and sorting small components
  • Power supply control
  • Gap monitoring and control
  • Recognize holes and drills

8. Wind speed / Wind direction Sensor

Wind speed/wind direction sensor commonly called anemometer uses the ultrasonic technique to get wind speed and direction.

Applications:

  • Environmental weather stations
  • Drifter Buoys
  • Oceanographic and meteorological stations
  • Harbours and seaports
  • Road tunnels

9. Radar Sensor

Radar transmit short microwave signals that travel at the light speed. Radar sensors are used for measurement of liquid levels. The output analog current (4-20 mA). This current is converted to the voltage by placing a resistor and read by the ADC of a microcontroller.

10. Solar Radiation Sensor

Global radiation sensor (solar radiation) uses photo voltaic diode for measuring solar radiation.

Applications:

  • Meteorological stations
  • Hydrological and agriculture
  • Energy applications
  • Irrigation

11. Humidity Sensor

Humidity sensor calculates the humidity of the present location. Humidity is an important parameter for environmental observance, consumer electronics and medical diagnostics.

Applications:

  • Humidity transmitter
  • Handheld devices
  • Refrigerators
  • Air compressors
  • Weather stations
  • Industrial incubators
  • Medical systems
  • Dew measurement

12. Air Quality Sensor [Gas sensor]

This sensor monitors the number of gases in the air like CO2 (carbon dioxide), SO2 (sulfur dioxide), CO (carbon monoxide) etc.

Applications:

  • Meteorological institutes
  • Health agencies
  • Homes and Hospitals
  • Industrial applications
  • Ventilation systems
  • Air cleaning

13. Light Sensor

Light sensor captures the ambient light (dark/bright) and converts it to current.

Applications:

  • Display backlight in Mobiles and LCDs
  • PDA (Personal digital assistant)
  • TVs, Cameras
  • Toys
  • Automatic street light control
  • CCTVs

14. Rainfall Sensor

Meteorological agencies use rain gauge sensor to measure the amount of rainfall falls in a particular location. Rainfall is measured in mm. The most used device for measuring rainfall is Tipping bucket Rain gauge.

15. Soil Moisture Sensor

Soil moisture measures the amount of salt and moisture in the soils. It also measures the temperature in the soil. It is based on SDI-12 protocol.

16. Water Level Sensor

Water level sensor calculates the depth of water in lakes, dams and rivers. There are various analog and digital based water level sensors.

Applications:

  • Water level monitoring
  • Environmental applications
  • Groundwater tanks
  • Surface water applications

Conclusion

Sensors have become a vital part of consumer electronics, industrial electronics, Robotics and Internet of things. I hope this article gives you an overview of different types of sensors used in the industry.

 

산업 모니터링에 관한 다른 Contents도 확인 하세요. 

 

'ForBeginner' 카테고리의 다른 글

2-0. 왜 Sensor의 이해가 필요한가?  (0) 2021.05.19
2-4. 센서와 변환기  (0) 2021.05.19
2-2. Types of Sensors  (0) 2021.05.18
8-7. MSSQL(View)  (0) 2021.05.18
8-5. 트리거(Trigger)  (0) 2021.05.18

Five sensory organs of human body such as ears which senses sound in the environment nose which senses smell in the environment and tongue which senses taste of any food atom that we eat skin which senses the hotness or coldness of other body and eyes which senses different colors seen from it in

The same way sensor is an electronic device which detects and responds to some type of input from the physical environment and converts this output signals to in human readable display now let’s have a look

 

What is a Sensor?

In general, sensor is known as a Detector.

The basic definition of,

A sensor is an electronic equipment that is used to detect and observe the physical activities and pass the notifcation/signal to other electrical control devices.

In other words, a sensor is an electronic device that can transform energy from one form to another form. So, it is also called a Transducer.

The main function of the sensor is to identify and communicate with physical quantities such as temperature, heat, pressure, distance, moisture, gas, and so on.

 

And it provides output in the form of electrical signal to connected control systems.

 

You can easily understand this from following simple block diagram.

For example, in an automation system, the sensor is the most important equipment that provides an input to the programmable logic controller (PLC).

In daily life applications, commercial and industrial devices, the educational projects, different types of sensor are used with a specific role.

What are the different types of Sensors?

Sensors are split up into four main categories. Such as,

  • Analog Sensor
  • Digital Sensor
  • Active Sensor
  • Passive Sensor

Each category is having the different types of sensor as follows.

 

1. Temperature Sensor (온도 센서)

Temperature sensor uses to detect the temperature and heat energy and convert it into an electrical signal (in form of voltage or current).

There are several types of temperature sensor used.

  • Thermometer
  • Thermocouple
  • Resistance Temperature Detector (RTD)
  • Thermistor Temperature Sensor
  • Semiconductor Temperature Sensor
  • Vibrating Wire Temperature Sensor

The temperature sensor is used in a computer, refrigerator, automobile, medical device, cooking appliances, electrical motor, etc.

 

2. Pressure Sensor (압력 센서)

Pressure sensor is called Pressure Transducer or Pressure Transmitter or Piezometer.

A pressure sensor detects the pressure of air, gas, water and provides electrical signal to the controller.

 

According to different uses and many more features, it is divided into different parts like,

  • Vacuum Pressure Sensor
  • Absolute Pressure Sensor
  • Gauge Pressure Sensor
  • Differential Pressure Sensor

Pressure sensors are used in many systems like pneumatic, hydraulic, vacuum systems, etc.

 

3. Touch Sensor

The touch sensor is called a Tactile sensor. It is an electronic sensor that is used for detecting and recording physical touch.

Capacitive touch sensor, resistive touch sensor are the best example of touch sensor.

 

It is used in industrial applications like switches for turn on/off light, remote control by the air conditioner (AC), door open/close operation, elevator, and robotics, smartphones, so on.

An oximeter is one of the best example of a touch-based sensor to detect oxygen levels in the human body.

In this COVID pandemic, Pulse Oximeter is in huge demand. It is easy to handle and operate, even at your home. You can easily buy an online Pulse Oximeter.

 

4. Image Sensor

The image sensor is an electronic device that is used to detect the image pixels and provide information to the display devices.

There are analog and digital types of sensor. Generally, an electronic image sensor is classified into two main types.

  • Charge-Coupled Device (CCD)
  • Active Pixel Sensor 

For the digital camera, closed-circuit television (CCTV), medical imaging equipment, thermal imaging devices, radar, sonar, etc., image sensors are used.

 

5. Motion Sensor

Motion sensor measures and records physical activities or movements. It is classified into different types.

  • Active Motion Sensor
  • Passive Motion Sensor
  • Tomographic Motion Sensor
  • Gesture Motion Sensor

The motion sensor is used in home security, automatic doors operation, microwaves, robotics, ultrasonic waves, gesture detector, etc.

 

6. Light Sensor

Light sensor is a photoelectric device. This sensor detects and converts the brightness or luminescence of light or photon into an electrical signal.

There are three types of light sensor.

  • Photoresistor or Light Dependent Resistor (LDR)
  • Photodiode
  • Phototransistor

It is widely used in the solar system, automobile, agriculture sector (automatic sprinkler system), and electronic-based project device like Arduino.

 

7. Vibration Sensor

Sometimes, vibration sensor is known as Piezoelectric Sensor.

The vibration sensor detects and records any movement or activities. And it provides data or signals to connected machines or systems.

 

This sensor helps to send acknowledgement if there is any hazardous activity.

 

In an industrial area such as gas and oil, food and beverage, mining, metalworking, paper, wind power, power generation, the vibration sensords are needed.

 

8. Humidity Sensor

Humidity sensor is also known as a Hygrometer.

For detecting moisture in air and soil, the humidity sensor is very essential. Mostly, it is used in Air Conditioner (AC) system.

WS1 Pro is an example of the wireless humidity sensor.

 

9. Proximity Sensor (근접센서)

Proximity sensor can easily detect nearby objects without any physical touch. It is divided into different types like-

  • Capacitive Proximity Sensor
  • Inductive Proximity Sensor

It is widely used in smartphones, tablet computers, machines, robotic systems, roller coasters, etc.

 

10. Colour Sensor

Colour sensor is the type of photoelectric sensor.

It helps to sense the color of an object and recognize the color mark. This sensor uses RGB (red, green, and blue) color scale.

SEN-11195 is the best example of the color sensor.

For colour painting and printing, cosmetic material, textile area, medical diagnosis, computer color monitor, and the process control, colour sensor is used.

 

11. Radiation Sensor

A radiation sensor is an electronics instrument that senses and measures the radiation particles like alpha, beta, gamma, neutrons, X-ray.

Also, it senses electromagnetic radiation like waves, cosmic radiation (sunlight).

Radiation sensor includes three different type.

  • Gas-filled Radiation Sensor
  • Scintillation Radiation Sensor
  • Solid-state Radiation Sensor

This sensor is used for nuclear energy, medical imaging modalities, and monitoring of environmental radioactivity.

 

12. Level Sensor

The main role of the level sensor is to measure the level or height of different materials like solid, liquid, and gaseous.

It is classified into different parts.

  • Laser Level Sensor
  • Float Sensor
  • Capacitive Level Sensor
  • Resistive Level Sensor
  • Ultrasonic Level Sensor
  • Hydrostatic Level Sensor
  • Optical Level Sensor
  • Electromagnetic Level Sensor

It is widely used in vessel, container, water tank, fuel tank bin, etc for water level check.

 

13. Position Sensor

Position sensor determines the displacement and the position (like linear and rotational).

Basically, position sensor available in the different types.

  • Optical Position Sensor
  • Linear Position Sensor
  • Rotary Position Sensor
  • Inductive Position Sensor
  • Capacitive Position Sensor
  • Fiber-Optic Position Sensor
  • Ultrasonic Position Sensor

For example, a potentiometer contains the rotational position sensor that can vary with angular movement.

The position sensor is used in domestic and industrial applications like door closing/opening, valve monitoring, motor controlling, throttles for controlling the flow of fuel or power to an engine.

 

14. Gas or Smoke Sensor

Gas sensor is used to detect different types of gasses, toxic or explosive gasses, smoke in the air. Some of these sensors are also capable to measure gas concentration. 

Gas or smoke sensor is divided into three parts.

  • Optical Type Smoke Sensor
  • Ionization Type Smoke Sensor
  • Laser Type Smoke Sensor

Smoke sensor is used in plant, industries, buildings, ships, airplanes, etc.

 

15. Flame Sensor

The flame sensor easily detects fire or flame of nearby materials. These detected signals are passed to the connected control devices.

It is used in industrial areas for an alarm system, natural gas plant, fire suppression system and Arduino based design fire detector project.

 

16. Leak Sensor

Leak sensor is used in a closed vessel or vaccum for detecting water leakage, fluid leakage, air leakage, etc.

As per the working role, it is divided into two main parts.

  • Spot Leak Sensor
  • Flow Leak Sensor

17. Accelerometer (가속도계)

Accelerometer is an instrument that measure motion acceleration or velocity.

It is used in many applications such as hand gesture controlled robot, navigation system for aircraft and missiles, process and control system, vehicle acceleration, and other rotating electronic equipment like a turbine, roller, fan, compressor, pump.

 

18. Tilt Sensor

Tilt sensor detects and varies with an angular movement, angular slope, angular motion, axes of the reference plane.

It is mostly used for monitoring the angle and auto-rotating operation in mobile, tablet, hand-held games, boats, vehicles, and aircraft, etc.

 

19. Mark Sensor

Mark sensor works as photoelectric type of sensor. It is used to sense colour mark on presence of an objects.

Mark sensor is widely used in printing and packaging industries.

 

20. Flow Sensor or Float Sensor

Flow sensor measures and detects virtually any process fluid. This detected data will be provided to the controller system.

It is used in industrial area, power generating instruments, power plant, etc.

 

산업 모니터링에 관한 다른 Contents도 확인 하세요. 

 

'ForBeginner' 카테고리의 다른 글

2-4. 센서와 변환기  (0) 2021.05.19
2-3. Analog & Digital Sensors  (0) 2021.05.19
8-7. MSSQL(View)  (0) 2021.05.18
8-5. 트리거(Trigger)  (0) 2021.05.18
8-2-1. MSSQL (Join)  (0) 2021.05.17
  • View는 기존 Table에 모든 Data가 있는데, 의미있는 Data로 다시 Rearrage할때 사용된다. 
  • 자주 조회하는 Data를 Select Group 과 Select join을 이용하여 View로 만들어 놓으면 편리하게 사용할 수 있다. 

 뷰(View)란 무엇인가? 

  1. 뷰는 사용자에게 접근이 허용된 자료만을 제한적으로 보여주기 위해 하나 이상의 기본 테이블로부터 유도된, 이름을 가지는 가상 테이블이다.
  2. 뷰는 저장장치 내에 물리적으로 존재하지 않지만 사용자에게 있는 것처럼 간주된다.
  3. 뷰는 데이터 보정작업, 처리과정 시험 등 임시적인 작업을 위한 용도로 활용된다.
  4. 뷰는 조인문의 사용 최소화로 사용상의 편의성을 최대화 한다.

뷰(View)의 특징

  1. 뷰는 기본테이블로부터 유도된 테이블이기 때문에 기본 테이블과 같은 형태의 구조를 사용하며, 조작도 기본 테이블과 거의 같다.
  2. 뷰는 가상 테이블이기 때문에 물리적으로 구현되어 있지 않다.
  3. 데이터의 논리적 독립성을 제공할 수 있다.
  4. 필요한 데이터만 뷰로 정의해서 처리할 수 있기 때문에 관리가 용이하고 명령문이 간단해진다.
  5. 뷰를 통해서만 데이터에 접근하게 하면 뷰에 나타나지 않는 데이터를 안전하게 보호하는 효율적인 기법으로 사용할 수 있다.
  6. 기본 테이블의 기본키를 포함한 속성(열) 집합으로 뷰를 구성해야지만 삽입, 삭제, 갱신, 연산이 가능하다.
  7. 일단 정의된 뷰는 다른 뷰의 정의에 기초가 될 수 있다.
  8. 뷰가 정의된 기본 테이블이나 뷰를 삭제하면 그 테이블이나 뷰를 기초로 정의된 다른 뷰도 자동으로 삭제된다.

뷰(View)사용시 장 단점

장점

  1. 논리적 데이터 독립성을 제공한다.
  2. 동일 데이터에 대해 동시에 여러사용자의 상이한 응용이나 요구를 지원해 준다.
  3. 사용자의 데이터관리를 간단하게 해준다.
  4. 접근 제어를 통한 자동 보안이 제공된다.

단점

  1. 독립적인 인덱스를 가질 수 없다.
  2. ALTER VIEW문을 사용할 수 없다. 즉 뷰의 정의를 변경할 수 없다.
  3. 뷰로 구성된 내용에 대한 삽입, 삭제, 갱신, 연산에 제약이 따른다.

 

 간단한 예제 

뷰 정의문

--문법-- CREATE VIEW 뷰이름[(속성이름[,속성이름])]AS SELECT문; --고객 테이블에서 주소가 서울시인 고객들의 성명과 전화번호를 서울고객이라는 뷰로 만들어라-- CREATE VIEW 서울고객(성명, 전화번호) AS SELECT 성명 전화번호 FROM 고객 WHERE 주소 = '서울시';

 

뷰 삭제문

 뷰는 ALTER문을 사용하여 변경할 수 없으므로 필요한 경우는 삭제한 후 재생성한다.

--문법-- DROP VIEW 뷰이름 RESTRICT or CASCADE --서울고객이라는 뷰를 삭제해라-- DROP VIEW 서울고객 RESTRICT;

RESTRICT : 뷰를 다른곳에서 참조하고 있으면 삭제가 취소된다.

CASCADE : 뷰를 참조하는 다른 뷰나 제약 조건까지 모두 삭제된다.

 

산업 모니터링에 관한 다른 Contents도 확인 하세요. 

'ForBeginner' 카테고리의 다른 글

2-3. Analog & Digital Sensors  (0) 2021.05.19
2-2. Types of Sensors  (0) 2021.05.18
8-5. 트리거(Trigger)  (0) 2021.05.18
8-2-1. MSSQL (Join)  (0) 2021.05.17
8-2. MSSQL(Group by, Having)  (0) 2021.05.17
  • 트리거는 테이블의 Data가 변경시에 사용한다.
  • A Table의 트리거를 사용하여 B Table에 insert할 경우에는 B Table의 Primary key를 잘 선택 해야 한다. 
  • B Table의 Key로 인해서, Trigger의 동작이 Error나면, A Table의 Data도 insert되지 않는다. 
  • A Table의 트리거를 사용하여 Romote Server에 insert하지 않아야 한다. 
  • Connection이 끊어졌을경우, Trigger는 Error나게 되고, 소실된 Data를 찾을 수 없다. 
  • Remote서버에 insert할 경우에는 Procedure를 이용하여 작업한다. 

 

 

1. 트리거(Trigger)란?

 

 

 

 

트리거(Trigger)란 영어로 방아쇠라는 뜻인데, 방아쇠를 당기면 그로 인해 총기 내부에서 알아서 일련의 작업을 실행하고 총알이 날아갑니다. 이처럼 데이터베이스에서도 트리거(Trigger)는 특정 테이블에 INSERT, DELETE, UPDATE 같은 DML 문이 수행되었을 때, 데이터베이스에서 자동으로 동작하도록 작성된 프로그램입니다. 즉! 사용자가 직접 호출하는 것이 아니라, 데이터베이스에서 자동적으로 호출하는 것이 가장 큰 특징입니다. 

 

 

트리거(Trigger)는 테이블과 뷰 데이터베이스 작업을 대상으로 정의할 수 있으며, 전체 트랜잭션 작업에 대해 발생되는 트리거(Trigger)와 각행에 대해 발생되는 트리거(Trigger)가 있습니다.

 

 

2. 트리거(Trigger)가 적용되는 예

 

다음과 같은 상황에서 트리거(Trigger)를 사용할 수 있습니다. 어떤 쇼핑몰에 하루에 수만 건의 주문이 들어옵니다. 주문데이터는 주문일자, 주문상품, 수량, 가격이 있으며, 수천명의 임직원이 일자별, 상품별 총 판매수량과 총 판매가격으로 구성된 주문 실적을 실시간으로 온라인상에 조회를 했을 때, 한사람의 임직원이 조회할 때마다 수만 건의 데이터를 읽고 계산해야합니다. 만약 임직원이 수만명이고, 데이터가 수백만건이라면, 또 거의 동시다발적으로 실시간 조회가 요청된다면 시스템 퍼포먼스가 떨어질 것입니다.

 

따라서! 트리거(Trigger)를 사용하여 주문한 건이 입력될 때마다, 일자별 상품별로 판매수량과 판매금액을 집계하여 집계자료를 보관하도록 만들어보겠습니다. 먼저 관련된 테이블을 생성해보겠습니다. 

테이블은 다음과 같습니다. 주문정보테이블에 실시간으로 데이터가 입력될 때마다 트리거가 발동되어 자동으로 일자별판매집계테이블에 일자별, 상품별 판매수량과 판매금액을 계산해 업데이트 하는 작업을 하도록 하고, 사용자들은 미리 계산된 일자별판매집계테이블을 조회하게 하여 실시간 조회를 지원하게 하는 것입니다. 

 

3. 트리거(Trigger) 구현

 

자, 이제 2개 테이블을 CREATE, DDL을 통해 만들어보겠습니다.

 

CREATE TABLE ORDER_LIST(

    ORDER_DATE  CHAR(8) NOT NULL,

    PRODUCT     VARCHAR2(10) NOT NULL,

    QTY         NUMBER NOT NULL,

    AMOUNT      NUMBER NOT NULL

);

 

CREATE TABLE SALES_PER_DATE(

    SALE_DATE   CHAR(8) NOT NULL,

    PRODUCT     VARCHAR2(10) NOT NULL,

    QTY         NUMBER NOT NULL,

    AMOUNT      NUMBER NOT NULL

 

);

 

SELECT *

FROM ORDER_LIST

 

SELECT *

FROM SALES_PER_DATE

 

조회를 해보면 다음과 같습니다.

 

 

아직 2개 테이블다 데이터가 없음을 확인할 수 있습니다. 

 

이제 트리거(Trigger)를 만들어 보겠습니다. 트리거(Trigger)를 구현하기 위해 우선 절차형 SQL과 PL/SQL을 알아야합니다. 절차형 SQL과 PL/SQL은 따로 글을 올리도록 하고, 오늘은 절차형 SQL과 PL/SQL을 안다는 전제하에 트리거(Trigger)를 구현해보겠습니다.

 

 

 

트리거(Trigger) 처리 절차를 설명하면 다음과 같습니다.

8 ~ 14 Line 

 Trigger를 선언합니다. 

order_list 테이블에 insert가 발생하면 그 이후 each row 즉 각 행에 해당 트리거(Trigger)를 적용한다라는 뜻입니다. 또한, declare 선언문에는 변수를 선언합니다. order_list 테이블에 있는 order_date, product Type에 맞게 o_date, o_prod 변수를 선언합니다.

 

15 ~17 Line

new 는 트리거(Trigger)에서 사용하는 구조체 입니다. new는 새로 입력된 레코드 값을 담고 있습니다.

o_date 에 새로 들어온 order_date 값을 , o_prod 에 새로 들어온 product 값을 저장합니다.

 

18 ~ 26 Line

sales_per_date 테이블에 update 구문을 실행하는데, 기존에 있는 qty, amount 를 누적합해서 다시 Set 합니다. 여기서 where문을 통해 현재 새로 들어온 날짜과 상품이 일치하는 데이터만 해당 update문을 실행하도록 조건을 걸었습니다. 

또한 만약 해당 조건에 모두 해당되지 않는다면, if sql%notfound 구문이 실행됩니다. 기존에 있던 레코드 값이 아니고 전혀 새로운 레코드이기 때문에 insert 구문을 통해 새로 들어온 데이터를 새로 삽입합니다. 

끝으로 / 부분은 트리거(Trigger)를 실행하는 실행명령어입니다.

 

위 구문을 실행하면, 이제 2개 테이블에 트리거(Trigger)가 적용된 것입니다. 

 

이제 order_list 테이블에 레코드를 insert 해서 sales_per_date 테이블에 트리거(Trigger)가 자동으로 동작하여, 데이터 값을 자동으로 계산하고 반영하는지 확인해보겠습니다!

 

ORDER_LIST 테이블에 아래와 같이 데이터 값을 삽입해보겠습니다.

 

-> INSERT INTO ORDER_LIST VALUES('20120901','MONOPACK',10,300000)

 

삽입후 ORDER_LIST, SALES_PER_DATE 테이블 조회를 해보겠습니다.

 

ORDER_LIST 정상적으로 값이 삽입되었습니다. 

트리거에 의해서 SALES_PER_DATE 에도 정상적으로 값이 삽입되어있습니다.

 

자. 다시한번 값을 삽입하고 테이블을 확인해보겠습니다.

 

-> INSERT INTO ORDER_LIST VALUES('20120901','MONOPACK',20,600000);

 

ORDER_LIST 를 조회하면 지금까지 삽입한 값들이 리스트로 있습니다. 

SALES_PER_DATE 테이블은 트리거에 의해서 주문날짜별 상품별 물량과 가격이 합산되어 업데이트 되어있음을 확인할 수 있습니다.

4. 트리거(Trigger)와 트랜잭션(Transaction)의 상관관계

  

이번에는 다른 상품으로 주문 데이터를 입력한 후 두 테이블의 결과를 조회해보고 트랜잭션을 ROLLBACK 해보겠습니다. 판매 데이터의 입력취소가 일어나면, 주문 정보 테이블(ORDER_LIST)과 판매 집계테이블(SALES_PER_DATE )에 동시에 입력(수정) 취소가 일어나는지 확인해보기 위함입니다.

 

 

-> INSERT INTO ORDER_LIST VALUES('20120901','MULTIPACK',10,300000);

 

ORDER_LIST 에 정상적으로 판매 데이터가 삽입되었습니다. 

 

SALES_PER_DATE 테이블은 트리거에 의해 판매날짜별, 상품별 누적 물량과 가격이 업데이트 되었습니다.

 

 

이제 ROLLBACK; 명령어를 실행해보겠습니다. 

ORDER_LIST 테이블에 방금 삽입한 판매데이터가 취소되었습니다.

 

SALES_PER_DATE 테이블에도 똑같이 트리거로 입력된 데이터 정보까지 하나의 트랜잭션으로 인식하여 입력 취소가 되었습니다. 

 

즉, 트리거는 데이터베이스에 의해 자동 호출되지만 결국 INSERT, UPDATE, DELETE 구문과 하나의 트랜잭션 안에서 일어나는 일련의 작업들이라 할 수 있다. 

 (추가로 트리거는 Begin ~ End 절에서 COMMIT , ROLLBACK 을 사용할 수 없다.)

 

산업 모니터링에 관한 다른 Contents도 확인 하세요. 

'ForBeginner' 카테고리의 다른 글

2-2. Types of Sensors  (0) 2021.05.18
8-7. MSSQL(View)  (0) 2021.05.18
8-2-1. MSSQL (Join)  (0) 2021.05.17
8-2. MSSQL(Group by, Having)  (0) 2021.05.17
3-0. 왜 PLC의 이해가 필요한가?  (0) 2021.05.15
  • 중복을 제거하기 위한 Table 디자인으로
  • 분석가능한 의미있는 데이터를 보기 위해서는 반드시 Join의 연습이 필요하다.
  • 아래 다이어그램의 이해를 바탕으로 어떤 Join을 사용할지 결정 해야 하며,
  • 대부분 Inner Join또는 Left Join이 사용된다. 

 

조인(JOIN) ? 

두 개 이상의 테이블을 곱한 결과 집합 이라고 간단히 MSDN에 정의되어있다.

 

JOIN에는 INNER JOIN OUTER JOIN 그리고 CROSS JOIN 이렇게 세가지 종류가 있으며,

실무에서는 대부분 INNER JOIN과  LEFT OUTER JOIN을 사용한다.

 

그림을 보며 하나씩 알아가 보자.

 

 

 

1. INNER JOIN

 

교집합의 결과를 출력해 준다고 생각해주면 쉽다.
그림과 같이 두 테이블의 조건에 모두 만족하는 데이터만 출력해 준다.

 

JOIN유형 생략시 기본적으로 INNER JOIN으로 들어가게 되며,

INNER JOIN시 LEFT,RIGHT같은 기준을 정해주지 않는데, INNER JOIN은 두 조건을 모두 만족하는 결과를 출력해주기 때문에 기준이 되는 테이블을 정해주지 않아도 되기 때문이다.

 

 

2. OUTER JOIN

1) LEFT OUTER JOIN


OUTER JOIN이 INNER JOIN과 다른점은 조건에 맞지 않는 데이터도 표시해 준다는 점이다.

 

LEFT JOIN 수행시 먼저 표기된 좌측 테이블에 해당하는 데이터를 먼저 읽은 후 나중에 표기된 우측 테이블에서 JOIN대상 데이터를 읽어온다. 

즉 A테이블과 B테이블이 있을 때 A가 기준이 되어, A와 B를 비교한다음 B의 JOIN 컬럼에서 같은 값이 있을 때 해당 데이터를 가져오고 B의 JOIN컬럼에서 같은 값이 없는 경우에는 B테이블에서 가져오는 컬럼들은 NULL 값으로 채우는 것이다.

 

참고로 OUTER JOIN은 기본적으로 LEFT OUTER JOIN으로 명시되며, OUTER 키워드는 생략가능하다.

 

2) RIGHT OUTER JOIN

 

RIGHT JOIN은 LEFT JOIN과는 반대로 우측 테이블이 기준이 된다고 생각하면 된다.

 

3) FULL OUTER JOIN

 

JOIN 수행시 좌측과 우측의 모든 데이터를 읽고 JOIN 후 결과를 생성하며, 두 개의 테이블 모두가 기준이 된다.

합집합의 결과를 출력해준다고 생각하면 쉽다.

 

단 UNION ALL이 아닌 UNION 기능과 같으므로 중복 데이터는 삭제된다.

 

 

3. CROSS JOIN

 

 

CROSS JOIN은 상호 조인이라고도 불리며, 한 쪽 테이블의 모든 행들과 다른 테이블의 모든 행을 조인시키는 기능을 한다.

그래서 CROSS JOIN의 결과 개수는 두 테이블의 행의 개수를 곱한 개수가 된다.

 

CROSS문은 모든 행에 대한 결합이 발생하기 때문에 ON구문을 사용할 수 없다.

예전에는 데이터에 대한 카피 후 연산이나 부분합을 구할 때 쓰였지만, 지금은 CUBE나 GROUPPING으로 대체되었고 현재는 잘 쓰지 않는다.

 

산업 모니터링에 관한 다른 Contents도 확인 하세요. 

'ForBeginner' 카테고리의 다른 글

8-7. MSSQL(View)  (0) 2021.05.18
8-5. 트리거(Trigger)  (0) 2021.05.18
8-2. MSSQL(Group by, Having)  (0) 2021.05.17
3-0. 왜 PLC의 이해가 필요한가?  (0) 2021.05.15
3-4. PLC 통신 종류  (0) 2021.05.15

+ Recent posts