ADC problem V6 16F877A

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
stewartbaker
Posts: 116
Joined: Tue Jul 17, 2012 9:34 am
Been thanked: 18 times
Contact:

ADC problem V6 16F877A

Post 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 348 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ADC problem V6 16F877A

Post 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.

stewartbaker
Posts: 116
Joined: Tue Jul 17, 2012 9:34 am
Been thanked: 18 times
Contact:

Re: ADC problem V6 16F877A

Post 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.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ADC problem V6 16F877A

Post 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.

stewartbaker
Posts: 116
Joined: Tue Jul 17, 2012 9:34 am
Been thanked: 18 times
Contact:

Re: ADC problem V6 16F877A

Post 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.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ADC problem V6 16F877A

Post 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.

stewartbaker
Posts: 116
Joined: Tue Jul 17, 2012 9:34 am
Been thanked: 18 times
Contact:

Re: ADC problem V6 16F877A

Post 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.

Jero
Posts: 3
Joined: Tue Nov 26, 2013 11:52 am
Been thanked: 2 times
Contact:

Re: ADC problem V6 16F877A

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ADC problem V6 16F877A

Post 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.

Jero
Posts: 3
Joined: Tue Nov 26, 2013 11:52 am
Been thanked: 2 times
Contact:

Re: ADC problem V6 16F877A

Post 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!

Post Reply