Announcement

Collapse
No announcement yet.

Announcement

Collapse
No announcement yet.

Modified sketch for improved timing precision.

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

  • SaltyDog
    replied
    Here is the code. You will need to swap the pins back of course.
    Attached Files

    Leave a comment:


  • SaltyDog
    replied
    Why is mainsample and efeSample inverted? They should be the same polarity as Tx Pulse.

    Leave a comment:


  • Teleno
    replied
    Originally posted by SaltyDog View Post

    The code I was using is attached.
    Actually I meant the code from Gounghouk.


    These are the signals I get on my setup, including sound. They match the original sketch exactly. Audio 490 Hz, period 1000ms, delay 10us, etc.

    Using this sketch Arduino_PI2.0.1.zip

    Tx pulse and mainSample:

    Click image for larger version  Name:	20240209_220325.jpg Views:	0 Size:	150.8 KB ID:	420094


    Tx pulse and efeSample

    Click image for larger version  Name:	20240209_220252.jpg Views:	0 Size:	158.5 KB ID:	420095


    Sound on pin 11.


    Click image for larger version  Name:	20240209_220354.jpg Views:	0 Size:	170.4 KB ID:	420096

    I'm mystified about the whistle cause I haven't touched the sound.



    Leave a comment:


  • SaltyDog
    replied
    Originally posted by Teleno View Post

    My code is based on the original by George. I might have missed improvements by others, including delays and pulse widths. Would really like to see your code.

    Enjoy the wedding, and congrats I suppose.
    The code I was using is attached.
    Attached Files

    Leave a comment:


  • Teleno
    replied
    Originally posted by SaltyDog View Post

    I don't have time at the moment, have my Daughters wedding ... will try after that with your latest code. I presume you have a full working unit that performs in the field, not just on the bench? Correct timing is one thing, but actual use is the best ..
    My code is based on the original by George. I might have missed improvements by others, including delays and pulse widths. Would really like to see your code.

    Enjoy the wedding, and congrats I suppose.

    Leave a comment:


  • SaltyDog
    replied
    Originally posted by Teleno View Post

    If yiu post the sketch you're using I can look at the differences and maybe figure out the problem.

    I focused on the timing and I might inadvertently have broken other parts of the code.

    Is the timing of the pulses right? The delays and pulse widths? I mean on the scope.
    I don't have time at the moment, have my Daughters wedding ... will try after that with your latest code. I presume you have a full working unit that performs in the field, not just on the bench? Correct timing is one thing, but actual use is the best ..

    Leave a comment:


  • Teleno
    replied
    Originally posted by SaltyDog View Post
    Teleno I had high hopes that your mods would improve the sensitivity, but in actual operation, was worse than the code I am using from Gunghouk
    Also, there is an annoying background whistle. My test gold ring was only found at 25cm, where as with the fast-write code from Gunghouk was 40cm.

    No idea why. I will investigate further when I have some time. I was using your version 2.0
    If yiu post the sketch you're using I can look at the differences and maybe figure out the problem.

    I focused on the timing and I might inadvertently have broken other parts of the code.

    Is the timing of the pulses right? The delays and pulse widths? I mean on the scope.

    Leave a comment:


  • SaltyDog
    replied
    Teleno I had high hopes that your mods would improve the sensitivity, but in actual operation, was worse than the code I am using from Gunghouk
    Also, there is an annoying background whistle. My test gold ring was only found at 25cm, where as with the fast-write code from Gunghouk was 40cm.

    No idea why. I will investigate further when I have some time. I was using your version 2.0

    Leave a comment:


  • Teleno
    replied
    In this version,
    - floating arithmetic replaced by integers.
    - timing parameters defined in microseconds
    - interrupt code minimized, parts moved to loop
    - mainSample delay can be as low as 1us

    Aduino_PI2.0.1.zip

    Click image for larger version  Name:	20240209_140733.jpg Views:	0 Size:	147.9 KB ID:	420076
    Attached Files

    Leave a comment:


  • Teleno
    replied
    Originally posted by pito View Post
    This is an Arduino PI forum = and this is arduino program
    This thread is about Arduino Nano PI, a project based on Atmega328P.

    If you want to discuss other topics just open your own separate thread instead of derailing mine.

    Leave a comment:


  • pito
    replied
    This is an Arduino PI forum = and this is arduino program

    Leave a comment:


  • Teleno
    replied
    Here's how to do the mod on the PCB with minimum impact.

    Cut the "south' pins of R5 an R11 as close to their pads as possible (so that you can solder them back to undo the mod) and pull their free ends slightly up (~30 degrees) .

    With a soldering iron and a length of insulated mod wire, connect the free end of R5 to the old pad of R11. Another length of wire and connect the free end of R11 to the old pad of R5. Done!

    To avoid accidental shorts place some foam/tape between the cut pins and their old pads.

    The red lines in the figure mark the pins to cut.

    Test point TP2 is no longer the TX signal but the EFE signal. To see the TX probe the "north" end of R11 instead (the one soldered to its pad).


    Click image for larger version  Name:	20240209_093420.jpg Views:	0 Size:	156.8 KB ID:	420070

    Leave a comment:


  • SaltyDog
    replied
    And what is the point of posting that here? This is an Arduino PI forum, unless I am mistaken.

    Leave a comment:


  • pito
    replied
    and here is simple code for stm32f103,

    HTML Code:
    HardwareTimer pwmtimer2(2);
    
    void setup() {
    
      pinMode(PA3, PWM);// CH4
      // pinMode(PA3, OUTPUT);// CH4
      pinMode(PB11, INPUT_PULLDOWN);
      //Timer 2
      pwmtimer2.pause();
      //pwmtimer2.setPrescaleFactor(180);// 180 = 4kHz
      // pwmtimer2.setPrescaleFactor(1800);// 1800 = 400Hz
      // pwmtimer2.setPrescaleFactor(3600);// 3600 = 200 Hz
      //pwmtimer2.setPrescaleFactor(5000); // 140 Hz
       pwmtimer2.setPrescaleFactor(3000);
      //pwmtimer2.setOverflow(100 - 1);//
       pwmtimer2.setOverflow(90);        // =
     // pwmtimer2.setOverflow(50);        //
      pwmtimer2.setCompare(TIMER_CH4, 1);
      pwmtimer2.refresh();
      pwmtimer2.resume();
    }
    void loop() {
      /*
        if (digitalRead(PB11) == HIGH)
        {
        }
        else
        {
        pwmtimer2.refresh();
    
        }
      */
    }​
    pic, 200 ns and 20 us

    Click image for larger version

Name:	image.png
Views:	654
Size:	396.7 KB
ID:	420061Click image for larger version

Name:	image.png
Views:	627
Size:	405.3 KB
ID:	420062

    Leave a comment:


  • SaltyDog
    replied
    Good Info, will try it out .... needed to see this to decide to make the step to modify the board (pin swap)

    Leave a comment:

Working...
X