Jump to content
The simFlight Network Forums

record to csv


Recommended Posts

Hi Pete!

 

I would ask you for help if  possible.

 

I am useing Prepar3d V2.5 and FSUIPC 4.949f.

 

For a project I have to do (urgently) I have to record parameters during our test flights.

I used your example "record to csv.lua" which works for me.

But unfortunately I am not good enough to retríeve all necessary data via FSUIPC and display it in a "readable format".

 

I got throttle, prop, mixture rpm etc. but I need more information

 

Where I have problems is:

 

AoA

sideslip angele (as degrees)

flap (as degrees)

roll rate (as degrees/second)

yaw rate (as degrees/second)

 

Probably all that information can be retrieved but my programming skills ar very limited.

 

We would also be interested in elevator force, aileron force and rudder force but here I am not even sure if we can get those information.

(By force I mean the force the pilot has to apply to move the rudder)

 

So if you could help me to get your example program "enhanced" it would help me.

 

And: I can fund that work if the price is reasonable.

 

 

 

Regards

 

Klaus

Link to comment
Share on other sites

Where I have problems is:

 

AoA

sideslip angele (as degrees)

flap (as degrees)

roll rate (as degrees/second)

yaw rate (as degrees/second)

 

Probably all that information can be retrieved but my programming skills ar very limited.

 

We would also be interested in elevator force, aileron force and rudder force but here I am not even sure if we can get those information.

(By force I mean the force the pilot has to apply to move the rudder)

 

Did you try searching the offsets list provided in your FSUIPC Documents folder at all? I found these pretty quickly:

 

AoA (searched for "AoA"). same as "incidence alpha", offset 2ED0

Sideslip angle (searched for "side slip"), same as "incidence beta", offset 2ED8

Flaps in degrees:  there's a whole set of theses for the different flap sections, see 30F0 - 30FE

Roll rate (searched for "Roll"), offset 30B0

Yaw rate (searched for "yaw"), offset 30B8

 

Please do try using search facilities in your PDF viewer. They work quite well, though sometimes you need to think of alternative search words.

 

As for force to move the controls, I don't think this is simulated at all. And surely it varies according to aircraft design. On many airliners these days is it simulated/generated in any case, not real. You'd need to derive it mostly from aircraft specifications I would have thought.

 

Pete

Link to comment
Share on other sites

Hi Pete!

 

Thank you for your reply!

 

Yes I did search and find the items in your document.

 

And I do get data into the .csv file.

 

But the values I get do not seem to make any sense.

(Maybe my programming is just wrong)

 

Maybe you allow me to send you my .lua file and have a look into it.

(Flaps has still to be done)

 

And as said: Yo dont need to do that for free.

 

Thank you in advance.

 

Klaus

 

 

 

 

Link to comment
Share on other sites

But the values I get do not seem to make any sense.

(Maybe my programming is just wrong)

 

Once the correct offset is found, there are really only two things to get right:

 

1. The TYPE of variable being read. Many of thoseI listed are 64-bit (double) floating point values. Only the flaps values are integers, in 16-bit unsigned "words".

 

2. The arithmetic, which is Lua follows standard maths rules, division (/) and multiplication (*) following left to right rule unless parentheses () are used.  Junior school stuff.

 

Maybe you allow me to send you my .lua file and have a look into it.

(Flaps has still to be done)

 

Just paste it into a message here.

Pete

Link to comment
Share on other sites

Hi Pete!

 

Thx! You are probably right  :???:  Junior school stuff but ......

 

-- "Record to CSV" example data logging LUA plug-in, by Pete Dowson, September 2008
 
-- Open an exisitng "FSrecord.csv" file to append to, or create it if it doesn't exist
-- It will go into the Modules folder because I've not included a full path (like "C:\....")
-- By using "assert" you get an error message if this fails
 
f = assert(io.open("FSTD_Test.01.csv","a+"))
 
 
-- write the CSV column headings
f:write("\r\nmsecs,msec,time,lat,lon,alt(ft),pitch,bank,hdgT,hdgM,vs,ias,tas,gs,throttle,prop,mixture,rpm,manifold,elevator axis,elevator,aileron axis,aileron,rudder axis,rudder,trim axis,trim,A0A,rollrate,yawrate,stall,load,slip\n")
 
--  note the elapsed mSecs count now so can provide relative mSec timing column
time0 = ipc.elapsedtime()
 
-- Loop until our Flag 0 is set (by assigned FSUIPC control)
while not ipc.testflag(0) do
 
-- Set the timestamp for this loop
time = ipc.elapsedtime() - time0
 
-- Read all the data we want from FSUIPC
hour, min, sec, hourZ, minZ  = ipc.readStruct(0x238, "5UB")
gs, tas, ias = ipc.readStruct(0x02B4, "3UD")
lat, lon, alt, pitch, bank, hdgT = ipc.readStruct(0x0560,"3DD", "2SD", "1UD")
mach = ipc.readUW(0x11C6)
vs = ipc.readSW(0x842)
 
-- throttle = ipc.readSW(0x332E)
throttle = ipc.readSW(0x088C)
proplever = ipc.readSW(0x088E)
mixturelever = ipc.readSW(0x0890)
rpmscalar = ipc.readSW(0x08C8)
rpm = ipc.readSW(0x898)
manifold = ipc.readSW(0x08C0)
 
elevatoraxis = ipc.readSW(0x3328)
elevatorcontrol = ipc.readSW(0x0BB2)
aileronaxis = ipc.readSW(0x332A)
aileroncontrol = ipc.readSW(0x0BB6)
rudderaxis = ipc.readSW(0x332C)
ruddercontrol = ipc.readSW(0x0BBA)
trimaxis = ipc.readSW(0x3338)
trimcontrol = ipc.readSW(0x0BC0)
 
AoAindicator = ipc.readSW(0x2ED0)
rollrate = ipc.readSD(0x0384)
yawrate = ipc.readSW(0x30B8)
stallwarning = ipc.readSW(0x036C)
loadfactor = ipc.readSW(0x11BA)
sideslip = ipc.readSW(0x2ED8)
 
-- now convert them all from FS units into those we normally recognise
gs = (gs * 3600) / (65536 * 1852)
tas = tas / 128
ias = ias / 128
mach = mach / 20480
vs = vs * -3.28084
 
lat = lat * 90 / (10001750 * 65536 * 65536)
lon = lon * 360 /  (65536 * 65536 * 65536 * 65536)
alt = alt * 3.28084 / (65536 * 65536)
pitch = pitch * 360 / (65536 * 65536)
bank = bank * 360 / (65536 * 65536)
hdgM = hdgT - (ipc.readSW(0x02A0) * 65536)
hdgM = hdgM * 360 / (65536 * 65536)
hdgT = hdgT * 360 / (65536 * 65536)
 
throttle = (throttle / 16384) * 100
proplever = (proplever / 16384) * 100
mixturelever = (mixturelever / 16384) * 100
 
manifold = (manifold / 1024)
rpm = (rpm * rpmscalar) / 65536
 
a, b = math.modf(rpm / 10)
rpm = (a * 10)
 
msec = time / 1000
 
loadfactor = loadfactor / 624
 
 
-- but only log this time IF we aren't in an FS menu, or loading scenery
-- (check the "ready-to-fly" flag word at 3364)
-- and provided we are not paused (flagged at 0264)
 
 
if (ipc.readUW(0x3364) == 0) and (ipc.readUW(0x0264) == 0) then
  -- if alt >= 2000 and alt <= 3000 then
 
   -- write a CSV line to the open file
   f:write(string.format("%d,%02.1f,%02d:%02d:%02d,%02.4f,%03.4f,%.1f,%.2f,%.2f,%03.1f,%03.1f,%d,%d,%d,%d,%d,%d,%d,%d,%02.1f,%d,%d,%d,%d,%d,%d,%d,%d,%d,%.2f,%.2f,%d,%.2f,%d\n",
time,msec,hour, min, sec,lat,lon,alt,pitch,bank,hdgT,hdgM,vs,ias,tas,gs,throttle,proplever,mixturelever,rpm,manifold,elevatoraxis,elevatorcontrol,aileronaxis,aileroncontrol,rudderaxis,ruddercontrol,trimaxis,trimcontrol,AoAindicator,rollrate,yawrate,stallwarning,loadfactor,sideslip))
 
  -- end
end
 
-- 20 times per second, roughly (allow 2 mSecs overhead)
ipc.sleep(498)
--ipc.sleep(93)
 
end
 
-- tidy up at end ...
f:write("\n")
f:close()
 
-- end of example program
 
Thank yo for your assistance
 
Klaus
Link to comment
Share on other sites

Er ... look. You've not even got the first point correct, reading the correct value types as I instructed and which should be really obvious:

 

AoAindicator = ipc.readSW(0x2ED0)
 
You are reading a 16 bit signed word (SW) for an offset clearly documented as a double (FLOAT64), which is obviously read using the ipc.readDBL function. You only had to look thngs up!!!!
 
rollrate = ipc.readSD(0x0384)
 
SD = signed DWORD. But this is documented as a 32-bit float (ipc.readFLT).
 
And on it goes. You've apparently not bothered to look them up to ascertain what they are now what the correct functions are to read them!
 
:-(
 
Pete
Link to comment
Share on other sites

Sorry. I am not known for my patience, nor certainly am I by any stretch of the imagination a good teacher. I do hope, however, that folks can read, or if not get someone to read for them. ;-)

 

I admit that my knowledge in programming is limited and I do have problems with SW, UW, etc. etc.

 

It is not really programming at all, just matching words. Words like "Float32" for instance match in both the offsets list and the Lua function list. You can even use a "search" option to find these matches.

 

There's also a simple guide to bits, bytes, words and so on in the FAQ subforum thread

About bits numbers and hexadecimal

Although there's more there than you need at present, it doesn't cover 32-bit floating point (FLOAT32 or just FLT) nor "double" -- 64-bit floating point (FLOAT64 or DOUBLE or just DBL).

 

Pete

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.