MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

Go to page 1Go to page 012Go to page 2Go to page 2
Avatar
herbiem
Posts: 71
Supporter
Hi Guys
I have built a Heading indicator for my default C172 in FSX built using 2 Stepper motors and 2 encoders
The Heading Bug Encoder moves the Bug on the flight sim and on my instrument
And this all works fine I can adjust the Bug with the encoder and it works on my instrument and on the Sim
In case someone is wanting to no how this is what I have set
Input -Encoder Event ID On left Heading_Bug_Dec 65880 Param 0
On Right Heading_Bug_Inc 65879 Param 0
Output I used User preset Autopilot-AP Heading. Offset 0x07CC 2 Byte
Transform ($*360)/65536
Comparison <0 set it to $+360 else set it to $
The problem I have is with the Heading Dial.
When I turn the encoder to adjust the Heading this adjusts on the sim BUT does not turn theinstrument dial. Note on the Sim both the Dial and the Bug move together when making adjustment
The setting I have are
Input -Encoder Event ID On left Gyro_Drift_DEC 65878 Param 0
On right Gyro_Drift_INC 65877 Param 0 Which I think is correct because it adjusts the Sim
Output Output I used User preset. Pos/Attitude- Heading. Offset 0x0580 4 Byte
Transform $*(360/65536)/65536 Comparison <0 set it to $+360 else set it to $
I have gotten this far by trial and error and reading this Forum so there might not be any logic to what I have or have said:rolleyes: :rolleyes:
Just need to get the instrument Dial ( I think it is call the Gryo)?? to turn when I turn the encoder.
I hope I have explained this clearly?
Any help thoughts would be appreciated
Ian
2020-10-08 11:51
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 5474
Supporter
Should be possible.

I got no time to figure out in the moment. This will take some weeks pretty sure .
But maybe i can guide you a little bit.

Open a new Config.... Create some Outputs ( without any device) and read Offsets you think they can be interesting. Not use Formulas. Just raw values at first.
Then use your Encoder to turn the dial. And observe what of the offsets also change here. Turn it back Check if offset go back to the old value and so on.

If your lucky there exist a final offset we can use. If not i think there should be a offset for the "drift". So a offset that show us the "difference" between the real heading and the selected. Finaly we can build a fromula that read the "difference" and use as "varibale placeholder" the real heading and calculate the final result that should be showed by the dial.

PLEASE: Do research.... Find the needed Offsets. If you get in trouble with the formula.... Show me the data ( best way on DISCORD) and i can help with the calculation !
Good Luck !
2020-10-10 15:21
Avatar
herbiem
Posts: 71
Supporter
Thanks for the guidance
I will work on it in the next day or so and confirm how I get on.
Ian
2020-10-11 00:41
Avatar
krono
Posts: 27
Hi herbiem

I have the same setup with 2 encoders and 2 stepper motors in P3d.
The stepper motors are run through mobiflight but to get the sim to react to the encoders I found it easiest to use spad.next with FSCUIP 07CC. This works well across any plane needed and both programs work well together.

Ken
2020-10-12 07:12
Avatar
herbiem
Posts: 71
Supporter
Thanks for the reply Ken
I was hoping not to spend any more $$$ on my sim than I need to but this looks like it is the answer
I am still thinking that it should still be possible to get it to work in Mobieflight
I have tried all sorts of things
I know it is the Gryo drift as this is what the encoder is set to and that makes the dial move correctly on the Sim but the dial on my panel does not move
I don't see in the OUTPUT tab a FSUIPC "use offset" for Gryo drift. I have tried most of those that are listed as use preset but no luck.
I imagine that it is to do with some sort of transformation but I am not to hot on the math's side of things:)
Got the Bug working fine.
Anyone else got any suggestions would be great. I have tried what pizman82 suggested but no luck yet.
Ian
2020-10-13 03:44
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 5474
Supporter
You guys confusing me.

1. Krono said he do the encoders with spad-next..... We should not care about cause Ian you still say your encoders already work. So why you think about that.

2. Krono said his Gauges work via Mobiflight..... So why he not simply tell you what Offset he read for the Gyro ?? That would solve all questions !

3. Why do you talk about Presets and "Output Tab ...USE Offset" stuff. I still tell you to tryout OFFSETS.... Means you should simply open the FSUIPC List ( PDF file in your modules folder. )
Search this document for the word "Gyro" if you still think thats the correct term for that dial.

My search hits this 3 Offsets....

iconQuote:

0B18 8 Byte Gyro suction in inches of mercury (Hg), floating point double
(FLOAT64)


That sounds wrong to me.....

****

iconQuote:

0C3E 2 Gyro drift amount ( *360/65536 for degrees).
Note that whilst it may appear that the value is accurate to
fractions of a degree, the actual setting capability (via an event)
is based on whole degrees, just like the INC/DEC controls. Any
value written here will normally be read back slightly
differently, based upon this granularity.



Thats sounds like the INPUT ..... Test if this is the correct position OR if this is the difference between the Heading maybe.

****
iconQuote:

2B00 8 Gyro compass heading (magnetic), including any drift.
64-bit floating point.



And thats sounds like what you need.... If not then pretty sure THIS in combination with 0C3E is the final solution !.
Good Luck !
2020-10-13 06:58
Avatar
herbiem
Posts: 71
Supporter
Hi pizman82
Well thank you thank you.:thumbup: :thumbup:
Sorry for the confusion in my description I should have said "Use preset" not offset and also that not all presets are listed as has been pointed out in other posts.
Yes you are correct I have the Encoders working and thanks to you I now have the Dial working using the Offset 0C3E 2 Gyro drift amount ( *360/65536 for degrees).
I had read through the FSUIPC List but did not put 2 and 2 together:huh: regarding the Gyro
So now it is all sort of working except that when I turn the dial in my panel to adjust the Gyro drift the Heading Bug does not move with it as it does on the Sim.(FSX Cessna 172)
My heading Bug is set up as per my original post, so I am guessing I need a Precondition in the Gyro setup to move the Bug with the Gryo Drift Dial is this correct
Are you or some one able to point me in the right direction.
Thanks again
Ian
2020-10-13 23:59
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 5474
Supporter
This gonna be tricky.

Technical i would say the value of Heading Bug must be "Gyro Drift MINUS Heading Bug" .....

For example the HEading Bug is in 90° EAST. Its basicly in the 3 o clock Position Aslong the Dial itself is pointed to North.
If we fly to East heading 90° then the Heading Bug must be technical in the 12 o clock Position ( 0° ) .
So if we say the heading bug should show "Heading Bug Offset Value MINUS Current Dial Value (Gyro) in our example 90-90=0
Lets say the dial show to 30° and HEading Bug is in 90° 90-30=60 .... So the Heading is in 60° ( 2 o clock) .

PROBLEM: The HEading Bug pretty sure use Compas Mode to avoid a 360° Turn if it reach the 359/0 Border. Here i not know if it get "crazy" if our calculation occure in a value LESS then Zero ..... For example if we fly 270° West and HEading Bug is in 90° Position ..... Here 90-270= MINUS180 .....

Try1: Use a transform that say HEading Bug " Current Value MINUS Value of Gyro" ( Placeholder varibale of the other Config)
Try2: Use a Formula like if(Heading Minus Gyro Less then 0 THEN Heading+360 minus Gyro ELSE Heading minus Gyro)

I hope you understand what i mean ! If not we must do this in a Discord seasson or i need to try out by myself in the next weeks !
Good Luck !
2020-10-14 00:32
Avatar
krono
Posts: 27
Hi
Sorry for not adding all the material you may need. I use lua files in fsuipc for all planes. Here is the lua I use for the 172.


local A1 = 0
local A2 = 0

while 1 do
-- read first 16 characters from aircraft title (Aircraft.cfg file)
AIRCRAFT = ipc.readSTR(0x3D00, 16)

if string.sub(AIRCRAFT,1,8) == "A2A C172" then
-- A2A C172
-- A2A Local Vars
-- Gauge --
PANELLIGHT = ipc.readLvar("L:BATTERY1SWITCH")

-- Heading Indicator --
COMP = ipc.readDBL(0x2B00)
GYOBEAR = ipc.readUW(0x07CC)
GYROHEAD = (360 - COMP) + ((GYOBEAR * 360) / 65536)
-- AttIndBank --
AttitudeIndicatorBank = ipc.readDBL(0x2F78)
if AttitudeIndicatorBank < 0 then
AttIndBank = (359 + AttitudeIndicatorBank)
else
AttIndBank = AttitudeIndicatorBank
end

-- IndPitch --
AttitudeIndicatorPitch = ipc.readDBL(0x2F70)
if AttitudeIndicatorPitch <= -26 then
IndPitch = -26
elseif AttitudeIndicatorPitch >= 26 then
IndPitch = 26
else IndPitch = AttitudeIndicatorPitch
end



if AttitudeIndicatorBank == 0 then
PitchWithCorrection = IndPitch
ipc.writeDBL(0x6684, PitchWithCorrection)

local A2 = A1
end

-- Write to custom offsets (Allowable Range: x66C0 to x66FF using 6640 192 offsets)

-- Gauge --
ipc.writeUB(0x6660, PANELLIGHT)
ipc.writeDBL(0x6640, COMP)
ipc.writeUD(0x6694, GYROHEAD)
ipc.writeDBL(0x667C, AttIndBank)

end


end


The offset for the heading you are looking for is GYROHEAD. This offset is read straight into mobiflights "Base settings"

Ken
2020-10-14 02:32
Avatar
herbiem
Posts: 71
Supporter
Thank you both for your thoughts and input
I will try both pizman82's and Kens and report back as to how I get on
Once again this community is great and always helpfull
Ian
2020-10-14 05:44
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 5474
Supporter
This technic is inverted to my idea..... Looks good !

Note... You not need the LUA stuff.... You be able to do this in MF, too.

iconQuote:

COMP = ipc.readDBL(0x2B00)
GYOBEAR = ipc.readUW(0x07CC)
GYROHEAD = (360 - COMP) + ((GYOBEAR * 360) / 65536)



In theory Config 1 ( named e.g. COMP ) read Offset 2B00.......
Config 2 (named e.g. GYOBEAR ) read Offset 07CC
In Config 2 we use a "placeholder" . Value of Config "COMP" as symbol e.g. "a" .... In Config 2 $ finaly represent the GYOBEAR.
Transform of Config 2 .... to rebuild krono´s system : (360-a)+(($*360)/65536)
(Not sure if you need all brackets should work with less, too) .

NOTE:
Finaly also here COMPAS mode is the tricky question.

Lets say current Dial Value (COMP) is currently 270° . and Heading Bug is at 350° .... Then Kronos system say 360-270=90 .... 90+350=440
440 represent "80" Degrees ( 440-360=80) So a full turn and 80 degrees further.
This position is 100% Correct. BUT i don´t know if Mobiflight can handle a Value bigger 359 here.

WHATEVER..... If this is a problem you again need a IF Condition..... Instead of my idea this is inverted.
Here we say in compare IF Value >359 THEN $-360

SURE: You can run the gauge without Compas Mode ! But then a turnover 0-359 or 359-0 occure in a 360° turning backwards of the gauge !

******************
Please report final experience ! Specialy if the Compas Mode is a factor or not !
Good Luck !
2020-10-14 06:36
Avatar
krono
Posts: 27
Hi
The reason I use the lua method is so that the gauge profile is changed with each plane I use. The lua file finds the name of the plane and then loads the gauges offset as needed for it.
2020-10-14 12:52
Avatar
herbiem
Posts: 71
Supporter
Thanks Krono
I have never used Lua but might give it a go if I cant get pizman82's suggestions a go
Ian
2020-10-15 04:09
Avatar
krono
Posts: 27
Herbiem

Just a short note to point out that the lua I showed you is for the A2A 172. The 07CC and 2B00 are both straight fsuipc offsets so you should be ok for the default 172 in FSX. When the new offsets are written in the --Gauge-- section note that these are the offsets you input into mobiflght I couldnt get the images to work correctly to put online so below is a description of each page.
Config wizard

Gyro Compass
FSUIPC Page
Base settings
Offset 0x2B00
Value Type Float Size in Bytes 8

Compare Page
tick on Add comparism to modify the current value
if current value is < 0
set it to $+360
else set it to $

Display Page
Steps per revolution
Sim/Stepper 360 2048
Test value 180
tick compass mode


Gyro Compass Bearing Stepper
FSUIPC Page
Base settings
Offset 0x6694
Value Type int Size in Bytes 4

Compare Page


Display Page
Steps per revolution
Sim/Stepper 360 6170 ...note yours will differ as to your gearing
Test value 180
tick compass mode

If you are creating a lua then simply cut and paste the info I gave you previously. You can manually start the lua once fsx is started by double clicking the file. This should help you test it.
Ken
2020-10-15 08:32
Avatar
krono
Posts: 27
Herbiem
If you use the lua don't forget to --rem-- out the line

if string.sub(AIRCRAFT,1,8) == "A2A C172" then

Otherwise the lua will not do anything if you are using the default 172 and not the a2a 172

Ken
2020-10-15 15:00
Go to page 1Go to page 012Go to page 2Go to page 2