PIC Control Board

This thread is a continuation of:
lynxmotion.net/viewtopic.php?t=642&start=30.

Aggghhh!
So many questions!

I’ve spent the last couple of days researching my options, and I’m finding that they’re expensive.

They actually have a USB to DB25, as well, so I could go with that, right?
sewelldirect.com/USB-to-DB25-Adapter.asp
Is that one-way as well?

No, I don’t have a serial port.
:frowning:
Does a USB->Serial adapter count?

And, this won’t actually program the PIC, right?
sparkfun.com/commerce/produc … ucts_id=22
That’s why it’s got the ICSP port?

I’ve been looking into compilers, and it seems that all of the free versions of the C or Basic compilers don’t support the 4620.
Should I give that up as a lost cause and start learning assembler?

I’m going to need a board to assemble this all on.
I’ve looked at various types of proto-boards, and I think that I’m going to use perf board.
I’ve had bad issues with breadboards (things fall out when I bump them).
Also, perf boards are cheap.
:smiley:
Oh, yes, there was a point to this explanation.
Does anyone know of a good-quality perf board?
I was going to pick up one from the Shack, but I saw a post of someone hating on the ones from there.

That USB to DB25 thing might not work - notice where it says “only for printers, will not work with other devices”. Then they point you to the “true parallel port” which costs 100 bucks…

I would imagine that a USB->serial adapter would work, because a serial port is always going to be bidirectional and such. It might not have modem-control lines, but that shouldn’t matter.

And right, that board from SparkFun will not program the PIC. Even if the HW was there to do it, there would have to be a SW package to go with it.

“PICC Lite” supports the 16F877. You’d be giving up some raw speed, but I really think it would keep you busy for quite a while.
Or, get the free version of C18 from Microchip:
microchip.com/stellent/idcpl … t=SW006011
I think it supports only the 18-series PICs. It is fully functional for the first 60 days, and after that it still works, but without some optimizations (no big deal for most folks).
I wouldn’t recommend starting with assembler, unless you’ve done it before. I think it would be discouragingly tedious. With a compiler, it will at least sometimes tell you “you can’t do that”.

If you can talk yourself into going to the lower-end PICs (for educational purposes), consider getting this:
microchip.com/stellent/idcpl … t=DV164101
It’s only $36, and it is a USB-based programmer, comes with all the SW you need including the PICC Lite compiler, it has 8 LEDs, a button, a pot, and a small prototyping board. It gets power from the USB port. It only supports certain 8-pin and 14-pin PICs (but see below…). I have one, and it works great. You could learn a lot of stuff while getting ready to move up to the bigger PICs. Don’t underestimate the little PICs - their only big disadvantage for most robotics projects is a lack of I/O pins. For a lot of projects you could just use more than one of the smaller PICs, instead of one big one. One for servo control, another for sensors, etc. The biggest challenge would be in making them talk to each other (if that’s needed). According to the web page, it actually supports several 20-pin PICs also, such as 16F690. If that’s correct, it makes it real useful. I’ll investigate… Some of those PICs support I2C…

I would assume that places like Jameco would have a variety of bare perfboard. The differences is things like what type of material it is (phenolic or fiberglass), and what plating (if any) it has. The best boards tend to be a pale greenish color, and there will be a round plated-through tinned pad on every hole. The cheap Shack boards may be phenolic (brown stuff), with no copper at all, or with un-tinned copper. Un-tinned copper is a pain - it doesn’t solder nicely. I can send you a chunk of a good-quality board if you need it.

Pete

Back when I had all my gear setup, I used to use WinPic (check it out here on my PC. Haven’t used it in a while but seem to remember that it could be configured for a range of hardware programmers, programs a large range of PICs (both PIC16 & 18 ), ran on WinXP without needing additional drivers and it’s free.

For PIC hardware programmers, check out Dontronics. I used to use a DIY-K149 parallel port kit (I notice now it’s available in USB), it’s not too expensive (?) US$53 (without the ZIFF socket), can be used for chips up to 40pin and worked pretty well. Unfortunately Dontronics is in Australia (ah home…), but I think he buys the kits in from OS so I’m sure there’d be a supplier in the US. Anyway, gives you an idea of some programmers that are available.

Cheers,

Chris

Microchip seems to have a free IDE as well. Is there something wrong with using their IDE? I have not goten into pics yet so I don’t know.

Here is the link to it for download:

ww1.microchip.com/downloads/en/D … 0_full.zip

Threr are other manuals and support docs on the Microchip web.

Yes, Microchip (and Atmel I think) give away their IDE.
It includes the assembler and other tools.
IF you have their programming HW, then the IDE does the programming stuff for you.
But if you get any 3rd-party programmer, then you have to know what SW is required to make it go, and what PICs does it support.

But the free IDE’s are not the same as the C compiler.

The PICC Lite compiler is a command-line tool, which is fine. You can edit source code with Notepad, or with MS VC++, or whatever you have.
The licensed version of PICC comes with an IDE based on Eclipse.

Pete

Hmmm…

Pete, I’ll keep the 16F877 and other PIC options in mind, in case my current hopes don’t pan out.

OOOH!
:open_mouth:
I wasn’t aware that Microchip had a C compiler!
That makes things simpler.
:smiley:
::starting the 3-day download now (I <3 56K)::

I’m a bit confused as to what you said there.

Is it possible to use MPLAB if I get a 3rd-party programmer that doesn’t explicitly state that it’s compatible with MPLAB (with the C18)?
I realise that the 3rd-party programmers will come with their own software, but I’m not sure how this software works.
Do they interface the 3rd-party programmer with IDE’s such as MPLAB?
Or do they only interface their 3rd-party programmer with their 3rd-party IDE?

To clarify:
I’m wondering if the IDE that I use will be determined by which programmer I select?

Chris, hold that thought.
I’d like to pester you about those links that you gave me, but I need to understand the above, first.
:wink:

Hi Nick,
Microchip has two C compilers that I know of: C18 and C30. C18 is only for 18-series PICs I think, and C30 is for 24-series, 30, and 33 series.
So if you stay with an 18F-series PIC, then C18 is the compiler for you.

Regarding IDE’s:
MPLAB is (generally) only useful for you in two ways:

  1. If you have a Microchip-brand programmer, such as ICD2, PICkit-1, PICkit-2, etc.
  2. If you are doing assembly code, since it includes an assembler.
    In addition, it may integrate with C18 and give you some tools (otherwise, C18 can be run from a command-line I assume).

If you get a non-Microchip programmer, then you’ll need whatever SW goes with it, to allow you to burn chips. MPLAB will not recognize a 3rd-party programmer.

Regardless of what programmer you use, you can still create your burnable code with C18/MPLAB, or with PICC Lite, or whatever. *** All of them produce a HEX file as output. The HEX file is what you give to the programmer to burn into the PIC. ***
Whether your code is in C, BASIC, assembly, or whatever; the end result will be a HEX file that contains the actual bytes that need to be burned. The Intel HEX file format is standard. (FYI - there are other formats that are possible, some are proprietary.)

Here’s a summary of what I would get (if I were you):

One combo:
18Fxxxx PIC
C18 compiler (free)
MPLAB (free)
3rd-party USB programmer (with it’s own SW) ($ ??).
If MPLAB and C18 integrate together, then MPLAB could be your code-editing IDE. Else, you use your own editor (Notepad, etc.).

Second combo:
Certain lower-end PICs, 16F, 10F, 12F, etc.
Microchip PICkit-1 USB programmer ($36).
PICC Lite compiler (free).
The IDE for development is Notepad, or whatever you like. For burning PICs, you use the SW that comes with the PICkit.

Third combo:
Any PIC you want.
Microchip ICD2 USB programmer ($150).
C18 compiler (free)
MPLAB (free)

Perhaps the only advantage of the “Second combo” is that it’s very “plug and play” – in just a few minutes, you would be running demo apps that make LEDs flash, etc., and doing the tutorials, etc.

Pete

Ahhh!

Thanks for the great explanation!
That was very clear.
:slight_smile:

I think I’m going to go with the first option, since it allows me the cheapest route to use the best software.

By the way, from their description, it does indeed seem to say that C18 is just a program that gets layered over the original MPLAB IDE.

Thanks again!!!

BTW, I did some snooping with the PICkit-1 board last night. I peeked at the EXE for the GUI app, to see which PICs it really supports.
Unexpectedly, I found the 16F877A in there, although it’s mentioned in the docs as a supported device (running the app doesn’t tell you what it supports - it queries the PIC for it’s ID, and if it recognizes it, it displays the type name).
The source code for the app is available, but it’s an older version that supports fewer PICs.

So, PICkit-1 supports at least two 40-pin PICs it would appear. And, by modifying the PC app, it might be able to support many more.

Pete

I’m in Boston, this weekend for a meeting (a.k.a. all-expenses-paid vacation), so I stole their WiFi and downloaded everything from the MPLAB and C18 pages.
So, I’ll be spending the next few weeks reading all of that and then starting to mess around with the C18 compiler and MPLAB.

I’m more-or-less leaning towards the DIY-150 programmer kit (from the site that Chris linked me).
I’ve posted their forums asking whether or not the 18F4620 is specifically suppported in their SW, since the kit’s latest version of software doesn’t have it listed (although a year old post on their site said that they were about three weeks away from that).

I like the look of this one for a few reasons:
(1) USB, so no messy (and sometimes unpredictable) adapter hassles
(2) SW supports large range of PICs.
(3) Pretty cheap.
(4) Active forums.

Okeydokes.
I’ve done a bit of head scratching and a lot of .pdf reading.

Every board that I’ve seen seems to use an external oscillator with a PIC.
And yet, there’s an internal oscillator inside my micro…
What, exactly is the purpose of using an external one?

Even after all that reading, I’m still not sure that I’m understanding this correctly.

The internal oscillator is capable of 32Mhz with 4x PLL.
Is it possible to use an external oscillator that’s faster than that?

The internal oscillator’s frequency is not very precise or stable, compared to an external crystal.
So, the “8 Mhz” may be off by a fair amount, and it will change with temperature.
By “fair amount”, we may be talking a fraction of a percent (I don’t know the spec), but with an external crystal you could expect to stay within maybe a 100th or 1000th of a percent.

For most applications, the internal oscillator is accurate enough. This includes everything a robot is likely to need.
If you’re needing a real-time clock that stays within a few seconds after running for hours or days, then you need a real crystal.

The external crystal will allow you to run faster (i.e. 40 Mhz on some PICs, maybe more on others).

Pete

Ahhh!

Well, I doubt that I’ll ever need that kind of accuracy.
If so, then there’s a neat widget that I saw in Servo that has calendar and time output.
It’s got a lithium battery and uses power-saving technologies.
Supposedly, it’ll last ten years, and it’s much more accurate than a microcontroller.

Anyhow…
I’ll stick the internal’s 32MHz.
That should be fast enough for anything that I’m doing, and probably too fast for most things.

Thats what Mr. Gates said in the begining… :unamused: :laughing:

Ah, that’s cool. I didn’t know that you could use the PLL with the internal oscillator.

WHAT?
Andy didn’t know something?!?!?!?!

Quick, guys, this is our chance, everybody point and laugh at him!

:laughing:

Hey Nick,
In one of my projects in my “real job”, it looks like we’ll be using an 18F2420 (very similar to the one you chose). So I’ll be getting some real experience with it soon.

Pete

Sweet!
That’s just the 24 pin version of what I’ll be using.

About controlling servos…
I can’t simply hook an I/O pin to the yellow wire of a servo and PWM away, right?

I’m thinking that I should use the I/O PWM to turn on and off a transistor through which the larger current flows.
Does that sound right?

Yes, you can connect a PIC pin directly to the ‘yellow wire’ on a servo - no problem! I’m doing it right now (with a 16F88) to drive a small servo for my sensor-sweeper (like a movable eye that scans the path ahead). The servo’s signal input is TTL-compatible.

The next step is how to generate the PWM signal (50 Hz, 1.5 mS pulses for servo-center).

Previously, I was doing it with “Timer 0” producing an interrupt every 32 uS, and then the code counts the interrupts and turns “on” the pulse every 20 mS, and turns it off again 1.5 mS later. That worked fine, except that I couldn’t get much better than 32 uS resolution when running on an 8 Mhz clock.

What I’m debugging tonight is using the “CCP module” (Capture, Compare, PWM - read about it in the PIC spec). I still use the interrupt routine to determine the 20 mS intervals (when a pulse needs to start), but I use the CCP in ‘Compare mode’ (with Timer 0) to decide when to stop each pulse. This should give me very good resolution on the pulse width. The SSC-32 probably does something similar.

But while you’re still getting started, you can do the simplest thing, which is to write code that does this:

  1. Output a ‘1’ on the pin.
  2. Do nothing for 1.5 mS.
  3. Output a ‘0’ on the pin.
  4. Do nothing for 18.5 mS.
    (Of course, it’s not very exciting, because the servo will only know how to go to its center position).

Pete