Page 1 of 1

ADC problem V6 16F877A

Posted: Mon Nov 11, 2013 11:51 am
by stewartbaker
This program simulates OK, but seems to generate incorrect code.

AN0 is not recognised, and the AN1 input affects both analogue channels.

Stewart
16F877A_ADC_Test.fcfx
(7.71 KiB) Downloaded 349 times

Re: ADC problem V6 16F877A

Posted: Mon Nov 11, 2013 3:08 pm
by Benj
Hi Stewart,

The RAW functions and ADC module can only work with one channel at a time so you are essentially setting the program up for channel 0 and then channel 1 and then all the samples you are doing will then reference channel 1. If you remove the RAW enables and then change the RawAverage to GetInt then it should work fine. I will have a look into creating the Average function as an all in one Get operation as this would be nice to have.

Re: ADC problem V6 16F877A

Posted: Mon Nov 11, 2013 3:19 pm
by stewartbaker
Hi Benj,
Thanks for the explanation of what I am seeing. The program I am developing started life in V5, and the RAW ADC functions work fine in that. As you say there is no problem when GetInt is used, but the averaging is very useful.
It would be great if can roll the Average and Get functions together.

Cheers Stewart

B.T.W although I have only been playing with V6 for a few days, I like what I see. For example the debugging facility is much nicer that in V5.

Re: ADC problem V6 16F877A

Posted: Mon Nov 11, 2013 4:59 pm
by Benj
Hi Stewart,

Ok I have added the GetAverage functions now which should work as expected.
adc_base.fcpx
(4.69 KiB) Downloaded 304 times
Let me know how you get on.

Re: ADC problem V6 16F877A

Posted: Tue Nov 12, 2013 10:26 am
by stewartbaker
Hi Benj,
Sorry, I must be missing something, but I can't see a difference between the original adc_base model and the new one...
I gave the old one a different extension and copied the new one into PF/Flowcode 6/Components. Was this correct ?

Stewart
Benj wrote:Hi Stewart,

Ok I have added the GetAverage functions now which should work as expected.
adc_base.fcpx
Let me know how you get on.

Re: ADC problem V6 16F877A

Posted: Tue Nov 12, 2013 1:09 pm
by Benj
Hi Stewart,

Whoops I had added the new functions but not made them public so they were hidden by default.

This component should be better.
adc_base.fcpx
(4.79 KiB) Downloaded 272 times
I gave the old one a different extension and copied the new one into PF/Flowcode 6/Components. Was this correct ?
Yep that's all you have to do, as well as restart Flowcode after moving the file.

Re: ADC problem V6 16F877A

Posted: Tue Nov 12, 2013 4:57 pm
by stewartbaker
Ah, that's much better - thanks.

Stewart
Benj wrote:Hi Stewart,

Whoops I had added the new functions but not made them public so they were hidden by default.

This component should be better.
adc_base.fcpx
I gave the old one a different extension and copied the new one into PF/Flowcode 6/Components. Was this correct ?
Yep that's all you have to do, as well as restart Flowcode after moving the file.

Re: ADC problem V6 16F877A

Posted: Tue Nov 26, 2013 11:59 am
by Jero
Hi all,

I'm also using the PIC16F877A uC and have a problem with the ADC (I think): I'm using two ADC channels: A0 and A1, and then displaying them on a LCD. Using the sensorboard with the photodiode on A0 and the pot on A1, everything goes just fine. However, when I switch the sensor board for the terminal board, and attach two different wires to A0 and A1, the values seem to follow each other. When shorting A0, A1 goes to about 30 mV. Similarly, shorting A1 causes A0 to go to about 30 mV. When applying a proper voltage on the wires, they both follow A0. Just touching either of the wires while they don't have a voltage applied causes them both to give a 0V reading. Does anyone know what I might be doing wrong?

Cheers,

Jero

Re: ADC problem V6 16F877A

Posted: Wed Nov 27, 2013 11:50 am
by Benj
Hello Jero,


What is the charge time currently set to. If this is too small then this may explain the cross channel bleed problems your seeing.

Can you explain how the external parts of the terminal board is wired up so we can try and gauge if there is anything here causing problems.

Re: ADC problem V6 16F877A

Posted: Fri Nov 29, 2013 4:28 pm
by Jero
It is solved, I was a bit stupid, the unconnected wires gave random signals (probably due to electromagnetic interference?), when I connected the bunch to the rest of the circuit, all was well.
Thanks anyways!