Announcement

Collapse
No announcement yet.

AHMERIXIS MD - Making my Own Design Detector

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

  • #16
    Not happy with my results today

    Attached the results I achieved today... the best sample time was about 7.9 uS with 8 bit... until about 10Khz (signal) the resolution is acceptable... but something over that value is not good.

    I am using an Arduino Nano.


    long numSamples = 0;
    byte samples = 200;
    byte values[200];
    int i;
    long t, t0;


    void setup()
    {
    Serial.begin(9600);


    ADCSRA = 0; // clear ADCSRA register
    ADCSRB = 0; // clear ADCSRB register
    ADMUX |= (0 & 0x07); // set A0 analog input pin
    ADMUX |= (1 << REFS1) | (1 << REFS0); // set reference voltage
    ADMUX |= (1 << ADLAR); // left align ADC value to 8 bits from ADCH register


    // sampling rate is [ADC clock] / [prescaler] / [conversion clock cycles]
    // for Arduino Uno ADC clock is 16 MHz and a conversion takes 13 clock cycles
    //ADCSRA |= (1 << ADPS2) | (1 << ADPS0); // 32 prescaler for 38.5 KHz
    //ADCSRA |= (1 << ADPS2); // 16 prescaler for 76.9 KHz
    ADCSRA |= (1 << ADPS1) | (1 << ADPS0); // 8 prescaler for 153.8 KHz
    //ADCSRA |= (1 << ADPS1); // 4 prescaler
    //ADCSRA |= (1 << ADPS0); // 4 prescaler


    ADCSRA |= (1 << ADATE); // enable auto trigger
    ADCSRA |= (1 << ADIE); // enable interrupts when measurement complete
    ADCSRA |= (1 << ADEN); // enable ADC
    ADCSRA |= (1 << ADSC); // start ADC measurements
    }


    ISR(ADC_vect)
    {
    if (numSamples < samples){
    //byte x = ADCH; // read 8 bit value from ADC
    values[numSamples] = ADCH;
    //Serial.println(x);
    numSamples++;
    }
    }

    void loop()
    {

    if (numSamples == samples)
    {
    Serial.println("---- begin");
    t = micros() - t0; // calculate elapsed time


    Serial.print("uS between samples: ");
    Serial.println((t * 1.0) / (samples * 1.0));
    Serial.println(t);
    //delay(2000);


    for(i = 0; i < samples; i++) {
    //Serial.println(values[i]);
    Serial.println(values[i] * 1.1 / 255.0);
    }
    delay(10000);

    // restart
    t0 = micros();
    numSamples = 0;
    }
    }
    Attached Files

    Comment


    • #17
      hint:
      when posting code to the forum put 'code' tags around the code to post.

      The code tags are [ c o d e ] 'code to post' [ / c o d e ]
      remove the spaces inside the square brackets like this and all the formatting, indents, etc. are not removed.

      Code:
      long numSamples = 0;
      byte samples = 200; 
      byte values[200];
      int i;
      long t, t0;
      
      
      void setup()
      {
        Serial.begin(9600);
        
        
        ADCSRA = 0;             // clear ADCSRA register
        ADCSRB = 0;             // clear ADCSRB register
        ADMUX |= (0 & 0x07);    // set A0 analog input pin
        ADMUX |= (1 << REFS1) | (1 << REFS0);  // set reference voltage
        ADMUX |= (1 << ADLAR);  // left align ADC value to 8 bits from ADCH register
      
      
        // sampling rate is [ADC clock] / [prescaler] / [conversion clock cycles]
        // for Arduino Uno ADC clock is 16 MHz and a conversion takes 13 clock cycles
        //ADCSRA |= (1 << ADPS2) | (1 << ADPS0);    // 32 prescaler for 38.5 KHz
        //ADCSRA |= (1 << ADPS2);                     // 16 prescaler for 76.9 KHz
        ADCSRA |= (1 << ADPS1) | (1 << ADPS0);    // 8 prescaler for 153.8 KHz
        //ADCSRA |= (1 << ADPS1);    // 4 prescaler 
        //ADCSRA |= (1 << ADPS0);    // 4 prescaler
      
      
        ADCSRA |= (1 << ADATE); // enable auto trigger
        ADCSRA |= (1 << ADIE);  // enable interrupts when measurement complete
        ADCSRA |= (1 << ADEN);  // enable ADC
        ADCSRA |= (1 << ADSC);  // start ADC measurements
      }
      
      
      ISR(ADC_vect)
      {
        if (numSamples < samples){
          //byte x = ADCH;  // read 8 bit value from ADC
          values[numSamples] = ADCH;
          //Serial.println(x);
          numSamples++;
        } 
      }
        
      void loop()
      {
        
        if (numSamples == samples)
        {
          Serial.println("---- begin");
          t = micros() - t0;  // calculate elapsed time
      
      
          Serial.print("uS between samples: ");
          Serial.println((t * 1.0) / (samples * 1.0));
          Serial.println(t);
          //delay(2000);
      
      
          for(i = 0; i < samples; i++) {
              //Serial.println(values[i]);
              Serial.println(values[i] * 1.1 / 255.0);
          }
          delay(10000);
          
          // restart
          t0 = micros();
          numSamples = 0;
        }
      }

      Comment


      • #18
        Originally posted by waltr View Post
        hint:
        when posting code to the forum put 'code' tags around the code to post.

        The code tags are [ c o d e ] 'code to post' [ / c o d e ]
        remove the spaces inside the square brackets like this a...........
        Great, I will next time!

        Thanks

        Comment


        • #19
          Fake LF357 vs TL071?

          Hi everyone,

          Which one you think looks better... I have replaced the LF357 (which I think it is fake) with a TL071.

          Which one you think work better, see the attached picture.

          Thanks a lot!
          Click image for larger version

Name:	fake lf357 vs tl071.jpg
Views:	1
Size:	308.6 KB
ID:	358268

          Comment


          • #20
            Originally posted by nncu2020 View Post
            Hi everyone,

            Which one you think looks better... I have replaced the LF357 (which I think it is fake) with a TL071.

            Which one you think work better, see the attached picture.

            Thanks a lot!
            [ATTACH]53323[/ATTACH]
            I like the 357 trace better. Looks like could sample either after a 12us delay so maybe not much difference unless one has more noise for low signal targets.

            Comment


            • #21
              Hi Green,

              Why do you think LF357 is better?

              TL071 has a more smooth curve when no object is present. I see a best balance ground-vcc/gnd-vee in TL071.

              Can you please give more details? I am just beginning :-)

              I bought the LF357 from China (ebay), so I don't think it is really a real one.

              Comment


              • #22
                Originally posted by nncu2020 View Post
                Hi Green,

                Why do you think LF357 is better?

                TL071 has a more smooth curve when no object is present. I see a best balance ground-vcc/gnd-vee in TL071.

                Can you please give more details? I am just beginning :-)

                I bought the LF357 from China (ebay), so I don't think it is really a real one.
                357 is faster, gets to zero sooner. Don't know if it matters if both are out of saturation when sample is taken. I'm still learning also, maybe someone else could give their thoughts.

                Comment


                • #23
                  Maybe I can use the null offset pins to balance the output .... ?

                  Comment


                  • #24
                    Originally posted by nncu2020 View Post
                    Maybe I can use the null offset pins to balance the output .... ?
                    Why do you need to balance the output? Aren't you reading the output with an A-D?

                    Comment


                    • #25
                      No, I just want to know why LF357 and TL071 have different behavior if the circuit is exactly the same.

                      I will try to use an ADC, but not in that specific point. I will use a voltage range coupling to input the signal to the ADC.

                      Comment


                      • #26
                        Originally posted by nncu2020 View Post
                        No, I just want to know why LF357 and TL071 have different behavior if the circuit is exactly the same.

                        I will try to use an ADC, but not in that specific point. I will use a voltage range coupling to input the signal to the ADC.
                        ________ TL071 LF357
                        bandwidth 3MHz 20MHz
                        slew rate 13V/us 50V/us

                        Comment


                        • #27
                          LF357 has 50V/us slew rate compared to 13V/us of TL071 . This is a main reason. If LF doesn't work very stable try to put capacitor in negative feedback, or try to find original LF not from china . There are lot of ebay sellers who sell old (1980 YOM) LF

                          Comment

                          Working...
                          X