Jump to content
43oh

Servtes1426459984

Members
  • Content Count

    2
  • Joined

  • Last visited

Posts posted by Servtes1426459984

  1.  Impossible to say something about your problem but we can say about our:

     How are both device connected to microcontroller? I assume you are using an LP Stellaris HQ120 or a new TIVA 123,  are pin used for SPI devices separated? are you sure no collision between channel? Is IRQ service updated?

     More detail are needed before to say just try something.

     Why not use LP connected instead of a slow device like enc28j60?

     

    Both devices connect them following pin mapping documentation energy

    Yes, I am using a Stellaris Launchpad LMF120

    Yes, SPI port 2 if for nrf20l01 and SPI port 3 for enc28j60.

    I have two modules connected and energized, runin the same code, the ethernet part always work, but the RF part only works if I disable the Ethernet side.

     

    Where I live I have like getting a connected

     

    I think the UIPEthernet/enc28j60 library is very time sensitive and the wireless module interrupt processing causes problems. I think the LP Connected Ethernet is DMA driven and probably more interrupt friendly.

    I will be reviewing the code =)

     launchpad, I'm doing what I have on hand.
     
    thanks
  2. Hi good day ...
     
    I'm doing a project that consists of a network of RF sensors that communicate to a station connected to the Ethernet network, the target station that read the sensors and update the variables shown in the IP address configured.
     
    I have connected the module NRF24L01 SPI port 2. I am using Enrf24 library.
     
    I have the enc28j60 SPI3 module connected to the port. I am using the library UIPEthernet, configure the module to use port 3 Enc28J60Network modifying the file that is included in the same library.
     
    I have the following problem:
    -The NRF24L01 module works well alone. (Although this module connected and energized enc28j60).
    -The Enc28j60 module works well alone. (Although this module connected and energized NRF24L01).
     
    In my code, if I comment the line
    Ethernet.begin (mac, ip); NRF24L01 module operates but does not work enc28j60 module.
     
    If I uncommented the same line opposite happens.
     
    attached files of my project, I add my code.
    What could be my problem?
    Regards
     
    #include <SPI.h>			//Libreria para habilitar el puerto de perifericos serie
    #include <UIPEthernet.h>    //Micro IP adaptado a LMF120H5QR
    #include <Enrf24.h>			//Manejador para envio de mensajes RF
    #include <nRF24L01.h>		//Controlador del modulo RF
    #include <string.h>			//Libreria para el manejo de cadenas de texto
    
    void nodoEthernet();
    void nodoRF();
    void printIndex();
    
    /*Valores de los sensores*/
    float temperatura1 = 0;
    float temperatura2 = 0;
    float temperatura3 = 0;
    int humedad2 = 0;
    int humedad3 = 0;
    
    /*Mapeo de pines SPI del Stellaris LMF120H5QR*/
    #define P2_0   PA_5     // CE
    #define P2_1   PA_6     // CSN
    #define P2_2   PA_7     // IRQ
    
    /*Configuracion de nodo RF*/
    Enrf24 radio(P2_0, P2_1, P2_2);
    const uint8_t rxaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 }; //Direccion MAC del nodo RF principal
    void dump_radio_status_to_serialport(uint8_t);
    
    /*Configuracion del puerto Ethernet*/
    EthernetServer server(80); //Iniciar servidor en el puerto 80
    int statusConfig = 0;	   //codigo de configuracion
    
    void setup()
    {
      Serial.begin(9600); //Puerto Serie para depuracion
      SPI.begin();	//Iniciar el puerto SPI
      SPI.setDataMode(SPI_MODE0);
      SPI.setBitOrder(MSBFIRST);
    
      /*Configuracion de arranque del nodo RF*/
      radio.begin(25000);  // Velocidad 250kbps, canal 0, max TX power
      radio.setRXaddress((void*)rxaddr);
      radio.enableRX();  // Iniciar Escucha RF canal 0
     
      /*Configuracion de Arranque del puerto Ethernet*/
      //Serial.println("Estableciendo conexion Ethernet....");
      byte mac[] = {0x00, 0x4f, 0x49, 0x00, 0x00, 0x03}; //Direccion MAC
      IPAddress ip = IPAddress(192, 168, 1, 100);			 //Direccion IP
      //Ethernet.begin(mac, ip); //Iniciar el puerto con los parametros MAC y IP
      server.begin(); 
    }
    
    EthernetClient client;
    
    void loop()
    {
    
      nodoEthernet();
      nodoRF();
    
    }
    
    void nodoEthernet()
    {
      client = server.available();
    
      if (client) 
      {                            
        String cadenaEntrante = "";     //Cadena para guardar las peticiones del cliente
        while (client.connected())  //Mientras un cliente este conectado
        {            
          if (client.available()) //Si hay bytes para leer del cliente
          {                
            char c = client.read();  //Leer un byte
            Serial.print(c); //Mostrar el byte en el puerto serie
            if (c == '\n')  //Si es un retorno de carro
            {                   
              //Si la linea actual esta en blanco se tienen dos retornos de carro.
              //Lo cual seria el final de la peticion HTTP y se puede proceder a responder.
              if (cadenaEntrante.length() == 0)
              {
                break;
              }
              else {      
                cadenaEntrante = "";
              }
            }
            else if (c != '\r') 
            {    
              cadenaEntrante += c;
            }
    
            if (cadenaEntrante.endsWith("GET / "))
            {
              statusConfig = 0;
              printIndex();
            }
    
            //Leer peticiones del cliente
            if (cadenaEntrante.endsWith("GET /temperatura1")) {EnviarDatos(1);}
            if (cadenaEntrante.endsWith("GET /temperatura2")) {EnviarDatos(2);}
            if (cadenaEntrante.endsWith("GET /temperatura3")) {EnviarDatos(3);}
            if (cadenaEntrante.endsWith("GET /humedad2")) {EnviarDatos(4);}
            if (cadenaEntrante.endsWith("GET /humedad3")) {EnviarDatos(5);}
          }
        }
        //Cerrar la conexion
        client.stop();
        //Serial.println("cliente desconectado");
      }
    
    }
    
    
    int EnviarDatos(int dato)
    {
      switch(dato)
      {
      case 1: 
        client.println("HTTP/1.1 200 OK");
        client.println("Content-type:text/html");
        client.println();
        client.println("<html>");
        client.println(temperatura1);
        client.println("</html>");
        break;
      case 2: 
        client.println("HTTP/1.1 200 OK");
        client.println("Content-type:text/html");
        client.println();
        client.println("<html>");
        client.println(temperatura2);
        client.println("</html>");
        break;
      case 3:
        client.println("HTTP/1.1 200 OK");
        client.println("Content-type:text/html");
        client.println();
        client.println("<html>");
        client.println(temperatura3);
        client.println("</html>"); 
        break;
      case 4:
        client.println("HTTP/1.1 200 OK");
        client.println("Content-type:text/html");
        client.println();
        client.println("<html>");
        client.println(humedad2);
        client.println("</html>"); 
        break;
      case 5:
        client.println("HTTP/1.1 200 OK");
        client.println("Content-type:text/html");
        client.println();
        client.println("<html>");
        client.println(humedad2);
        client.println("</html>");  
        break;
      default: 
        break;
      }
    
    
    }
    
    
    void printIndex()
    {
      client.println("HTTP/1.1 200 OK");
      client.println("Content-type:text/html");
      client.println();
      client.println("<html>");
      client.println("<head><title>Fancy Sensors</title>");
      client.println("<style>");
      client.println("body{ background: whitesmoke; color:black; font-family:Consolas, monospace; font-size: 16px; }");
      client.println("article{ background: #f0f8ff; border - style: solid; border-color: #008080;");
      client.println("border-width: 8px; border-radius: 0.5em; margin: 1em auto; padding: 1em 0;");
      client.println("width: 80 % ; text-align: center; box-shadow: 10px 10px 5px #888888; }");
      client.println("input{ width: 100 % ; font-size: 24px; text-align: center; }");
      client.println("table{ font-size: 24px; } td{ text-align: center; }label{ display: block; margin: .5em 0 0 0; }</style>");
      client.println("</head>");
      client.println("<body>");
      client.println("<article>");
      client.println("<header style=\"font-size: 24px;\"><h1>Fancy Sensors</h1></header>");
      client.println("<table border = 0, align = \"center\", cellspacing = \"30\">");
      client.println("<tr>");
      client.println("<td><label>Temperatura Zona 1</label><input type = \"text\" value =\" "); 
      client.print(temperatura1); 
      client.print("\""); 
      client.print("readonly /></td>");
      client.println("<td><label>Humedad Zona 2 % </label><input type = \"text\" value =\" "); 
      client.print(humedad2); 
      client.print("\""); 
      client.print("readonly/></td>");
      client.println("</tr><tr>");
      client.println("<td><label>Temperatura Zona 2</label><input type = \"text\" value =\" ");
      client.print(temperatura2); 
      client.print("\""); 
      client.print("readonly/></td>");
      client.println("<td><label>Humedad Zona 3 % </label><input type =\"text\" value =\" ");
      client.print(humedad3); 
      client.print("\""); 
      client.print("readonly/></td>");
      client.println("</tr>");
      client.println("<tr><td><label>Temperatura Zona 3 </label ><input type =\"text\" value =\" ");
      client.print(temperatura3); 
      client.print("\""); 
      client.print("readonly/></td>");
      client.println("<td>");
      client.println("</td>");
      client.println("</tr>");
      client.println("</table>");
      client.println("</article>");
      client.println("</body>");
      client.println("</html>");
    
    }
    
    
    
    void nodoRF()
    {
      char inbuf[33];
    
     dump_radio_status_to_serialport(radio.radioState());
    
      while (!radio.available(true))
        ;
      if (radio.read(inbuf)) {
        Serial.println("**************************************************************");
        Serial.print("Paquete Recibido: ");
        Serial.println(inbuf);
    
    
        String cadenaRecibida = inbuf;
        
        if(cadenaRecibida.startsWith("TMP1"))
        { 
          String temp = cadenaRecibida.substring(4);
          int temperatura = temp.toInt();
          float fTemp = ((3.0 * temperatura * 100.0)/1023.0);
        }
        else
        if(cadenaRecibida.startsWith("TMP2"))
        { 
          String temp2 = cadenaRecibida.substring(4);
          int temperatura2 = temp2.toInt();
          //float fTemp = ((3.0 * temperatura * 100.0)/1023.0);
        }
        else
        if(cadenaRecibida.startsWith("HUM2"))
        { 
          String hum2 = cadenaRecibida.substring(4);
          int humedad2 = hum2.toInt();
         // float fTemp = ((3.0 * temperatura * 100.0)/1023.0);
        }
        else
         if(cadenaRecibida.startsWith("TMP3"))
        { 
          String temp2 = cadenaRecibida.substring(4);
          int temperatura2 = temp2.toInt();
          //float fTemp = ((3.0 * temperatura * 100.0)/1023.0);
        }
        else
        if(cadenaRecibida.startsWith("HUM3"))
        { 
          String hum2 = cadenaRecibida.substring(4);
          int humedad2 = hum2.toInt();
         // float fTemp = ((3.0 * temperatura * 100.0)/1023.0);
        }
    
      }
    }
    
    
    void dump_radio_status_to_serialport(uint8_t status)
    {
      Serial.print("Estado del tranceptor principal: ");
      switch (status) {
        case ENRF24_STATE_NOTPRESENT:
          Serial.println("No hay un tranceptor instalado");
          break;
    
        case ENRF24_STATE_DEEPSLEEP:
          Serial.println("Modo de ultra bajo consumo <1uA ");
          break;
    
        case ENRF24_STATE_IDLE:
          Serial.println("Modulo de inactividad ON||Fucionando con oscilador");
          break;
    
        case ENRF24_STATE_PTX:
          Serial.println("Transmitiendo de forma activa");
          break;
    
        case ENRF24_STATE_PRX:
          Serial.println("Modo de Recepcion de Datos");
          break;
    
        default:
          Serial.println("Codigo de estado desconocido");
      }
    }
    
    

     

×
×
  • Create New...