Ankündigung

Einklappen
Keine Ankündigung bisher.

Konnekting on Pro Micro

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    Konnekting on Pro Micro

    I have a piece of code that is working on a Leonardo. Now I want to try it on a Pro Micro but it doesnt work.
    It seems to stop after the "Setup is ready".

    Is there something special about the pro micro's that I am overlooking?

    #2
    Hi, can you post your piece of code?

    Kommentar


      #3
      Code:
      // include the library code:
      #include <LiquidCrystal.h>
      #include <KonnektingDevice.h>
      #include "kdevice_IO_v1.h"
      
      
      #define CHANNELS_COUNT 1
      
      // ################################################
      // ### KONNEKTING Configuration
      // ################################################
      
      #define KNX_SERIAL Serial1// Leonardo/Micro etc. use Serial1
      
      // ################################################
      // ### IO Configuration
      // ################################################
      #define PROG_LED_PIN 15
      #define PROG_BUTTON_PIN 2
      #define Output1 A0
      #define Output2 A1
      #define Output3 A2
      #define Output4 A3
      #define Trigger1 9
      #define Trigger2 10
      #define Trigger3 14
      #define Trigger4 15
      
      // ################################################
      // ### Global variables, sketch related
      // ################################################
      
      int trigger[] = {COMOBJ_trigger1, COMOBJ_trigger2, COMOBJ_trigger3, COMOBJ_trigger4};
      int port[] = {Trigger1, Trigger2, Trigger3, Trigger4};
      const int portCount = 4;
      int buttonState[portCount];      // current state of the button
      int lastButtonState[portCount]; // previous state of the button
      const int rs = 8, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
      LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
      
      // ################################################
      // ### SETUP
      // ################################################
      
      void setup() {
        lcd.begin(16, 2);
        lcd.setCursor(0, 0);
        lcd.print("Hello Robin! ");
      
        pinMode(Output1, OUTPUT);
        pinMode(Output2, OUTPUT);
        pinMode(Output3, OUTPUT);
        pinMode(Output4, OUTPUT);
        pinMode(Trigger1, INPUT_PULLUP);
        pinMode(Trigger2, INPUT_PULLUP);
        pinMode(Trigger3, INPUT_PULLUP);
        pinMode(Trigger4, INPUT_PULLUP);
      
        // Initialize KNX enabled Arduino Board
        Konnekting.init(KNX_SERIAL,
                        PROG_BUTTON_PIN,
                        PROG_LED_PIN,
                        MANUFACTURER_ID,
                        DEVICE_ID,
                        REVISION);
        // set up the LCD's number of columns and rows:
        lcd.setCursor(0, 1);
        lcd.print("Setup is ready!");
      }
      
      
      
      // ################################################
      // ### LOOP
      // ################################################
      
      void loop() {
        Knx.task();
        if (Konnekting.isReadyForApplication()) {
          // Reading Triggers *******************************
          for (int var = 0; var < portCount; var++) {
            buttonState[var] = digitalRead(port[var]);
            Serial.write(var);
            if (buttonState[var] != lastButtonState[var]) {
              if (buttonState[var] == HIGH) {
                Knx.write(trigger[var], false);
                lcd.setCursor(0, 1);
                lcd.print("Button released!");
              } else {
                Knx.write(trigger[var], true);
                lcd.setCursor(0, 1);
                lcd.print("Button pushed!");
                lcd.print(var);
              }
              lastButtonState[var] = buttonState[var];
              delay(100);
            }
          } //End for
        } //End Ready Application
      } //End Loop
      
      // ################################################
      // ### KNX EVENT CALLBACK
      // ################################################
      
      void knxEvents(byte index) {
      
        switch (index) {
          case COMOBJ_output1:
            if (Knx.read(COMOBJ_output1)) {
              digitalWrite(Output1, HIGH);
            } else {
              digitalWrite(Output1, LOW);
            }
            break;
          case COMOBJ_output2:
            if (Knx.read(COMOBJ_output2)) {
              digitalWrite(Output2, HIGH);
            } else {
              digitalWrite(Output2, LOW);
            }
            break;
          case COMOBJ_output3:
            if (Knx.read(COMOBJ_output3)) {
              digitalWrite(Output3, HIGH);
            } else {
              digitalWrite(Output3, LOW);
            }
            break;
          case COMOBJ_output4:
            if (Knx.read(COMOBJ_output4)) {
              digitalWrite(Output4, HIGH);
            } else {
              digitalWrite(Output4, LOW);
            }
      
          default:
            break;
        }
      };

      Kommentar


        #4
        That should not be your problem, but anyway
        Code:
         
         Serial.write(var);
        but no Serial.begin...

        Kommentar


          #5
          Yeah not the solution.
          Deleted it.

          Kommentar


            #6
            I'd say wrong wired KNX Serials, but if you say your LCD does output the "Setup is ready" then this should not be the case...
            Can you check if the code runs into the loop() method and if its stuck at knx.task() by adding serial.Writes (or lcd writes) before and after the Knx.task method with a delay afterwards?

            Kommentar


              #7
              Konnekting is not ready for application.
              This is failing: Konnekting.isReadyForApplication()

              Code:
              void loop() {
                lcd.clear();
                lcd.setCursor(0, 0);
                lcd.print("Loop started");
                delay(2000);
                Knx.task();
                lcd.clear();
                lcd.setCursor(0, 0);
                lcd.print("KNX tasks ended");
                delay(2000);
                if (Konnekting.isReadyForApplication()) {
                  lcd.clear();
                    lcd.setCursor(0, 0);
                    lcd.print("App is Ready");
                    delay(2000);
                }else{
                  lcd.clear();
                    lcd.setCursor(0, 0);
                    lcd.print("App not Ready");
                    delay(2000);
                }//End Ready Application
              } //End Loop

              Kommentar


                #8
                Okay. You have to program your device via the Konnekting Suite. (KNX GA's, parameters , aso..)

                isReadyForApplication will return only true if your device is not in programm mode and its not in factory state.


                Code:
                bool KonnektingDevice::isReadyForApplication() {
                    bool isReady = (!isProgState() && !isFactorySetting());
                    return isReady;
                }
                Zuletzt geändert von ChriD; 26.06.2018, 21:47.

                Kommentar


                  #9
                  That was my guess.
                  I tried the communication test and that worked fine.
                  Afterwards I tried the original code and it wouldnt program in the konnekting suite. Now I think I should have waited longer?
                  After some fiddling it works now.
                  Such a stupid mistake.
                  Thanks for the help!!!
                  Zuletzt geändert von RobinL; 26.06.2018, 22:16.

                  Kommentar

                  Lädt...
                  X