Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing TC offset steps to 0.10f #235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CoryCharlton
Copy link

Fixes #232

@borland1
Copy link

borland1 commented Nov 1, 2022

After reconsidering this problem, I found that there are limits to how fine the LCD Setup Menu adjustments can be easily made. This is because the settings are saved to limited EEPROM space and the fact that the associated variables 'minval', 'maxval', and 'offset' are saved in EEPROM space as 8-bit integers.

See in header file setup.h:

typedef struct {
	const char* formatstr;
	const NVItem_t nvval;
	const uint8_t minval;
	const uint8_t maxval;
	const int8_t offset;
	const float multiplier;
} setupMenuStruct;

As an example, uint8_t is 1-byte unsigned with range of only 0 to 255, while int8_t is 1-byte signed with range of only -128 to 127.

Here are some acceptable changes that increase the resolution of LEFT and RIGHT TC's, for both GAIN and OFFSET values, configured in the LCD Setup Menu, with the following changes made to file setup.c.

static setupMenuStruct setupmenu[] = {
	{"Min fan speed    %4.0f", REFLOW_MIN_FAN_SPEED, 0, 254, 0, 1.0f},
	{"Cycle done beep %4.1fs", REFLOW_BEEP_DONE_LEN, 0, 254, 0, 0.1f},
	{"Left TC gain    %1.3f", TC_LEFT_GAIN , 150, 250, 50, 0.004f},    //  <-------
	{"Left TC offset  %+1.1f", TC_LEFT_OFFSET, 0, 250, -125, 0.20f},   //  <-------
	{"Right TC gain   %1.3f", TC_RIGHT_GAIN, 150, 250, 50, 0.004f},    //  <-------
	{"Right TC offset %+1.1f", TC_RIGHT_OFFSET, 0, 250, -125, 0.20f},  //  <-------
};

Note the blank spacing changes in the text labels, before the "%", as this changes the position of the displayed text on the LCD Setup menu. Changes also corrects for the current inverse texting artifact at the far right of the display, when LEFT or RIGHT TC OFFSET values are too negative (compare the two images shown below).

The above changes will allow setting:
Left and Right TC Gains in range of values between 0.800 and 1.200 in increments of 0.004, and
Left and Right TC Offsets in range of values between -25.0 and +25.0 in increments of 0.2 degrees C.

Setup Menu with above changes..
T962SetupMenu

For comparison, Setup Menu with stock firmware V.0.5.2..
T962reflow18

To get the above changes to work with the oven TC sensors, some additional changes are needed in files setup.c, setup.h, and sensor.c. Similar to what's done in the setup code file, the sensor code file also converts RAW data values read from EEPROM memory, to the real data values ( i.e., the Left and Right TC Gain and TC Offset ) so that they are consistant with what's shown on the LCD display Setup/Calibration Menu, using the data conversion parameters (i.e., offset and multiplier). The conversion parameters were hard coded in the sensor code file too, so rather than editing the hard coding in two separate files, the following changes eliminate the need for that.

Specifically, in file setup.c,

image

change line 26, as follows..

    const setupMenuStruct setupmenu[] = {

In file setup.h,

image

add a new line after line 12, as follows..

    const setupMenuStruct setupmenu[6];

In file sensor.c,
image

add a new line after line 11, as follows..

   #include "setup.h"

Also in file sensor.c,

image

change the following lines,

line 44, as follows..

   adcgainadj[0] = ((float)temp + setupmenu[TC_LEFT_GAIN].offset) *
						setupmenu[TC_LEFT_GAIN].multiplier;

line 51, as follows..

   adcgainadj[1] = ((float)temp + setupmenu[TC_RIGHT_GAIN].offset) *
						setupmenu[TC_RIGHT_GAIN].multiplier;

line 58, as follows..

   adcoffsetadj[0] = ((float)temp + setupmenu[TC_LEFT_OFFSET].offset ) *
						setupmenu[TC_LEFT_OFFSET].multiplier;

line 65, as follows..

   adcoffsetadj[1] = ((float)temp + setupmenu[TC_RIGHT_OFFSET].offset ) *
						setupmenu[TC_RIGHT_OFFSET].multiplier;

That is all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

For Setup/Calibrations OFFSET Parameter for Left and Right TCs are Too Course
2 participants