Electronics > Repair
HP 3478A: How to read/write cal SRAM
<< < (20/41) > >>
steve1515:
Hmm... I took a look at what my code would return for these example results and I get something different when the raw value is equal to 8. It looks like it's possible that I have a bug where I should be subtracting 16 when the nibble is >= to 8 instead of just > 8. (I'm missing the equal sign.) If I make that correction, I get the same results as fenugrec.

This is what I'm currently getting:

--- Code: ---Raw    Gain
13F1C    1.012906
fff1c    0.988906
88888    1.088888

--- End code ---

This is what fenugrec's code returns:

--- Code: ---Raw    Gain
13F1C    1.012906
fff1c    0.988906
88888    0.911112

--- End code ---

Note the difference in the last entry. I suppose I should hold off on making any correction since fenugrec believes we might both be doing something incorrect in the decoding. I'll go with whatever fenugrec says since he understand the firmware much more then I do. :)

fenugrec, what do you think? Should I make the correction or should we look into this some more?
fenugrec:
Hi Steve,


--- Quote from: steve1515 on January 21, 2020, 09:20:43 pm ---Should I make the correction or should we look into this some more?
--- End quote ---

IMO it wouldn't hurt to run a few more tests. One could simply hook up the meter to a reasonably stable source (or resistor), and try a bunch of different gain constants and note the results. We did this a while ago but only crudely with 3-4 constants IIRC.

Now I'd be curious to test one range with offset=0 and gain=00000 then changing some gain digits for key values, i.e. 0,7,8,9,A,F. I'd try changing maybe the first and 3rd digit, so around a dozen tests in total (i.e. 00000, 70000, 70700, etc) plus maybe the two extremes, 77777 and 88888. Still fairly simple, and definitely easier than analyzing 8048 assembler.
lmester:
Steve,

With the test data I get the same results as you. It looks like I did implement your gain unpack code correctly.


--- Code: ---Raw    Gain
13F1C    1.012906
fff1c    0.988906
88888    1.088888
--- End code ---



Since I'm allowing the user to edit a gain or offset value I first must unpack the data. After the user submits the revised value I then re-pack it with a new checksum.

It looks like the problem is in my code to re-pack the gain value.  I'm getting different results on two of the three test gains.


--- Code: ---Decode Value Encode Value
13F1C 1.012906 13F1c 1.012906
FFF1C 0.988906 0110F 1.001099
88888 1.088888 FFFFE 0.988888


--- End code ---

It looks like what I need is a correct algorithm for re-packing the gain into the meter calibration format. Mine is not working correctly for all gain values.

Would you or fenugrec be able to help me get the gain data properly re-packed? Also, let me know if I need to make changes in the unpack algorithm.

Below is the flawed function that I'm currently using.


--- Code: ---function RevGain$(g)   
'reverse gain. calculate gain encoded value in hex.
'Uncompressed gain in g. Returns encoded gain in RevGain$ 
gt=g-1 '?? 1 is a constant & not used in the calc. is this correct ??
RevGain$="" 'Build new string into a null string.
for i = 6 to 2 step -1
    'Add any needed trailing 0's to get i digits in number
gd=val(right$(mid$(str$(gt)+"00000",1,i+2),1))

    if gd>5 then
        cd=gd+6
        gt=gt+(10-gd)*10^-i
    else
        cd=gd
        gt=gt-gd*10^-i
    end if

    gt=int((gt+(5*10^-11))*10^10)/10^10 'round off to fix compiler math error
    RevGain$=dechex$(cd)+RevGain$ 'Build compressed gain hex string.
 
next i
end function
--- End code ---
fenugrec:

--- Quote from: lmester on January 22, 2020, 02:28:29 pm ---Would you or fenugrec be able to help me get the gain data properly re-packed? Also, let me know if I need to make changes in the unpack algorithm.

--- End quote ---

Sure, but as I mentioned we may be slightly wrong (or at least uncertain) about the decoding; it would be really good to do some kind of test as I described, before spending too much time on a possibly-wrong encoding implementation.
Miti:
I could help in the weekend. I have a reasonably accurate and stable 3V reference made with MAX6126A. If you can tell me exactly what offsets and gains you want to check, I’ll give you the readings.
Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod