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.

Which PICs would do this?

Status
Not open for further replies.

grrr_arrghh

New Member
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
 
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.
 
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.
 
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.
 
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.
 
i don't need accuracy! Cap chargin will be fine.

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.

You might also want to consider up/down buttons. It's good for some applications, bad for others.
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 said:
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, ...)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top