SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By kirkzeus
#39452
Hi all

I am a complete novice when it comes to PICs. Some years ago I had some experience in electronics and am now heavily into computers and simple programming.

I am looking to dip my toes into the world of PICs and know very little about them. I want to be able to use a PIC over an ethernet connection and run on it a small web server and ideally FTP. In addition I want it to have some digital and analogue input/outputs so that I can typically monitor simple sensors such as temperature and also to control relays, with the results/control to be done via its web page.

The final desire of mine is for ALL programming to be done via the ethernet connection. Is there such a device out there? From what I can gather, programming has to be done via a separate serial port which I really don't want to do as the PIC will be in a remote location.

Any feedback/advice would be much appreciated - I live in the UK.

Many thanks.
By Shifted
#39454
The biggest thing with running an FTP and HTTP server on it will be memory. If you want the ability to upload/download files you will need to have a decent sized storage medium available. You will also need enough RAM to run the FTP, HTTP, and TCP/IP stacks. I'm mostly an ARM guy myself, I'm not sure if there are any PIC's that fit the bill.

You do have a couple options though, somebody makes an ethernet interface module complete with HTTP and FTP server in DIP package form. The memory is however limited. As far as programming over ethernet, it is very possible, but will require you to write a custom bootloader that listens for a programming signal on the ethernet port before switching control to the main() function in your program. Its less of a device feature and more of a software one, as long as the chip supports ethernet.
By brennen
#39457
Have you considered the PIC-WEB MINI or the PIC-WEB boards? You would probably have to write a programming-over-ethernet bootloader, but other than that, these boards seem to fit the bill. There is probably a bootloader that would fit your needs online somewhere if you dig for it enough.
By winston
#39506
This might be heretical, but if you're starting with 8 bit microcontrollers, I'd use Atmel's AVR instead of the PIC. Easier to program (my programmer is just an old printer cable with the Centronics end chopped off and 4 1k resistors), and faster per clock cycle (most AVR instructions are 1 cycle, most PIC instructions take 4) so an AVR without a crystal (running off its internal oscillator) at 8MHz will be round about as fast as a PIC running at 32MHz.

Sparkfun has an AVR tutorial using the Free (as in both free as in freedom and free as in free beer) gcc-avr tools.

For ethernet, there's lots of choices. I think some microcontrollers now may have ethernet built in, but there's also the Wiznet W5100 (which is ethernet + TCP/IP on a chip, so your microcontroller doesn't need a TCP/IP stack), or the CP2200 (single chip ethernet, but you'll need a TCP/IP stack) or the Microchip ENC29J60. The W5100 in particular will simplify the communications side so you can spend more of your time working on the actual application code for your device.
By SOI_Sentinel
#39522
Hmmm...

I think they're thinking of the Lantronix XPORT as the ready to go solution. 10/100 ethernet in serial out (with a LITTLE configuration) in a DIP format, including ethernet jack. The Wiznet part also works, but you have to get a dev board or be willing to solder TQFP parts.

Back to PICs.

Microchip provides a free TCP/IP stack for their PIC18s and dsPICs. They also provide a nominally free C compiler (Windows student editions or GCC based for Linux). This stack works with the already mentioned ENC28J60s (DIP28) or the PIC18's that have integrated 10 base T electronics. Still need a jack and magnetics. PIC18's with ethernet are TQFP only, though.

So, let's look at DIP package PICs then. Largest 18F is the PIC18F4685, 96KB flash and 3.3K RAM. 16 bit hardware bests out at 64K flash and 8K Ram (PIC24FJ64GA002, 28 pins).

So, software?

http://www.microchip.com/stellent/idcpl ... odeId=1489

28-34KB flash. Big thing that I can't tell is how it would handle (if they CAN handle) ethernet bootloading. I've seen it in the app notes for CAN, but a quick look isn't bringing it to my attention for ethernet.
By kirkzeus
#39559
Thanks all for your feedback.

One question.

With the 'programming-over-ethernet' bootloader, won't this have to be first loaded/programmed into the PIC via a connection other than the ethernet connection, BEFORE I can use the ethernet for programming the PIC?

If so, does this mean that I therefore have to buy a hardware programmer to install this bootloader via some sort of serial connection?

I hope not as I don't have access to a hardware programmer and the PIC will be installed at a remote location, hence the need to have ALL programming done via the ethernet including the installation of the bootloader.

Any thoughts welcome.

Many thanks again.
User avatar
By Chupa
#39643
being a complete novice i think your biting off more than you can chew for now.

No matter what you end up doing you will need a way to get initial code (be it a bootloader, or whatever) to the device which will then allow you to bootload via whatever means you had in mind. Ive never seen any over-ethernet-bootloaders for PICs, but i could be wrong, so if thats what you want to do you may have to write your own, thats a pretty tall order for a novice.

http://www.ljcv.net/projects/minipic10t/index.html is a nice site with bare bones PIC18+ENC28J60 project. Or you could buy a demo board.

the project your looking to do is not a beginner one IMO. Maybe it would be best to start small if your looking to dive into the world of MCUs? If this is just a one time thing i would consider gogin with a Lantronix thing that SOI_sentinel suggested. THat makes things a lot simpler as its just USART com basically. Your going to need a way to program a PIC no matter what you do so keep that in mind.

I have a little experience with atmel, but i dont like them. I feel like because it uses GCC the documentation is lacking. flame on! :twisted:
User avatar
By bigglez
#39644
Chupa wrote:I have a little experience with atmel, but i dont like them. I feel like because it uses GCC the documentation is lacking. flame on! :twisted:
Greeting Chupa,

May I suggest BASCOM, a compiled basic for the Atmel devices?

Alternatively, Atmel AVR Studio4 where you can program AVRs
in assembly. Plus it's free...

I thoroughly enjoyed doing both when first introduced to uCs.

Comments Welcome!
User avatar
By Chupa
#39645
i used AVR studio4 with GCC. I just found it hard getting started because i couldent find a Getting started guide and other similar docs.

with microchip it was like BOOM http://microchip.com/stellent/idcplg?Id ... t=SW006011
and i was on my way.

I feel like because GCC is open source theres no official guide and everywhere you go people are like RTFM. Well where is the FM? i don't know, i could be making this all up in my head, or maybe im just a PIC fanboy... If someone can recommend a book or something or a web page i would appreciate it. Atmel does have one thing Microchip dosnet. C examples (As well as ASM) in their data sheets, at least the one I saw did. And thats good, i still feel like I might always be missing something though without a good overall type guide.

I dont enjoy BASIC :x
//sorry for hijacking the thread.
By kirkzeus
#39651
Chupa wrote:being a complete novice i think your biting off more than you can chew for now.
Thanks for the reply.

I want to get a PIC setup that will be able to achieve my goal, which is analogue/digital input/output, with http/ftp/etc. and to be able to remotely programme the device via the ethernet.

I feel that it would be a wasteful and costly exercise to go through various devices just to learn and then have to buy yet another one because the previous one won't achieve my goal. Surely it is far better to get the device that will do what I want first time and then learn the basics from that. I always get the best experience from making mistakes :)

I just hope that in this technologically advanced age which we live in, there is a device out there that will do this:wink: Or am I expecting too much for a device to do this (Hmm, I had hoped that the PC-MINI-WEB would have some remote programming-over-the-ethernet software out there)

Many thanks again
User avatar
By Chupa
#39658
You can do it, just expect a ton of hurdles on the way.

No PIC device (that i know of) comes with a preloaded Ethernet bootloader. You will most defiantly need a programer. And even if it did, if you screwed up while working on your bootloader theres a chance that you would need to reburn the chip the old fashion way.

Get yourself a demo board and a PIC burner and go to town.

Personal opinion on olimex products:
The olimex "tech support" guy on these forums always seems to have an attitude (pretty rude one) when he posts on these forums. and also spark fun dosent seem to carry the nicer PIC Ethernet webboard anymore and with the smaller Ethernet mini-web board the ICSP breakout headers have been out of stock for at least the same amount of time. So you would need to make your own if you got that one with a cheep ICSP programmer.

Or just bare bones it up with that link i posted earlier. The first thing i would do if i were going that route is fix that setup to use interrupts from the eth IC.
By riden
#39661
kirkzeus wrote:I am a complete novice when it comes to PICs...
The final desire of mine is for ALL programming to be done via the ethernet connection... as the PIC will be in a remote location.
The phrases "complete novice" and "PIC in remote location" really don't go together. I intend no disrespect. I consider myself a well seasoned programmer and have developed my share of mission critical applications. Even after writing commercial software for over 25 years, I have been bit by having the computer at a remote location (i.e., inaccessibility). Nothing is more annoying to have to drive a hundred miles (round trip) because the timing of the reset logic didn't take into account temperature extremes. :cry:
kirkzeus wrote:I want to get a PIC setup that will be able to achieve my goal, which is analogue/digital input/output, with http/ftp/etc. and to be able to remotely programme the device via the ethernet.
It depends upon the nature of the remote programming. If you mean being able to completely replace the firmware, yes you will need a bootloader. But some applications can be "scripted" (interpreted), and the program can be replaced by changing the contents of the flash that holds the script code. That is the technique I used for a robotic project and also for a weather monitoring application. The firmware (which almost never has changed) is designed to run a script that is contained in EEPROM/FRAM. What is the nature of the type of remote programming you want to do? Perhaps it might lend itself to this approach.
kirkzeus wrote:I feel that it would be a wasteful and costly exercise to go through various devices just to learn and then have to buy yet another one because the previous one won't achieve my goal.
If you can't find a suitable board with an Ethernet bootloader that has everything you want, consider focusing on the non-network functionality by buying or building a board that can interface with another board that provides network functionality (web server, FTP, etc.) I took this approach after I got tired of the pain of reprogramming my PIC-WEB all the time when I wanted to change some aspects of my automation system. Let the PIC-WEB (or the network device of your choosing) handle serving the web pages, uploading and downloading data, and communicating with your daughter board. It is a nice way of decoupling a complex system. You can gain experience programming and debugging without the added overhead of the network integration.
kirkzeus wrote:I just hope that in this technologically advanced age which we live in, there is a device out there that will do this.
I can relate to your frustration. You would think that once a problem has been solved, we can move on, and not have to go back and solve the same problem again and again. However, we live in technology advanced age but not a technology mature age. In a technology mature age, the next generation of products build upon the successes of the past without having to reinvent the wheel or worse, go backwards (e.g., XP + 5 years + $$$ = Vista). But we are moving in the right direction. There will always be innovators whose products will break through. It is also interesting to note that much of this innovation is occurring outside of the U.S.
chupa wrote:Personal opinion on olimex products:
The olimex "tech support" guy on these forums always seems to have an attitude (pretty rude one) when he posts on these forums. and also spark fun dosent seem to carry the nicer PIC Ethernet webboard anymore and with the smaller Ethernet mini-web board the ICSP breakout headers have been out of stock for at least the same amount of time.
The support, in my opinion, has been more terse (and slow to arrive) than rude. Being more responsive is an area of improvement for them (considering that this is the support forum Olimex links to). Olimex products are available from other vendors as well, including one in the U.K. (see the Olimex site).

I would also agree that kirkzeus can investigate other solutions from other manufactures (AVR, etc.). My focus is in the PIC arena because that is where most of my recent work has taken me. However, I really like the Atmel products, and more and more networked enabled solutions are coming to market.
By Philba
#39693
After following this thread, a couple of things spring to mind:

- you might be a bit ambitious in your choice of first projects
- the PIC18 based network products will probably underwhelm you in terms of their features and flexibility - in particular, the web pages are pretty static. and the amount of space to store the pages is limited.
- the PIC18 based networks products will probably overwhelm you with the amount of development you will have to do to meet your goals.

I would suggest looking at more capable networking products. For example, the Atmel NGW1000 (~$70) may well be a very good choice. It runs linux and you can remotely load your program. Since it runs linux and has an apache web server (plus a whole host of linux applications), you have lots of options. I believe there is a PIC32 option but I didn't see it after a quick look at microchip's site

Good luck
By kirkzeus
#39755
Philba wrote:
I would suggest looking at more capable networking products. For example, the Atmel NGW1000 (~$70) may well be a very good choice. It runs linux and you can remotely load your program. Since it runs linux and has an apache web server (plus a whole host of linux applications), you have lots of options. I believe there is a PIC32 option but I didn't see it after a quick look at microchip's site

Good luck
Thanks for the feedback.

Hmm, I hadn't thought of a Linux based device. That does actually appeal to me. I will have a detailed look at the NGW100 and see if it "ticks all the boxes" as far as my requirements are concerned. However on first glance, it doesn't seem to have any analogue inputs, so I will have to find a way of overcoming this as I want to measure external temperature and battery dc voltage.

Thanks again
By winston
#39795
There are modules around that measure temperature and give you a digital output (SHT7x series, for instance - gives temp and relative humidity on the same chip). This way an engineer has solved all the noise and calibration issues for you and stuck it all in a chip.

For battery DC voltage you can make design compromises: for example, if all you're interested in is a voltage threshold, you can use a comparator and fixed reference, which will give a digital output. At worst you'll need to add an ADC to your project.