PDA

View Full Version : PIC16F690 Comparator C1 - some helpage needed!



HankMcSpank
- 12th March 2010, 01:31
I'm not getting anything out of the C1 comparator, have I missed anything with my register settings



ANSEL = %00000110 ' AN1-AN2 enabled - the rest all digital
CM1CON0 = %10100000 ' C1 On, C1 Output enable, take VREF from C1In+ pin, Select C1In0- channel
TRISA.0 = 0
TRISA.1 = 1
TRISA.2 = 1

ANSELH = %00000011 ' AN7-AN8 enabled
CM2CON0 = 0 'C2 off.


I'm connecting a VREF DC level externally to pin 19 PortA.0 (which is C1IN+), something ain't right - when I scope Pin 19 -it's the yellow trace here - there's some random high/low switching going on (it should be steady DC - I checked the DC when removed from the PIC - it's rock solid...this pulseing is coming out of the PIC pin!)

http://img691.imageshack.us/img691/263/scopel.jpg (http://img691.imageshack.us/i/scopel.jpg/)



and an analogue sine wave to PortA.1 (which is C12IN0-) ...I'm scoping PortA.2 (which is C1OUT) - nothing there :-(

Many thanks for any help!

HankMcSpank
- 12th March 2010, 02:01
Ok, after spending ages on this ...and getting desperate, with one last push, I swapped everything around to use comparator2 instead - that one works fine.

Heaven knows what's going on with then C1IN+ pin 19 !!

Darrel Taylor
- 12th March 2010, 02:39
I guess I'm a little late, but ...

You had RA0 set to Output (C1IN+)
And RA2 set to Input (C1OUT)

TRISA.0 = 0
TRISA.2 = 1
<br>

HankMcSpank
- 12th March 2010, 10:21
Thanks Darrel, but in my defence...

1. It was late (like 2.00am UK time).
2. I'm a noob
3. I'm stoopid!

Darrel Taylor
- 12th March 2010, 21:51
I disagree.
You seem to be doing fine.
He who makes no mistakes, makes nothing.
(one of my signature quotes)

Anyhow, I've been playing with the tone detector I mentioned in the other thread.
Getting some interesting results, but nothing workable yet.

If that's where you're headed with the comparator, I may have some thoughts ... although, not very good one's.
<br>

HankMcSpank
- 13th March 2010, 00:46
I disagree.
You seem to be doing fine.
He who makes no mistakes, makes nothing.
(one of my signature quotes)

Anyhow, I've been playing with the tone detector I mentioned in the other thread.
Getting some interesting results, but nothing workable yet.

If that's where you're headed with the comparator, I may have some thoughts ... although, not very good one's.



Thanks for the moral support!

re extracting frequency from an analogue using a comparator - well, as you know, I used a sig gen - it was good, I used a guitar...alas, as predicted the result were just too erratic. I'm not at the stage yet where I feel up to programming in sufficient 'intelligence' to cater for all the variations (averaging, disregarding counts outside a 'window etc'), but that's where I want to get to.

In the meantime, I've since changed to a PIC16F690 iiit's a challenging little PIC for someone at my level, but it has way more pins for me to play with (the last IC got on my nerves becuase I had to share some of the programming pins with the comparator pins - mucho switching back & forward)

I read that Application Note you linked me to in my other thread ....I'm still standing on the chair trying to catch the info that went way over my head! :D

Darrel Taylor
- 16th March 2010, 00:28
Well I thought I would have something to say ... but I haven't got the darn thing working either.

Maybe I should go read that appnote again.
I'll use a butterfly net to catch the stuff wizzing over my head. :)

Haven't given up yet.
<br>