I am a new to UAV and I do a gasoline powered heli with pixhawk v2. In ardupilot ,using throttle control ESC, I want to change to throttle control SRV. Could anyone tell me what the file and the code I should modify? Thanks.
You should not have to modify the code for your gas heli. The throttle servo can be driven directly from one of the SERVO outputs by assigning the function of HeliRSC. This is usually on SERVO8 so you would assign SERVO8_FUNCTION a value of 31 for the engine throttle. And set the SERVO8_MAX and SERVO8_MIN to values that will not bind your throttle linkage, but still allow idle cut-off and full-throttle.
Depending whether you have a governor on the engine, or have no governor and want to use a throttle curve, will determine which H_RSC_MODE you use. With a governor the throttle signal to the governor will be sent from the SERVO output on Pixhawk that you choose to use using H_RSC_MODE 2. And the H_RSC_SETPOINT will be set to your desired headspeed. The governor will use it’s speed sensor and control the throttle to maintain the headspeed, so will handle output to the throttle servo. Endpoints for the throttle servo must be set in the engine governor.
With no governor on the engine, you can use H_RSC_MODE 3 and set the H_RSC_POWER_HIGH/LOW/NEGC for a three-point throttle curve, and in this case the throttle servo will be hooked directly to the SERVO output you choose for the throttle.
The final thing is the idle speed. There is a parameter called H_RSC_IDLE that must be set to allow the engine to idle and warm up, but it must be set to have the engine idle but not have the clutch engaged. Then there is two params, H_RSC_RAMP_TIME and H_RSC_RUNUP_TIME. The ramp time will determine how long it takes to move the throttle from idle to governed speed. The runup time is set to how long it actually takes the engine to get to full speed. For piston these must set to values that will smoothly engage the clutch and provide a gradual runup - usually 30 seconds or more.
The throttle control on RC8 will be assigned to a on/off switch on your radio.
So the procedure for starting is to first arm the flight controller (disable the DISARM_DELAY by setting to zero). Start the engine. If it has an electric starter built-in you can use channel 9 or 10 on a momentary switch to activate the starter. The engine will start and idle using the H_RSC_IDLE setting. Let it warm up a bit. Now throw the Channel 8 switch for the governor function. It will engage the clutch and spool up, and you can go flying.
When you land, turn off the Channel 8 switch, which will return the engine to idle to let the head spool down and disengage the clutch. When the cylinder head temp drops to a safe level for shutdown, disarm the flight controller and it will stop the engine by closing the throttle.
Hope this helps.
Thank you very much.
I think you mean add a governor on the engine and adjustment parameters.
The throttle outputs channel take PWM to ESC now.But I want to make the throttle outputs channel take PWM to SRV directly.
If I want to solve the problem at its roots,what can I do? Should I modify the code?
Thanks a lot.
It will already do that. There is no difference between the pwm signal to an ESC or a mechanical servo.
When the pwm signal to an ESC ，I have met two questions:
1.PWM in 1500ms-1100ms has no output value, and the input and output value of the throttle channel is not linear.
When I pull down the controller at the midpoint, there is no output value, and suddenly drop to 1100ms. This is not feasible on the gasoline engine. I think the ESC does not have torque at low speed.
2.ESC cannot revise the direction of the SRV.
If I adjusted on the controller, it will not be unlocked in MP.
That’s why I want to modify the code.
I guess I don’t understand what you’re saying. I have two different helicopters with piston engines and I fly them fine with no special modifications to the code.
Do you have a log file from the Pixhawk that would show the behavior you describe? That would maybe be helpful.
Thanks very much. Because of the limited level of English, it may be that my expression is not accurate enough.
I do not want to open the external speed regulator. I also want to make the pwm signal to a mechanical servo,not to an ESC.
I’m glad to be acquainted with you in the community。
Yes, I understand what you want to do. The ArduPilot software can already do that without any modifications to the code. It just requries setting the parameters properly to do it.
That’s great! Would you like to tell me which parameters should I set to and how to if making the pwm signal to a mechanical servo directly,not to an ESC.
Do you have a governor on your engine? Or do you want to use it without a governor?
use it without a governor
OK, so it’s pretty simple. I will assume you are flying the latest Copter 3.5.4.
Hook your throttle servo directly to the Pixhawk’s SERVO8 pins
Make sure you have a switch on your radio set up to turn RC8 on and off. The pwm range for Channel 8 should’ve been set during your RC calibration, but check the RC8_MIN and RC8_MAX values to make sure it was set to the full range of your radio’s output. And set RC8_TRIM to the same value as RC8_MIN
Go to the SERVO8_FUNCTION and set it to 31. Set the RC8_TRIM and RC8_MIN to 1400. Set the RC8_MAX to 1600. Set H_RSC_MODE to 3
Set the DISARM_DELAY parameter to 0 and set the BTN_ENABLE parameter to 0
Arm your flight controller but do not start the engine. The throttle servo should’ve moved when you armed. Note the position of the throttle. Turn on the Channel 8 throttle switch on your radio. Note which way the servo moves. It should open the throttle with the switch on, and close the throttle with the switch off. If it operating in reverse, then set the SERVO8_REVERSED parameter to 1. Try turning the throttle switch on and off and observe the throttle servo. It should now be operating in the correct direction.
Turn the throttle switch off on your radio. Look at the throttle. It should be partly open. Reduce the values of RC8_MIN and RC8_TRIM until it completely closes the throttle plate. It is important to have the throttle plate completely closed so the engine will stop if it is running.
Turn the throttle switch on your radio on. Set the SERVO8_MAX until the throttle is wide open. Check by turning the throttle switch on your radio on and off and observe the throttle servo. It should go from idle cutoff (completely closed) to full throttle when you turn the switch on and off, but not bind the servo or linkage.
Disarm the flight controller. Set the H_RSC_IDLE parameter to 100. Arm the flight controller. You should see the throttle servo move and open the throttle to a point where the engine would start and idle without engaging the clutch. If 100 is not enough, set it to 150 or 200. Adjust that H_RSC_IDLE until it looks like the throttle plate is at a point with the flight controller armed where it would idle the engine.
Set H_RSC_POWER_LOW to 200. This is the throttle opening that will be used at zero collective pitch.
Set H_RSC_POWER_HIGH to 500. This is the throttle opening that will be used at full positive collective pitch.
Set H_RSC_POWER_NEGC to 200. This is the throttle opening that will be used at full negative collective pitch.
Note that these three H_RSC_POWER settings determine a three-point throttle curve based on collective pitch. So with the above settings we have a flat (no change) throttle from full negative collective to zero collective. And increase throttle from zero collective and 20% to 50% open at full positive collective pitch. You will actually have to adjust these to fit your engine and gearing, desired headspeed, and blade loading. The above are suggested starting settings just to get it initially working.
Set the H_RSC_RAMP_TIME to 40. Set the H_RSC_RUNUP_TIME to 45. These determine how fast the throttle will open when you spool up the head on the heli.
Remove the main and tail rotor blades from the heli. Arm the flight controller. Prime the engine, start it and let it idle and warm up. If it is idling too slow and wants to quit, then your H_RSC_IDLE is too low and must set it higher. If the engine idles too fast and engages the clutch and starts turning the head, then the H_RSC_IDLE is too high and must be lowered. After you find the correct H_RSC_IDLE setting, disarm the flight controller. The engine should stop.
Put the main and tail rotor blades back on the heli. Arm the flight controller and start the engine, let it idle and warm up. The head should not turn except by some drag in the clutch bearing.
Turn on the Channel 8 throttle switch. The engine should speed up and engage the clutch and start turning the head and begin to accelerate smoothly over the next 40-45 seconds. Let it accelerate with the collective lever at or near zero pitch and see what you get for headspeed. If it’s too low adjust the H_RSC_POWER_LOW to a higher value. Turning off the Channel 8 throttle switch will return the engine to idle. Keep adjusting H_RSC_POWER_LOW until you get the correct headspeed for zero pitch. Depending on how you have your negative collective pitch set up, I would suggest setting H_RSC_POWER_NEGC to the same value as H_RSC_POWER_LOW for now.
H_RSC_POWER_HIGH must be set to a value that is higher than H_RSC_POWER_LOW to provide more throttle opening (torque) as you increase collective pitch. So it’s now time to test that. Start your engine, let it warm up, turn on the throttle switch and spool it up. Gently feed in collective pitch until it starts to get light on the skids. The engine should be maintaining speed and not bogging down, or speeding up, as you reach hover collective pitch. If it bogs down, increase the H_RSC_POWER_HIGH setting. If it speeds up too much reduce the H_RSC_POWER_HIGH setting. Typically, having the engine speed up a bit as you reach hover collective is more desirable than having it bog.
Now that you have found a close H_RSC_POWER_HIGH setting, take off and hover the heli. Try some full collective pitch climbs from hover and see how much the engine bogs. If it bogs too much, increase the H_RSC_POWER_HIGH value. If you have a really “hot” engine with deep gearing and it speeds up when you do a full collective climb, then reduce the H_RSC_POWER_HIGH.
You should be close enough to tune the H_RSC_POWER settings to get it to run the way you want. And you can adjust the H_RSC_RAMP and H_RSC_RUNUP times to your liking as to how aggressive or gentle you want the engine to engage the clutch and spool up.
So to recap, the procedure to fly is to arm the flight controller, start the engine and let it warm up. Turn on the throttle switch and let it spool up, and you’re ready to fly. When you land, turn off the throttle switch and let the engine idle. Then shut it off by disarming the flight controller.
Without a governor on the engine, this is the only way I would recommend flying the heli with the MODE 3 throttle control. If you put a governor on it then we can do more advanced setup using either MODE 2 or MODE 1 with idleups. But with no governor the MODE 3 is the only one that will work for Auto flight if you lose radio contact with the heli.
Would you have few minutes to talk via phone? I have a fairly serious project and would like to get some feedback from you.
I am new to the site and do not see a method for a PM.
Absolutely. I will PM you with my phone number.
Thank you very much. Your answer is very careful. I’ll try it .
Please ask if you have a problem figuring it out. There’s a lot of settings to make there and it takes a bit of fiddling around without a governor to get it “right”. But it will work - I guarantee you it will. I think some improvements could be made to the three-point throttle curve because it’s hard to get it to fit the torque curve of most piston engines. I think you’ll find that you’ll have to allow a bit of engine speed-up from zero pitch to hover collective pitch when you adjust the H_RSC_POWER settings. And it won’t compensate very well for differences in payload without a using a governor.
I plan on looking at that part of the code when I get time. ArduPilot could use an internal governor function.