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

#111 Post by Keith Baxter »

Hi Kirk,

Ok so you are flashing the Leonardo with Air Manager and I suggest, as you did, using pin D9 as first choice and D5 as second choice. The other two outputs "might" cause issues. I have had issues on a mega2560 where pin frequencies need to be the same as another one.

In the instrument code I use this dataref and lets stick with that. That is the dataref I use in most of my instruments. Whilst the dataref <says deg_C>, some airframes change the value to °F. We will cross that bridge later if we have to.
"sim/cockpit2/engine/indicators/EGT_deg_C","FLOAT[8]"

The temp values are not important with the test instrument tool. The tick marks are.
So run the test instrument and get the tick mark values and add them to the list below.
After that revert and we will discuss the temperature values to apply to the tick marks.

0 = 0
n1 =
n2 =
n3 =
n4 =
n5 =
n6 =



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

#112 Post by jph »

Nice going guys.
Re the Leonardo. Yes, D9 is the first pin you would use. Then any of the others. Using any other than D9 would presume you have already set D9 as PWM out and all the Asterix comment is saying is the the frequency is fixed on all to whatever is on D9 - they follow that - note, this is frequency, not duty cycle, duty cycle is totally independent for all channels of course. So with just one PWM you would use D9 only. It is quite common that the Hardware PWM module shares a set frequency with other channels.

Kirk, re datasheets. When you work with these units commercially - as I did for several years freelance and 30 years hobby - well mainly the microchip PIC 18F series, then you have to know the datasheet virtually inside out as you are using most modules depending on project. It is always at hand as a reference. As you are programming a 'family' of devices 80% plus tends to be the same so a lot of the info is common. Also one datasheet is very similar to another. A bit like a car manual. They all have common features and specialist ones.
Joe. CISSP, MSc.

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

Re: How to connect a Moving coil gauge

#113 Post by Kaellis991 »

Keith,

The Leonardo I am using is flashed for AM and is being used for my magneto key starter switch. Which is working great using pins D10 thru D13 and now pin D5.
I was using D9 for one of the starter positions but changed that to D5 to free up D9 for the EGT.

I created the test instrument using the test code. And added it to my Piper Panel.
With that test instrument running after I turn on the light bulb for my Piper Panel I get a large black box with red numbers up in the upper left corner of that black box.

Rotating the mouse wheel increments that number from 0 to 1 in .001 increments. At first I wasnt sure it was working because I kept rolling the mouse and nothing was happening.
It wasnt until I got to around .600 that I started to see the needle move. That takes a lot of mouse wheel revolutions at .001 increments to go from 0 to .600

So here is what I get....Needle at low = .625----Needle full is .975
Do I record the values at every tick mark? All 21 of them, small and large?
EGT Low.jpg

EGT Full.jpg

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

Re: How to connect a Moving coil gauge

#114 Post by Keith Baxter »

Hi,

Spot on Kirk. Well done. Awesome that you previous work with Joe's help is now showing promise. I think @jph drinks milk. ;) No wait @Ralph is the cow guy. :?

You do not have to add the test instrument to your panel. Just run it in create/edit. We are just getting values for our interpolate table.

Yes, there would be a big difference between nil and the first < big tick > mark. Do not worry about that. It is within the scale scope. We can fix it so that when a dataref value is read, the pointer moves to the first tick mark.


Just record the values at the LARGE tick marks and complete the table.

0 = 0
n1 = 0.625
n2 =
n3 =
n4 =
n5 =
n6 = 0.975




Keith
Last edited by Keith Baxter on Mon May 30, 2022 2:31 pm, edited 1 time in total.
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

#115 Post by Kaellis991 »

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,
The values have been recorded.

I am still a little fuzzy though on the use of Instruments vs. hardware in Air manager.
With that code you posted above is that to be added to a new instrument or a new hardware function or both?

Also In the abitrary values under the egt_table you have large value numbers, 200, 400 etc, with a comma and then what I assume is to be the fractional number I just recorded.
In your last post you show n1, n2, etc. = the value...

Do I actually use the numbers 200, 400, 600 etc. and those represent the large tick marks in equal intervals between 0 and 1000.... Five total ticks after the zero tick mark?

Is this what my table list will be with the values that I have determined? My zero location has a value of .625. Does that reside in the brackets in the top egt_table line?

egt_table = {{0 , 0.625},
{200 , 0.677},
{400 , 0.745},
{600 , 0.811},
{800 , 0.888},
{1000 , 0.975}}

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

Re: How to connect a Moving coil gauge

#116 Post by Keith Baxter »

Hi,

No. You are running before crawling.

We have now established the tick mark values

0 = 0
n1 = 0.625
n2 = 0.677
n3 = 0.745
n4 = 0.811
n5 = 0.888
n6 = 0.975

We are going to use these values in our interpolate table. So replace the <egt_table> with this.

egt_table = {{0 , 0},
{982 , 0.625},
{1038 , 0.677},
{1093 , 0.745},
{1145 ,0.811},
{1205 ,0.888},
{1260 ,0.975}}


I have done a hardware instrument using those values. Name it what you prefer. I called it "Kirks EGT Gauge" and it is a "hardware function instrument".
Here is the code.

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 were determined via the test instrument tool
egt_table = {{0 , 0},
             {982 , 0.625},
             {1038 , 0.677},
             {1093 , 0.745},
             {1145 ,0.811},
             {1205 ,0.888},
             {1260 ,0.975}}
                     
--Subscribe to the EGT dataref and drive the PWN                     
 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) 
And this is the HW instrument.
Kirks EGT Gauge - .siff
(2.19 KiB) Downloaded 65 times

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

#117 Post by jph »

Keith Baxter wrote: Mon May 30, 2022 2:06 pm I think @jph drinks milk. ;) No wait @Ralph is the cow guy. :?

Keith
Tea total these days unfortunately Keith, and lactose intolerant so can't even sample @Ralph Ralph's delicious dairy products ! :cry: .. (Tea total courtesy of diabetes for an early 65th birthday present) :( .. catching you up you old git. ;)

Out of interest and FYI, the scale on that instrument is, I believe, from 1200F to 1700F

Great work on the code bud. Nice one. !
Joe
Joe. CISSP, MSc.

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

Re: How to connect a Moving coil gauge

#118 Post by Keith Baxter »

jph wrote: Mon May 30, 2022 3:01 pm
Keith Baxter wrote: Mon May 30, 2022 2:06 pm I think @jph drinks milk. ;) No wait @Ralph is the cow guy. :?

Keith
Tea total these days unfortunately Keith, and lactose intolerant so can't even sample @Ralph Ralph's delicious dairy products ! :cry: .. (Tea total courtesy of diabetes for an early 65th birthday present) :( .. catching you up you old git. ;)

Out of interest and FYI, the scale on that instrument is, I believe, from 1200F to 1700F

Great work on the code bud. Nice one. !
Joe
Cool Joe

Thanks for the instrument temp scale. That is a easy fix.
Lets wait for Kirk feedback before we venture there.

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

#119 Post by Kaellis991 »

Keith / Joe,

Here's my feedback.....Where's the single malt? It's a holiday.....

I have had some success....the mixture control is definitely affecting the real gauge but my real EGT is not matching the EGT in the aircraft that I have running in Xplane.
Is that because the values for the temps are not correct?

Let's see if I can explain....
Throttle set to idle, mixture is full...Xplane gauge shows temps at the 1st large tick mark but my real EGT is pegged at full deflection.

To get the real EGT needle to drop requires moving the mixture handle down about 2/3 of its travel from full mixture setting
There is a very small range around 1/3 up the mixture travel where the needle will swing from 0 to max. with a mixture handle movement of about 1/2".

When the needle on the real gauge does start to move it moves in large increments...then slows and then speeds up...it sorta pulses as it travels from min. to max. and vice versa...

Right around here is where the handle only needs to be moved less than 1/2" to change the real gauge from min. to max. deflections.
image.png
Edit: Do these values help? The top image is with 1/3 mixture to increase the temps to max. The second image is mixture almost at cutoff...
image.png
image.png

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

Re: How to connect a Moving coil gauge

#120 Post by Kaellis991 »

jph wrote: Mon May 30, 2022 1:17 pm Nice going guys.
Re the Leonardo. Yes, D9 is the first pin you would use. Then any of the others. Using any other than D9 would presume you have already set D9 as PWM out and all the Asterix comment is saying is the the frequency is fixed on all to whatever is on D9 - they follow that - note, this is frequency, not duty cycle, duty cycle is totally independent for all channels of course. So with just one PWM you would use D9 only. It is quite common that the Hardware PWM module shares a set frequency with other channels.

Kirk, re datasheets. When you work with these units commercially - as I did for several years freelance and 30 years hobby - well mainly the microchip PIC 18F series, then you have to know the datasheet virtually inside out as you are using most modules depending on project. It is always at hand as a reference. As you are programming a 'family' of devices 80% plus tends to be the same so a lot of the info is common. Also one datasheet is very similar to another. A bit like a car manual. They all have common features and specialist ones.
Joe,
Great fill-in-the-blanks explanation about what that asterisk comment really means.

Post Reply