Tuesday, December 13, 2005

Altitude calculations

The cold turned out to be the flue of the year, so I haven't been able to do much on this project for some time. Now I'm out of the fever fog and have been able to do some research about the altitude calculations and such. This is something I have to work on, but I will get back with more details as I start to implement it.

Wednesday, December 7, 2005

Low alt warning

Headache, soar throat, a voice like James Earl Jones and some slight fever. The diagnosis is a cold. But nothing is going to stop me from working on this project.

I had planned to start working on the input into the flight computer, but we decided that we needed to get the low alt warning to work properly. After some research it seems like we will be able to make all the different low alt warnings work. AJ37 i a rather old plane so it had a rather simple system compared to modern aircrafts. All conditions for low alt warning are based on the current height and do not consider any obstacles in front of the aircraft, which would have been impossible or at least not feasible to do in Microsoft flight simulator since there is no functions or variables to get that information. The only ways around that would have been to either have our own set of terrain height data which would probably not match the terrain in the simulator good enough, or we would have to hack the terrain file format in the simulator and that would be a very big project. Luckily we don't have to that.

Apart from the warnings you get altitude hold and some special warnings at different weapon choices, which are not indicated in the HUD anyway, there are two conditions for low alt warning: bottenvarning and metspövarning (translates roughly to bottom warning and pole warning). The bottom warning is induced by the radar altitude falling below 150 m and at the same time is not less than half the altitude measured by air pressure. The pole warning is induced by the current sink rate predicting the aircraft to hit the ground within 7 seconds. There are also some extra conditions for these warnings.

Low alt warning is indicated in the HUD by the altitude pole package is blinking with a 5Hz frequency. This is now done for the pole and bottom warning except that the only extra condition I've implemented is that no low alt warning is induced under 50 m if the landing gears are out. To implement the rest of the conditions I need to do more research.

At the same time I put back the function that turns the HUD off at climb angles over 15 degrees or under -15 degrees. This function has a hysteresis, which means that it's not turned on until the climb angle are lower than 12 degrees or higher than -12 degrees. This function was implemented earlier, but was commented out when I did a restructuring of the program last summer.

I don't know if anyone is reading this programming diary, but if I sometimes am a bit to technical, use terminology you don't understand, I might not be technical enough or there is something you wonder about then feel free to tell me. Maybe some one would like to see some screenshots?

Now I'm returning to the bed so I can get rid of this cold.

Sunday, December 4, 2005

I got and idea...

Some early morning work. Woke up and had a slight feeling that it was actually possible to get an acceleration value from flight simulator. When you wake up in the morning and have an idea, you shouldn't stay in bed. It's imperative to act while the idea is still fresh. And quite right.... there is a value for acceleration over the X, Y and Z axis. Can't understand where I got the impression there wasn't. Then it was just half an hour work to make the time line for rotation order to move.

This means that start mode (or takeoff mode as you would probably call it in English) is 100% finished, and it's time to start working on input and output from the data panel. This is to be able to present navigational data in the other HUD modes.

Tuesday, November 29, 2005

Speed error indicator

Today I've fixed the steering of the speed error indicator in landing mode (the little vertical line on the velocity vector). The function has been there since before, but now I've also got the logic for it. The code is written for both 12 degrees and 15.5 degrees alpha, but since we haven't connected the button to change between these, only 12 degrees work at this moment. I've also fixed the warning for critically low speed.

Saturday, November 26, 2005

Low nav mode

the low nav mode that I made earlier is now connected with the new logic and seems after the first test to work as it should. In this mode I've also added the functionality to toggle the course indicator by pressing the ref. omk. button. Now I only have a few things left before I start working on the input and out put from the CK program to the data panel.

Saturday, November 19, 2005

Adjustments and settings

Today's work was primarily to put all possible adjustments to the HUD into an INI-file. This way the adjusments and calibrations don't have to be med everytime the program is started. Additionally I have once again made it possible to use the ref. omk. button, but with slightly modified functionality. And I've also added the possability to tilt the HUD display at takeoff and landing. Since a HUD of this type has a very limited field of view, and much of the interresting presentation at takeoff and landing is positioned lower than you would like in normal flight, it is possible to physcally tilt the reflector glass of the HUD. But to get a proper presentation this has to be accompanyed by a similar tilt in the computer generated image. When the glass is tilted, a microswitch is pressed and the HUD-program gets a signal to tilt the image to a preset position... As simple as that.

Friday, November 18, 2005

Flight computer

Restructuring of the HUD (SI) program completed. I've implemented some variant of the bridge design pattern to control the different modes of the HUD. I hope that the HUD program this way will be easier to maintain. The hard thing about this project is tat we don't really know from the start how things are going to work. We do have a lot of documentation, but it's far from complete. And when I try to implement one thing we usually find that the way we assumed it worked is simply not true, or at least not the whole truth.

I've now started the flight computer program (CK). But since I haven't worked out the details for the communication between my programs, I included the whole CK program in the SI program with an interface between. This way it should be simple to just lift the CK code to a separate program when I want to. The restructuring means that we've lost some of the functionality. But this is simply a matter of not reaching it at the moment. The code for it is still there.

Since we now have a CK program, I've got the mode selector to work. Start mode is activated and deactivated according to the right conditions.

Saturday, October 15, 2005

Reading data from the simulator

Today I've been able to read the aircraft's current position, which means the commanded course in the HUD is starting to work. This is stuff that should be placed in the flight computer, but since I haven't made that program yet these functions will have to be placed in the HUD program temporarily. However this means that for the moment there will not be anything else than hardcoded waypoints. I'll see if I have the time tonight to make the program change waypoint according to the right conditions.

Wednesday, October 12, 2005

Project overview

It might be a good idea to give you an overview of this project to understand what I am doing.

SUL37 is a project to build a simulator based on a real SAAB AJ37 cockpit. We are 6 people from completely different parts of Sweden involved in this project. For simulation we use Microsoft Flight simulator 2004 which is projected on a big screen in front of the cockpit. Our goal is realism and we aim to be as true to the original as possible. Everything in the cockpit is original except for the displays for HUD and radar. Most of the gauges are modified to house stepper motors that we can control from our software, and there is only a few reserve gauges that aren't working so far. To top this there is a pneumatic G-simulation system fitted in the ejection seat.

My contribution to this project is the software for the flight systems. that includes the HUD presentation system, the radar display system and the flight computer for navigational calculations and other tasks. The programming is made in C++ and the graphical presentation is made with OpenGL. The different sub systems will be distributed to several programs on several computers. This way we can use old "junk" computers that don't cost us anything, but the different systems will then have to communicate in some way. To start with we will probably use FSUIPC since this is what we use to fetch data from the simulator, but we might want to make some interface of our own down the line.

The original hardware for the HUD (head up display), or SI as it is called in system 37, is kept as it is except we've replaced the small round CRT with an old b/w TV. Since the TV is slightly larger than the original CRT, and since we need to have a closer focus for the HUD presentation (the simulated world is projected just a few meter in front of the pilot instead of infinity as the real world) we've also placed our own optics between the TV and the HUD. The result is almost perfect.

The radar display, or CI as it is called in system 37, is also replaced by a b/w TV with a green filter and a Fresnel lens in front of it. The radar display presents some navigational aid, a horizon line and a radar image in PPI och B-scope. I have plans for a realistic radar simulation with shadows and proper illumination. But since this is very complicated it is not something I prioritize.

Finally the central flight computer, or CK as it is called in system 37, is the heart of the whole system. The flight computer has many different tasks, but one of the main things is navigational calculations. it controls what is presented in the HUD and radar display, but also many of the gauges. The pilot controls the computer from a panel on the right side.

I will write more about the different systems as I make the programs for them.

Monday, October 10, 2005

SI starting to take shape

After a few hours in the AJSH37 simulator at the F7 airbase in Såtenäs, and now recently a few hours in a similar simulator at SAAB in Linköping, and after having gone through all not classified documentation we have been able to get our hands on and then some, I think I've got a somewhat good understanding of how the HUD works. The program I made last summer is now restructured and as a result it was easy and quick to add some new HUD modes. What we have now is the startmode (I'm still not entirely sure how to make calculations for rotation velocity though), a somewhat complete nav mode, low nav mode and optical landing mode.

Today I've also made some real progress of making the HUD-program communicating with the simulator.... With one exception. There don't seem to be any variable in FlightSim for climb angle. But I think it should be possible to calculate that from vertical speed and ground speed. This seems to give me correct values, but unfortunately these variables are not updated more than a few times every second which renders them almost unusable. So I have to find some other way. If anyone has any suggestions, I'd be happy to try it.

Finally I started to add functionality for commanded altitude, which seems to work just fine. I also adjusted radar altitude so it is presented correctly. Next step is to finish the commanded altitude, but that would require waypoints I guess, and that is a completely different part of this project.

After some thinking, drawing and calculting I think I've figured out a way to get the climb angle

climbAngle = pitchAngle - (sin(rollAngle) * beta + cos(rollAngle) * alfa)

At least it seems right to me, but if I'm thinking all wrong please tell me. Here is a video of the result