Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

What PIC do I need?

Status
Not open for further replies.
I want a PIC that will receive 5v on an input on one of 4 pins that are attached to momentary foot switches that will then send out 5v from up to 6 output pins.

So, I'm guessing I'll be needing a 12 pin PIC and I just wont use 2 of the inputs>

However, the foot switched maybe only be tapped for a fraction of a second. Will any old PIC be able to keep up with this? Will it be able to recognise the 5v even if it's only high for a fraction of a second and then instantly process one of the commands? What sort of processing speed would be recommended for this?

It's just being used to turn on MOSFET switches.
 
So there are 4 inputs. Maybe 4 momentary switches.
There are 6 outputs. Do all of the out puts act the same? Do they send out 5V at the same time. I am trying to find out if the output signals can be tire together.
Some PICs use an external oscillator on tow pins, some have an internal oscillator.
Many PICs need a reset pin. Did you count power and ground?
From experience, next week you will find a use for two more pins. Maybe you should get a part with some 'unused' pins.

There is no speed problems! Even the slowest part will work.
 
4 inputs, 6 outputs. They'll all be outputting 5v constantly but will have a certain number on and off.

For example, if momentary switch 1 is hit, it will put 5v out of 3,4 and 6 (random). If switch 2 is hit it will put 5v out of 1,2,3. etc. etc.

I didn't account for power and ground. Doh.

Yah, the speed was the main worry, cheers. :)
 
I can't see exactly what you want but I believe you could easily check all inputs, set all outputs and (do something else) 1000 times/ second.
I know you said "PIC" but if you are just starting out.....there are some "basic stamps" that use a PIC and can be programmed in BASIC which is easy to understand for beginners. They connect directly to a PC for programming.
 
I can't see exactly what you want but I believe you could easily check all inputs, set all outputs and (do something else) 1000 times/ second.
I know you said "PIC" but if you are just starting out.....there are some "basic stamps" that use a PIC and can be programmed in BASIC which is easy to understand for beginners. They connect directly to a PC for programming.

I've worked on a few PIC projects before using assembly like a few LED chasers and servo PWM projects.

It's just I'm not very organised and I can see myself getting something with too little i/o and wont register a very fast switch. But, I suppose anything above 12 pins will work. I could also add some fancy LED dances for the standby setting on the spare pins. ^_^
 
I/O (in out) pins

Actually speaking you have to look for "I/O pins".

What family have you worked with?

If you know the 18F, you should be OK using the 18F1320.

More than ten IO pins available.
 
The 18F is much smarter than a 16F. If I understand right you could use any 16F. I am now using parts with internal OSC to same two pins and $. With a little work many parts can use the "reset" pin as an input.
 
The 18F is much smarter than a 16F. If I understand right you could use any 16F. I am now using parts with internal OSC to same two pins and $. With a little work many parts can use the "reset" pin as an input.

I just remembered internal OSC would be a lot easier space/money wise etc. so I'll go for one with that too. :3

Right, so anything above 12ish pins with an internal OSC at any speed should be fine. Now to look for the cheapest one of..... those. Hahaha ^_^
 
...and wont register a very fast switch.

Unless you are pushing the switch well into or above the MHz range you don't have to worry.

To a microcontroller humans are extremely slow.

In fact, you could count the bouncing of the switch contacts as they close if you wanted (as an example).
 
Last edited:
Unless you are pushing the switch well into or above the MHz range you don't have to worry.

To a microcontroller humans are extremely slow.

In fact, you could count the bouncing of the switch contacts as they close if you wanted (as an example).

The beauty of technology. :') It's hard to believe sometimes.
 
lol is that a tear i saw you shed?
 
Up to you, Luke.

Moving to the 18F family you will leave behind the so many "complications" the 16F have. That is my opinion / my experience, anyway.

Now that I think of it, other posters are right. The internal oscillator would be enough if your timing is just dictated by the need of pressing buttons and getting results from that.

If you dare to jump, 18F1320.
 
If you are looking at the 18F1320 you may want to check out the 18F1330. It has one less timer but it is has advanced PWM for motor control, can run 4X faster on the internal OSC due to a PLL, and it has 3 hardware breakpoints instead of 1 for debugging. To make the PLL work they are reduced the number of timers by1.
 
Last edited:
Although the 18F has been mentioned, if all you are doing is checkinga digital input (yes/no) and making outputs high/low, then any PIC microcntroller is capable of that - as long as it has the available number of IO required for the project. With much talk about timers, debug breakpoints - if yo're starting out do yourself a favour:

1) Get a PIC thats commonly used for tutortals/examples on the internet, so you can use the example code given straight into the chip without having to modify it for a slightly different device. Examples from small to large, 12F629/675, 16F630, 16F628A (thats getting old now), 16F877A, 18F1220.

1a) Get what ever PIC is available to you - no point in going out your way to get a 'really cool' new PIC.

2) For just making pins high/low, the vast number of peripherals on PICs (ADC's, PWM, UART, SPI, I2C, timers...etc..) will most likely be redundant, and as some are 'on' by default, the first part of your code will be purely to turn these things off because you're not going to use them. A nice basic 16F series will do just fine, and is supported by almost every compiler. 628A if its sill not too old to start getting expensive

3) What are you writing code in? MPLAB for assembly obviously, but if you're a C person, mikroC do a 'free' version for non-profit/educational purposes, with a limit on code size. They have many many examples, large support on the internet, and is quite easy to understand.

4) Buy a pickit2 programmer, or clone :) Some ebay shops sell these very cheaply. If you're trying to make your own programmer, this has been a source of headaches for many.


Don't worry about the speed of checking a button press. Humans can, at best, do around maybe 20ms 'tap' - and for a momentary switch a lot of that at the start will be switch bounce. The general standard speed for PIC's is 4Mhz (internal oscillators), and can execute one instruction per 4 clocks - giving a million instructions per second. So you could read your input pin 20 thousand times for even the quickest tap. And even then theres interrupts which jump to a block of code when a pin changes state - no need to manually 'read' the pin, so you could sense the footpress in a few us. Of course you can reduce the clock speed to reduce power consuption (5mA for 4Mhz? uA for 32kHz...) but unless you're running this off watch batteries - I don't see the point :)

And yes, technology is great :) I have yet to really use a PIC to its full capabilities, I would say much code writen these days is 90% 'waiting' for something to happen, or delays. And those are just 20MHz 8-bit machines...
 
You make some good points Blueteeth but I have a comment.

MikroC is a bit of a trap. It is easy to use with a lot of non standard stuff. After the users gets hooked on it other C's will seem too different and the user will most possibly buy it. Last time I checked they wanted to sell you debugger hardware too. Maybe they now allow the PK2/PK3. CCS works the same way.

Hi-Tech's Lite compiler works well enough and does not have the code limit.
 
Wise words, they do integrate their own programmer/deubgger and its probably how they are able to allow for a free version, because many users might eventually decide to just use Mikroe's gear. However, believe it or not, I got away without using a ICD for years, and the software for the PICkit2 meant that upon pressing the button, the PIC can be programmed with the hex files its currently 'pointed at'. Ergo, I just used mikroC for testing, using its inbuilt routines and handy 'configuration word' facility, compiled, then pressed the button on the PICkit2.

Also, as its a complete compiler/IDE/terminal/emulator all in one package - I found it just plain convenient to install, and use that for pretty much everything save programming. For actual work/contracts/projects, I would switch to C18 once I had proven the idea 'could be done'. And I don't tihnk I have reached the code limit in MikroC yet.... although as I said, I only every used it if I wanted to get an idea into a working circuit in less than a couple of hours.

Ok, probably sounds like I'm plugging the compiler here, but I thought I'd mention it for the OP, because it's very friendly for beginners, doesn't really require any fiddling to get it to work, just install, and the 'help/support' on that compiler is frankly much better than any microchip helpfiles I have seen. My next purchase will be the full version, which is saying a lot since I really am a cheapskate (make my own dev boards, rarely buy software) plus theres nothing worse than having to 'set up' ones IDE and compiler to streamline the whole process if you just want to make some LED's light up :)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top