开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: LOOKING FOR HELP ADDING USB TO EXISTING BITX40 ARDUINO SKETCH


 

I made 2 functions and call them from the the usb / lsb case button (in bold)

It compiles and i can tune lsb but usb does not seem to work.

However, if i change th - to a plus in the if_offset - Usb seems to be there.

I


#ifdef IF_Offset
?uint32_t vco = bfo - (vfo * SI5351_FREQ_MULT);
?si5351.set_freq(vco, SI5351_CLK0); // WAS 0
?tbfo = "LSB";
?si5351.drive_strength(SI5351_CLK0,SI5351_DRIVE_8MA);?

#endif


I tried the other frequencies but they thru of the cal.


Joe
ve1bwv


buttonState3 = digitalRead(buttonPin3);
? if (buttonState3 != lastButtonState3) {
? ? if (buttonState3 == HIGH) {
? ? ? buttonPushCounter3++;
? ? ? switch (buttonPushCounter3) {
? ? ? ? case 1:
? ? ? ? ? Serial.println("USB");
? ? ? ? ? tft.setFont();
? ? ? ? ? tft.setTextSize(1);
? ? ? ? ? tft.fillRect(130, 225, 60, 15, GREY);
? ? ? ? ? tft.drawRect(130, 225, 60, 15, GREY);
? ? ? ? ? tft.setCursor(142, 229);
? ? ? ? ? tft.setTextColor(DARKGREY, GREY);
? ? ? ? ? tft.print("SSB/CW");
? ? ? ? ? delay(100);
? ? ? ? ? tft.fillRect(130, 225, 60, 15, DARKGREY);
? ? ? ? ? tft.drawRect(130, 225, 60, 15, GREY);
? ? ? ? ? tft.setCursor(142, 229);
? ? ? ? ? tft.setTextColor(WHITE, DARKGREY);
? ? ? ? ? tft.print("SSB/CW");
? ? ? ? ? delay(100);
? ? ? ? ? tft.fillRect(269, 130, 44, 18, BLACK);
? ? ? ? ? tft.setFont(&FreeSans9pt7b);
? ? ? ? ? tft.setTextSize(1);
? ? ? ? ? tft.setCursor(270, 145);
? ? ? ? ? tft.setTextColor(WHITE, BLACK);
? ? ? ? ? tft.println("USB");
? ? ? ? ? void usbjoe();

? ? ? ? ??
? ? ? ? ? break;
? ? ? ? case 2:
? ? ? ? ? Serial.println("CW");
? ? ? ? ? tft.setFont();
? ? ? ? ? tft.setTextSize(1);
? ? ? ? ? tft.fillRect(130, 225, 60, 15, GREY);
? ? ? ? ? tft.drawRect(130, 225, 60, 15, GREY);
? ? ? ? ? tft.setCursor(142, 229);
? ? ? ? ? tft.setTextColor(DARKGREY, GREY);
? ? ? ? ? tft.print("SSB/CW");
? ? ? ? ? delay(100);
? ? ? ? ? tft.fillRect(130, 225, 60, 15, DARKGREY);
? ? ? ? ? tft.drawRect(130, 225, 60, 15, GREY);
? ? ? ? ? tft.setCursor(142, 229);
? ? ? ? ? tft.setTextColor(WHITE, DARKGREY);
? ? ? ? ? tft.print("SSB/CW");
? ? ? ? ? tft.fillRect(269, 130, 44, 18, BLACK);
? ? ? ? ? tft.setFont(&FreeSans9pt7b);
? ? ? ? ? tft.setTextSize(1);
? ? ? ? ? tft.setCursor(270, 145);
? ? ? ? ? tft.setTextColor(WHITE, BLACK);
? ? ? ? ? tft.println("CW");
? ? ? ? ? break;
? ? ? ? case 3:
? ? ? ? ? Serial.println("LSB");
? ? ? ? ? tft.setFont();
? ? ? ? ? tft.setTextSize(1);
? ? ? ? ? tft.fillRect(130, 225, 60, 15, GREY);
? ? ? ? ? tft.drawRect(130, 225, 60, 15, GREY);
? ? ? ? ? tft.setCursor(142, 229);
? ? ? ? ? tft.setTextColor(DARKGREY, GREY);
? ? ? ? ? tft.print("SSB/CW");
? ? ? ? ? delay(100);
? ? ? ? ? tft.fillRect(130, 225, 60, 15, DARKGREY);
? ? ? ? ? tft.drawRect(130, 225, 60, 15, GREY);
? ? ? ? ? tft.setCursor(142, 229);
? ? ? ? ? tft.setTextColor(WHITE, DARKGREY);
? ? ? ? ? tft.print("SSB/CW");
? ? ? ? ? tft.fillRect(269, 130, 44, 18, BLACK);
? ? ? ? ? tft.setFont(&FreeSans9pt7b);
? ? ? ? ? tft.setTextSize(1);
? ? ? ? ? tft.setCursor(270, 145);
? ? ? ? ? tft.setTextColor(WHITE, BLACK);
? ? ? ? ? tft.println("LSB");
? ? ? ? ? ?void lsbjoe();
? ? ? ? ? buttonPushCounter3 = 0;
? ? ? ? ? // void lsbjoe();
? ? ? ? ? break;
? ? ? ? ??
? ? ? ? default:
? ? ? ? ? // if nothing else matches, do the default
? ? ? ? ? // default is optional
? ? ? ? ? break;








void lsbjoe(){
uint32_t vco = bfo - (vfo * SI5351_FREQ_MULT);
si5351.set_freq(vco, SI5351_CLK0);?
? tbfo = "LSB";
? volatile uint32_t LSB = 1199850000ULL;
? bfo = LSB;
? si5351.drive_strength(SI5351_CLK0,SI5351_DRIVE_8MA); //you can set this to 2MA, 4MA, 6MA or 8MA WAS CLK0
? return;
}

void usbjoe(){
uint32_t vco = bfo + (vfo * SI5351_FREQ_MULT);
si5351.set_freq(vco, SI5351_CLK0); // WAS 0
?
? tbfo = "USB";
? bfo = USB;
? volatile uint32_t USB = 1200150000ULL;
? si5351.drive_strength(SI5351_CLK0,SI5351_DRIVE_8MA); //you can set this to 2MA, 4MA, 6MA or 8MA?
? return;
}

On Fri, Jul 28, 2017 at 12:45 AM, Jerry Gaffke via Groups.Io <jgaffke@...> wrote:
Looks like PD8W was written to drive the BFO with CLK0 from the Si5351 instead of using the Bitx40 analog BFO.
Though that is only activated if this line turns it on:
? ??#ifdef IF_Offset

My guess is that this never worked.

The PD8W code initializes the possible BFO frequencies in hundredths of a hz with these lines:

volatile uint32_t LSB = 1199850000ULL;
volatile uint32_t USB = 1200150000ULL;

The mistake I see is that the crystal filter is not centered on 12.000000mhz, it's more like 11.997000.
The value for LSB given above is correct if the VFO is operating down around 5mhz, the BFO is 1500 hz above the crystal filter center.
But the value for USB should be more like 11.995500 mhz, at 1500hz below the crystal filter center.

If the VFO is operating up at 19mhz, then we flip them so the BFO for USB is 11.9985 and for LSB is 11.9955 mhz.

If confused, read post ? ? /g/BITX20/message/24724
Note that I made the discussion easier to follow in post 24724 by assuming the filter is centered on 12.000mhz,?
but it is actually centered on something like 11.997000 mhz.

The filter uses the series resonant mode of the quartz crystals, and that series resonant mode is a few khz lower
in frequency than the parallel resonant mode marked on the the crystal as 12.000 mhz.
The analog bfo uses the crystal in the 12.000 mhz parallel resonant mode, that frequency is brought down a little bit by
adding capacitance.?

The Bitx40+Raduino as shipped does not have the Si5351's CLK0 driving the BFO,
that would require a hardware mod.? As shipped, only CLK2 of the Si5351 is used, to drive the VFO.

Jerry, KE7ER



On Thu, Jul 27, 2017 at 07:44 pm, Jerry Gaffke wrote:
I don't know anything about this PD8W code.
However, somewhere in the PD8W code it says:
? ??volatile uint32_t USB = 1200150000ULL;

That code you borrowed from Allard is treating the variable USB as a boolean,
so I assume Allard's version of the USB variable should have a value of either zero (false) or 1 (true):

if (USB) // if we are in UPPER side band mode
? ? si5351.set_freq((IF + Dial_freq) * 100ULL, SI5351_CLK2);
? else // if we are in LOWER side band mode
? ? si5351.set_freq((IF - Dial_freq) * 100ULL, SI5351_CLK2);//12-7 = 5


Join BITX20@groups.io to automatically receive all group messages.