S2000 coolant gauge working but need help

Testing and development of Megasquirt 3

Moderators: jsmcortina, muythaibxr

Post Reply
psifreak
MS/Extra Newbie
Posts: 2
Joined: Sat Dec 03, 2022 9:22 am

S2000 coolant gauge working but need help

Post by psifreak »

I have been messing around with the generic output code to drive a S2000 coolant gauge and I have got that working, however with the current way the code is written it affects every generic pwm table that is using "variable frequency" I cant seem to wrap my head around a way to have it affect only one of the tables like maybe only "generic pwm F" any help would be appreciated.

here is a snippet of my code from ms3_misc.c starting at line 3954.
//
if ((gp_stat & 0x30) == 0x20) { // variable frequency, fixed duty
unsigned int trig2;
unsigned char f;

/* use the duty variable as the frequency 1Hz */
f = *sw_pwm_duty;
if (f) {
f = f / 10;
trig = 9500 / f;
trig2 = 234;
trig = trig - trig2; /* maintain period and allow for rounding */
}
//
set the table up as a curve using coolant as the load axis a value of 10 will light up the first bar (well the one next to the one that is always lit) and a value of 60 will be full scale.
the formula does need some tweaking because it wont get to every bar because of rounding but that can be fine tuned later. It also probably doesn’t need the second “trig =” at all and the “f = f / 10” is a little hack but this was for proof of concept.
Thanks for any help.
psifreak
MS/Extra Newbie
Posts: 2
Joined: Sat Dec 03, 2022 9:22 am

Re: S2000 coolant gauge working but need help

Post by psifreak »

This code gives much better control over the output.
starting at line 3954
//
if ((gp_stat & 0x30) == 0x20) { // variable frequency, fixed duty
unsigned int trig2, j;
unsigned char f;

/* use the duty variable as the frequency 1Hz */
f = *sw_pwm_duty;
if (f) {
j = f * 38;
trig = 9600 - j;
trig2 = 234;
}
//
NOTE; inserting this code in the ms3_misc.c file will affect every table that has "variable frequency" selected.

using this code
bar 2 will be on with a value of 26, bar 3 will be on with a value of 93, bar 4 will be on with a value of 158,
bar 5 will be on with a value of 186, bar 6 will be on with a value of 207, bar 7 will be on with a value of 219.
bar 1 is always on that can't be changed its how the gauge is programmed.
it takes about 15 - 20 seconds for the gauge to react (longer if moving more than one bar) so keep that in mind when fine tuning the values to what you would like.
Post Reply