Dev Blog 5 - fiat lux (part I)
In this blog entry I will talk about some aspects of the electrical system implemented in our simulated Lockheed Vega 5. And even though the Vega's electrics are very simple, there is a lot to write about it. Therefore I decided to split this up into two parts to make it more accessible. I hope that you gain some useful insight, not only to how things work in this little airplane, but also into my approach of simulating real world physics in the FSX/Prepar3D.
What the FS provides
I always found FSX lacking when it comes to a proper simulation of electricity. It seems incomplete, badly documented and in some cases plainly wrong and I want to first take some time to talk about WHY it doesn't make much sense to me. I base my opinion in this matter on my own meager understanding of physics and the information presented in Microsoft's SDK. Please also note that I won't recap basic electrical theory, like Ohm's law.
The number one issue I am having with the FSX electricity is the representation of the battery. When you load up an aircraft in the simulator, it's battery gets initialized to the maximum battery voltage, as set in the aircraft.cfg. And as long as there is no generator/alternator supplying the battery with power, the battery voltage will gradually drop, based on the load you put on the bus.
In the real world we tend to express the capacity of a battery in Ampere-hours (Ah), which means that if you have a 40 Ah battery, it can supply 40 Ampere of electricity for one hour, or 1 Ampere for 40 hours. And yes, you will see the voltage drop when the battery empties, but that's rather a symptom of the problem. The actual CHARGE is what indicates the health of your battery. FSX doesn't have any variable setup to reflect the battery charge, the only thing you can go by is the voltage.
Another point of contention is the lack of access to the bus system. While it is possible to set up an in-depth representation of the electrical bus system in the aircraft.cfg, I find it to be a complete waste of time, since it doesn't provide the events to connect or disconnect any of the buses. Furthermore, you can't even use simconnect to do so.
Fortunately, FSX provides one very important feature to the developer and from my point of view, it is the best feature of FSX's electrical system! It allows you to completely switch off the internal electrical system by adding "electric_always_available = 1" to the aircraft.cfg.
OK, now that's done, what now? Well... we build a new electrical system from the ground up of course!
Since only used to start the engine and power the lights, the electrical system of the Lockheed Vega was rather crude and simple. A 12 Volt battery provides you with all power you need, fuses of the melting type protect the components from surges and the small access panel on the left side of the fuselage allows access to the battery to plug in an external battery or ground power unit. The generator of the engine is utilized to charge the battery and an electric motor can crank and start the engine. I tried my best to simulate all those components in our Lockheed Vega.
The battery of our Vega has a maximum charge, representing it's capacity. It will decreases over time and exposure to cold air. If you're driving a car you know what I am talking about. Over time, your battery gets weaker and weaker, and at some point it's useless to charge it, because it's capacity has dropped to much and it can't provide enough power to the starter motor any more. In this case your only course of action is too replace it. The same is true in the Vega.
The charge of the battery represents the current electrical potential of the battery. You can charge your battery either with your generator, or the external battery cart that can be requested through the ground crew interface in the sim. The charge is persistent, meaning if you leave your aircraft with an empty battery when exiting the sim, it will be empty when you start it up again. It is calculated based on the load you put on it. Even a fully charged battery will be empty the next day if you forgot to turn of the lights when you leave.
If you remember your physics classes in high school you will be familiar with the following beginning of an exercise: "An ideal 12 Volt battery with an internal resistance of 0 Ohm[...]". Well, this is not an ideal world and any battery in reality does have an internal resistance. It is this resistance that causes a voltage drop as you increase the load on it. Maybe you noticed the lights of old cars slightly dimming when you crank the starter? That's caused by the voltage drop of the battery, which in turn is caused by the internal resistance of the battery.
Keep in mind that this aircraft was built in the 1920s and commercial use of electricity has only been around for a few decades. Compared to today's standard, the battery of the Vega was pretty bad and it's properties can vary quite a bit. On loading the aircraft for the first time it will be provided with a new, randomly generated battery. To give you some numbers: the internal resistance will be somewhere between 0.042 to 0.082 Ohm and the charge somewhere between 32 and 48 Ah.
Generator and battery cart
Once your engine is running, you should turn on the generator to charge your battery. The voltage produced by the generator depends on the rpm of the engine, it will only produce enough power at or above ~1000rpm. On the other hand it can generate close to about 14 Volts when your engine is at full power.
Similarly, the ground power unit can charge your battery while on the ground, or overnight. It's nothing more than an external battery, but for simplicity reasons it doesn't loose it's charge. It connects directly to the battery and therefore still charges when the master battery switch is in the OFF position.
In the image to the left you'll see the left half of the 2D panel I use to debug the aircraft. It displays all relevant variables of the electrical system.
This concludes the first part of the developer's blog "fiat lux" about the power generation. Part II will be about the electrical load and how it's effects. It will be up in a week or two and I hope you'll stick around for it. As always, please feel free to comment below if you have objections to what I wrote or any other remarks that are on your mind.