|
|
View previous topic :: View next topic |
Author |
Message |
temtronic
Joined: 01 Jul 2010 Posts: 9377 Location: Greensville,Ontario
|
|
Posted: Thu Nov 25, 2021 5:21 pm |
|
|
this .....
Quote: | I write some calibration data (fairly accurate and good enough for the first start-up) to the SAF when I program the µcontroller for the first time.
Then I execute a calibration routine to save the exact values to the SAF. |
has me confused.
Why do you put in known bad calibration data THEN actually run a 'calibration routine' and the save the GOOD data ?
While you don't say what the device is you're calibrating, the first operations are pointless. You could just as easily store in ROM and then run the calibration routine, even then, it's still a waste of time and code as you run a real 'calibration routine'.
Also how many bytes of 'data' are needed to be saved ?
It may be possible to write them to some area of memory. when the program then runs the 'calibration routine', can we assume you'll ask 'do you want to use the new calibration or the old one' ??
If this project requires a RealTimeClock, all have battery backed RAM, some EEPROM, that could easily be used for a few bytes of 'calibration data'. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19658
|
|
Posted: Fri Nov 26, 2021 1:25 am |
|
|
I suspect things are being made harder than they need to be.
Have the genuine configuration data start with a flag to say 'real data'.
Something that is unlikely to happen accidentally like 0x55AA.
Then the code reads the flag. If the flag is not 0x55AA, load your
'good enough' values. You can do this simply by declaring the structure
that contains the values with default values. No need for these to ever
be put into the ROM.
So if you have the structure something like:
Code: |
char tbuff[20]; //ram buffer for temporary I/O
uint16 check;
struct cal {
unsigned int16 flag;
float lowcal;
float hical;
} cal_data = {0,0.13456, 0,456789};
read_program_memory(0xF80, tbuff,4);
check=make16(tbuff[2],tbuff[0]);
if (check==0x55AA)
{
//here flag is legitimate, so load now the data
}
//if the flag was right, we have now loaded the cals, otherwise
//we still have the values defined in cal_data.
|
Before you write the cal_data, you make sure that flag is set to 0x55AA
Then write all the data including the flag.
Now remember you can only store whole bytes in the low 8 bits of
each instruction word, so you will need to move the bytes to the
correct locations in the buffer before you write, and copy the bytes
from alternate locations when you read. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9377 Location: Greensville,Ontario
|
|
Posted: Fri Nov 26, 2021 6:40 am |
|
|
curious...
Still have no idea WHAT this 'calibration data' is for.
Historically 'cal data' is for a specific sensor, tested under strict, known conditions. Usually for it's end use. They also get recalibrated on a time schedule (once per year) or 'hours of use'.
If an analog sensor, several readings are done to ensure accurate calibration.
so.... it'd be nice to know what sensor is being used here, storing 'bad' cal data could lead to very bad results depending on what the PIC is controlling !! |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|