Overunity.com Archives is Temporarily on Read Mode Only!



Free Energy will change the World - Free Energy will stop Climate Change - Free Energy will give us hope
and we will not surrender until free energy will be enabled all over the world, to power planes, cars, ships and trains.
Free energy will help the poor to become independent of needing expensive fuels.
So all in all Free energy will bring far more peace to the world than any other invention has already brought to the world.
Those beautiful words were written by Stefan Hartmann/Owner/Admin at overunity.com
Unfortunately now, Stefan Hartmann is very ill and He needs our help
Stefan wanted that I have all these massive data to get it back online
even being as ill as Stefan is, he transferred all databases and folders
that without his help, this Forum Archives would have never been published here
so, please, as the Webmaster and Creator of this Forum, I am asking that you help him
by making a donation on the Paypal Button above
Thanks to ALL for your help!!


Arduino experience, someone?

Started by antimony, September 13, 2020, 12:37:45 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

EMJunkie

Quote from: onepower on September 16, 2020, 05:43:49 PM
cheors
Quote
You should use the PWM function to get a stable frequency :

PWM does not work well when generating or receiving radio frequencies other than PWM data because a radio signal is generally a sine wave not PWM. 

Note the PWM signal below, does that look anything like a sine wave?. So while a PWM signal could vary with time and invert periodically to produce a pseudo-sine wave it's just a very poor way of doing things. Antimony mentioned the better option which is to used a dedicated RF chip to manage AM/FM signal processing and modulation.

Regards







onepower is completely wrong!

Digital Radio Signals are the NORM today! See attached image.

onepower is very clearly very far behind on technology! Beware of his advice as it is not true and not correct!

This is terrible information please research what people say and cross reference all information!

Best wishes, stay safe and well in these dire times,
   Chris Sykes

onepower

Chris
Quoteonepower is completely wrong!
Digital Radio Signals are the NORM today! See attached image.
onepower is very clearly very far behind on technology! Beware of his advice as it is not true and not correct!
This is terrible information please research what people say and cross reference all information!

Oh dear, I'm not even sure how to respond to that, lol.

First the only literature I could find on all digital radio technology was science research papers from 2018-2019 so yes I may be a year behind cutting edge technology, not the first time. To date the only practical PWM sine wave generators I knew of were used in low frequency 60 Hz power inverter technology. However to my knowledge all digital radio's still use an analog signal generator as the carrier regardless of whether the modulation is AM, FM or Digital.

Second digital radio's still use an analog sine wave as the carrier signal and the digital part simply means sending binary code(one's and zero's) or numbers to represent the information just like a computer does not PWM. Digital; "expressed as series of the digits 0 and 1, typically represented by values of a physical quantity such as voltage or magnetic polarization." So digital doesn't mean PWM it means binary information (1 and 0). Hell, I was building this stuff yesterday using an two Arduino Uno's to send/receive digital information and my analog 433MHz TX/RX as the interface between them.

Do you always need to be such a drama queen Chris?, I mean really?. You seem like a smart guy then you pull this shit and come off sounding like a complete loser, your better than this in my opinion.

To ramble a bit, I actually thought of a Pulse Width Modulated pseudo-sine wave carrier signal years ago however the problem is bandwidth and time. It works like this, if my digital carrier is frequency X and I use a digital modulation of Y then obviously the resolution in bits per second of Y cannot be greater than X. Basically there is only so much information we can cram into a finite period of time. Thus the binary on/off nature of the carrier X starts eating into our allowable time for our binary information Y which is our limitation. Simply put, the PWM would have to be oscillating in the mid to upper GigaHertz range to make it a practical proposition which gets expensive and it's generally unstable.

Look at your router frequency of 2.4 GHz or the relatively new 5 GHz which apparently uses a 39 GHz oscillator... 39 billion cycles per second with a wavelength of 7.6 mm. Now imagine you want to generate a stable digital carrier frequency which needs to be magnitudes larger into let's say the low end like 100 GHz or 3 mm. You see were almost out of the RF band and into the microwave/infrared band of the EM spectrum. At which point the whole nature of the technology would need to change and were just not there yet.

Regards







antimony

I am really thankful for you guys taking your time to post in my thread, trying to help me out.

I have such a limited free time to do this stuff, but i always try to pay it forward all the help or consultation i have gotten from OU and all the other electronics forums i have been and am a part of when i can to help others, so i am really grateful.

I found this code yesterday when i was cruising google and this is probably the closest to what i need that i have found.
Here is the link.
http://www.n6qw.com/LCD_to_OLED.txt

And here is the code:

/*
  07/2017 From N6QW
This sketch is being used with a new transceiver build using a 4.9152 MHz HB Filter and a 1/2 OLED display.
The rig is called the Mini-Rig and is a 5 watt SSB Transceiver. Because of the use of the  TUF-1 set drive level to 8 MA

It will operate with the 1" OLED or the 1/2" OLED with no code changes.

Modified 7/2018 to operate with the dual VFO code
Modified to have two VFO's, Tune Function and CW ID

This is an upgrade to the Junk Box Rig
NOTE TO Builders -- you have to have the Rotary Files and the Si5351 File snad the Tone.h in the same folder as the sketch
These are included files -- so just loading the skecth in to an IDE will not make this play


*/
 
    #include <SPI.h>
    #include <Wire.h>
    #include "si5351.h"
    #include "Rotary.h"
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>
    #define OLED_RESET 4
    Adafruit_SSD1306 display(OLED_RESET);
    #include "Tone.h"
    #define TONE_PIN 6
    #define NOTE_B5  988
   
    #define ENCODER_B    2                     // Encoder pin A
    #define ENCODER_A    3                    // Encoder pin B
    #define ENCODER_BTN  A3
   
    Si5351 si5351;
    long int frq;

    int_fast32_t rx = 10378500L; // Starting frequency of VFO operating frequency plus offset which is selectable IF = 3.180 MHz
    int_fast32_t rx2= 0L; // variable to hold the updated frequency
    int_fast32_t increment = 100; // starting VFO update increment in HZ.
    int_fast32_t bfo = 3178500L; // default offset sideband inversion thus USB
    int_fast32_t rx1 = 10378500L;
    int_fast32_t rx3 = 10378500L;
    int_fast32_t vfoA = 1;
    int_fast32_t vfoB = 1;
    int_fast32_t old_vfoA = 1;
    int_fast32_t old_vfoB = 1;

    int RunOnce = 1;
   
    String hertz = "1"; //initial tune step rate.
    byte ones,tens,hundreds,thousands,tenthousands,hundredthousands,millions ;  //Placeholders
   
   
    Rotary r = Rotary(2,3); // sets the pins the rotary encoder uses.  Must be interrupt pins.
   
    int i = 0;
    int z = 0;
    const int TX = 4;  //USE VFO A only on transmit
    const int VS = 5;
    const int SW = A1;  // Toggle Switch USB/LSB
    const int SW1 = A2; // provides the TUNE fucntion
    const int VFO = A0;
   

   const int tonepin = 6;
   int buttonstate = 0;
   
   int buttonState = 0;
   int lastButtonState = 0;
   int lastbuttonstate = 0;
   
  void setup()   {
   
    display.clearDisplay();  // clears the screen and buffer
   

     
     PCICR |= (1 << PCIE2);
     PCMSK2 |= (1 << PCINT18) | (1 << PCINT19);
     sei();
   
   
    display.setRotation(2);
   // display.begin(0x3C);
   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
    delay(20);
   
 
   

      // Connect to a button that goes to GND on push to set the 4 step rates
     
     
   
     
     pinMode(SW1, INPUT);  // Tune function
     digitalWrite(SW1, HIGH);
     pinMode(SW,INPUT);// USB/LSB Select
     digitalWrite(SW,HIGH);
     pinMode(4, INPUT); digitalWrite(4, HIGH);
     pinMode(5, INPUT); digitalWrite(5, HIGH);
     pinMode(7, OUTPUT); digitalWrite(7, LOW);
     pinMode(A0, INPUT);
     pinMode(A3,INPUT); digitalWrite(A3,HIGH);
   
     
     #if defined(__MK20DX128__) || defined(__MK20DX256__)
     tft.setBitrate(24000000);
     #endif
     
     
     
      si5351.init(SI5351_CRYSTAL_LOAD_8PF);
      si5351.set_correction(100);
     
      si5351.set_pll(SI5351_PLL_FIXED, SI5351_PLLA);
     
     //si5351.set_freq(rx , SI5351_PLL_FIXED, SI5351_CLK0);

     
      si5351.set_freq(bfo, 0, SI5351_CLK2);
     
      si5351.drive_strength(SI5351_CLK0,SI5351_DRIVE_8MA); // Higher Drive since it is a TUF-1 DBM
      si5351.drive_strength(SI5351_CLK2,SI5351_DRIVE_8MA);
   
   
   
 
}
 
  void setincrement(){

    if (increment == 10){increment = 100;  hertz = "1";}
         
    else if (increment == 100){increment = 1000; hertz="2";}
    else if (increment == 1000){increment = 10000; hertz="3"; }
  else if (increment == 10000){increment = 100000; hertz="4";}
   // else if (increment == 100000){increment = 1000000; hertz="  1M";}
    else{increment = 10; hertz = "  0";}; 

         
         
         
     delay(150); // Adjust this delay to speed up/slow down the button menu scroll speed.
             display.setTextSize(2);
             display.setTextColor(WHITE);
             display.setCursor(105,50);
             display.println(hertz);   
}
 
  void showFreq(){
     
     
   
 
      millions = int(((rx)-bfo)/1000000);
      hundredthousands = ((((rx)-bfo )/100000)%10);
      tenthousands = ((((rx)-bfo )/10000)%10);
      thousands = ((((rx)-bfo )/1000)%10);
      hundreds = ((((rx)-bfo )/100)%10);
      tens = ((((rx)-bfo )/10)%10);
      ones = ((((rx)-bfo )/1)%10);
     

 
     
       

          delay(25);
       
             
  } 

       



     


   

   

 
  ISR(PCINT2_vect) {
  unsigned char result = r.process();
 
    if (result) {
     if (result == DIR_CW){rx=rx-(1*increment);}
     else {rx = rx+(1*increment);};       
      if (rx >=50000000L){rx=rx2;}; //This sets the upper LO range 50 MHz
      if (rx <=5000000L){rx=rx2;};  // This sets the lower LO range 5 MHz
     
      }
  }

 
 
  void loop() {


       SplashScreen();
       RunOnce = 0;
           
        checkMode();
        CheckSB();
        CheckDisplay();
        CheckVS();
        CheckTX();
     
       
         
        lastButtonState = buttonState;
        lastbuttonstate = buttonstate;
       
       
      showFreq();
       
 
     
     
     
     

   
        display.display();
         
        if (rx != rx2){
       
           showFreq();
           
           si5351.set_freq(rx  , SI5351_PLL_FIXED, SI5351_CLK0);
           rx2=rx ;
           
       
       
       
         
         
           }
 

buttonstate = digitalRead(A3);
         if(buttonstate != lastbuttonstate){
         if(buttonstate == LOW) {
           
       
          setincrement();
         
         }
         }


             
             
       
     
  }
         
       
   
   
     
     

  //**********************************************************
    void checkMode(){
        buttonState = digitalRead(SW1); // creates a 10 second tuning pulse trani 50% duty cycle and makes TUNE appear on the screen
       if(buttonState != lastButtonState){
        if(buttonState == LOW){
         
         
         
     
          useVFOA();
        display.setTextColor(WHITE);
        display.setTextSize(2);
        display.setCursor(10,35);   //We are dsiplaying the received Freq
               
         display.println(rx1 - bfo);
         display.setCursor(1,50); 
         display.print("TUNE");
        display.display();
        delay(12);
        for(int i = 0; i < 100; i++) {
         tone(6, NOTE_B5);
         delay(50);
         noTone(6);
         delay(50);
         
         }
        delay(100);   // de N6QW in CW

           dash();   //D
           dot();
           dot();
           delay(300); //E
           dot();

           delay(400);

           dash();    //N
           dot();
           delay(300);
           dash();   //6
           dot();
           dot();
           dot();
           dot();
           delay(300);
           dash();  //Q
           dash();
           dot();
           dash();
           delay(300);
           dot();     //W
           dash();
           dash();
           delay(300);
        }
       else{
         
        display.setTextSize(2);    // This prints a Black TUNE over the RED TUNE and makes it disappear from the scereen
         display.setTextColor(BLACK);
         display.setCursor(1, 50);
         display.print("TUNE");
   
         noTone(6);
   
       }
         
     
         delay(50);
   
    }
   
   
     
   

 
 
   


 
  }

//*********************Check Sideband ************************************
     
       
     void CheckSB(){
     
          // *** S Meter code smaple the audio output and uses a log function
         
       
       
     
     if(digitalRead(SW)){  //********If SW is true do the following.
       bfo = 3181500L;  //Sideband inversion with the LO above the operating frequency
       si5351.set_freq( bfo, 0, SI5351_CLK2);{
       
     
       display.setTextSize(2);  // lets you toggle bewteen USB and LSB without having a screen overwrite
       display.setTextColor(BLACK);
       display.setCursor(92,50); 
       display.println("LSB");
       
       display.setTextSize(2);
       display.setTextColor(WHITE);
       display.setCursor(92,50); 
       display.println("USB");}
     
     }
      else{                //**********if not, do this.
         
         
         
         
          bfo = 3178500L; // Keep in mind the LO is above the operating frequency so sideband inversion
          si5351.set_freq( bfo, 0, SI5351_CLK2);
       
          display.setTextSize(2);   // lets you toggle bewteen USB and LSB without having a screen overwrite
           display.setTextColor(BLACK);
           display.setCursor(92,50); 
          display.println("USB");
         
          display.setTextSize(2);
          display.setTextColor(WHITE);
          display.setCursor(92,50); 
          display.println("LSB");
      }
         
      }     
     
   //*************************** Splash Screen ********************

void SplashScreen() {
    if (RunOnce == 1) {

 
    display.setTextColor(WHITE);
 
    display.setCursor(25, 0);
    display.setTextSize(3);
    display.println("N6QW");
    display.setTextSize(2);
 
    display.println(" AKA Pete");
   
        display.display();
    display.clearDisplay();
    delay(400);
   
    display.setTextColor(WHITE);
    display.setTextSize(2);
    display.setCursor(5,30);
    display.println("Ham Genius");
    display.display();
    delay(500);
    RunOnce = 0;

   
   
     
    }
   display.clearDisplay();
  }
   

  // ********************** Check Display ***************************


  void CheckDisplay(){

          display.setTextSize(2);
          display.setTextColor(WHITE);
          display.setCursor(2,1);
          display.println("A");
          display.setCursor(2,18);
          display.println("B");
         display.setCursor(1,50);
          display.println("N6QW");
           
         
  }

//*************************************** VFO A or B ****************


void CheckVS(){  //thus a toggle switch controls writing which VFO indirectly

        digitalRead(5);
        if(digitalRead(5) == HIGH){
            digitalWrite(A0, HIGH);
            useVFOA();
             z = 1;
            }
           else {
           digitalWrite(A0, LOW);
           useVFOB();
            z = 2;
            }
   
       }

// *************************************VFO A*******************

       void useVFOA(){   // Has logic so you can have the correct display in concert with USB/LSB

         
           CheckFreq1();
           
   
          digitalRead(A0) == HIGH;

          display.setTextSize(2);

     
             rx = rx1;

             

            display.setTextColor(WHITE);
            display.setCursor(25,1);
            display.print(rx1-bfo);
       
         
            rx1 == vfoA;
            vfoA = rx1;
            old_vfoA = vfoA;
            showFreq();
            si5351.set_freq(vfoA , SI5351_PLL_FIXED, SI5351_CLK0);
   
         }
         

     
     
    // ******************************** VFO B *****************************
  void useVFOB(){
       
                         
            CheckFreq2();
           
            digitalRead(A0) == LOW;
           
            display.setTextSize(2);
         
            rx = rx3;
           

            display.setTextColor(WHITE);
            display.setCursor(25,18);
            display.print(rx3-bfo);
           

           
               

         
           
            rx3 == vfoB;
            vfoB = rx3;
            old_vfoB = vfoB;
            si5351.set_freq(vfoB , SI5351_PLL_FIXED, SI5351_CLK0);

         
           
  }
 

//*************

/*    //Not Needed
void CheckFreq(){


                if (rx != rx2){ 

               
                showFreq();
               
             
           
            si5351.set_freq(rx  , SI5351_PLL_FIXED, SI5351_CLK0);
            Serial.println(rx);
            //si5351.set_freq(bfo  , SI5351_PLL_FIXED, SI5351_CLK2);
               rx2 = rx;
         
   

   
       }


    }

*/


   
//************************* Frequency Change 1 *************************


  void CheckFreq1(){

       
         
          if( rx != rx2){   // This is the key to memory

       
            si5351.set_freq(rx1  , SI5351_PLL_FIXED, SI5351_CLK0);
            Serial.println(rx1);
            si5351.set_freq(bfo  , SI5351_PLL_FIXED, SI5351_CLK2);
            rx1 = rx;
           
         showFreq();

           }     
 
  }
//************************* Check Frequency 2 *******************************

void CheckFreq2(){


           
              if( rx != rx2){
             
           
            si5351.set_freq(rx3  , SI5351_PLL_FIXED, SI5351_CLK0);
           
            si5351.set_freq(bfo  , SI5351_PLL_FIXED, SI5351_CLK2);
            rx3 = rx;

         showFreq();

}
}

// *************************** Check for Transmit *************************


// ***************************************Check for TRansmit ******************************************
/* This has proven to be a nasty problem for me as I have not been able to implement this in software. Try as I might
*  the software does not follow what I want to do. I have total functionality with two separate VFO's --my failure is how
*  to transmit on one while receiving on the other. Finally I hit on a simple hardware solution. Pin A0 is either set high or
*  low depedning on whether Pin 5 is grounded via a switch. So lets add some hardware in that loop like a NC relay. So here is
*  how it would work.
*  1) In the receiove mode by engaging Pin 5 high or low with an external switch we have a choice of VFO A or VFO B
*  2) Let us say we want to make VFO A the Receive and Transmit VFO and VFO B Receive only
*  3) When the PTT Switch ground Pin 4 it also causes a NC relay to open. So if you were receiving on VFO B the break in the circuit
*     would cause the controlling VFO to be VFO A whihc means you would be transmitting on VFO A.
*  4) If you purposefully open the VFO A/B sweitch then you would receive and transmit entirely on VFO A.
*  5) Adding yet another switch in the loop in the line feeding the juice (or ground) to the NC relay Then you would receive and transmit only on VFO B
*  6) Normal Opeartion would entail opening the A/B select swithc so that you would pick the transmit frequency on VFO A. Then closing the switch you would
*     have VFO A fixed for transmit and tune around on VFO B. Opening the switch then tuning and transmitting is on VFO A
*/
void CheckTX() { //Green Dot comes on to PTT Also selects which VFO A is used for tranmit
         
       digitalRead(4);

         if(digitalRead(4) == LOW){
               
                display.setCursor(10,35);   //We are dsiplayin the received Freq
                display.setTextSize(2);
                display.setTextColor(WHITE);
                display.println(rx1 - bfo);

            /*    display.setCursor(52,50);   //We are dsiplayin the received Freq
                display.setTextSize(2);
                display.setTextColor(WHITE);
                display.println("T=A"); */

                display.fillCircle(108, 40, 4, WHITE);

           
               
             
                   useVFOA();
                 
                  digitalWrite(7, HIGH);
                 
         }
}

//**** Generating CW *********

void dash(){

       tone(6, NOTE_B5);
        delay(300);
        noTone(6);
        delay(100);
}

void dot(){

      tone(6, NOTE_B5);
      delay(100);
      noTone(6);
      delay(100);
}


onepower

Antimony
Yikes, that is a lot of code for a fairly simple VFO, lol.

QuoteThis has proven to be a nasty problem for me as I have not been able to implement this in software. Try as I might
*  the software does not follow what I want to do. I have total functionality with two separate VFO's --my failure is how
*  to transmit on one while receiving on the other. Finally I hit on a simple hardware solution. Pin A0 is either set high or
*  low depedning on whether Pin 5 is grounded via a switch. So lets add some hardware in that loop like a NC relay.

If you want to switch between TX/RX frequencies or channels you could use a multiplexing chip. I used to use them all the time in the not so good old days when I had to build my own micro computers using logic gate gate chips. Which is why I love Arduino's, $5 boom, we have a fast reliable computer to do stuff.

Here is a start...https://www.instructables.com/id/Multiplexing-with-Arduino-and-the-74HC595/

You want to watch the rise/fall transition times, 500ns for the 74HC595, which could become a problem in high bandwidth applications. You will be fine and MUX/deMUX is a good solution when we have a limited number of input/output channels. I would prefer to use a small footprint microcomputer and multiplex rather than use a larger board like the Mega.

As well, instead of using time consuming serial string functions it can be done physically with a MUX chip basically converting all the parallel data into serial data or vice versa. That's how we used to do it, lol.

Regards


partzman

Actually, today the most sophisticated method of generating wideband RF waveforms is via DDS or Direct Digital Synthesis.  Simply put, it involves a digital lookup table in whatever resolution is required that drives a DAC to produce whatever waveform is required.  This then requires a simple change in clock frequency to change the overall output frequency.  Most all if not all function/arbitrary generators in use today use DDS.  The current technology of high frequency DAC's limits the output signal to about 1v rms or less in most cases.  This is then amplified by a linear RF amp to reach the  levels seen today in the popular generators used on the bench.

If an when high speed DAC's (whether integrated or discrete) in the neighborhood of 2-4MHz are available that will supply 50v rms or so output are available, I will be able to demonstrate infinite OU at any basic power level with my MEI or Magneto Electric Induction circuits.  This is possible only with the direct switched mosfet output of the DAC because the mosfets will be able to operate in a reverse conduction mode that allows the negative energy or current to be fed back to the supply.  This can't be done with linear amplification.

My youngest son uses DDS in his line of synthesizer products that he markets to the music industry but these operate obviously in the audio range and are much more manageable at higher voltage levels.

Regards,
Pm