¿ªÔÆÌåÓý

Re: Calibration


Jack Purdum
 

Hi Alf:

I still don't know for sure how the tuning constant is used. I'm replacing the Si5351 DDS with a modified version of our VFO board (Mar, 2016, QST) and a new TFT display so I haven't spent much time with the code. Because of the graphics display, I had to change out the Nano and go with the Mega 2560 Pro Mini. Those two boards sit on a custom PCB that plugs into the back of the display. (See picture.) Dennis (W6DQ) is working on the circuitry for an RF AGC, S meter, and CW mode. When I get the mods done, I will likely write the last-used frequency, WPM, and mode to EEPROM and then put a call to read those values out in setup() so they are active on power-up. I'm hoping to learn more about the Raduino code when I start digging around for my own code.

If I do find something, I'll let the group know.

Jack, W8TEE



From: alf <fpdbase@...>
To: [email protected]
Sent: Thursday, February 16, 2017 7:26 AM
Subject: Re: [BITX20] Calibration

Jack Purdum via Groups.Io wrote:
> Around line 275 in the Raduino.ino file are a series of calls that
> write the calibration number to EEPROM as a /long/ data type to the
> first 4 bytes of EEPROM. What's interesting is that there is no
> /EEPROM.read()/ call in the code to fetch it on power up. Unless there
> is some way to write the offset to the Si5351, I don't understand what
> the /EEPROM.write()/ is for. Also, the current code makes the
> programmer know (guess??) whether numbers are stored Big Endian or
> Little Endian.
>
> A more portable and easier way would be in the /calibrate() /function:
>
> cal = (cal * 10000000l) / frequency;
> EEPROM.put(0, cal);? ? ? ? ? ? ? ? ? //Write the 4 bytes into the
> eeprom memory at location 0
>
>
> //cal = (cal * 10000000l) / frequency;? ? ? ? ? ? // Original code...
> //Write the 4 bytes into the eeprom memory.
> //EEPROM.write(0, (cal & 0xFF));
> //EEPROM.write(1, ((cal >> 8) & 0xFF));
> //EEPROM.write(2, ((cal >> 16) & 0xFF));
> //EEPROM.write(3, ((cal >> 24) & 0xFF));
>
> When you need to retrieve /cal/, use:
>
> EEPROM.get(0, cal);? ? ? ? ? ? ? ? // Read 4 bytes from EEPROM at
> memory address 0
>
> This might even save a few bytes of code space. The /put()/ and /get()
> /methods work because the underlying C++ compiler can use indirection
> without the address-of operator (&) by using the variable as a
> reference object.
>
> Also, don't forget to replace /sprintf() /in the code, which will also
> save some code space. (That was discussed in an earlier post.)
>
> I haven't read through the code closely enough to see how
> the/calibrate()/ function works. However, unless that result is stored
> in EEPROM or some other non-volatile code space, I don't see how it
> works on subsequent powerups.
>
> Jack, W8TEE
> ------------------------------------------------------------------------
>
Hi Jack et al,
? ? ? ? ? ? ? ? ? ? On investigating the calibration routine, its
values are being stored in the eeprom, however there is no function to
retrieve them in the setup routine on startup. In the main loop
function, the doTuning() is active controlling the vfo frequency and
updating the display. The frequency upon starting is determined by the
position where tuning potentiometer happens to be. On my Bitx-40 I used
a momentary switch connected to one of the digital pins to provide a
Lock/Unlock function, now when powering up, a boolean flag is tested for
the Lock/Unlock inhibiting the doTuning(), this allows the changes I
made to setup() to retrieve the stored calibration and set the si5351 to
the wanted frequency.

? Just a code snippet, lots more fun to be had, looking forward to
others ideas.

? Alf vk2yac

#define LOCK (3) // pin to attach switch to

? int eeAddress = 0; //EEPROM address to start reading from

void checkLock() {
? if (digitalRead(LOCK) == HIGH)
? ? return 0;
? else
? ? ? if(lockUnlock)
? ? ? ? lockUnlock=false;
? ? ? ? else
? ? ? ? ? lockUnlock = true;
}

setup() {
? pinMode(LOCK, INPUT);
? digitalWrite(LOCK, HIGH);
? EEPROM.get(eeAddress, frequency);? ? ? ? ? ? ? ? // Read 4 bytes from
EEPROM at? memory? address 0
? setFrequency(bfo_freq - frequency);
? updateDisplay();
}

void loop(){

/*
? checkCW();
? checkTX(); */
? ? checkButton();
? ? checkLock();
? if(lockUnlock){
? ? ? doTuning();
? }
}





Join [email protected] to automatically receive all group messages.