Analogue Input not working
-
- Flowcode V4 User
- Posts: 288
- Joined: Wed Nov 02, 2011 11:15 pm
- Has thanked: 29 times
- Been thanked: 30 times
- Contact:
Analogue Input not working
Hello all
I have a project using the 16F1786 and so far its not put a foot wrong, until it starts refusing to read AN10 (on portB).
So, datasheet says I need to select the pin as analogue, so I have the c-code anselb = 0x02;
It also says I now need to state that its an input, so the c-code I have is trisb = 0x02;
But it still seems the analogue values are not random, but just seem wrong... I don't really need much resolution so I started off just using bytes. But for some reason the values decrease before going back up. I have checked the analogue voltage is correct with a scope (it may be a little noisy but I'm sure I have got away with noisier signals in the past, the scope trace is below).
I have then tried reading as int, but still getting strange values.
Anyone have any idea's?
Thanks
I have a project using the 16F1786 and so far its not put a foot wrong, until it starts refusing to read AN10 (on portB).
So, datasheet says I need to select the pin as analogue, so I have the c-code anselb = 0x02;
It also says I now need to state that its an input, so the c-code I have is trisb = 0x02;
But it still seems the analogue values are not random, but just seem wrong... I don't really need much resolution so I started off just using bytes. But for some reason the values decrease before going back up. I have checked the analogue voltage is correct with a scope (it may be a little noisy but I'm sure I have got away with noisier signals in the past, the scope trace is below).
I have then tried reading as int, but still getting strange values.
Anyone have any idea's?
Thanks
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Analogue Input not working
Hi
Can you post your Flowchart I probably have 1786 in my lab and will try to run your FC with me .
Can you post your Flowchart I probably have 1786 in my lab and will try to run your FC with me .
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Flowcode V4 User
- Posts: 288
- Joined: Wed Nov 02, 2011 11:15 pm
- Has thanked: 29 times
- Been thanked: 30 times
- Contact:
Re: Analogue Input not working
Hello Qmesar
Nothing on the program now seems to work, I have some serious warnings on the compiler messages I am now trying to get rid of. I think I am going to revert back to a version that was working well and attempt to make small changes at a time before compiling. Even the analogue inputs on PortA have stopped now, I am a little anxious that I have somehow damaged the ADC on the IC... I have another board I can check this on as well though.
If I have tried all the above and still nothing, I will post the program - a simplified version as its a little long winded at the moment doing various other things.
Thanks
Nothing on the program now seems to work, I have some serious warnings on the compiler messages I am now trying to get rid of. I think I am going to revert back to a version that was working well and attempt to make small changes at a time before compiling. Even the analogue inputs on PortA have stopped now, I am a little anxious that I have somehow damaged the ADC on the IC... I have another board I can check this on as well though.
If I have tried all the above and still nothing, I will post the program - a simplified version as its a little long winded at the moment doing various other things.
Thanks
-
- Flowcode V4 User
- Posts: 288
- Joined: Wed Nov 02, 2011 11:15 pm
- Has thanked: 29 times
- Been thanked: 30 times
- Contact:
Re: Analogue Input not working
Hello Qmesar
Following my last post...
I have tried new hardware - there is no change
I have simplified the program as much as possible and withdrawn all serious warnings from compiler messages.
I do however need two Analogue inputs, one on AN10 (RB1) and the other on AN0 (RA0), neither of which is working as it should.
AN10 - this is the input I mentioned earlier - the values seem to start off around 0x80 (around 0V) then drop down to 0x00 (around 1.1V) before going back up again. Below is a scope trace with the UART value of the analogue input being read and the Voltage going into the pin (Red Channel below). (ignore the first byte for now).
AN0 - The one for some reason just gives me 0x00 no matter what voltage is applied into the pin. The value is sent through UART on the fist byte and the Voltage can be seen in Red below.4
I have also attached the simplified program (V6.1.4.0)
Thanks for your help...
Following my last post...
I have tried new hardware - there is no change
I have simplified the program as much as possible and withdrawn all serious warnings from compiler messages.
I do however need two Analogue inputs, one on AN10 (RB1) and the other on AN0 (RA0), neither of which is working as it should.
AN10 - this is the input I mentioned earlier - the values seem to start off around 0x80 (around 0V) then drop down to 0x00 (around 1.1V) before going back up again. Below is a scope trace with the UART value of the analogue input being read and the Voltage going into the pin (Red Channel below). (ignore the first byte for now).
AN0 - The one for some reason just gives me 0x00 no matter what voltage is applied into the pin. The value is sent through UART on the fist byte and the Voltage can be seen in Red below.4
I have also attached the simplified program (V6.1.4.0)
Thanks for your help...
- Attachments
-
- Analogue Issues.fcfx
- (31.29 KiB) Downloaded 230 times
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Analogue Input not working
Hi.
I am out of my lab this week ,I will give it ago when I am back.
just something I noticed
you have the oscon setting ar 0x7A for 16Mhz internal oscillator ,as far as I could remember in all my projects with a 16F17xx device at 16Mhz my OSCON where set at 0x78 .
make sure about this as it directly influence the TAD time of the ADC and that could cause strange behaviors
I am out of my lab this week ,I will give it ago when I am back.
just something I noticed
you have the oscon setting ar 0x7A for 16Mhz internal oscillator ,as far as I could remember in all my projects with a 16F17xx device at 16Mhz my OSCON where set at 0x78 .
make sure about this as it directly influence the TAD time of the ADC and that could cause strange behaviors
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Flowcode V4 User
- Posts: 288
- Joined: Wed Nov 02, 2011 11:15 pm
- Has thanked: 29 times
- Been thanked: 30 times
- Contact:
Re: Analogue Input not working
Hello Qmesar
The second to last bit on the osccon register is the system clock select bits. the 1* which the 0x7A states I'm using the Internal oscillator block, where the 0x78 would use the FOSC<2:0> configuration words. I not sure it will make a difference but I will give it a go.
Thanks
The second to last bit on the osccon register is the system clock select bits. the 1* which the 0x7A states I'm using the Internal oscillator block, where the 0x78 would use the FOSC<2:0> configuration words. I not sure it will make a difference but I will give it a go.
Thanks
-
- Flowcode V4 User
- Posts: 288
- Joined: Wed Nov 02, 2011 11:15 pm
- Has thanked: 29 times
- Been thanked: 30 times
- Contact:
Re: Analogue Input not working
Hello Qmesar
Unfortunately changing the osccon register did not work, seems i will need to wait for you to return to the lab...
Thanks
Unfortunately changing the osccon register did not work, seems i will need to wait for you to return to the lab...
Thanks
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Analogue Input not working
Hi That is fine now we know
I will make a plan to run the adc on my setup will let you know
I will make a plan to run the adc on my setup will let you know
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Analogue Input not working
Hi.
I have just modified an old project of mine (sorry I am out of the lab,I have no time to analyse your Flowchart).
(1) I used the MATRIX ADC component set it to AN10 RB1
(2) Used the XT Oscillator on the EB006V9 and apply a varying Voltage at AN10 and Check the Results in the ICD
both returned values(int and Voltage ) is 100% correct Then I switched to Internal Oscillator and output the ADC value on PORTA of the EB085 Combo board LED's it is working fine
I see no problem with the MATRIX ADC component for the PIC16F178x devices you should be able to use any ADC pin and get the correct values.
I attach my test project for you reference
I hope this helps
I have just modified an old project of mine (sorry I am out of the lab,I have no time to analyse your Flowchart).
(1) I used the MATRIX ADC component set it to AN10 RB1
(2) Used the XT Oscillator on the EB006V9 and apply a varying Voltage at AN10 and Check the Results in the ICD
both returned values(int and Voltage ) is 100% correct Then I switched to Internal Oscillator and output the ADC value on PORTA of the EB085 Combo board LED's it is working fine
I see no problem with the MATRIX ADC component for the PIC16F178x devices you should be able to use any ADC pin and get the correct values.
I attach my test project for you reference
I hope this helps
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Flowcode V4 User
- Posts: 288
- Joined: Wed Nov 02, 2011 11:15 pm
- Has thanked: 29 times
- Been thanked: 30 times
- Contact:
Re: Analogue Input not working
It's a little odd...
AN0 only works if I set the ADC components to AN1 (however analogue voltage is applied to AN0 or pin 2), but AN1 is also affected. So analogue voltages on both pins 1 & 2 change the value when read just AN1...
And if the c-code ansela = 0x01; & trisa = 0x01; is not applied the components still works but looks to be inverted.
I need ti try and figure out what happening with AN10 now... but if someone can look into why this issue may be occurring it would be very handy to get this fixed.
Thanks
AN0 only works if I set the ADC components to AN1 (however analogue voltage is applied to AN0 or pin 2), but AN1 is also affected. So analogue voltages on both pins 1 & 2 change the value when read just AN1...
And if the c-code ansela = 0x01; & trisa = 0x01; is not applied the components still works but looks to be inverted.
I need ti try and figure out what happening with AN10 now... but if someone can look into why this issue may be occurring it would be very handy to get this fixed.
Thanks
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Analogue Input not working
Hi
I used the same Flowchart I posted above I just added the AN0 and AN1 they work fine with me .
as you can see here I have 5V on AN0 and 1.62Volt on AN1 and they respond as they should
Are you setting the ADC module parameters in the Properties
I used the same Flowchart I posted above I just added the AN0 and AN1 they work fine with me .
as you can see here I have 5V on AN0 and 1.62Volt on AN1 and they respond as they should
You do not need to set anything in C Code when using the MATRIX ComponentLord Grezington wrote:And if the c-code ansela = 0x01; & trisa = 0x01; is not applied the components still works but looks to be inverted.
Are you setting the ADC module parameters in the Properties
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Flowcode V4 User
- Posts: 288
- Joined: Wed Nov 02, 2011 11:15 pm
- Has thanked: 29 times
- Been thanked: 30 times
- Contact:
Re: Analogue Input not working
Hello QMESAR
Still having no luck. I cant use your code, is it completed on FC8?
All the module parameters are default.
There is definitely something wrong with this part though, I have used an entirely different hardware on a development board I designed and I am still getting strange readings....
If AN10 = 0V, and I adjust AN0, AN0 works perfectly.
If AN0 = 0V, and I adjust AN10, AN10 works perfectly.
But
If AN10 = 2.5V (127), and AN0 = 0, AN0 then also equals 2.5V (127)
As I increase AN0, the value decreases and hits 0 s AN0 hits 2.5V. Its as though they are either adding together or subtracting one from the other even though there is nothing like this in the code.
Please can you repeat the test using AN0 and AN10 (I am locked into these on the hardware)? Also preferably on FC6 (I have not updated in a while). I have attached the most simple program I could to show on hardware what is happening (using SPI to read the values).
Thanks
Still having no luck. I cant use your code, is it completed on FC8?
All the module parameters are default.
There is definitely something wrong with this part though, I have used an entirely different hardware on a development board I designed and I am still getting strange readings....
If AN10 = 0V, and I adjust AN0, AN0 works perfectly.
If AN0 = 0V, and I adjust AN10, AN10 works perfectly.
But
If AN10 = 2.5V (127), and AN0 = 0, AN0 then also equals 2.5V (127)
As I increase AN0, the value decreases and hits 0 s AN0 hits 2.5V. Its as though they are either adding together or subtracting one from the other even though there is nothing like this in the code.
Please can you repeat the test using AN0 and AN10 (I am locked into these on the hardware)? Also preferably on FC6 (I have not updated in a while). I have attached the most simple program I could to show on hardware what is happening (using SPI to read the values).
Thanks
- Attachments
-
- Analogue Test.fcfx
- (7.42 KiB) Downloaded 179 times
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Analogue Input not working
Well ok if you are using FC6 then I am sure its not working with you as there was a bug in the Analog component for the 16F17xx devices that got solved in late FC 7 just before FC 8Lord Grezington wrote:Please can you repeat the test using AN0 and AN10 (I am locked into these on the hardware)? Also preferably on FC6 (I have not updated in a while)
No use I test this for you with FC7 or 8 ask Ben /Matrix to look into the ADC component for 16F17xx devices in FC 6
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Flowcode V4 User
- Posts: 288
- Joined: Wed Nov 02, 2011 11:15 pm
- Has thanked: 29 times
- Been thanked: 30 times
- Contact:
Re: Analogue Input not working
Thanks QMESAR
Ben or anyone else from flowcode, please can you send be a bug fix for this?..
Thanks
Ben or anyone else from flowcode, please can you send be a bug fix for this?..
Thanks
-
- Flowcode V4 User
- Posts: 288
- Joined: Wed Nov 02, 2011 11:15 pm
- Has thanked: 29 times
- Been thanked: 30 times
- Contact:
Re: Analogue Input not working
I may be able to use a 16F1933 in the application. Are their any known bugs for this micro that I need to know about?
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Analogue Input not working
HiLord Grezington wrote:I may be able to use a 16F1933 in the application. Are their any known bugs for this micro that I need to know about?
This is hard to give an answer as the FC world has move on it is at least 3-4 years since we used FC6 ,best would be you try a 16F1933 or move on to FC8
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- 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: Analogue Input not working
Hello,
Here are some updated v6 files for you to try.
First of all this file needs to be placed into your "Flowcode 6/FCD/PIC" folder.
Next this file needs to be placed into your "Flowcode 6/CAL/PIC" folder.
Restart Flowcode and hopefully your ADC channels will now be working correctly.
Here are some updated v6 files for you to try.
First of all this file needs to be placed into your "Flowcode 6/FCD/PIC" folder.
Next this file needs to be placed into your "Flowcode 6/CAL/PIC" folder.
Restart Flowcode and hopefully your ADC channels will now be working correctly.
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