Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 29th August 2004, 10:31 PM   #1
Default Which PICs would do this?

Hi.

my forthcoming PIC based project will be fairly simple (the sort of thing that could be done with about 5/6 555 timers!). However, I need some way of setting a time period. So my plan is to have a pot wired as a potential divider, and the PIC reads the voltage on the wiper. The PIC would then multiply (?) the voltage by some defined value to get a time period based on the voltage it read. This time period would be used as a 'delay'. Is this a good way to do it, and can someone show me an exmaple of the routine needed to do this? (I reckon I can do the rest of the code)

I assume, I need a PIC with an analogue input? Can someone recomend one? (I was going to use a PIC16F628, as in Nigel's tutorial, but it doesn't seem to have any analogue inputs...)

Also, can anyone direct me to a list of explanations of the various suffixes for PICs (e.g. 'A', '-04' etc).

Thanks

Tim
grrr_arrghh is offline  
Old 29th August 2004, 10:45 PM   #2
Default

You can use the capacitor charge technique to read a pot with a pic that hasn't got any AD, Nigel's tutorials for the joystick do so.
Exo is offline  
Old 29th August 2004, 11:45 PM   #3
Default

ah yes, it does. How though, would I use the reading to create the required delay?
grrr_arrghh is offline  
Old 30th August 2004, 01:21 AM   #4
Default

Cap charging is a rather poor & inaccurate way to read a pot. Why not just get one with an ADC to begin with? They generally don't cost more... even still, an extra $1 isn't worth starting a conversation over.

You might also want to consider up/down buttons. It's good for some applications, bad for others.
Oznog is offline  
Old 30th August 2004, 06:28 AM   #5
Default

What about making it "smart".
With a lcd display and a few buttons to set the times, etcs


Kent
kentken is offline  
Old 30th August 2004, 07:28 AM   #6
Default

If you want a 16F628 with built-in A2D, have a look at the 16F819, basically a 628 with 5x10 bit A2D - and it has an 8MHz internal clock oscillator, although you can switch it to various different speeds - including 4MHz like the 628.

If you're only wanting an input pot, one output pin, and a start button (and perhaps a stop button), you could use the 12F675, an 8 pin FLASH PIC with 10 bit A2D. Same size as a 555, but will make a much better timer :lol:

As for the capacitor charging technique, it's basically how the joystick port on your PC works - there's no A2D on a joystick port, just the same capacitor charging technique!. It's certainly more than accurate enough for reading a pot.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 30th August 2004, 09:14 AM   #7
Default

I think the capacitor A to D you're talking about is called a "dual slope" converter. They can be quite accurate but they depend on the accuracy (and temperature drift) of your capacitor and resistors. But for an extra buck you probably should just buy a PIC with an AtoD.

Another possible solution is a rotary encoder. They use mechanical switches to output digital position. I don't think they are too much more than a nice pot.
bmcculla is offline  
Old 30th August 2004, 11:01 AM   #8
Default

i don't need accuracy! Cap chargin will be fine.

Quote:
If you're only wanting an input pot, one output pin, and a start button (and perhaps a stop button), you could use the 12F675, an 8 pin FLASH PIC with 10 bit A2D. Same size as a 555, but will make a much better timer
I need two outputs, one input (A2D or digital, with the cap charging method) and another input for a start button.

Quote:
You might also want to consider up/down buttons. It's good for some applications, bad for others.
Quote:
What about making it "smart".
With a lcd display and a few buttons to set the times, etcs
This is my first pic project!! (thats a no) - appreciate the suggestions anyway.

OK - I can see I have the choice of a PIC with a built in A2D or using the cap charging method (i'm sure there are other methods, but they will only confuse me). SO, could someone please give me an example of the code I would need to read/convert these to a time delay - or at least give me the name of the parameters so that I can look them up.

Thanks very much

Tim
grrr_arrghh is offline  
Old 30th August 2004, 11:42 AM   #9
Default

Quote:
Originally Posted by grrr_arrghh
OK - I can see I have the choice of a PIC with a built in A2D or using the cap charging method (i'm sure there are other methods, but they will only confuse me). SO, could someone please give me an example of the code I would need to read/convert these to a time delay
What you need to do is write a variable delay routine. A routine wich you call with a certain number in a variable and then the routine will delay for that time period.

Take, for example, you want to delay between 1 and 100 seconds. Then you write a delay routine wich you call with a number in W. If there's a 1 in W 1 second will be delayed, and so on

Then you read the pot (with eighter technique). It will return a number, for the AD method for example, it will return a value between 0 and 1024 (10bit). All you need to do is scale this number to fit your 100 second requirement (divide the result by approx. 10).

You can look at the piclist for all the routines you want (delays, divisions, ...)
Exo is offline  
Reply

Tags
pics

Thread Tools
Display Modes




All times are GMT. The time now is 03:24 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker