PowerNodeNG: verschil tussen versies

Uit MakerSpace Leiden
Ga naar: navigatie, zoeken
(i2c scanning)
(IMPORTANT)
 
(4 tussenliggende versies door dezelfde gebruiker niet weergegeven)
Regel 7: Regel 7:
 
In use at the [[NodeVoordeur]], [[NodeMetal]] and [[NodeBandsaw]].
 
In use at the [[NodeVoordeur]], [[NodeMetal]] and [[NodeBandsaw]].
  
= Bring up =
+
= IMPORTANT =
  
Scripts to help debugging/testing a new board being build
+
[[Bestand:Usb-condom.jpg|150px|USB Galvanic Isolator/Separator]]
  
== i2c scanning ==
+
The Olimex POE is not galvanically isolated. So it is essential to use a [[Galvanic USB isolator|USB condom/galvenic separator]] when it is connected both to Ethernet and USB. As otherwise there is a voltage delta of 48 or 2x72V between your laptops earth.
  
An I2C scan should, at least, find the RFID unit (PN532=0x24) and the i2c expander (MCP=0x20). It may find the screen (typically 0x58 or 0x60) if wired in.
+
= Bring up =
  
````
+
Scripts to help debugging/testing a new board being build
#include <Wire.h>
 
  
// Correct values for https://github.com/Hans-Beerman/NodeStandard/blob/master/KiCad_Files/NodeStandard/NodeStandard.pdf
+
== Serial check ==
//
 
const int I2C_SDA = 13;
 
const int I2C_SCL = 16;
 
  
// the setup function runs once when you press reset or power the board
+
    void setup() {
void setup() {
+
      Serial.begin(115200);
  Serial.begin(115200);
+
   
 +
      // Required to flush/empty any cruft/different baud-rate during programming.
 +
      //
 +
      while (!Serial) {
 +
        Serial.println();
 +
        delay(10);
 +
      };   
 +
      Serial.println("\n\n" __FILE__ "\n" __DATE__ " " __TIME__);
 +
    }
 +
   
 +
    // the loop function runs over and over again forever
 +
    void loop() {
 +
        static unsigned long lst = 0;
 +
        if (millis() - lst > 1000) {
 +
          lst = millis();
 +
          Serial.println("tok");
 +
        };
 +
    }
  
  // Required to flush/empty any cruft/different baud-rate during programming.
+
== i2c scanning ==
  //
 
  while (!Serial) {
 
    Serial.println();
 
    delay(10);
 
  };
 
  
  Serial.println("\n\n" __FILE__ "\n" __DATE__ " " __TIME__);
+
An I2C scan should, at least, find the RFID unit (PN532=0x24) and the i2c expander (MCP=0x20). It may find the screen (typically 0x58 or 0x60) if wired in.
 
 
#define GPIOPORT_I2C_RECOVER_SWITCH            (15)      
 
  pinMode(GPIOPORT_I2C_RECOVER_SWITCH, OUTPUT);
 
  digitalWrite(GPIOPORT_I2C_RECOVER_SWITCH, 0);
 
  
  Wire.begin(I2C_SDA, I2C_SCL /*, clock frequency */);
+
    #include <Wire.h>
};
+
   
 
+
    // Correct values for https://github.com/Hans-Beerman/NodeStandard/blob/master/KiCad_Files/NodeStandard/NodeStandard.pdf
void scan_i2c()
+
    //
{
+
    const int I2C_SDA = 13;
  Serial.println ();
+
    const int I2C_SCL = 16;
  Serial.println ("I2C scanning (PN532=0x24, MCP=0x20)");
+
   
  byte count = 0;
+
    // the setup function runs once when you press reset or power the board
 
+
    void setup() {
  for (byte i = 8; i < 128; i++)
+
      Serial.begin(115200);
  {
+
   
     Wire.beginTransmission (i);         // Begin I2C transmission Address (i)
+
      // Required to flush/empty any cruft/different baud-rate during programming.
     if (Wire.endTransmission () == 0)  // Receive 0 = success (ACK response)
+
      //
 +
      while (!Serial) {
 +
        Serial.println();
 +
        delay(10);
 +
      };
 +
   
 +
      Serial.println("\n\n" __FILE__ "\n" __DATE__ " " __TIME__);
 +
   
 +
     #define GPIOPORT_I2C_RECOVER_SWITCH            (15)
 +
      pinMode(GPIOPORT_I2C_RECOVER_SWITCH, OUTPUT);
 +
      digitalWrite(GPIOPORT_I2C_RECOVER_SWITCH, 0);
 +
      
 +
      Wire.begin(I2C_SDA, I2C_SCL /*, clock frequency */);
 +
    };
 +
   
 +
    void scan_i2c()
 
     {
 
     {
       Serial.print (" - Device at address: ");
+
       Serial.println ();
      Serial.print (i, DEC);
+
      Serial.println ("I2C scanning (PN532=0x24, MCP=0x20)");
      Serial.print (" (0x");
+
      byte count = 0;
      Serial.print (i, HEX);
+
   
      Serial.println (")");
+
      for (byte i = 8; i < 128; i++)
      count++;
+
      {
 +
        Wire.beginTransmission (i);          // Begin I2C transmission Address (i)
 +
        if (Wire.endTransmission () == 0)  // Receive 0 = success (ACK response)
 +
        {
 +
          Serial.print (" - Device at address: ");
 +
          Serial.print (i, DEC);
 +
          Serial.print (" (0x");
 +
          Serial.print (i, HEX);
 +
          Serial.println (")");
 +
          count++;
 +
        }
 +
      }
 +
      Serial.print ("Found ");
 +
      Serial.print (count, DEC);
 +
      Serial.println (" device(s).");
 +
    }
 +
   
 +
    // the loop function runs over and over again forever
 +
    void loop() {
 +
      {
 +
        static unsigned long lst = 0;
 +
        if (millis() - lst > 10 * 1000) {
 +
          lst = millis();
 +
          scan_i2c();
 +
        };
 +
      };
 +
      {
 +
        static unsigned long lst = 0;
 +
        if (millis() - lst > 1000) {
 +
          lst = millis();
 +
          Serial.println("tok");
 +
        };
 +
      };
 
     }
 
     }
  }
 
  Serial.print ("Found ");
 
  Serial.print (count, DEC);
 
  Serial.println (" device(s).");
 
}
 
 
// the loop function runs over and over again forever
 
void loop() {
 
{
 
  static unsigned long lst = 0;
 
  if (millis() - lst > 10*1000) {
 
    lst = millis();
 
    scan_i2c();
 
  };
 
};
 
{
 
  static unsigned long lst = 0;
 
  if (millis() - lst > 1000) {
 
    lst = millis();
 
    Serial.println("tok");
 
  };
 
};
 
}
 
''''
 

Huidige versie van 1 jan 2024 om 20:57


Nieuwe generieke power nodes; gemaakt door HansB.

Not yet fully documented, https://github.com/Hans-Beerman/NodeStandard.

In use at the NodeVoordeur, NodeMetal and NodeBandsaw.

IMPORTANT

USB Galvanic Isolator/Separator

The Olimex POE is not galvanically isolated. So it is essential to use a USB condom/galvenic separator when it is connected both to Ethernet and USB. As otherwise there is a voltage delta of 48 or 2x72V between your laptops earth.

Bring up

Scripts to help debugging/testing a new board being build

Serial check

   void setup() {
     Serial.begin(115200);
   
     // Required to flush/empty any cruft/different baud-rate during programming.
     //
     while (!Serial) {
       Serial.println();
       delay(10);
     };    
     Serial.println("\n\n" __FILE__ "\n" __DATE__ " " __TIME__);
   }
   
   // the loop function runs over and over again forever
   void loop() {
       static unsigned long lst = 0;
       if (millis() - lst > 1000) {
         lst = millis();
         Serial.println("tok");
       };
   }

i2c scanning

An I2C scan should, at least, find the RFID unit (PN532=0x24) and the i2c expander (MCP=0x20). It may find the screen (typically 0x58 or 0x60) if wired in.

   #include <Wire.h>
   
   // Correct values for https://github.com/Hans-Beerman/NodeStandard/blob/master/KiCad_Files/NodeStandard/NodeStandard.pdf
   //
   const int I2C_SDA = 13;
   const int I2C_SCL = 16;
   
   // the setup function runs once when you press reset or power the board
   void setup() {
     Serial.begin(115200);
   
     // Required to flush/empty any cruft/different baud-rate during programming.
     //
     while (!Serial) {
       Serial.println();
       delay(10);
     };
   
     Serial.println("\n\n" __FILE__ "\n" __DATE__ " " __TIME__);
   
   #define GPIOPORT_I2C_RECOVER_SWITCH             (15)
     pinMode(GPIOPORT_I2C_RECOVER_SWITCH, OUTPUT);
     digitalWrite(GPIOPORT_I2C_RECOVER_SWITCH, 0);
   
     Wire.begin(I2C_SDA, I2C_SCL /*, clock frequency */);
   };
   
   void scan_i2c()
   {
     Serial.println ();
     Serial.println ("I2C scanning (PN532=0x24, MCP=0x20)");
     byte count = 0;
   
     for (byte i = 8; i < 128; i++)
     {
       Wire.beginTransmission (i);          // Begin I2C transmission Address (i)
       if (Wire.endTransmission () == 0)  // Receive 0 = success (ACK response)
       {
         Serial.print (" - Device at address: ");
         Serial.print (i, DEC);
         Serial.print (" (0x");
         Serial.print (i, HEX);
         Serial.println (")");
         count++;
       }
     }
     Serial.print ("Found ");
     Serial.print (count, DEC);
     Serial.println (" device(s).");
   }
   
   // the loop function runs over and over again forever
   void loop() {
     {
       static unsigned long lst = 0;
       if (millis() - lst > 10 * 1000) {
         lst = millis();
         scan_i2c();
       };
     };
     {
       static unsigned long lst = 0;
       if (millis() - lst > 1000) {
         lst = millis();
         Serial.println("tok");
       };
     };
   }