PPM, PWM 신호 개념


아두이노가 ESC를 직접 콘트롤 하던, 아두이노가 flight controller로 신호를 보내서 쿼드콥터를 컨트롤 하던, 아두이노가 RC 조정기로 부터 신호를 받아서 읽고 ESC를 콘트롤 하던, 어떤 경우에도 이들 사이에 주고 받는 신호의 규칙을 알아야 하겠다...  이 규칙을 알아야 조립이 된 쿼드콥터를 써먹을 수 있다.  통상 RC 조정기와 리시버를 달면 이런걸 몰라도 되지만, 그럼 뭔가를 만든다는 의미가 별로 없지 않은가...

이로한 신호의 체계를 알고 다룬다면 다양한 방법의 프로젝트가 가능해 질 것 같다.
일단 이번의 목표는 아두이노가 센서값을 읽어서 계산을 하여 flight controller로 신호를 보내서 쿼드콥터를 컨트롤 하는 반자동 비행을 구현하는 것이므로, 통상 RC 조정기에서 시작되고 리시버에서 나와 4개의 ESC로 가는 신호를 구현해야 함...

인터넷으로 검색하면 주로 RC 조정기에서 보내는 신호를 아두이노에서 읽는 방법에 대한 정보가 많다.  RC 조정기를 가지고 아두이노 기반 로봇이나 RC를 조정하려하니 그런 것 같다...

먼저 PWM 이나 PPM이라는 용어가 나오는데,


Guide to PWM and PPM

PWM and PPM are two common words used in the R/C industry. PWM stands for Pulse Width Modulation and PPM stands for Pulse Position Modulation. Some devices that use PWM for control are ESC's (electronic speed controls) and servos. PWM is a technique used to relay data in the form of a varying pulse width.
You may be already familiar with binary, 1's and 0's; where a 1 is represented as 'on' and a 0 as 'off'. An example of this would be a light switch. Turning the switch on would indicate a 1, off a 0. In the case of a PWM/PPM signal, a voltage applied indicates a 1 and vice versa. However, in the case of R/C electronics this 'on/off' data is not enough, this is where the pulse width comes in.
The way we relay data to a servo for instance is the time the pulse is on. In the case of R/C electronics this time is usually around 1-2 milliseconds. A servo or ESC will monitor this pulse and begin counting when the pulse is detected and stop counting when the pulse stops. The time the pulse is on will determine the servo position. For example, sending a servo a 1ms pulse will make the servo swing completely left while a 2ms pulse will swing the arm completely right.
Generally in R/C equipment an entire PWM pulse will last a total of 20ms. The entire pulse is called a frame. A complete frame will include both the time the pulse is high (1-2ms) and the time the pulse is low. The image below represents a typical PWM frame.

1.jpg




Although the frame lasts 20ms the important part of the pulse is the time the pulse is on; 1-2ms. Although the time between pulses is not as important it does play an important role. Usually keeping the time between pulses around 20ms is best. If the delay is longer, a servo for example will lose holding power. A pulse can be generated much faster but 20ms is best for most situations.
So what is the point in waiting up to 20ms? This is an R/C specific and will help understand PPM. Again, PPM stands for Pulse Position Modulation. PPM basically is several PWM signals lined up back to back. A PPM frame looks like this:

2.jpg




Aside from the gaining servo holding power, the reason for the 20ms frame is just having the ability to line up several PWM signals in the same frame. Like I said before, the time the pulse is on is what is important because we are able to strip out this relevant data from a PPM frame to re-generate a PWM frame. For example, if a radio only sent 1 PWM signal at a time, it would take 20ms per channel. If you have an 8 channel radio each update would take 160ms. The same data can be packed into a PPM frame and only take 20ms per update. Transmitters and receivers are the two most common R/C devices that use PPM.
The following are lists of common devices that use PPM and PWM.
R/C Devices that use PWM Pulses:
Servos
Electronic Speed Controllers
R/C switches
R/C lights
R/C receivers
Data loggers
Failsafe's
Autopilot/Stabilization systems
Servo Controller

R/C Devices that use PPM Pulses:
R/C transmitters
R/C receivers
Autopilot/Stabilization systems
PCTx

요약하면 RC에 통상 쓰이는 PWM은 20ms (20/1000 초 = 100분의2초) 단위로 0 또는 1의 디지털 신호인데, 아두이노 디지털 단자에서 0 이면 접지 즉 0볼트 (LOW), 1 이면 5V (HIGH) 가 출력되는 방식 처럼, 20ms (이를 1 프레임이 한단다) 안에 1 (1~2ms 동안) 또는 0을 출력하는 것이라 함.
PWM은 모터나 ESC로 보낼 때 사용.  그런데 모터나 ESC가 한개가 아닌 다수일 경우, 20ms x 모터 갯수 대로 시간이 더 걸리게 되므로 예를 들면 서보모터의 경우 20ms 가 넘으면 정지시켜 잡고 있는 힘을 잃게 된다는 군요.  따라서 20ms 안에 다수의 PWM을 섞어서 동시에 보낼 수 있는 신호가 PPM인가 봅니다.  그러므로 RC 조정기와 RC 리시버 사이의 신호는 PPM이 될 수 밖에 없어 보이네요.

아두이노에서 RC 조정기 신호를 읽으려면 PPM,
아두이노에서 ESC나 모터로 신호를 보내려면 PWM 신호를 보내야 겠네요...

보통 50Hz 라니까 1000 나누기 50 = 200 이고 200 나누기 20 이면 10개의 PWM을 PPM 으로 만들 수 있다는 얘기인데... 실제는 9개의 PWM이 가능하다 한다.  20ms가 빈칸이 없이 계속 반복되면 어디서 부터 20ms 가 시작되는지 모를 테니까... 즉 RC 보면 4채널, 6채널 이러는데 9채널이 최고라는 얘기고 9개의 모터를 제어할 수 있다는 말...

20ms 마다 특정 위치에 1-2ms를 5V를 반복하여 켜준다면 그 특정위치에 해당되는 채널은 계속 켜짐 신호를 받는 것임.

3.jpg


통상은 최소 1ms ~ 최대 2ms 사이값이며 중간값은 1.5ms 이고 신호가 20ms 프레임마다 반복되며 5V라고 한다.  위 그림의 설명과는 약간 다름...


4.PNG



쿼드콥터는 모터가 4개 이므로,  아두이노가 모터나 ESC를 제어하려면 4개의 PWM 신호를 만들어서 송출해야 하고,

아두이노가 플라이트콘트롤러의 AIL, ELE, THR, RUD, AUX 핀으로 신호를 보내려면 역시 5개의 PWM 신호가 필요하다.

만약 RC 조정기에서 또는 스마트폰 조정기에서 아두이노로 신호를 주고, 아두이노가 쿼드콥터를 제어하려면 아두이노는 5채널의 들어오는 PPM을 읽어서, 모터나 ESC를 제어하기 위하여 적당한 4개의 PWM를 만들어서 송출해야 하는 것임.

위로 스크롤