[simpits-tech] Arduino victory!

dabigboy at cox.net dabigboy at cox.net
Mon Aug 6 17:42:03 PDT 2012


---- geneb <geneb at deltasoft.com> wrote: 
> On Sun, 5 Aug 2012, dabigboy at cox.net wrote:
> 
> > Well, this non C coding, Python welding cockpit builder has just 
> > achieved another little victory: I am driving a real Cessna OAT (outside 
> > air temp) gauge with an Arduino, from within Python on my laptop. I had 
> > to use a resistor to pull voltage down, otherwise even low PWM duty 
> > cycles overwhelmed the little temp gauge, resulting in a very poor 
> > resolution (basically the gauge would max out at a cycle of 24 out of 
> > 255 pulses). Calibration is not exactly perfect, but it's close enough 
> > for now. I think the serial comms was the hardest part! Working great 
> > now...more importantly, I am sending two pieces of data (temp and flap 
> > setting) and am able to keep them straight in the Arduino...yay!
> 
> Congrats!
> 
> An easy way to improve the accuracy of the gauge would be to find out what 
> the min/max drive values are and then use the map() function to map 
> temperature values coming from the simulator to the gauge position.  I 
> used the scaling algorithym(sp?) that map() uses when I did my airspeed 
> indicator demo a few years ago.
> 
> g.

Hmmm I had not heard of map() before....I just looked it up. If I understand this correctly, it would provide a handy way for me to define a function that matches the curve and units of my temp scale, and then apply it to whatever temp reading is coming from the sim, no? I already found the min/max PWM values for the gauge, what I'm doing now is adding a fixed number to my temp value (since the gauge reads temps down to -50, and obviously I need to send values greater than 0 to the PWM pin). I figured, based on the min and max values only, the ratio of temp units to PWM units (my PWM range is still a bit less than the temp range....about 140 steps over a 170*F gauge). But this does not give me perfect results, and it appears to be for two reasons:

1: The gauge's scale is slightly non-linear....for example, -50 to 0 is finer than 0 to +50, and anything over 100 gets a slightly different scale also.
2: Response of the needle doesn't seem to be perfectly linear with PWM duty cycle; I'm guessing the resistance of whatever element was in the original temp probe on the aircraft is non-linear, and the gauge was just designed to match this.

My hack for the moment is to add a different offset to the temp value before converting it to PWM units...it comes reasonably close at most temps. I could probably just tack on a few more unique offset ranges and get the temp real close.

Getting a larger resistor might allow me to go 1-to-1 temp vs PWM values, which I suppose would simplify the calibration routine (code-wise and in my head also). But right now I am using basically "free" electrical components: this particular big ol' resistor was pulled from the video/sweeper logic board from my gutted Bendix weather radar unit, which also includes a host of other lovely goodies. :)

Matt


More information about the Simpits-tech mailing list