Announcement

Collapse
No announcement yet.

Bipolar PI design

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

  • ivconic
    replied
    A good friend mailed me two PICs from a neighboring state... a long time ago!
    They never arrived.
    It happens with our local mob called "Post and Customs".
    So I am forced to think about alternative solutions.
    Porting code from PIC to AVR is an interesting task.
    These days I am preparing to try it.
    But I'm out of shape!
    Because I have an inflamed nerve in my shoulder that produces sharp pain and interferes with my focus.
    I flipped through the book again and looked at the source code that Carl provided.
    I had a problem at first because Carl is a huge fan of abbreviations that don't resemble anything!
    And the worst thing is when he mixes up those abbreviations and uses one in the text and the other on the schematic!
    Oooooahahahaha!
    Carl... another suggestion for "Errata"...
    Right now I'm an "idiot" and I don't understand anything.
    Here is the graph and timing.
    As a dumb programmer I need a literal translation of the train of pulses into the correct order.
    Source code comments didn't help me much!
    Carl is "The Duke of Obfuscation"!
    His works do not need additional copyright protection!


    Click image for larger version  Name:	Timing.jpg Views:	0 Size:	129.4 KB ID:	434832


    And here is the first attempt at porting the code:
    (I checked on an Atmega328P, it actually works!?? But you need to organize the timings better...)


    Warning!
    The code is under development, NEVER try it with mosfets if you are not a fan of white smoke!
    ​

    ​
    Code:
    #include <Arduino.h>
    
    #define TXP_PIN 9   // Transmit Positive Pulse (PB1)
    #define TXN_PIN 10  // Transmit Negative Pulse (PB2)
    #define ADC_POT A1  // Potentiometer for delay adjustment
    #define TCLKP 2     // Demodulator control (PD2)
    #define GCLKP 3     // Demodulator control (PD3)
    #define TCLKN 4     // Demodulator control (PD4)
    #define GCLKN 5     // Demodulator control (PD5)
    #define BCLK 6      // Charge pump control (PD6)
    #define LED_PIN 13  // Debug LED (PB5)
    
    // Timing constants for 5kHz PPS
    #define TX_PERIOD 200  // 200µs period for 5kHz PPS
    #define TX_WIDTH 50    // 50µs TX pulse width
    #define MAIN_DELAY 15  // 15µs delay before sampling
    #define MAIN_WIDTH 10  // 10µs main sample width
    #define GND_DELAY 5    // 5µs ground delay
    #define GND_WIDTH 40   // 40µs ground width
    
    volatile unsigned long pulseDelay = MAIN_DELAY; // Default delay after main pulse
    
    void setup()
    {
        DDRB |= (1 << PB1) | (1 << PB2) | (1 << PB5); // Set TXP, TXN, and LED as outputs
        DDRD |= (1 << PD2) | (1 << PD3) | (1 << PD4) | (1 << PD5) | (1 << PD6); // Set control pins as outputs
        
        Serial.begin(115200);
        Serial.println("Bipolar PI (5kHz PPS)");
        
        noInterrupts();
        TCCR1A = 0;
        TCCR1B = (1 << WGM12) | (1 << CS10); // CTC mode, no prescaler
        OCR1A = 16000; // Match value for 1ms (assuming 16MHz clock)
        TIMSK1 |= (1 << OCIE1A); // Enable Timer1 interrupt
        interrupts();
    }
    
    ISR(TIMER1_COMPA_vect)
    {
        PINB |= (1 << PB5); // Toggle LED for debug
    }
    
    void generatePulse()
    {
        PORTB |= (1 << PB1);  // TXP HIGH
        PORTB &= ~(1 << PB2); // TXN LOW
        delayMicroseconds(TX_WIDTH); // TX pulse width
        PORTB &= ~(1 << PB1); // TXP LOW
        PORTB |= (1 << PB2);  // TXN HIGH
        delayMicroseconds(TX_WIDTH);
        PORTB &= ~(1 << PB2); // TXN LOW
        delayMicroseconds(pulseDelay); // Delay before demodulator signals
    }
    
    
    
    void controlChargePump()
    {
        PORTD |= (1 << PD6);  // BCLK HIGH
        delayMicroseconds(50);
        PORTD &= ~(1 << PD6); // BCLK LOW
    }
    
    void loop()
    {
        generatePulse();
        controlDemodulator();
        controlChargePump();
        delayMicroseconds(TX_PERIOD - (2 * TX_WIDTH + pulseDelay + MAIN_WIDTH + GND_DELAY + GND_WIDTH)); // Adjust cycle timing for 5kHz PPS
    }
    
    
    void controlDemodulator() // 25uS delay is just for testing purposes, don't be confused by this...
    {
        PORTD |= (1 << PD2);  // TCLKP HIGH
        delayMicroseconds(25);
        PORTD &= ~(1 << PD2); // TCLKP LOW
            delayMicroseconds(25);
        PORTD |= (1 << PD4);  // TCLKN HIGH
        delayMicroseconds(25);
        PORTD &= ~(1 << PD4); // TCLKN LOW
            delayMicroseconds(25);
        PORTD |= (1 << PD3);  // GCLKP HIGH
        delayMicroseconds(25);
        PORTD &= ~(1 << PD3); // GCLKP LOW
            delayMicroseconds(25);
        PORTD |= (1 << PD5);  // GCLKN HIGH
        delayMicroseconds(25);
        PORTD &= ~(1 << PD5); // GCLKN LOW
        //delayMicroseconds(25);
        
       delayMicroseconds(MAIN_WIDTH); // Demodulator pulse width
      
    }
    
    /*
     * Reserved
     * void controlDemodulator()
    {
        PORTD |= (1 << PD2);  // TCLKP HIGH
        PORTD &= ~(1 << PD4); // TCLKN LOW
      
        PORTD &= ~(1 << PD3); // GCLKP LOW
        PORTD |= (1 << PD5);  // GCLKN HIGH
        
        delayMicroseconds(MAIN_WIDTH); // Demodulator pulse width
        
        PORTD &= ~(1 << PD2); // TCLKP LOW
        PORTD |= (1 << PD4);  // TCLKN HIGH
    
        PORTD |= (1 << PD3);  // GCLKP HIGH
        PORTD &= ~(1 << PD5); // GCLKN LOW
    }
     */
    
     /*
     *  void generatePulse() {
        PORTB |= (1 << PB1);  // TXP HIGH
        PORTB &= ~(1 << PB2); // TXN LOW
        delayMicroseconds(TX_WIDTH); // TX pulse width
        
        PORTB &= ~(1 << PB1); // TXP LOW
        delayMicroseconds(3); // DEAD TIME (adjustable)
    
        PORTB |= (1 << PB2);  // TXN HIGH
        delayMicroseconds(TX_WIDTH);
        
        PORTB &= ~(1 << PB2); // TXN LOW
        delayMicroseconds(3); // DEAD TIME before next cycle
    }
    
    MOSFET Switching Characteristics
    IRF9640 (P-Channel)
    
    Turn-On Delay (td(on)): ~25 ns
    Turn-Off Delay (td(off)): ~100 ns
    Total Switching Time: ~125 ns
    IRF740 (N-Channel)
    
    Turn-On Delay (td(on)): ~10 ns
    Turn-Off Delay (td(off)): ~80 ns
    Total Switching Time: ~90 ns
    -P-MOSFETs (IRF9640) turn off slower (~100 ns delay)
    -N-MOSFETs (IRF740) turn off slightly faster (~80 ns delay)
    *************
    -1 µs dead time between TXP OFF and TXN ON
    -1 µs dead time between TXN OFF and next cycle
    -Prevents shoot-through & protects MOSFETs
    
    **************************************************
    void generatePulse() {
        PORTB |= (1 << PB1);  // TXP HIGH
        PORTB &= ~(1 << PB2); // TXN LOW
        delayMicroseconds(TX_WIDTH); // TX pulse width
    
        PORTB &= ~(1 << PB1); // TXP LOW
        delayMicroseconds(1); // DEAD TIME (~1 µs)
    
        PORTB |= (1 << PB2);  // TXN HIGH
        delayMicroseconds(TX_WIDTH);
    
        PORTB &= ~(1 << PB2); // TXN LOW
        delayMicroseconds(1); // DEAD TIME (~1 µs)
    }
    
    ************************************************
     */​
    ​​

    Leave a comment:


  • pechkata
    replied
    Hello Detector#1.
    I didn't mean the scheme - but the words.
    I dragged the scheme with the post - I don't know how it is cut.
    Meaning - how can you comment on something you didn't do.
    Nothing personal - sorry.

    Leave a comment:


  • Detectorist#1
    replied
    Why you want this? What is the purpose? This is only one not very good solution for controlling of 4053 switches. Further improvements are more better.

    Leave a comment:


  • pechkata
    replied
    Originally posted by ivconic View Post
    It is very difficult to find anything in the book that is not very interesting.
    But I immediately decided on the Bipolar PI design as the first thing to focus on.
    There are several reasons for that.
    First, I like the idea of ​​a "non-invasive" detection method because of the possibility of adapting this project for demining purposes.
    Second, this approach is only the tip of the iceberg of possibilities for further development of PI detectors. That is my humble opinion, there are probably many who will disagree with me.
    I have tried to participate in the AMX thread a long time ago but felt deprived of the vast knowledge that the other participants in the thread undoubtedly have.
    Then I realized that I still have a lot to learn in order to be an equal interlocutor with others.
    Luckily Carl's book is here, I have plenty of time to read and study. And now I'm slowly (after all, I'm quite old) starting to understand some things.
    That's why I think Bipolar PI design is a good initial step and an introduction to some broader knowledge.
    Carl offered very interesting solutions that "provoke" further thoughts.
    There are two parts in particular that I really like. TX and audio. I wouldn't dwell on audio for now, because I think it is necessary to make it first and only then draw conclusions.
    At this point I would focus on TX first.
    Originally from the book Bipolar PI TX looks like this:


    Click image for larger version  Name:	BiPolar PI a.jpg Views:	553 Size:	228.9 KB ID:	432528​​
    I am also not very aware of this matter - especially with these chips - peak.
    But I want the readers of this forum to look into your words.

    Leave a comment:


  • Carl-NC
    replied
    Amazon for paperback. If you want hardback you might find it on Amazon or you can order it through a retail bookseller.

    Leave a comment:


  • detecto
    replied
    Where can i buy latest book? @Carl?

    Leave a comment:


  • Carl-NC
    replied
    Originally posted by algan View Post
    Hi Carl, here the two impulses to are high, and for example if one is low and the other is high, then the picture will be the same as in the book, but won't the bugs then disappear, have you tested it this way? Thanks.​
    Fig 23-11 only applies to the differential coil driver (Fig 23-10), not the H-bridge driver. The H-bridge driver produces flyback only in one direction.

    Leave a comment:


  • ivconic
    replied
    I didn't just randomly choose this project around which I started the topic, but for a good reason.
    Unfortunately, I still don't have the conditions to make it.
    A friend sent me a PIC from a neighboring country, but the package did not arrive.
    A frequent occurrence with Serbian post offices and customs.
    So I have nothing new to post except to follow what other colleagues are doing.



    Porting the code to the AVR won't be a difficult task, but it will take time. But it also entails redesigning the pcb. And so the tasks pile up.
    ​​

    Leave a comment:


  • algan
    replied

    Hi Carl, here the two impulses to are high, and for example if one is low and the other is high, then the picture will be the same as in the book, but won't the bugs then disappear, have you tested it this way? Thanks.​

    Leave a comment:


  • pechkata
    replied
    Hello everyone.
    Works just as described in the book.
    Not a bad idea - I've never made a detector with this pumping before.
    Something like multi-frequency.
    I like it.

    Leave a comment:


  • algan
    replied
    Yes, thanks, I thought it was just according to the diagram in the book, I missed reading this topic.

    Leave a comment:


  • Carl-NC
    replied
    I don't understand what you are requesting. Also, Fig 23-11 has an error. See the Errata thread for the correction.

    Leave a comment:


  • algan
    replied
    Hello, Carl, I would like to ask, there is another diagram of the bipolar generator shown in the book, and the diagram actually shows what is on the oscilloscope, and could you post the diagram of the generator that is pictured in the book, so that we can do it to this diagram. Thanks. Click image for larger version

Name:	333333333333.jpg
Views:	424
Size:	371.0 KB
ID:	434747

    Leave a comment:


  • Detectorist#1
    replied
    Hi Carl,
    Sorry, you are right - with POT connected in series with the input resistor, the curve is very non linear. The gain when POT is zero and is connected in series with the backward 1K resistor is not 1 but 2 but this not changes the total curve of dependence. Sorry again!

    Leave a comment:


  • Carl-NC
    replied
    Here are the gain curves with the pot in both places. I've reduced the pot to 10k instead of 50k. With the pot in series with R54 the gain is very linear [G = (R54+P4)/R53]. With the pot in series with R53 (and R54 = 10k) it is very non-linear [G = R54/(R53+P4)]. If you do this with a 50k pot it becomes even more non-linear.

    Click image for larger version

Name:	image.png
Views:	410
Size:	10.8 KB
ID:	434738​

    Leave a comment:

Working...
X