Announcement

Collapse
No announcement yet.

Hattusa Pulse

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

  • jeep6789
    replied
    Should we use a chip with low voltage drop instead of 7085, because it has a voltage drop of 2v, and then opamp 5v, 12v and gnd, they seem to have some problems with the opamp voltage

    Leave a comment:


  • jeep6789
    replied
    I don't understand the power connection method of lf353, so its total voltage value is only 7v?

    Leave a comment:


  • ivconic
    replied
    Originally posted by F117 View Post
    Instead of using an I2C IO expander 8574 + 2x16 char LCD,
    why not simply attach an I2C OLED display ?
    Cheaper, simpler, less old-fashioned and more creative...
    eg
    https://www.amazon.com.be/-/en/Ardui...df_B0BNHSGC63Z

    When you insist on using the LCD, do you really need the IO expander? I can see some unused and "reserve" spare pins on the processor.
    I think it is due Proteus simulation, in reality I think it is not the case.
    Yes anything that have I2C can be served as output.
    I have few of those displays, but those are too small... or I am too old and my sight is getting worse.
    Anyway; good idea, for those with good sight.


    Leave a comment:


  • BC547
    replied
    Instead of using an I2C IO expander 8574 + 2x16 char LCD,
    why not simply attach an I2C OLED display ?
    Cheaper, simpler, less old-fashioned and more creative...
    eg
    https://www.amazon.com.be/-/en/Ardui...df_B0BNHSGC63Z

    When you insist on using the LCD, do you really need the IO expander? I can see some unused and "reserve" spare pins on the processor.

    Leave a comment:


  • ivconic
    replied
    Check C19 on your schematic; it is reversed!

    Leave a comment:


  • ivconic
    replied
    Click image for larger version  Name:	image.png Views:	0 Size:	33.5 KB ID:	411251

    Check this out!
    ​Although the code is still small, only 1/4 of the total capacity; there is even a 1% difference in size,
    when you apply the optimizations I mentioned in the previous post.
    But the saving on capacity is secondary, the main gain is on the speed of execution and greater accuracy of timings.
    ...

    And it's important to mention that I'm using Arduino IDE 1.8.5 which is a very old version.
    I use that version on purpose because of the hundreds of programs I've written and still use when building devices and due some compatibility issues.
    Newer versions of the IDE have much better optimization when compiling, so this whole story will look much better if you use newer versions of the Arduino IDE.
    ​​

    Leave a comment:


  • ivconic
    replied
    Before you continue writing the code; please take a look at what i remade.
    First; for a clearer code: it's always good to divide the code into tabs as independent units, it's easier to view and navigate the code.
    It looks more organized everywhere.
    Second; it is always better to use direct port/pin manipulation, wherever the situation allows.
    Once upon a time, I did a comparison and came to the conclusion that this method is about 14 times faster than Cpp functions.
    Third; MOST IMPORTANT!!! Always try to keep the IRQ as short as possible and as little loaded with functions as possible.
    Direct port/pin manipulation also comes in handy for this purpose.
    ...
    Check out this code that I have modified in some places. I didn't delete your original lines, I just commented on them.
    In the Proteus simulator it might not show, but once you have the hardware ready; you'll be surprised at the difference in code execution speed.
    And this is especially important when it comes to a PI detector, whose quality of work depends mostly on precise timings.
    ​

    Hattusa_code02.zip

    Leave a comment:


  • ivconic
    replied
    "...atmega328p is an old architecture..."

    Let it be.
    But if Atmega gets the job done well; why discard it or change it?
    I have been working with the Atmega328P for years and have built dozens, maybe over a hundred different devices with it.
    Of course, commercial devices for which I received money. You could say that I make a living from it.
    Why would I change that?
    I don't look back at those comments at all, like "old, outgrown, backward...".
    They can talk about that as much as they want.
    But the chip is cheap, easy to find, and does a great job for me in many different devices.
    And I have no intention of giving up the Atmega 328P, on the contrary; I have dozens more good ideas with it.
    Even more; it's much more satisfying when you do something good with more modest material than when you "kill an elephant for a kilo of meat"...
    as many people advocate and talk about doing... although so far I haven't seen them actually do anything, to be honest. Just empty words.
    Not to be long; don't give up, keep working, you have my sincere support.
    Give me a day or few to review everything. Don't mind if I'm slow, I'm busy with other things that I can't put off.

    ​

    Leave a comment:


  • ivconic
    replied
    Originally posted by Hattusa View Post
    I waited for a suggestion for my design in my 1st message, no response. I know ads1115 is slow. To overcome this, I increased the sampling rate. It works at 1 khz. I said that atmega328p is an old architecture.
    As a result, I am trying to make a simple but effective device.
    My goal is to build a device on felezjo, amateur work so...

    You can use ads115 on the 15th bit. ie 15 bits.

    Will this device be of any help to you? I thought that you would contribute to me and I to you during the construction of this device. Or I aim to show (as far as I know) how to design a PI to newbies dealing with these things.

    If you don't believe it will help, let's not continue the project. what are you thinking?​
    My personal opinion is that it will help to many newcomers, and it is splendid example of mixing analog with digital.
    I think you should continue working on it. I will try to catch up too.
    Give me some time, I am over-occupied these days, too much responsibilities.
    I can obtain AD1115 and LF398.
    So I will make it sooner or later, be sure in that.
    But before I make it; I will try to make some changes.
    Some minor adaptations for my own taste.
    I will post any eventual work, step by step.
    Don't give up!
    There are people with expert knowledge and this project will not be very interesting to them, but majority of people are not with knowledge at such level and this project will be of a great value for them, trust me.
    BTW this is forum, that's what is all about with forums; anybody with any level of knowledge to come and to find something intersting for him.
    Don't be disappointed if a lot of people don't join the thread right away.
    Because forum activity has dropped drastically in the last few years, and especially in the last few months.
    But times are changing. That's how it's always been.
    There is a period of reduced activity and there is a period of increased activity.
    You just do your thing and don't look back to see if someone answers or not.
    Believe that as the project progresses; more and more people will pay attention.
    Perhaps it is a bit unfortunate that the AMX project is already taking place on the forum, which should be "top notch" and people's attention is more focused there.
    Everyone is waiting for Carl to make something really good and release it as a project.
    I wouldn't look back on it. Every idea is good for someone and every idea will have its audience.
    I applaud to your good will on this and advise you not to give up.
    I will participate from my side according to my capabilities.​


    Leave a comment:


  • Hattusa
    replied
    I waited for a suggestion for my design in my 1st message, no response. I know ads1115 is slow. To overcome this, I increased the sampling rate. It works at 1 khz. I said that atmega328p is an old architecture.
    As a result, I am trying to make a simple but effective device.
    My goal is to build a device on felezjo, amateur work so...

    You can use ads115 on the 15th bit. ie 15 bits.

    Will this device be of any help to you? I thought that you would contribute to me and I to you during the construction of this device. Or I aim to show (as far as I know) how to design a PI to newbies dealing with these things.

    If you don't believe it will help, let's not continue the project. what are you thinking?​

    Leave a comment:


  • ivconic
    replied
    Then with a good filter you can read very accurate values of pressed button:

    Code:
    const int filterWeight = 128;  
    const int numReadings = 10;
    int average = 0;              
    const uint8_t ButtonPin PROGMEM = A0;
    enum Buttons{Button_OK = 1, Button_LEFT = 2, Button_RIGHT = 3, Button_UP = 4, Button_DOWN = 5};
    
    void setup()
    {
    }
    void loop()
    {
    }
    
      int old_button = 0;
      int getButton()
    {
      int i, z, sum;
      int button;
      i = 0;
      do
       {
       average = analogRead(ButtonPin);
       average = average + (analogRead(ButtonPin) - average) / filterWeight;
       i++;
       }
      while (i < numReadings);
      z = average;
      if (z > 850) button = 0;
      else if (z < 99) button = Button_RIGHT;
      else if (z > 130 && z < 200) button = Button_UP;
      else if (z > 300 && z < 380) button = Button_DOWN;
      else if (z > 450 && z < 580) button = Button_LEFT;
      else if (z > 700 && z < 850) button = Button_OK;
      else button = 0;
      return button;
    }
    ​

    Leave a comment:


  • ivconic
    replied
    ADS115 is 16bit, alright, but with only 860 sps, too slow.
    While Atmega328P's ADC is much faster, but... ENOB falls dramatically down with increase of the ADC clock frequency.
    This is informative article to read:

    http://www.openmusiclabs.com/learnin...adc/index.html
    So, no happy solution with any of the choices.
    ​That's why I insisted to see the video of it's behavior.
    To see what you get in reality from those two SAH chips, since I don't have conrete and present experiences with such.
    I guess, I will have to make it to see.
    ...
    At this moment I can give you only one suggestion, realting to the buttons.
    Avoid using buttons tied to digital pins, instead use 3,5 ot more buttons and one single analog pin.
    You will save digital pins for future upgrades and You'll get quite accurate and noise suppresed analog reading the values for 3, 5 and more buttons.
    Use 5 buttons for example like this:


    ​​Click image for larger version

Name:	image.png
Views:	533
Size:	7.4 KB
ID:	411243​

    Leave a comment:


  • Hattusa
    replied
    Did you try the code in proteus? so is my post correct? I guess I'm done with writing the menu. I updated the code now.

    Note: there is no reorder in the message I sent, I guess, I had to reload the code.​
    Code:
    /*
    Hattusa Pi Detector software
    */
    #include <Wire.h>               // Wire kütüphanesini ekliyoruz.
    #include <LiquidCrystal_I2C.h>  // LiquidCrystal_I2C kütüphanesini ekliyoruz.
    #include <Adafruit_ADS1X15.h>
    #include <EEPROM.h> /* EEPROM fonksiyonları için kütüphane dahil edilmelidir. */
    
    LiquidCrystal_I2C lcd(0x20, 20, 4);  // 16 karakter, 2 satır LCD için bağlantı adresi:0x20
    Adafruit_ADS1015 ads;                /* Use this for the 12-bit version */
    #define Pulse 8
    #define T0 3
    #define T1 2
    #define FerroSound 5
    #define NonFerroSound 9
    #define Enter 11
    #define Up 12
    #define Down 13
    bool BluetoothConnection = false, PressOk = false,AutoTuneOk =false,SettingsOk =false;
    uint8_t PulsePower, T0Delay, T1Delay, MenuSet, TsrHold, pTsrHold, EnterCounter, PressTime = 10;
    uint8_t EnterSelect, UpSelect, DownSelect, SoundLevel,AutoTune;
    float Batery, pBatery;
    long PressCount,AutoCount;
    uint16_t AutoT[10]={0,500,1000,1500,2000,2500,3000,3500,4000,4500};
    void setup() {
      pinMode(Pulse, OUTPUT);
      pinMode(T0, OUTPUT);
      pinMode(T1, OUTPUT);
      pinMode(FerroSound, OUTPUT);
      pinMode(NonFerroSound, OUTPUT);
      pinMode(Enter, INPUT);
      pinMode(Up, INPUT);
      pinMode(Down, INPUT);
      digitalWrite(Pulse, HIGH);
      BluetoothConnection = EEPROM.read(1);
      if (BluetoothConnection) Serial.begin(115200);  //start connection if bluetooth will be used
      PulsePower = EEPROM.read(2);
      if (PulsePower == 255) PulsePower = 150;
      T0Delay = EEPROM.read(3);
      if (T0Delay == 255) T0Delay = 50;
      T1Delay = EEPROM.read(4);
      if (T1Delay == 255) T1Delay = 25;
      TsrHold = EEPROM.read(5);
      if (TsrHold == 255) TsrHold = 50;
      SoundLevel = EEPROM.read(6);
      if (SoundLevel == 255) SoundLevel = 20;
      AutoTune = EEPROM.read(7);
      if (AutoTune == 255) AutoTune = 1;
      if(AutoTune ==0){
        AutoTuneOk =false;
      }else{
        AutoTuneOk =true;
      }
      Interrupt3Set();
      lcd.init();
      lcd.backlight();
      bool flipflop = false;
      for (int x = 0; x < 16; x++) {  //We wait for a while for the coil to energize and the signal to form, the opening menu has been added
        flipflop = !flipflop;
        if (flipflop) {
          lcd.setCursor(0, 0);
          lcd.print("HATTUSA OPENING!");
        } else {
          lcd.setCursor(0, 0);
          lcd.print("                ");
        }
        lcd.setCursor(x, 1);
        lcd.print(">");
        Batery = BattMeasure();
        delay(100);
      }
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("TSR:");
      lcd.print(TsrHold);
    }
    void loop() {
      Batery = BattMeasure();
      if ((Batery != pBatery) && SettingsOk ==false) {
        lcd.setCursor(10, 0);
        lcd.print(Batery);
        lcd.print("V ");
        pBatery = Batery;
      }
      if (TsrHold != pTsrHold) {
        lcd.setCursor(0, 0);
        lcd.print("TSR:");
        lcd.print(TsrHold);
        pTsrHold = TsrHold;
      }
      if(AutoTuneOk){
        if((millis() -AutoCount) >AutoT[AutoTune]){
          AutoCount =millis();
          // autotune code will be written
        }
      }
    
      /*    Main Menu Functions      */
      ButtonControl();
      if (PressOk) {
        if ((millis() - PressCount) > 500) {
          lcd.setCursor(0, 1);
          lcd.print("                ");
          PressOk = false;
        }
      }
    }
    void ButtonControl() {
      EnterSelect = digitalRead(Enter);
      UpSelect = digitalRead(Up);
      DownSelect = digitalRead(Down);
      /**  Enter Button Function   **/
      if (EnterSelect == 0) {
        EnterCounter = 0;
        while (EnterSelect == 0) {
          EnterCounter++;
          EnterSelect = digitalRead(Enter);
          delay(100);
          if(EnterCounter>PressTime)break;
        }
        if (EnterCounter < PressTime) {
          lcd.setCursor(0, 1);
          lcd.print("   G R O U N D  ");
          PressCount = millis();
          PressOk = true;
        } else {
          MenuSet++;
          if (MenuSet > 3) MenuSet = 0;
          if (MenuSet == 0) {
            lcd.clear();
            SettingsOk =false;
            pTsrHold = 0;
            pBatery =0;
          }
          if (MenuSet == 1) {
            lcd.setCursor(0, 0);
            lcd.print("SOUND:");
            lcd.print(SoundLevel / 10);
          }
          if (MenuSet == 2) {
            lcd.setCursor(0, 0);
            lcd.print("ATUNE:");
            if(AutoTune==0){
              lcd.print("OFF");
              AutoTuneOk =false;
            }else{
              lcd.print(AutoTune);
              AutoTuneOk =true;
            }
          }
          if(MenuSet ==3){
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("T0:");
            lcd.setCursor(8, 0);
            lcd.print("T1:");
            SettingsOk =true;
          }
        }
      }
      /*    Up Button Funciton  */
      if (UpSelect == 0) {
        if (MenuSet == 0) {
          TsrHold++;
          if (TsrHold > 99) TsrHold = 99;
          EEPROM.write(5, TsrHold);
        }
        if (MenuSet == 1) {
          SoundLevel += 10;
          if (SoundLevel >= 200) SoundLevel = 200;
          EEPROM.write(6, SoundLevel);
          lcd.setCursor(0, 0);
          lcd.print("SOUND:");
          lcd.print(SoundLevel / 10);
        }
        if (MenuSet == 2) {
          AutoTune++;
          if(AutoTune>=9)AutoTune =9;
            EEPROM.write(7,AutoTune);
           lcd.setCursor(0, 0);
            lcd.print("ATUNE:");
            if(AutoTune==0){
              lcd.print("OFF");
              AutoTuneOk =false;
            }else{
              lcd.print(AutoTune);
              lcd.print("  ");
              AutoTuneOk =true;
            }
        }
        if (MenuSet == 3) {
          lcd.setCursor(0, 0);
            lcd.print("T0:");
            lcd.setCursor(8, 0);
            lcd.print("T1:");
            //to be written
        }
        delay(200);
      }
      /*    Down Button Funciton  */
      if (DownSelect == 0) {
        if (MenuSet == 0) {
          TsrHold--;
          if (TsrHold < 1) TsrHold = 1;
          EEPROM.write(5, TsrHold);
        }
        if (MenuSet == 1) {
          SoundLevel -= 10;
          if (SoundLevel <=0) SoundLevel = 0;
          EEPROM.write(6, SoundLevel);
          lcd.setCursor(0, 0);
          lcd.print("SOUND:");
          if(SoundLevel==0){
          lcd.print("OFF");
          }else{
          lcd.print(SoundLevel / 10);
          lcd.print("   ");
          }
        }
        if (MenuSet == 2) {
          AutoTune--;
          if(AutoTune==255)AutoTune =0;
            EEPROM.write(7,AutoTune);
           lcd.setCursor(0, 0);
            lcd.print("ATUNE:");
            if(AutoTune==0){
              lcd.print("OFF");
              AutoTuneOk =false;
            }else{
              lcd.print(AutoTune);
              lcd.print("  ");
              AutoTuneOk =true;
            }
        }
        if (MenuSet == 3) {
          lcd.setCursor(0, 0);
            lcd.print("T0:");
            lcd.setCursor(8, 0);
            lcd.print("T1:");
            //to be written
        }
        delay(200);
      }
    }
    float BattMeasure() {
      float bat;
      int adc = analogRead(A0);
      return bat = (adc * (5.0 / 1023.0)) / 0.2326;  //10k /(33k +10k) =>0.2326
    }
    
    /*   timer2 interrup setting */
    void Interrupt3Set() {  // 1000 Hz (16000000/((124+1)*128))
      noInterrupts();
      TCCR2A = 0;
      TCCR2B = 0;
      TCNT2 = 0;
      OCR2A = 124;
      TCCR2A |= (1 << WGM21);
      TCCR2B |= (1 << CS22) | (1 << CS20);
      TIMSK2 |= (1 << OCIE2A);
      interrupts();
    }
    /*   timer2 interrup function */
    ISR(TIMER2_COMPA_vect) {
      digitalWrite(Pulse, LOW);
      delayMicroseconds(PulsePower);
      digitalWrite(Pulse, HIGH);
      delayMicroseconds(T0Delay);
      digitalWrite(T0, HIGH);
      delayMicroseconds(5);
      digitalWrite(T0, LOW);
      delayMicroseconds(T1Delay);
      digitalWrite(T1, HIGH);
      delayMicroseconds(5);
      digitalWrite(T1, LOW);
    }
    ​

    Leave a comment:


  • ivconic
    replied
    ​Click image for larger version  Name:	HATTUSA.jpg Views:	0 Size:	813.4 KB ID:	411238​


    How about really good resoluton like this?
    (4608x4608 is the max. this forum allows)


    Leave a comment:


  • ivconic
    replied
    Code compiles, no problem.

    Leave a comment:

Working...
X