My goal is to control drone by Raspberry PI. The Raspberry PI uses camera and OpenCV, sends control commands to AVR microcontroller which will generate the PWM control signal. Meaning that it will simulate pilot with transmitter-receiver setup.

In other words (to make it more clear). Raspberry tells the Atmega8 that the drone needs to go more forward. Atmega8 generates custom PWM signals on 8 pins. Those signals are sent directly to CC3D pins responsible for roll, pitch etc. Atmega8 replaces controller receiver in this setup. It generates signal not based on user input but on what Raspberry tells it.

In order to do that I need the parameters (period, voltage etc.) of the PWM signal that CC3D accepts to properly simulate it. I have found this topic:

CC3D - Replacing RC emitter with an RPi

He has the same problem as I do and he found the solution. Unfortunately I can't send pm and I can't comment because I'm new to the site... so basically there is no way for me to contact him.

So any help would be appreciated.

  • $\begingroup$ Welcome to Robotics MrOneTwo, but I'm afraid that it is not clear what you are asking. We prefer practical, answerable questions based on actual problems that you face, so it's a good idea to include details of what you want to achieve, what you tried, what you saw & what you expected to see. Please take a look at How to Ask & tour for more information on how stack exchange works and work through the Robotics question checklist to edit your question to make it clearer. $\endgroup$
    – Chuck
    Jul 7, 2016 at 17:35
  • 1
    $\begingroup$ For starters, in Fig 3-13 of the manual (the only manual I could find; the openpilot site seems to be down), it shows "Min 1000, Mid 1500, Max 2000". This would seem to be in-line with standard hobby servo timing. Have you tried this? What did you get? $\endgroup$
    – Chuck
    Jul 7, 2016 at 17:45
  • $\begingroup$ @Chuck - I tried to make it more clear. Hopefully it's good enough now. Also thank you for those links. I wrote a program for AVR microcontroller which generates signals like that. I will hopefully test it soon (wasn't able to perform any proper tests yet) and will keep this question updated for others. $\endgroup$
    – MrOneTwo
    Jul 12, 2016 at 14:57
  • $\begingroup$ @MrOneTwo even i am trying to do the same thing...i tried contacting him...commented also...but looks like he is no more active here.. :( $\endgroup$ Jul 12, 2016 at 17:32

1 Answer 1


Ok I actually was able to make it work.

First of all in the beginning of the testing I used my own program which generated PWM signals. I wanted to make them 50Hz with 1.5ms of duty cycle being neutral position (of stick of the controller for example), 2ms max and 1ms min. Unfortunately when I connected my microcontroller to the CC3D I wasn't able to get through calibration of the controller reliably.

So you could understand everything: I wrote a program in Python which reads keyboard buttons presses and sends data packet to microcontroller. By default the data sent from computer to AVR micro controller connected to CC3D looks as follows:


When I press one of the keys defined in Python program it would send:


The micrcontroller breaks down this message and uses the numerical values between letters to modify the PWM duty cycle.

I tested it again and again and sometimes I could get through calibration in LibrePilot (program to configure CC3D) but after the program showed really crazy behaviour of the sticks and buttons on the controller.

THE SOLUTION: Actually the solution is simple. Just use servo library for Arduino (I'm using Atmega8 with external 16Mhz and Arduino bootloader). It generates almost perfect 50Hz (my program couldn't generate as good of a custom PWM). With signal like that LibrePilot calibrates properly. Also worth pointing out is that you don't have to have those values of 1.5ms, 1ms, and 2ms set on the microcontroller. If the values are reasonable the LibrePilot's calibration process will be able to use the duty cycle you signal generates and bind it to max, min, neutral.

Below you can see how my hardware looks like. I hope I described everything clearly.

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.