caramoan tour package

caramoan tour package

Author Topic: MikroC's SPI Ethernet ENC28J60 Library  (Read 9744 times)

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #20 on: May 07, 2012, 01:01:01 PM »
Ready na. Kasi hindi naman 5V powered mcu nun. ;D ;D ;D

Anong PIC model po yun sir? (wala kasing alam about PIC) ;D ;D ;D
Computer Engineering National Organization registration thread


Philippine Electronics Forum

Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #20 on: May 07, 2012, 01:01:01 PM »

Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #21 on: May 07, 2012, 01:02:14 PM »
Plug and Play na yon prof. ;D ;D
As expained here:
may mga non-LF series PIC mcu that works fine even with 3.3V supply. i tried it with PIC18F2550, PIC18F2620. plus ung binanggit ni master Lurker na cheap PIC18F4620. these three are guaranteed working with 3.3V supply.

By the way sabay na tayo mag experiment sa ENC dahil hiniram yung module pati board ko.

On topic.
Heto yung pag configure sa iba pang pins sa PIC16f887 para sa simple examample natin sa taas.
Code: [Select]
       ANSEL = 0x0C ;          // AN2 and AN3 convertors will be used
        C1ON_bit = 0;           // Disable comparators
        C2ON_bit = 0;
        PORTA = 0 ;
        TRISA = 0xff ;          // set PORTA as input for ADC

I remove the button switches and output functions para madali lang natin ma discuss.
And madali lang din yan ma port sa ibang mcu.
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Philippine Electronics Forum

Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #21 on: May 07, 2012, 01:02:14 PM »

Offline PlCUSER

  • Diesel Generator
  • *
  • Posts: 1911
  • Pogi/Ganda Points: 153
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #22 on: May 07, 2012, 01:05:20 PM »
@prof.
PIC18F2620. May udp bootloader na. Kaya no need for progrmmer na to upgrade firmware.

Philippine Electronics Forum

Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #22 on: May 07, 2012, 01:05:20 PM »

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #23 on: May 07, 2012, 01:06:33 PM »
Tanong po master _Lurker_. :D Bakit po kailangan nating gamitin ang ANA as well as ADC? Or baka i-didiscuss nyo pa po yung mga explanations ng code na yan. :D
Computer Engineering National Organization registration thread


Philippine Electronics Forum

Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #23 on: May 07, 2012, 01:06:33 PM »

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #24 on: May 07, 2012, 01:17:19 PM »
@prof.
PIC18F2620. May udp bootloader na. Kaya no need for progrmmer na to upgrade firmware.

OT muna sir _Lurker_: :D

Sir PIC, newbee question po. Ano po ang gamit ng UDP bootloader? Have googled it ang gives me this results:

http://www.mikroe.com/forum/viewtopic.php?t=9093

http://www.mikroe.com/esupport/index.php?_m=downloads&_a=viewdownload&downloaditemid=151

http://rapidlibrary.com/files/udp-bootloader-win-zip_ulzbr98qyti89on.html
Computer Engineering National Organization registration thread


Philippine Electronics Forum

Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #24 on: May 07, 2012, 01:17:19 PM »

Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #25 on: May 07, 2012, 01:20:15 PM »
Bakit po kailangan nating gamitin ang ANA as well as ADC? Or baka i-didiscuss nyo pa po yung mga explanations ng code na yan. :D

Yung basic example ng mirkroC gumagamit ng ADC, button at output.
Yung button at output gumagamit ng script at looping sa HTML code niya,

Code: [Select]
<script>
var str,i;
str="";
for(i=0;i<8;i  )
{str ="<tr><td bgcolor=pink>BUTTON #" i "</td>";
if(PORTB&(1<<i)){str ="<td bgcolor=red>ON";}
else {str ="<td bgcolor=#cccccc>OFF";}
str ="</td></tr>";}
document.write(str) ;
</script>

Code: [Select]
<tr><th colspan=3>PORTD</th></tr>
<script>
var str,i;
str="";
for(i=0;i<8;i  )
{str ="<tr><td bgcolor=yellow>LED #" i "</td>";
if(PORTD&(1<<i)){str ="<td bgcolor=red>ON";}
else {str ="<td bgcolor=#cccccc>OFF";}
str ="</td><td><a href=/t" i ">Toggle</a></td></tr>";}
document.write(str) ;
</script>

Next time lang natin i-discuss yan.
Step by step lang master prof mahina ang kalaban. ;D ;D
Yung ADC lang muna ang i-discuss natin kasi marami din ito application like temperature and voltage telemetry.
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Offline PlCUSER

  • Diesel Generator
  • *
  • Posts: 1911
  • Pogi/Ganda Points: 153
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #26 on: May 07, 2012, 01:24:45 PM »
Ot:
Prof relate natin sa alam mong gamitin, si arduino. Si arduino ay atmega chip na may serial bootloader. Kaya you can upgrade the fw using serial comm (usb to serial sa case ni arduino).

Ung udp bootloader naman, you can upgrade the firmware of your pic mcu with enc module using ethernet port ng pc mo. Or even tru a wifi router.

Tama na daldalan prof. Makinig na ta kay master lurker. Baka batuhin na tayo ng eraser.

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #27 on: May 07, 2012, 01:31:34 PM »
Ot:
Prof relate natin sa alam mong gamitin, si arduino. Si arduino ay atmega chip na may serial bootloader. Kaya you can upgrade the fw using serial comm (usb to serial sa case ni arduino).

Ung udp bootloader naman, you can upgrade the firmware of you pic mcu with enc module using ethernet port ng pc mo. Or even tru a wifi router.

Tama na daldalan prof. Makinig na ta kay master lurker. Baka batuhin na tayo ng eraser.

Yun pala. Kaya pwede ka makapag-"BURN" ng FW using USB post ng PC ko because of this serial bootloader na andun sa loob ng ARDUINO. Tama po ba sir PICUSER? Therefore, pwede kong i-"BURN" ang program ng PIC using Ethernet port ng PC. :D :D



Yung basic example ng mirkroC gumagamit ng ADC, button at output.
Yung button at output gumagamit ng script at looping sa HTML code niya,

Code: [Select]
<script>
var str,i;
str="";
for(i=0;i<8;i  )
{str ="<tr><td bgcolor=pink>BUTTON #" i "</td>";
if(PORTB&(1<<i)){str ="<td bgcolor=red>ON";}
else {str ="<td bgcolor=#cccccc>OFF";}
str ="</td></tr>";}
document.write(str) ;
</script>

Code: [Select]
<tr><th colspan=3>PORTD</th></tr>
<script>
var str,i;
str="";
for(i=0;i<8;i  )
{str ="<tr><td bgcolor=yellow>LED #" i "</td>";
if(PORTD&(1<<i)){str ="<td bgcolor=red>ON";}
else {str ="<td bgcolor=#cccccc>OFF";}
str ="</td><td><a href=/t" i ">Toggle</a></td></tr>";}
document.write(str) ;
</script>

Next time lang natin i-discuss yan.
Step by step lang master prof mahina ang kalaban. ;D ;D
Yung ADC lang muna ang i-discuss natin kasi marami din ito application like temperature and voltage telemetry.

Nyahahaha. Pasensya sir. Masyadong excited eh. :D
Computer Engineering National Organization registration thread


Offline RiDdLeR???

  • Hydroelectric
  • ***
  • Posts: 3032
  • Pogi/Ganda Points: 208
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #28 on: May 07, 2012, 01:37:51 PM »
Setup ko na yung breadboard ko.  Meron ako dito ideal PICs to use, PIC18F46K22, PIC18LF4680 at PIC18LF2685.  Subukan na nanatin.  Balik mikroC na naman.

Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #29 on: May 07, 2012, 06:33:41 PM »
Wow!
Amazing devices master alyas.



On topic,

Code: [Select]
unsigned char SPI_Ethernet_doPacket();
Process incoming Ethernet packets.
It processes next received packet if such exists. Packets are processed in the following manner:

  • ARP & ICMP requests are replied automatically.
  • upon TCP request the SPI_Ethernet_UserTCP function is called for further processing.
  • upon UDP request the SPI_Ethernet_UserUDP function is called for further processing.

Spi_Ethernet_doPacket() must be called as often as possible.
Otherwise packets could be lost.

Code: [Select]
unsigned int SPI_Ethernet_UserTCP(unsigned char *remoteHost, unsigned int remotePort,
unsigned int localPort, unsigned int reqLength, TEthPktFlags *flags);

This is TCP module routine. It is internally called by the library. The user accesses to the TCP/HTTP request by using some of the SPI_Ethernet_get routines. The user puts data in the transmit buffer by using some of the SPI_Ethernet_put routines. The function must return the length in bytes of the TCP/HTTP reply, or 0 if there is nothing to transmit. If there is no need to reply to the TCP/HTTP requests, just define this function with return(0) as a single statement.

Parameters:
  • remoteHost: client's IP address.
  • remotePort: client's TCP port.
  • localPort: port to which the request is sent.
  • reqLength: TCP/HTTP request data field length.

Copy paste lang muna. ;D ;D ;D
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Offline carlsberg11

  • Lead Acid Battery
  • *******
  • Posts: 526
  • Pogi/Ganda Points: 30
  • Gender: Male
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #30 on: May 07, 2012, 09:14:05 PM »
Ready na. Kasi hindi naman 5V powered mcu nun. ;D ;D ;D
promise sir? promise ka muna! :D :D :D
Anyone who has never made a mistakes has never tried anything new.

-Albert Einstein

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #31 on: May 08, 2012, 01:00:26 AM »
Pwede kayang i-simulate yan sya sa Prot*us sir lurker?
Computer Engineering National Organization registration thread


Offline Kaizer03

  • Nuclear Reactor
  • ****
  • Posts: 4847
  • Pogi/Ganda Points: 225
  • C#<-->Android<-->Java
    • PhilRobotics
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #32 on: May 08, 2012, 01:56:34 AM »
^

yes...

BTW, ENC28J60 is 5V tolerant =)


--

nakakamiss ito,nakita ko na yung two boards ko for this, hope na magalaw ko ulet sya using my new workbench table ;D ;D ;D
Lend a hand for those who are in need!=)

Stop Hijacking!=) More Technical Posts!=)
 ;)

Kaizer Killer EX Pre-Alpha

Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #33 on: May 08, 2012, 11:45:33 AM »
Share naman po sa nagawa mong mga projects master kaizer...

Prof iba talaga pag meron hardware.
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #34 on: May 08, 2012, 01:00:46 PM »
OT:

Kaya nga eh. Mata-try mo talaga sir. Di bali po sir, comming na po yung HW ko. ;D ;D
Computer Engineering National Organization registration thread


Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #35 on: May 08, 2012, 05:09:32 PM »
Excited na din ako sa new ENC at sa isa pang toy. ;D

On topic.
Just a recap.
I have already posted the mikroC's simple hardware setup of ENC and PIC.
I also posted about how to configure the MAC and IP settings
as well as how to initialize the PIC mcu for it's CS and RESET pins.

So I think pwedi na tayo magsimula mag discuss a little about sa HTML.
Take note wala ako alam sa HTML so pleaaaaaaaaaaaaase bear with me.  ;)

But first just a review.
We need to call "SPI_Ethernet_doPacket()" as much as possible to avoid packet loss.
Everytime we call "SPI_Ethernet_doPacket()" and an HTTP request exist (usually galing sa browser mo), it will call "SPI_Ethernet_UserTCP" to further process the request.

So based sa conditional statements na nasa loob ng "SPI_Ethernet_UserTCP" nag depend ang webpage na ilalabas ni browser.

Sana malinaw lang yan. ;D ;D

The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Offline PlCUSER

  • Diesel Generator
  • *
  • Posts: 1911
  • Pogi/Ganda Points: 153
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #36 on: May 08, 2012, 05:13:43 PM »
excited na din akong matuto nito sayo master lurker. sa wakas.... ;D ;D ;D

Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #37 on: May 08, 2012, 05:32:16 PM »
^ ;D ;D ;D ;D ;D ;D ;D ;D
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #38 on: May 08, 2012, 05:57:36 PM »
Kuhang kuha sir. ;D
Computer Engineering National Organization registration thread


Offline carlsberg11

  • Lead Acid Battery
  • *******
  • Posts: 526
  • Pogi/Ganda Points: 30
  • Gender: Male
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #39 on: May 08, 2012, 10:41:10 PM »
marami na akong babasahin nito sir lurker.. whew!! sige go lang ng go!! :D :D :D
Anyone who has never made a mistakes has never tried anything new.

-Albert Einstein

Philippine Electronics Forum

Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #39 on: May 08, 2012, 10:41:10 PM »

 

Privacy Policy

Contact Us: elabph@yahoo.com