What is the purpose of the PPM encoder in APM2? Why didn't we use directly the PWM signal produced by the receiver and enter it to the microcontroller ATMEGA2560?

Working with the PPM signal is better than the PWM? if so why didn't we take the signal directly from the frequency demodulator in the receiver which it is a PPM signal and let ATMEGA2560 work as PPM decoder so the response will be faster?

Views: 5246

Reply to This

Replies to This Discussion

OK, so here is the problem. You are using an8 bit micro controller that can ONLY do one thing at a time. So in order to measure input channels, that takes time for each channel to measure the pulse width, then you store that value, move on to capturing the sensor data which takes time, and then perform the calculations and filter equations, then use hardware timers to output PWM signals out each of the required ports to the motors and servos. If you have done any tone or PWM generation coding in microcontroller, you would already know the problem, the main loop with big time and cycle intensive tasks is going to cause huge pauses (no pwm signal on the outputs) in the main program loop. In order to spped and streamline the process, The PPM encoder does the hard work of capturing all those RC inputs, measures the values and probably does some smoothing/filtering as well), perform failsafe functions, and give I nice easy and quick to read digital input into the main processor so that in the main program loop we can achieve a 200 hz speed in the loop, which is quick enough we don't get too many pauses or delays in the pwm outputs.

Again, follow some Arduino PWM tutorial and see that very quickly, you can run into issues trying to PWM mutiple signals out.

So sum up your question, using one processor actually makes it slower!!!

Here is a similiar problem on a PIC, but the principals are exactly the same from a code perspective. His main loop has a pause which results in a loud click or glitch in the pwm output, thus the same thing would be sent to the speed controls wreaking havoc!



Thank Mr Vernon 

as a summary what I understand from your answer:

the PPM encoder converts the PWM signals taken from the receiver to a digital values that are used to produce the correct PWM from ATMEGA2560?

Actually it is possible to use a PPM signal  - see the wiki

The PPM encoder exists mostly for safety reasons. Fail-safe and switching manual control etc.

Thank You Mr Andrew

@Andrew    The point is you still use the PPM encoder cpu. It's function is still the same, to provide the task of capturing the radio control inputs and presenting it to the main cpu the 2560 so that it's main loop speed is not slowed down collecting 8 channels worth of values. Put it this way, look at the source code the PPM runs (either for summed ppm or normal inputs), take that code (because you still have to do the capture and conversion) and put that in the main loop of the code running on the 2560. You will not be able to fly, because the main loop will be so slow, your motors will be erratic and forget about PIDS, the values have changed so much from where they were inserted in te loop, the bird is not were it last was.

Again, basic knowledge of programming 8 bit microcontrollers would explain this. You can only do one thing (function) at a time in the loop. Using 2 CPUs allows 2 things to happen at the same time. At a 200hz main loop, they feel the code is fast enough to not warrant a 3rd cpu for outputs. (That stament isn't entirely true, there is a cpu on each speed controller so techhnically, we do have some buffer interface happening to correct the non-continuous outputs). This is why discussions of an IC2 bus multi-channel speed control is in the works.

the PPM encoder converts the PWM signals taken from the receiver to a digital values that are used to produce the correct PWM from ATMEGA2560?

Yes, it decodes the the values in a much easier to digest and insert into the main software loop of the 2560. This in turn, allows the main loops to function at a reasonable rate because the truth is, a single 8 bit microcontroller cannot provide the multi tasking speed required. There are just too many conversions, too much time is taken in cycles.


Your question was why can't we just use one CPU- and I'm telling you why-it's not fast enough. You seem to be under the impression it's faster by doing the conversion in the 2560 and I'm telling you from experience codewise why it's not faster to do the conversion in the 2560. You are likely used to multithreaded CPUs but that is not wat we have here, thus we make a multitreaded CPU by ust using more than one CPU.

Vernon this isn't actually how the PPM encoder works.

Anyone interested in the workings of the PPM encoder have a look here at the source:


There are compile targets for both PPM chips on the APM1 and APM2.

Obviously, somebody didn't go through the trouble of designing a board with a second CPU is it was a trivial matter of including the code in the 2560-BTW the original question in this thread.

Sorry if I have to be a complete jerk about this, but the answer still rings true-there is a reason there is a second cpu on the board.

The orignal question is why doesn't the code just run on the 2560, so since you seem to have the answer, let's hear it? You've stated it's for safety-and why is it that safety cannot run as a function in the main loop of the ardupilot code?

The reason is redundancy. The PPM module runs a small, tight code base that does not change across upgrades, and will keep running if the 2560 locks up, crashes etc. It supports fail-safe, and radio pass-through ie, returning manual control (obviously only useful for planes).

More information is on the wiki here

Actually you are both right, and there is also a third reason.

The reason for using dedicated PPM hardware is both redundancy and PWM timing issues. The third reason is that on the APM2 the PPM chip also replaces the FTDI chip and is used for USB<->Serial translation and programming the ATmega2560.

Atmega328 is the PPM encoder/failsafe module, right? it is overheating on my APM1.4. When i try to calibrate radios on the APM mission planner, i get blank bars and no response for the RC channels. The situation is same for the test performed in terminal for pwm, radio. They are also giving 0 value for all channels. Now is there a way i can bypass this module, if it is not too critical, and get my APM to work with the RC receiver?

You can only bypass the PPM encoder, is your RC receiver has a built in PPM signal. If so you can connect this signal directly to the PPM input on the APM 1280/2560 main chip.

What do you mean by overheating? Does the chip get hot? Is so, you have an electrical problem in the RC inputs. The 328 chip should not become anything close to hot during normal operation.

Reply to Discussion


© 2017   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service