![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
Hey,
I'm stuck at the moment with how to check the I/O of the 16F628 PIC. I'll start from the beginning. I have 3 inputs, all of which I want to check the voltages and whether they are between a certain voltage or not. First I need to know how to accept the input (I've seen the use of ADRESH but not sure if it applies to this PIC because it has no A/D, so I doubt it) and then how to go about comparing it to a decimal number. I understand the use of add/sub's to compare, but I don't understand how to compare with a decimal number. I don't quite understand how to declare a decimal number either. How would one, say, declare a constant of 1.3V? Thanks for any help! |
|
|
|
|
|
|
(permalink) |
|
On the 628 you don't have an ADC. You do however have comparators. You could use a comparator to compare a pin to 1.3V. Place a variable resistor (and adjust for 1.3V) on 1 comparator input and the voltage to be tested on the other and the output will go high/low dependent on the input voltage.
Have a read of the data sheet and you should be able to work out how to set it up. Just reread your question and you can't use this method for 3 inputs as the 628 only has 2 comparators. Have you considered a 16F88? Mike. |
|
|
|
|
|
|
(permalink) |
|
I just took a quick look at the comparator module and by setting CMCON to 1, you can test 3 inputs against a fixed value.
Mike. |
|
|
|
|
|
|
(permalink) |
|
Ha,
I did the opposite. I looked over the chart at Microchips and saw only 2 comparators and went to look at the 16F88. I think it would actually be able to just slide right into my circuit in replace of the 628. I've seen more code examples using the A/D method vs. the comparators, but I've had no experience with either. What do you think would be better, given that the 16F88 seems to fit right into the circuit? *Note* That IC converts a frequency to voltage, which that voltage is needed by other components as well. So I'd rather avoid the PIC for that. Thanks alot, you've been a great help. |
|
|
|
|
|
|
(permalink) |
|
The 88 is probably the simplest solution. I posted some example code in the third post of this thread which shows how to read the ADC.
HTH Mike. |
|
|
|
|
|
|
(permalink) |
|
Yeah, from reading more into it, there seems to be a lotmore documentation on the A/D method. You're code gave me a few tips as well. I just hope it works in that circuit, but I doubt there is much of a difference between them. The ports line up all the same, and from the looks of it the 16F88 doesn't need any external additions, correct?
Thanks again! |
|
|
|
|
|
|
(permalink) |
|
The 16F88 is a direct replacement for the 628 and has the added advantage that the internal clock is twice as fast at 8MHz but is software settable to 4MHz should you have time critical code. It also has twice the memory.
Mike. |
|
|
|
|
|
|
(permalink) |
|
Honestly I would use the A/D converters of the PIC16F88 because I'm familiar with them, but the comparators of the PIC16F628A can do the job. I like the internal voltage reference of the comparators, that is software selectable. You need to set CMCON2:0 to b'010' and configure the VRCON register.
|
|
|
|
|
|
|
(permalink) | |
|
Quote:
It's an awesome chip. Now if only people would stop using the 16F84 PS looking at the 16F887 is a different beast than the 16F877, lots more little bits... |
||
|
|
|
|
|
(permalink) |
|
Will that affect my case? Or is it just a general fact? The pins seem to be identical for my purposes...
|
|
|
|
|
|
|
(permalink) |
|
You should be fine as you aren't using the USART.
Mike. |
|
|
|
|
|
|
(permalink) |
|
The A/D on the 16F88 are all on PORTA, you should be fine. Nice feature about the 16F88 you can split up the A/D. On the larger chips they have to be enabled in order. RA0 then RA1 etc...
|
|
|
|
|
|
|
(permalink) | |
|
Quote:
Mike. |
||
|
|
|
|
|
(permalink) |
|
I hate it when those picky details get in the way (grin)...
|
|
|
|
|
|
|
(permalink) | |
|
Quote:
|
||
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| code convertion 16F628 -> 16F84 | patroclus | Micro Controllers | 6 | 6th April 2006 08:34 PM |
| is the number if I/O pins on a 16f628 enough for my project? | ryan_ryan | Micro Controllers | 8 | 13th March 2005 01:22 PM |
| 16f628a programming only got 16f628 support will it work? | lompa | Micro Controllers | 6 | 18th December 2004 05:51 PM |
| JDM and 16F628 | patroclus | Micro Controllers | 13 | 15th December 2004 10:20 AM |
| Can JDM program 16F628 ??? | dy001 | Micro Controllers | 3 | 25th September 2003 03:06 PM |