Maker Pro
Maker Pro

Help Getting Started with PIC Microcontrollers

Supercap2F

Mar 22, 2014
550
Joined
Mar 22, 2014
Messages
550
There is no definitive list for the PICKIT 3 for some reason.

shumifan50 said that the PICKIT 3 sports all PICs.

Thanks for the PICKIT 2 sported devices list! :)

Dan
 

pyromaniac4382

Feb 7, 2013
61
Joined
Feb 7, 2013
Messages
61
I think it is almost all PICs. Just make sure you confirm before you buy. Nothing worse than waiting for a chip to come in, and then not being able to use it when it does finally get there.
 

Supercap2F

Mar 22, 2014
550
Joined
Mar 22, 2014
Messages
550
I just checked out the "Configure->Select Device, and then click on the Device drop-down" thing and the PIC16F1788 is the only PIC that I listed that works with the PICKIT 2.:eek: I guess I'm really going to get the PICKIT 3!

Thanks :D

Dan
 

pyromaniac4382

Feb 7, 2013
61
Joined
Feb 7, 2013
Messages
61
I think I returned my PICKIT 2 for the same reason.I think it depends on the MPLAB software.
 
Last edited:

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Newer chips are not supported by the PICKIT 2 through MPLAB, but many of them are supported through the PICKIT stand-alone app. You can build in MPLAB, then program with the PICKIT 2 app. But you do not get in-circuit debugging on those chips.

Since you are planning on buying newer chips, I would go with the PICKIT 3, which reminds me, I need to order one of those myself.

Bob
 

Supercap2F

Mar 22, 2014
550
Joined
Mar 22, 2014
Messages
550
Another question about PICs: do they have a funtion where they can read frequencies up to 20kHz? Like if it "sees" a 10Hz signal on a pin it will do something that you program in to it. If so then can you set a range on it? Like from 10-20Hz it will do the same thing.

Hope that makes sense :confused:

Dan
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Yes, you can do that. There are several ways.

If the frequency you want to measure is high, you can use it to clock a counter and use a second counter as a time reference to measure the intervals between when the first counter wraps around.

If the frequency you want to measure is low, you can detect individual transitions using an interrupt handler (or even polling, in some circumstances) and sample the reference counter when a transition is detected.

The most generic way is to use a feature called input capture (ICP). This is not available on all PICs and is normally tied into the output compare function, which is similar. When a transition occurs on the input, the value in a reference timer is sampled and latched into the "input capture register". Normally, an interrupt is also generated, but ICP can be used in polled mode in some circumstances. The firmware just reads the input capture register and it knows the exact time when the input transition occurred. Normally the hardware is configured to respond to only rising edges, or only falling edges, but the interrupt handler can flip the polarity bit so that both edges can be captured.

Edit: Once you have the period of the input signal you can convert it to a frequency, or just define your thresholds in terms of periods instead of in terms of frequencies. You may also need some logic to detect when an input signal stops, or slows down, because capturing transitions means that your logic will only get executed when there is a transition, not if the transitions stop, and you may need to detect that.

If you want specific recommendations, tell us more about what you want to do.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
I'm sure Microchip has a selector that allows you to nominate what features you want and it lists parts that have them.

Try here. I told it I wanted a PIC16F series chip in a 14 pin package with a 16MHz internal oscillator, 1 comparator and 3 ADC channels. It gave me a list of 24 to choose from.

It's a shame thy don't list PICkit 2 & 3 compatibility on the selector :(
 

shumifan50

Jan 16, 2014
579
Joined
Jan 16, 2014
Messages
579
Depending on what you want to use it for, you might want to take a look at this:
http://www.instructables.com/id/Frequency-Detector-using-PIC-12F683-Processor/?ALLSTEPS

For remote controls I would use IR ( I am assuming it is still for robotics) and use the Vishay TSOP IR detectors. They eliminate all background IR (like daylight) and are really easy to use and allows overdriving the IR LED to achieve nice range. I have never done it but I imagine it should be possible to use them in conjunction with the USART to send data.
Look at this design - it is not a remote control, but can be easily adapted to run on a PIC and send/receive commands.
http://www.pcbheaven.com/circuitpages/Long_Range_IR_Beam_Break_Detector/

Here is the circuit for a full remote sender/receiver
http://www.coolcircuit.com/project/8chrem/
 
Last edited:

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
It's a shame thy don't list PICkit 2 & 3 compatibility on the selector :(
I wish they would include the core type on the selection guide. Baseline, mid-range, enhanced mid-range, high end. Or just the instruction word size.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Depending on what you want to use it for, you might want to take a look at this:
http://www.instructables.com/id/Frequency-Detector-using-PIC-12F683-Processor/?ALLSTEPS
That's a bit different from the simple methods I suggested - it accepts an analogue signal, which may contain many frequencies, and performs simple digital signal processing on it to determine whether the detection frequency is present in the input signal or not.

It does not determine the frequency of the input signal; it detects whether the detection frequency is present or not. It is slower and more complicated than the methods I suggested. But you need to use that method if you have an input signal that's analogue and contains more than one frequency. The methods I suggested are only suitable for a digital signal, and only one that contains one frequency (possibly with some limited exceptions).
 

Supercap2F

Mar 22, 2014
550
Joined
Mar 22, 2014
Messages
550
Well which ever way I do it it sounds complex. Maybe you can tell me what would be the best way to do this: I found these really neat color sensors that covert color to frequency. So what I thought about doing was get a frequency to voltage converter then feed the output into a comparator with a variable reference voltage. So I looked around for some frequency to voltage converters, but found that they are rather complex (I could still figure out how to use them though). So being lazy, I thought I could just ask here to see if a PIC could do the same thing but less complexly.

Which way do you guys think would be the best?(sorry for taking this thread a little off topic)

(*steve*) said:
Try here. I told it I wanted a PIC16F series chip in a 14 pin package with a 16MHz internal oscillator, 1 comparator and 3 ADC channels. It gave me a list of 24 to choose from.

Thanks Steve, that will help out a lot!

Regards :)

Dan
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Well which ever way I do it it sounds complex. Maybe you can tell me what would be the best way to do this: I found these really neat color sensors that covert color to frequency.
Part number? Link to data sheet?

What do you want the PIC to do with the information? What other functions will it be performing?
 

Supercap2F

Mar 22, 2014
550
Joined
Mar 22, 2014
Messages
550
Hey Kris, it's digikey part number:TCS3200D-TRTR-ND (sorry I can't give you a link, I once told Steve that I would not post any). They have a color to voltage sensor to, but it's to small to solder to.

KrisBlueNZ said:
What do you want the PIC to do with the information? What other functions will it be performing?

Most likely I will just have it tell a motor/servo what to do, depending on the reading.

Thanks

Dan
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
That device doesn't convert colour to frequency... it converts light intensity to frequency

Sorry, I spoke too soon. I'll keep reading the data sheet.

OK, so the TCS3200 and TCS3210 are 8-pin SOIC devices that contain an array (8x8 for TCS3200; 6x4 for TCS3210) of photodiodes with coloured filters. 25% of them have red filters, 25% have green filters, 25% have blue filters, and 25% have no filter.

You select which colour you're interested in via two control pins, S2 and S3, and the device generates a frequency proportional to the amount of light falling on the selected photodiodes. The frequency is scaled according to the S0 and S1 pins to a full scale frequency of 600 kHz, 120 kHz or 12 kHz, typically. The fourth combination of S0 and S1 puts the device into power down.

So you could determine the colour being detected by reading the red, blue and green photodiode arrays alternately. The different colour photodiodes have different amounts of responsiveness to their colour, and you would need to do some scaling to get a reasonably accurate conversion of colour to a number that you could use to control a servo, but it should be possible.

I would use the maximum frequency, and have it clock a counter. Schedule sampling of the three colours using a timer interrupt. On each interrupt, read the counter and store the value as the intensity for the colour that was just sampled, then select the next colour, and reset the counter.

You'll need fairly low interrupt latency to get accurate results. This means that other code running in the device mustn't lock out interrupts for any significant length of time because that would delay servicing of the timer interrupt and cause the current and next counter values to be higher and lower, respectively, than they should be. If you can't meet that requirement, you might be able to read the timer that triggers the interrupt to work out how much the interrupt service was delayed. But I don't think you'll need to do that.

For a PIC, I would use timer 0 to schedule the interrupts, at a rate of around 1 kHz. That would give you 333 complete three-colour samples per second. If you don't need it that fast, use a slower timer interrupt. You would need to use the timer 0 prescaler to divide the instruction clock frequency down to a frequency of 256 times the interrupt frequency so timer 0 will wrap around at the right rate. (Actually you can reload timer 0 in the interrupt handler to get arbitrary division ratios, but this is messy and inaccurate.)

Then you can use timer 1 to count the pulses from the TCS3200 and use the interrupt handler to read and reset the timer as I described above. Almost every PIC or AVR has the required timers for reading the TCS3200.
 
Last edited:

Supercap2F

Mar 22, 2014
550
Joined
Mar 22, 2014
Messages
550
Thanks Kris!

When I learn C I will come back to this so I can understand better what your talking about. :p A update on how learning C is coming along: I ordered C for dummies on the 26th of last month, and I'm having trouble with the seller. Hopefully I will get it on thursday.

Dan
 

foTONICS

Sep 30, 2011
332
Joined
Sep 30, 2011
Messages
332
I have been looking at the PICkit 2 and it looks like I need another board to program the PICs. Do I? Or can I just hook it up to the PIC? If so then how? Will C work with all PICs? It looks like what I'm going to do is get C for dummies and get to know C. Then I will get the PICkit 2 and MPLAB IDE. And start out programing 8-bit PICs. What would be the best 8-bit PIC series to start out with?

Thanks Guys

Dan
I program my PIC16F627a's with nothing but a PICKIT2 and a breadboard. I mean you will need some hookup wire and a resistor or 2 but it's not that difficult
 

foTONICS

Sep 30, 2011
332
Joined
Sep 30, 2011
Messages
332
That is nonsense. Various projects have various requirements for RAM, program ROM and CPU speed. If you are making a commercial product and plan to buy many thousands of PICs, it is useful to make it run on the smallest, cheapest PIC that meets the needs. But for one-off projects, you can almost always just use a bigger / better PIC for $1-2 more and get away with unoptimized C code. Also, if you know the code patterns that are generated, you can do almost any optimization that the compiler is going to do by hand.

I have done several projects using 8-bit PICs with the free C compiler.

Bob
I second this, I'm currently writing code for a PIC16F627a to communicate via SPI with 2 wireless transceivers. The PIC16F627a doesn't have build in SPI hardware so I am coding all of the protocols myself (with help from KrisB of course). In addition to the SPI communication I will also be using the ADC's, creating lookup tables, and writing to displays. I would say this is a little more involved than blinking an LED
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
(sorry I can't give you a link, I once told Steve that I would not post any)

I hereby absolve you from your promise not to post *any* links.

This was a perfect opportunity to post a link. You're talking about a specific part that appears on a commercial web site and it's clearly not spam. This is a case when it is appropriate to post a link.

I think I vaguely remember the reasons I asked you not to post links. It is so vague now that I will not remember unless you start posting links out of the blue that look like spam.
 

Supercap2F

Mar 22, 2014
550
Joined
Mar 22, 2014
Messages
550
(*steve*) said:
I hereby absolve you from your promise not to post *any* links.

This was a perfect opportunity to post a link. You're talking about a specific part that appears on a commercial web site and it's clearly not spam. This is a case when it is appropriate to post a link.

I think I vaguely remember the reasons I asked you not to post links. It is so vague now that I will not remember unless you start posting links out of the blue that look like spam.

Thanks Steve!

Dan
 
Top