PDA

View Full Version : Using the Pot command.



timseven
- 11th August 2009, 20:53
Hi there I have a question related to the Pot command (I am using a 16F628 and PicBasic Pro). I am trying to compare the light intensities of four light sensors (4 infrared leds as sensors) . When these infrared leds are exposed directly to the sun light they put out about one volt dc. To be able to compare these voltages I am using the Pot cmd. I know that the Pot cmd is used to measure resistance not voltage but if the voltage applied to the R/C network varies the resistance will also varies accordingly to that voltage. I have read in a book that the voltage supplied by the Pot cmd. to the R/C network could be internal or external. The problem here is that if I feed an external voltage (one volt dc coming from the leds) to that circuit how can I make the Pot cmd send a 0 instead of a 1 before it reads the pin port again. In other words, the Pot cmd feeds it’s R/C network sending a 1 and then it reads the port to measure the time the cap took to fully charge. In my case I am sending the 1 from the leds. Do you know how make the Pot cmd send a 0 instead of a 1 or do you have a better idea? Thanks.

ardhuru
- 12th August 2009, 07:17
Hi,

For the application you have described, why not use LDRs instead of LEDs? They give a far more linear response over a wider spectrum.

Also, in my experience, the pot command used on different pins give a different reading. That is, for the same intensity, and even assuming all 4 of your LDRs are charachteristically identical, you are likely to get different readings on different pins, even on the same port.

Look at this thread for a possible solution: http://www.picbasic.co.uk/forum/showthread.php?p=70591

To avoid these hassles, why not use a pic with ADCs?

Regards,

Anand Dhuru

timseven
- 15th August 2009, 02:01
Well, looks like I'll have to go with LDRs and find a way to calibrate every one of it on each pin because I want to use the 16F628 and learn it the best I can before I try more powerful PICs. Thanks for your teaching and your time, very appreciated.

timseven
- 15th August 2009, 16:18
Hi: Reading the PIC 16F628 datasheet I found out that this PIC has two analog comparators on Port A. The explanation on that datasheet is a little confused for me and I need a little help to understand how could I use these comparator within PicBasic Pro for my project. They explain that the output of these comparators are read from the register CMCON and I have no idea of how can I access this register from Picbasic Pro. I would like to know how or where to find instructions or programs examples to learn how to use these comparators. Thanks a million.

mackrackit
- 15th August 2009, 17:03
This should help you get started.

http://list.picbasic.com/forum/messages/3064/3607.html?

timseven
- 17th August 2009, 20:23
Thanks to both of you for your help. I have learn a lot from the information you gave me. My project is going perfect and my programming without a glitch. Thank you again.