نمایش نتایج: از 1 به 10 از 18
Like Tree15 لایک

موضوع: ماژول شبکه enc28j60

Hybrid View

  1. #1
    Senior Member
    تاریخ عضویت
    Nov 2013
    نوشته ها
    183

    کتابخانه وکد ره اندازی

    شماتیک پایه ها واسه Mega 2560
    mosi <-> 51
    miso <-> 50
    sck <-> 52
    ss <-> 15
    rst <-> reset
    int <->
    CLK <->
    Vcc <-> 5v
    gnd <-> gnd

    چند تا توضیح واسه راحت تر کار کردن اونم اینکه
    1- در خط 6 ثابتی به نام STATIC وجود داره که مقدار نوشته شده جلوش 1 هست یعنی اینکه نیاز به تنظیم آی پی نداره و DHCP زحمت آی پی دادنشو میکشه اگر نمیخواین این طور باشه و میخواین خودتون بهش آی پی بدین اون عدد رو به 0 تبدیل کنید و بعد آی پی تونو داخل آرایه myip بنویسین
    2- در خط 14 در بین پارمترهای تابع عدد 15 وجود داره که تعیین کننده ی پایه ss ماژول هست که وصل کردین به پین 15 و خیلی خیلی مهم هست اگر هر برنامه نمونه ای از کتابخون رو باز کنید این کد رو حتما حتما باید اضافه کنید در غیر این صورت مشکل میخورید هر جا این کد نبود یک (کاما) , بزارید و عدد 15 رو بنویسید
    (در ضمن اگر ss رو به پین 53 مگا وصل کنید نیازی به این کد نیست ولی من خودم نتیجه نگرفتم و خیلی الافم کرد بهتره از 15 استفاده کنید )


    کد:
    // Present a "Will be back soon web page", as stand-in webserver.
    // 2011-01-30 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
     
    #include <EtherCard.h>
    
    #define STATIC 1  // set to 1 to disable DHCP (adjust myip/gwip values below)
    
    #if STATIC
    // ethernet interface ip address
    static byte myip[] = { 192,168,1,200 };
    // gateway ip address
    static byte gwip[] = { 192,168,1,1 };
    #endif
    
    // ethernet mac address - must be unique on your network
    static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
    
    byte Ethernet::buffer[500]; // tcp/ip send and receive buffer
    
    char page[] PROGMEM =
    "HTTP/1.0 503 Service Unavailable\r\n"
    "Content-Type: text/html\r\n"
    "Retry-After: 600\r\n"
    "\r\n"
    "<html>"
      "<head><title>"
        "Service Temporarily Unavailable"
      "</title></head>"
      "<body>"
        "<h3>This service is currently unavailable</h3>"
        "<p><em>"
          "The main server is currently off-line.<br />"
          "Please try again later."
        "</em></p>"
      "</body>"
    "</html>"
    ;
    
    void setup(){
      Serial.begin(57600);
      Serial.println("\n[backSoon]");
      if (ether.begin(sizeof Ethernet::buffer, mymac,15) == 0) 
        Serial.println( "Failed to access Ethernet controller");
    #if STATIC
      ether.staticSetup(myip, gwip);
    #else
      if (!ether.dhcpSetup())
        Serial.println("DHCP failed");
    #endif
    
      ether.printIp("IP:  ", ether.myip);
      ether.printIp("GW:  ", ether.gwip);  
      ether.printIp("DNS: ", ether.dnsip);  
    }
    
    void loop(){
      // wait for an incoming TCP packet, but ignore its contents
      if (ether.packetLoop(ether.packetReceive())) {
        memcpy_P(ether.tcpOffset(), page, sizeof page);
        ether.httpServerReply(sizeof page - 1);
      }
    }
    شب همگی خوش هر چند که باید گفت صبح بخیر
    فایل های پیوست شده فایل های پیوست شده
    ویرایش توسط navidnkh : 11-23-2013 در ساعت 12:15 AM

  2. #2
    Senior Member
    تاریخ عضویت
    Dec 2013
    محل سکونت
    ایران - شیراز
    نوشته ها
    220
    نقل قول نوشته اصلی توسط navidnkh نمایش پست ها
    شماتیک پایه ها واسه Mega 2560
    mosi <-> 51
    miso <-> 50
    sck <-> 52
    ss <-> 15
    rst <-> reset
    int <->
    CLK <->
    Vcc <-> 5v
    gnd <-> gnd

    چند تا توضیح واسه راحت تر کار کردن اونم اینکه
    1- در خط 6 ثابتی به نام STATIC وجود داره که مقدار نوشته شده جلوش 1 هست یعنی اینکه نیاز به تنظیم آی پی نداره و DHCP زحمت آی پی دادنشو میکشه اگر نمیخواین این طور باشه و میخواین خودتون بهش آی پی بدین اون عدد رو به 0 تبدیل کنید و بعد آی پی تونو داخل آرایه myip بنویسین
    2- در خط 14 در بین پارمترهای تابع عدد 15 وجود داره که تعیین کننده ی پایه ss ماژول هست که وصل کردین به پین 15 و خیلی خیلی مهم هست اگر هر برنامه نمونه ای از کتابخون رو باز کنید این کد رو حتما حتما باید اضافه کنید در غیر این صورت مشکل میخورید هر جا این کد نبود یک (کاما) , بزارید و عدد 15 رو بنویسید
    (در ضمن اگر ss رو به پین 53 مگا وصل کنید نیازی به این کد نیست ولی من خودم نتیجه نگرفتم و خیلی الافم کرد بهتره از 15 استفاده کنید )


    کد:
    // Present a "Will be back soon web page", as stand-in webserver.
    // 2011-01-30 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
     
    #include <EtherCard.h>
    
    #define STATIC 1  // set to 1 to disable DHCP (adjust myip/gwip values below)
    
    #if STATIC
    // ethernet interface ip address
    static byte myip[] = { 192,168,1,200 };
    // gateway ip address
    static byte gwip[] = { 192,168,1,1 };
    #endif
    
    // ethernet mac address - must be unique on your network
    static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
    
    byte Ethernet::buffer[500]; // tcp/ip send and receive buffer
    
    char page[] PROGMEM =
    "HTTP/1.0 503 Service Unavailable\r\n"
    "Content-Type: text/html\r\n"
    "Retry-After: 600\r\n"
    "\r\n"
    "<html>"
      "<head><title>"
        "Service Temporarily Unavailable"
      "</title></head>"
      "<body>"
        "<h3>This service is currently unavailable</h3>"
        "<p><em>"
          "The main server is currently off-line.<br />"
          "Please try again later."
        "</em></p>"
      "</body>"
    "</html>"
    ;
    
    void setup(){
      Serial.begin(57600);
      Serial.println("\n[backSoon]");
      if (ether.begin(sizeof Ethernet::buffer, mymac,15) == 0) 
        Serial.println( "Failed to access Ethernet controller");
    #if STATIC
      ether.staticSetup(myip, gwip);
    #else
      if (!ether.dhcpSetup())
        Serial.println("DHCP failed");
    #endif
    
      ether.printIp("IP:  ", ether.myip);
      ether.printIp("GW:  ", ether.gwip);  
      ether.printIp("DNS: ", ether.dnsip);  
    }
    
    void loop(){
      // wait for an incoming TCP packet, but ignore its contents
      if (ether.packetLoop(ether.packetReceive())) {
        memcpy_P(ether.tcpOffset(), page, sizeof page);
        ether.httpServerReply(sizeof page - 1);
      }
    }
    شب همگی خوش هر چند که باید گفت صبح بخیر
    ممنون از نکات مفید شما دوست عزیز کار مارو هم راه انداختی

  3. #3
    Junior Member
    تاریخ عضویت
    Sep 2014
    نوشته ها
    2
    نقل قول نوشته اصلی توسط navidnkh نمایش پست ها
    شماتیک پایه ها واسه Mega 2560
    mosi <-> 51
    miso <-> 50
    sck <-> 52
    ss <-> 15
    rst <-> reset
    int <->
    CLK <->
    Vcc <-> 5v
    gnd <-> gnd

    چند تا توضیح واسه راحت تر کار کردن اونم اینکه
    1- در خط 6 ثابتی به نام STATIC وجود داره که مقدار نوشته شده جلوش 1 هست یعنی اینکه نیاز به تنظیم آی پی نداره و DHCP زحمت آی پی دادنشو میکشه اگر نمیخواین این طور باشه و میخواین خودتون بهش آی پی بدین اون عدد رو به 0 تبدیل کنید و بعد آی پی تونو داخل آرایه myip بنویسین
    2- در خط 14 در بین پارمترهای تابع عدد 15 وجود داره که تعیین کننده ی پایه ss ماژول هست که وصل کردین به پین 15 و خیلی خیلی مهم هست اگر هر برنامه نمونه ای از کتابخون رو باز کنید این کد رو حتما حتما باید اضافه کنید در غیر این صورت مشکل میخورید هر جا این کد نبود یک (کاما) , بزارید و عدد 15 رو بنویسید
    (در ضمن اگر ss رو به پین 53 مگا وصل کنید نیازی به این کد نیست ولی من خودم نتیجه نگرفتم و خیلی الافم کرد بهتره از 15 استفاده کنید )


    کد:
    // Present a "Will be back soon web page", as stand-in webserver.
    // 2011-01-30 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
     
    #include <EtherCard.h>
    
    #define STATIC 1  // set to 1 to disable DHCP (adjust myip/gwip values below)
    
    #if STATIC
    // ethernet interface ip address
    static byte myip[] = { 192,168,1,200 };
    // gateway ip address
    static byte gwip[] = { 192,168,1,1 };
    #endif
    
    // ethernet mac address - must be unique on your network
    static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
    
    byte Ethernet::buffer[500]; // tcp/ip send and receive buffer
    
    char page[] PROGMEM =
    "HTTP/1.0 503 Service Unavailable\r\n"
    "Content-Type: text/html\r\n"
    "Retry-After: 600\r\n"
    "\r\n"
    "<html>"
      "<head><title>"
        "Service Temporarily Unavailable"
      "</title></head>"
      "<body>"
        "<h3>This service is currently unavailable</h3>"
        "<p><em>"
          "The main server is currently off-line.<br />"
          "Please try again later."
        "</em></p>"
      "</body>"
    "</html>"
    ;
    
    void setup(){
      Serial.begin(57600);
      Serial.println("\n[backSoon]");
      if (ether.begin(sizeof Ethernet::buffer, mymac,15) == 0) 
        Serial.println( "Failed to access Ethernet controller");
    #if STATIC
      ether.staticSetup(myip, gwip);
    #else
      if (!ether.dhcpSetup())
        Serial.println("DHCP failed");
    #endif
    
      ether.printIp("IP:  ", ether.myip);
      ether.printIp("GW:  ", ether.gwip);  
      ether.printIp("DNS: ", ether.dnsip);  
    }
    
    void loop(){
      // wait for an incoming TCP packet, but ignore its contents
      if (ether.packetLoop(ether.packetReceive())) {
        memcpy_P(ether.tcpOffset(), page, sizeof page);
        ether.httpServerReply(sizeof page - 1);
      }
    }
    شب همگی خوش هر چند که باید گفت صبح بخیر


    این کارو کردم با این خطا برخورد کردم :

    Arduino: 1.5.7 (Windows 8), Board: "Arduino Uno"

    Build options changed, rebuilding all

    In file included from sketch_nov27a.ino:1:0:
    C:\Users\Butterfly\Documents\Arduino\libraries\eth ercard_master/enc28j60.h:18:10: error: 'uint8_t' does not name a type
    static uint8_t buffer[];
    ^
    C:\Users\Butterfly\Documents\Arduino\libraries\eth ercard_master/enc28j60.h:19:10: error: 'uint16_t' does not name a type
    static uint16_t bufferSize;
    ^
    C:\Users\Butterfly\Documents\Arduino\libraries\eth ercard_master/enc28j60.h:21:10: error: 'uint8_t' does not name a type
    static uint8_t* tcpOffset () { return buffer + 0x36; }
    ^
    C:\Users\Butterfly\Documents\Arduino\libraries\eth ercard_master/enc28j60.h:24:10: error: 'uint8_t' does not name a type
    static uint8_t initialize (const uint16_t size, const uint8_t* macaddr,
    ^
    C:\Users\Butterfly\Documents\Arduino\libraries\eth ercard_master/enc28j60.h:28:27: error: 'uint16_t' has not been declared
    static void packetSend (uint16_t len);
    ^
    C:\Users\Butterfly\Documents\Arduino\libraries\eth ercard_master/enc28j60.h:29:10: error: 'uint16_t' does not name a type
    static uint16_t packetReceive ();
    ^
    C:\Users\Butterfly\Documents\Arduino\libraries\eth ercard_master/enc28j60.h:31:24: error: 'uint8_t' has not been declared
    static void copyout (uint8_t page, const uint8_t* data);
    ^
    C:\Users\Butterfly\Documents\Arduino\libraries\eth ercard_master/enc28j60.h:31:44: error: 'uint8_t' does not name a type
    static void copyout (uint8_t page, const uint8_t* data);
    ^
    C:\Users\Butterfly\Documents\Arduino\libraries\eth ercard_master/enc28j60.h:31:53: error: ISO C++ forbids declaration of 'data' with no type [-fpermissive]
    static void copyout (uint8_t page, const uint8_t* data);
    ^
    C:\Users\Butterfly\Documents\Arduino\libraries\eth ercard_master/enc28j60.h:32:23: error: 'uint8_t' has not been declared
    static void copyin (uint8_t page, uint8_t* data);
    ^
    C:\Users\Butterfly\Documents\Arduino\libraries\eth ercard_master/enc28j60.h:32:37: error: 'uint8_t' has not been declared
    static void copyin (uint8_t page, uint8_t* data);
    ^
    C:\Users\Butterfly\Documents\Arduino\libraries\eth ercard_master/enc28j60.h:33:10: error: 'uint8_t' does not name a type
    static uint8_t peekin (uint8_t page, uint8_t off);
    ^
    C:\Users\Butterfly\Documents\Arduino\libraries\eth ercard_master/enc28j60.h:41:10: error: 'uint8_t' does not name a type
    static uint8_t doBIST(uint8_t csPin =8);
    ^

    This report would have more information with
    "Show verbose output during compilation"
    enabled in File > Preferences.

    میشه کمکم کنید ؟
    توابع کتابخانه ایشو نصب کردم ولی توی برنامه نمیشناسشون !!!!!
    برد UNO استفاده میکنم ..

کلمات کلیدی این موضوع

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •  

SEO by vBSEO