How to connect a Moving coil gauge

Are you building a cockpit, planning to build one or just dreaming, this is your cockpit builder meeting point

Moderators: russ, Ralph

Message
Author
User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: How to connect a Moving coil gauge

#121 Post by Keith Baxter »

Hi Kirk.

You are correct.

But before we start chasing our tail. We need to establish if the dataref is indeed returning a °C value or a °F value.

This can normally be found within xplain's "Plain Maker" <standard><systems><limits1>
ice_screenshot_20220530-174822.png
Here we find that this airframes EGT is in °F and not °C so no need for conversion.



You can then simply change the scale to
egt_table = {{0 , 0},
{900 , 0.625},
{1000 , 0.677},
{1100 , 0.745},
{1200 ,0.811},
{1300 ,0.888},
{1400 ,0.975}}


Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: How to connect a Moving coil gauge

#122 Post by Kaellis991 »

Keith,

Those new numbers did not change the range of movement from min. to max. It's still in the same range of the mixture handle movement.
The temps only change on the real gauge within that narrow range of handle adjustment. While the gauge in the Xplane aircraft has a different response.
image.png

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: How to connect a Moving coil gauge

#123 Post by Keith Baxter »

Hi,

Ok meet me in the chat room on discord now. We will get to a solution ad revert the outcome for members not on the discord here.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: How to connect a Moving coil gauge

#124 Post by Kaellis991 »

Ok...lets see if I can remember how to do this...I have discord open.

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: How to connect a Moving coil gauge

#125 Post by Kaellis991 »

Kaellis991 wrote: Mon May 30, 2022 2:30 pm
Keith Baxter wrote: Mon May 30, 2022 3:51 am Hi Kirk,

Here is the code to run the EGT gauge if you are going to use the PWM method. I suggest you stick with the PWM method as Joe has helped you and no point in changing.
I have just used arbitrary values in the <egt_table>. I can go through determining theses values on the discord should you not know how to do that.

Code: Select all

-- Create new PWM pin for the EGT gauge
-- PWM frequency is set to 1 kHz, with a duty cycle of 0%.
egt_probe = hw_output_pwm_add("EGT Gauge", 1000, 0.)

--Create a interpolate table. These values you will have to determine.
egt_table = {{0 , 0},
                     {200 , 0.2},      
                     {400 , 0.4},
                     {600 , 0.6},
                     {800 , 0.8},
                     {1000 , 1}}
                     
--Subscribe to the EGT dataref and drive the PWM                     
 xpl_dataref_subscribe("sim/cockpit2/engine/indicators/EGT_deg_C","FLOAT[8]"  , function(egt_val)
 -- We can change the duty cycle runtime,                
 hw_output_pwm_duty_cycle(egt_probe, interpolate_linear(egt_table,egt_val[1]))                               
end)  
The code for the LED method is basically the same.
However, Joe has guided you with the PWM method so stick with that.

Keith
Keith / Joe,

To get the real gauge to sync with the Xplane aircraft gauge I assigned a temp value to all 21 tick marks on the gauge.
The process was to load up Xplane and start a flight with my Piper aircraft.
I recorded all 21 temps from the Xplane dataref that is used in the code above. The first three tick mark temps I got by setting mixture to rich, prop full and then advancing the throttle from idle to full.
The first tick mark temperature value was at idle or very close to it. It was a little tricky to determine the temp value when the needle is at the bottom of the scale but eventually I settled on 1250 for the lowest temp when the engine is running and the EGT needle was on the first tick mark. That could be a lower temp by 100 degrees or so but this seemed to work. At idle it settles at the range of 1050 to 1250 before the needle starts moving to the next tick or starts to kill the engine.
I then advanced the throttle until the temp reached the second tick then the third tick and recorded those temps. Then going to full throttle with full mixture the EGT needle peaked at the 4th tick mark.

After recording those first 4 tick temps I began leaning the mixture. As the mixture is leaned the temperature begins to rise and I was then able to record the temps for tick marks 5 through 18. For tick marks 19, 20 and 21 I had to reduce the prop RPM from full until the needle went through the last three ticks and peaked at about 1700 degrees at the top tick mark.

After I recorded all of those temps, I went back to the instrument test program in AM and by scrolling with the mouse wheel (what seemed endlessly at 1/10,000 of a unit at a time) through each of the tick marks and recorded the corresponding duty cycle. It was a little more troublesome because the real needle seems to hang slightly during the movement. I had to once in a while tap the gauge to free up the needle.

After placing all of those values in the EGT code table, it brought the real instrument and the sim instrument more in sync. It's not exactly perfect but pretty close now.
The real gauge now follows the sim gauge within one or two ticks or in some cases right on the money. I might be able to fine tune it even more.

One thing I noticed as I was using the mouse to scroll through the duty cycle numbers the needle was hanging up slightly. I had to tap the gauge once in a while to make sure the gauge needle was moving freely.
Attachments
image.png

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: How to connect a Moving coil gauge

#126 Post by Keith Baxter »

Hi,

Well done Kirk. Glad you got it sorted.

Remember to remove the print statement at line 35.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: How to connect a Moving coil gauge

#127 Post by jph »

Interesting, as I mentioned before, the gauge is 1200F to 1700F on the ticks. A quick image search on google for 'piper egt gauge' will show.
https://www.google.com/search?q=piper+e ... =635&dpr=1

Which do you believe also ? :) the readings from X-Plane, or the reading shown on the aircrafts x-plane gauge (NOT necessarily the same)
I would rather, initially, believe the X-Plane data as the X-Plane engine and modelling is pretty damn good but it is not always the case as some are specifically tweaked.

If you were to, for instance, accept that the EGT float values from X-Plane were the ones to use, then you would calibrate the 'real' gauge to that, where the First large tick is 1200F and each Large tick after is plus 100F, the intermediate small at 25F separation. Final large tick is 1700F.

As for finding the actual gauge PWM Duty Cycle settings it is important to make sure you are looking absolutely 100% square on to the gauge and also better to start at the top end (the 1700 mark) and work down 25 degrees C at a time (one tick) as the return spring, although light, is very slightly helping against an old gauge that may be a bit sticky.

I would be VERY tempted to simply set the gauge at the final tick (1700F) making sure you are looking absolutely square on and read the PWM, then at the fist tick (1200F) and again square on read the PWM then the gauge scale from first tick to last is a single interpolate between the two readings - not counting for the slight below 1200 to left stop , and above 1700 to right stop which could be accounted for after you have tested it.
It would certainly be interesting and should be more accurate. The only usual need for the multiple interpolate is a non linear gauge scale. This is not, it IS linear as we can see from other real world piper gauge examples that have the scale written on and the values from X-P are also a purely linear format , so there should be no issue really. You certainly should not be seeing a 50C variation (2 ticks). That could be simply the coding of the graphical gauge within X-P.

Also, has the gauge designer (the graphical gauge) made his own correction table ?. The way you can tell this is simply to look at the graphical gauge in X-Plane and the dataref values in F. Do they correspond exactly to the tick marks on the graphical gauge using the 1200 to 1700 scale at 25F tick separation ? - if not, that could be by design or by poor design of the original graphic panel gauge. Both are equally possible.

The joy of simulating data :lol:

Well, at least now you have all the tools. With Keith's nice code and test tool you can do anything and you seem to understand it ok.

As for the very fine step for the excellent test unit code , you can change it (I am sure @Keith Baxter Keith won't mind) to n_val= var_cap(n_val+(dir/200),0,1) instead of n_val= var_cap(n_val+(dir/1000),0,1) to give you a step of .005 as opposed to .001

As said now you have all the data you can experiment to your hearts content.

enjoy.
Joe
Joe. CISSP, MSc.

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: How to connect a Moving coil gauge

#128 Post by Kaellis991 »

Joe,

The very first gauge I received, that I damaged, had a legend with the scale calibration as shown in the first image below. The tick marks are closer together on the right hand side of the scale and a large tick mark dead center.
This is the same legend used in the JustFlight Piper Arrow I am running in Xplane.

The last EGT I purchased, which is the one I am using, came with the legend as shown in the second image.
The tick marks on that legend were evenly spaced with no tick mark in the center.

I took a chance and swapped out the legends to use the one that matches the aircraft in Xplane.
Because all of the tick marks are not equally spaced along the scale I used, it prompted me to identify each of the temp numbers from the Xplane datarefs rather than letting the code do a linear interpolation.
It may have been overkill, but I feel It was a way to get the two gauges to sync.

06C0B8D4-E6BA-402B-9602-1706CC9C9CF5.jpeg
3EF3D929-65F0-4841-911E-94C1A4E731F1.jpeg

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: How to connect a Moving coil gauge

#129 Post by jph »

Hi Kirk, yes, that would make a difference and definitely need interpolating. The great thing is you have time in the actual type of aircraft so have a good indicator on behaviour. I have not flown any Piper model, but have flown aircraft with the same donkey fitted :D .

excellent work. Great addition to the panel.
Joe
Joe. CISSP, MSc.

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: How to connect a Moving coil gauge

#130 Post by Kaellis991 »

Joe,

Again, thanks for all of your help, as well as the support I received from Keith.
Now I can move on to the next components.

Coming up next are the flap handle and rheostats in my switch panel.
Then comes the ULN2803A relay for my landing gear lights and the autopilot switches.

Kirk

Post Reply