Announcement

Collapse
No announcement yet.

Jazzing up the Arduino PI - full recipe

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Originally posted by Gunghouk View Post

    For the array for sure but there's plenty of memory available but as an alternative or efficient replacement for the IIR I can't say. I just like its compactness and understandibilty.

    All moot if the pot is replaced with an encoder.
    If it works for you, go ahead. I stick to the IIR filter.

    The step reponse is really nice.

    Click image for larger version  Name:	Schermopname (369).png Views:	0 Size:	57.2 KB ID:	420524


    Just two lines of code

    PHP Code:
     // IIR low-pass filter of pot readings
    potReadingY potReadingY - (potReadingY >> 4) + potReading;
    potReading potReadingY >> 4

    Comment


    • #32
      I have found that the last working version was 1.0.3 . After investigation it appears that the register settiing order had changed in the timers so I set them to the same as 1.0.3 then 1.04 and 1.05 worked.

      /**
      * URL: https://dbuezas.github.io/arduino-we...erOrSource=64& topValue=OCR0A&OCR0A=249
      * Mode : CTC
      * Period : 1 ms
      * Frequency: 1 kHz
      * Outputs :
      * - D5: 100.00%, set
      */
      TCNT0 = 0;

      /*OCR0A = txPeriod / 4 - 1;
      OCR0B = (byte) efeDelayCount;
      // initial pin states
      TCCR0A = 1 << WGM01 | 1 << COM0B1 | 1 << COM0B0; // set pin on compare match
      // force compare match to set pin
      TCCR0B |= (1 << FOC0B);
      // next pin state
      TCCR0A &= ~(1 << COM0B0); // clear efeSample
      // 1/64 prescaler
      TCCR0B = 1 << CS01 | 1 << CS00;
      // enable nterrupts
      TIMSK0 = 1 << OCIE0B;
      DDRD |= 1 << DDD5; // PWM pin 5 : EFE sample
      */
      // initial pin states
      TCCR0A = 1 << WGM01 | 1 << COM0B1 | 1 << COM0B0; // set pin on compare match
      // force compare match to set pin
      TCCR0B |= (1 << FOC0B);
      // next pin state
      TCCR0A &= ~(1 << COM0B0); // clear efeSample
      // 1/64 prescaler
      TCCR0B = 1 << CS01 | 1 << CS00;
      // enable nterrupts
      TIMSK0 = 1 << OCIE0B;
      OCR0A = txPeriod / 4 - 1;
      OCR0B = (byte) efeDelayCount;
      DDRD |= 1 << DDD5; // PWM pin 5 : EFE sample
      GTCCR = 0; // Release timers
      interrupts();

      Comment


      • #33
        Originally posted by Gunghouk View Post
        I have found that the last working version was 1.0.3 . After investigation it appears that the register settiing order had changed in the timers so I set them to the same as 1.0.3 then 1.04 and 1.05 worked.

        /**
        * URL: https://dbuezas.github.io/arduino-we...erOrSource=64& topValue=OCR0A&OCR0A=249
        * Mode : CTC
        * Period : 1 ms
        * Frequency: 1 kHz
        * Outputs :
        * - D5: 100.00%, set
        */
        TCNT0 = 0;

        /*OCR0A = txPeriod / 4 - 1;
        OCR0B = (byte) efeDelayCount;
        // initial pin states
        TCCR0A = 1 << WGM01 | 1 << COM0B1 | 1 << COM0B0; // set pin on compare match
        // force compare match to set pin
        TCCR0B |= (1 << FOC0B);
        // next pin state
        TCCR0A &= ~(1 << COM0B0); // clear efeSample
        // 1/64 prescaler
        TCCR0B = 1 << CS01 | 1 << CS00;
        // enable nterrupts
        TIMSK0 = 1 << OCIE0B;
        DDRD |= 1 << DDD5; // PWM pin 5 : EFE sample
        */
        // initial pin states
        TCCR0A = 1 << WGM01 | 1 << COM0B1 | 1 << COM0B0; // set pin on compare match
        // force compare match to set pin
        TCCR0B |= (1 << FOC0B);
        // next pin state
        TCCR0A &= ~(1 << COM0B0); // clear efeSample
        // 1/64 prescaler
        TCCR0B = 1 << CS01 | 1 << CS00;
        // enable nterrupts
        TIMSK0 = 1 << OCIE0B;
        OCR0A = txPeriod / 4 - 1;
        OCR0B = (byte) efeDelayCount;
        DDRD |= 1 << DDD5; // PWM pin 5 : EFE sample
        GTCCR = 0; // Release timers
        interrupts();

        What malfunction did you observe? The original code works for me.

        Comment


        • #34
          No display updates and no PWM outputs. I'm using a standard Nano not the lgt8f variant. I'll try the lgtf8 instead tomorrow with the original releases.

          Comment


          • #35
            Originally posted by Gunghouk View Post
            No display updates and no PWM outputs. I'm using a standard Nano not the lgt8f variant. I'll try the lgtf8 instead tomorrow with the original releases.
            You're correct. I've tried the original release on the Atmega328P and if OCR0A is loaded before setting the PWM mode in TCCR0A, it doesn't work. OCR0B can be configured in any order though.
            That's really strange. Timer1 doesn't have this problem. LGT8F328P works fine in both cases... a chinese clone being better than the original!

            Version 1.0.5 corrected

            ArduinoPI_fullPWM_1_0_5.zip
            Attached Files

            Comment


            • #36
              Hi Teleno Just tried this build on a LGT board by itself. I notice TX pulse width is ~100uS, is that because boost pin will be floating without the rest of the hardware?

              Looks like it, just shorted D12 to GND, and now ~50uS .. will try it in the unit now. Cheers.

              For me it looks like I only have to take the EFI sample to D5 instead of D8 I had it in the other timing thread.

              Comment


              • #37
                1.0.5 with encoder and boost toggled on push button.

                ArduinoPI_fullPWM_1_0_5Encoder.zip

                Comment


                • #38
                  Had to change the default for the boost switch. Because of the line:
                  Code:
                  boost = (digitalRead(boostPin) == HIGH);
                  Boost is therefor on by default (it has a pull high programmed in). This is the opposite of what was in the code prior to this thread.
                  Since I have a boost push button (momentary) I had to change the sense of that. So changed the above line to
                  Code:
                  boost = (digitalRead(boostPin) == LOW);

                  Comment


                  • #39
                    Is this using the encoder version? I'm using the momentary encoder push button to gnd and this toggles boost just fine.

                    Comment


                    • #40
                      Originally posted by Gunghouk View Post
                      Is this using the encoder version? I'm using the momentary encoder push button to gnd and this toggles boost just fine.
                      No, I am using the latest version from this thread. 1.0.5 The input is pulled up, so the default is boost on.

                      Comment


                      • #41
                        ArduinoPI_fullPWM_1_0_5EncoderBoost.zip ArduinoPI_fullPWM_1_0_5EncoderBoost.zip I just wanted to share the latest incarnation of Teleno's excellent PWM version 1.0.5 but now heavily modified to use an encoder to set main delay and TX power.
                        Pressing the encoder button toggles between setting delay or TX pulse width.

                        See attached photos.
                        A lot of stuff needs clearing out to make this a dedicated version without the potentiometer code though. All Teleno's hardware mods are still required for full functionality.

                        Click image for larger version  Name:	PXL_20240224_202411985.jpg Views:	0 Size:	520.6 KB ID:	420748 Click image for larger version  Name:	PXL_20240224_202440275.jpg Views:	0 Size:	503.5 KB ID:	420749

                        ArduinoPI_fullPWM_1_0_5EncoderBoost.zip




                        Comment


                        • #42
                          Sorry corrected zip attached. I've still forgotten to edit comments in my enthusiasm to share.

                          ArduinoPI_fullPWM_1_0_5EncoderBoost.zip
                          Attached Files

                          Comment


                          • #43
                            Very interesting project, thanks for sharing with us!
                            May i ask for absolutely simple version of code, just pulse generation, no buttons, no displays, no audio? It will be way easier for newbie in code writing, and in same time easy to replase these functions with analog parts.

                            Comment


                            • #44
                              Originally posted by talasumo View Post
                              Very interesting project, thanks for sharing with us!
                              May i ask for absolutely simple version of code, just pulse generation, no buttons, no displays, no audio? It will be way easier for newbie in code writing, and in same time easy to replase these functions with analog parts.
                              The original discussion is here but you still need knobs and buttons.
                              Arduino Nano PI Main Discussion
                              You can find original project files in completed projects.

                              https://www.geotech1.com/forums/foru...ain-discussion


                              Comment


                              • #45
                                Originally posted by talasumo View Post
                                Very interesting project, thanks for sharing with us!
                                May i ask for absolutely simple version of code, just pulse generation, no buttons, no displays, no audio? It will be way easier for newbie in code writing, and in same time easy to replase these functions with analog parts.
                                The original data is here -> Arduino Nano Pulse Induction Metal Detector Project - Published March 2021

                                Comment

                                Working...