Requests

This page is for you! If you’d like additional information about something I’ve posted about, or if there is a topic you think I should post about, please leave a comment and I’ll get right to it!

    • Marius Duennewald
    • January 30th, 2012

    Hey dude ! Awesome Blog u build up here !
    Just landed here because of your review about the Spektrum RC receivers and its interfacing. And as i saw that we use the same hardware i was exited😀
    Well in college we started to program avr microcontrollers too and this is a very interesting thing because i have a DX5e and an AR500 here too.
    Unfortunately we hardly heard something about PWM so we have to get that on our own. But I have no idea where to start for reading out pulse timings from an PWM…
    I just want to ask you if you can help me out with some c code… Perhaps it could be easier to understand the readout from an working program example.

    Greetings

    Marius

    • Hello Marius,

      I’d be glad to help. Will you be interfacing with the AR500 in the same way as my “RC Receiver Interface” post (using one OR’d signal)? The AVR has a pretty cool feature in that it can capture interrupts on an entire port of pins. I’ve used the AVR like this before and it made development very easy. Do you have any pin constraints (i.e. how many pins can you spare for this)?

      How much do you know about PWM and RC-PWM? RC-PWM is a special type of PWM. Are you just trying to read the values of the 5 RC-PWM signals coming from the AR500?

      When you say you are using AVR, is it AVR only? or with Arduino?

      I will get working on a post about these topics. Please reply with any details you are unfamiliar with and I’ll make sure to include them in the post.

      Thanks for reading!
      -Nic

    • ganu
    • December 29th, 2012

    Hi im also tryimg to build a quadcopter.
    so im using multiwii but can hardly understand the code as its huge
    i want to undertsnad how the feedback loop works and how RC PWM is read by microcontroller etc.
    Would be of great help if you can send me your documents on quad copter

    • First off, you should separate the feedback loop problem and the RC PWM problem. I have dicusses both of these issues on this blog. Take a look here for PID controllers (feedback controllers) and look here for help on interfacing a microcontroller with a RC PWM device.

      Let me know if you need anything else!

    • ganu
    • January 11th, 2013

    Hi
    Thank You for the reply.I understand everything in parts. Im an electronics engineer by profession.
    Actually what im looking for what kind of dynamics quadcopter has. Like do u model the quadcopter dynamics..
    an alogorithm as to how to close the loop…
    if you have documentation of software alogorithm that would me very helpful

    • What do you mean by quadcopter dynamics?

      Quadcopters are an interesting machine. There are a few different areas you must know about. The first is communicating between the transmitter, the receiver, then to your microcontroller. I’ve already covered this. It’s pretty easy.

      The next thing you must have is a method for determining the current aircraft attitude. You’ll have several sensors on your quadcopter, like gyros, accelerometers, and compasses. You must use a sensor fusion algorithm, like the Kalman filter to combine the sensor measurements and produce an aircraft attitude. Don’t worry if you don’t fully understand the sensor fusion stuff. I’d guess that less than 1% of quadcopter builders actually know how they work. The AeroQuad project has some code for many of these algorithms. You should try many of them and decide which one works best for you.

      Once you have the flight command from the transmitter, and the current aircraft attitude from the sensor fusion algorithm, you can put both into a set of PID controllers. The beauty of PID controllers is that they were designed for systems where the system transfer function is unknown or hard to obtain. PID controllers aren’t typically the best method for feedback control, but they provide a method for controlling systems without future knowledge of the system. Tuning a PID controller to a specific system can be accomplished through trial and error or by techniques like the Ziegler–Nichols method. The output of the PID controllers is an abstract aircraft attitude command. You must translate this command into four discrete motor commands.

      Wahoo! Your done!

    • Prad
    • February 27th, 2013

    Hey..read your blog & awesome work…am currently working on building a quadrocopter using LPC1769..is it possible for you to pass me the software code so that i could take a look? need help really badly regarding the programming part..

      • nic
      • February 28th, 2013

      I’d be glad to help you with specific aspects of your design. Let me know which areas you need help with. I’ve already covered many quadcopter topics in this blog. If you need help with others, please let me know. My source code is not in presentable order for entire distribution.

        • Prad
        • March 7th, 2013

        Thank you for your reply. I would like to know how do you control the speed (ESC) and the direction of the rotors? so thats why I need to check out your code if thats alright withya…would be reallyyy helpful if you did!!! Thank you.

    • PETER L SCHAEFER
    • March 22nd, 2015

    I WOULD LIKE ONE OF THESES BUILT CAR BUT CAN IT HAVE REMOTE CONTROL AND BOTH PROPELLER AND WHEEL POWER AS WELL

    • Hi Peter, I don’t follow your question. Can you clarify?

    • Thomas
    • March 26th, 2015

    Hi Nic,

    I’m currently in the process of developing my own quadcopter.

    I’ve some problems to under stand how to get from the roll, pitch and yaw angles to the PWM commands. I know how a PID controller works but have problems to apply it to a quadcopter and I realy don’t know what Multi-Rotor Throttle Mixing should do? Do you have some code examples for me please?

    Hope you can help me.

    Regards

    Thomas

    • Hi Thomas, thanks for the question. The way I organized my system was in several stages. The IMU driver determines current angles respective to the horizon and the yaw rate. The RC input gets translated into the desired angles and yaw rate. Using those two, I compute the error input to 3 PID controllers. The output of the 3 PID controllers goes to the throttle mixer. With a quadcopter, the two angles are easily mapped to the motors in X and Y axises. The yaw can be computed and added to the others. I’ll see if I can get something posted on this. Does this help?

        • Thomas
        • April 23rd, 2015

        Thx!

    • Tom
    • April 7th, 2016

    Hello! Thank you for sharing your knowledge. You are most gracious!

    I am retired. I have taken up electronics to keep my mind sharp. I am new to micro controllers and c code.

    I am building a DIY Reflow (Toaster) Oven to facilitate SMD soldering. I am using a Microchip 18F4550 with a K-Type thermocoupler and a Max6675 to interface them.

    PID error correction is often used in DIY Reflow Ovens. However, I have had difficulty in finding the code written in (just plain) c.

    I read that your PID program is specifically designed for use in RCs. Would you, please, adjust it for my use?

    I look forward to your reply and working on this with you!

    • Hi Tom,
      The PID controller in my post is completely general and can be used anywhere. I’ve since used this code for a high frequency power inverter design. You most certainly can use this PID controller in a reflow oven! Having fun flowing!
      -Nic

        • Tom
        • April 25th, 2016

        Hi, Nic, Thank you for your reply. As I am new to coding, I could use some help.

        The PIC18F4550 will be monitoring the current actual temperature. The PIC will need to place that temperature into your PID code, for processing. So, I need to know what name I should use to input the current temperature. I would think it would be something like “curr_temp = x;”, where “curr_temp” is the name that you used for the PID input variable and “x” is the reading from the MAX6675 temperature to SPI converter.

        Once the PID routine has processed the temperature information, it will output a corrected variable to use to switch the solid-state relay. I need to know the name of this variable, also.

        So, what I am trying to get at is how do I input the current temperature into the PID routine and get out the corrected information. I apologize for the extremely basic nature of these two questions, but I have not been able to discern their answers by looking at the PID code, as I am so new to it all.

        Thank you for your help!

      • Just to make sure, are you referring to the code on this page?
        https://nicisdigital.wordpress.com/2011/06/27/proportional-integral-derivative-pid-controller/

        Look at the diagram. Your temperature control system should operate like this:
        1. Figure out what temperature you’d like the output to be.
        2. Figure out what the current temperature is.
        3. Give the PID controller the error (current – actual).
        4. Use the PID output signal to control the relay (positive is on, negative is off).
        5. Wait for a fixed time interval (this is the “dt” in the parameter list).
        6. Go to step #1

    • Tom
    • May 6th, 2016

    Hi, Nic, Thanks for your continued help. Yes, the link is to the code in question. My questions were so basic that I think you missed them. Let’s see if I can make them clearer…

    I already understood steps 1-6. In Step #3, I am to input the present error into the PID Controller Code. To do that, I will be assigning this value to a name which you have already declared. I need to know this particular name. It looks like it could be “int_error,” or “curr_error.” So, to what declared name do I assign the error.

    The second question is similar. In Step #4, the PID Controller Code will have calculated the new value with which to drive the relay. It will be assigning this value to a name which you have already declared. I need to know this particular name. It looks like it could be “pid,” or “curr_error.” So, to what declared name is the new value with which to drive the relay assigned.

    To help convey the elementary nature of these two questions, I would point out that I do not need to understand every line of the PID Controller Code. Because I am a Noob, I readily admit I don’t.

    I just need to know how to input the error at the top of the code. Then, the code will work its magic and give me the corrected value with which to drive the relay.

    I need the names that you declared for these two values. I will define the temperature error name with the error value (present target temperature – present actual temperature.) The code will define the PID Output Factor name with the code’s output value. I need this name to assign it to the code that will drive the relay.

    I am embarrassed at the rudimentary level of these questions. If you would rather discuss this through e-mail, i.e., not be tying up this forum, I would gladly agree; you have my email address.

    Thank you for your continued help…

    • Tom,

      Here is a sample about how to use the PID controller. Think of the PID struct as an object variable. I’ve initialized the PID controller with sample values (4 lines after PID definition). You need to tune these values per your application.


      double getDesiredTemperature();
      double getCurrentTemperature();
      void setOutputState(double);

      void main() {
      const double DT = 0.100; // seconds

      PID pid;
      pid.windup_guard = 100.0;
      pid.proportional_gain = 1.0;
      pid.integral_gain = 2.0;
      pid.derivative_gain = 3.0;
      pid_zeroize(&pid);

      while (1) {
      double desiredTemperature = getDesiredTemperature();
      double currentTemperature = getCurrentTemperature();
      double error = desiredTemperature - currentTemperature;

      pid_update(&pid, error, DT);
      setOutputState(pid.control);

      waitSeconds(DT);
      }
      }

      A reflow oven isn’t a trivial design. You should thoroughly look through this project:
      https://github.com/0xPIT/reflowOvenController

    • Tom
    • May 10th, 2016

    Hi, Nic, thank you for the wonderful code!

    Your point about the design and safety of the oven is well taken. I have done tons of research. Here is where the project stands:
    – The oven is completely built and has already been in heating trials. It is based on common DIY Reflow Oven designs. As a safety measure, I am putting the controls in a separate box, not inside the oven’s controls space… One less possible melt-down…
    – The prototype controller is completely built. It is my design and is based on a PIC18F4550, a MAX6675 Thermocouple Interface, a Type-K thermocouple, a low voltage supply, a separate voltage regulator and a Crydom Solid-State Relay.
    – My brother is the coding expert. I am more about the hardware side of things. He is finishing up the portions of the code… SPI interface to the thermocoupler, USB interface to a laptop, autonomous heat regulation code by just the PIC and a java GUI program.

    I have been searching for a PID code in C. It has been rather difficult to find. Now that I know how to get into and out of the PID code, I will hand it off to my brother. He prefers to code in C.

    We are two retired guys that have taken up electronics to keep our minds sharp. He is trying to learn Eagle and I am trying to learn C. The Reflow Oven will allow us to take our designs up to a whole new level. We are excited about that.

    If we publish our work, I will be sure to post the link, here, for those folks that might have interest. Thank you so much for your help!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: