ADC problem V6 16F877A
Moderator: Benj
-
- Posts: 116
- Joined: Tue Jul 17, 2012 9:34 am
- Been thanked: 18 times
ADC problem V6 16F877A
This program simulates OK, but seems to generate incorrect code.
AN0 is not recognised, and the AN1 input affects both analogue channels.
Stewart
AN0 is not recognised, and the AN1 input affects both analogue channels.
Stewart
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 116
- Joined: Tue Jul 17, 2012 9:34 am
- Been thanked: 18 times
Re: ADC problem V6 16F877A
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.
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.
- 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
Hi Stewart,
Ok I have added the GetAverage functions now which should work as expected.
Let me know how you get on.
Ok I have added the GetAverage functions now which should work as expected.
Let me know how you get on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 116
- Joined: Tue Jul 17, 2012 9:34 am
- Been thanked: 18 times
Re: ADC problem V6 16F877A
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
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.
Let me know how you get on.
- 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
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.
Whoops I had added the new functions but not made them public so they were hidden by default.
This component should be better.
Yep that's all you have to do, as well as restart Flowcode after moving the file.I gave the old one a different extension and copied the new one into PF/Flowcode 6/Components. Was this correct ?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 116
- Joined: Tue Jul 17, 2012 9:34 am
- Been thanked: 18 times
Re: ADC problem V6 16F877A
Ah, that's much better - thanks.
Stewart
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.Yep that's all you have to do, as well as restart Flowcode after moving the file.I gave the old one a different extension and copied the new one into PF/Flowcode 6/Components. Was this correct ?
Re: ADC problem V6 16F877A
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
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
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: ADC problem V6 16F877A
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!
Thanks anyways!