Hello,
While finetuning my program I stumbled upon a problem with the internal reference voltage (ARef) of my Arduino Mega. I set the internal reference voltage to 2.56V just like LeighM explained me in one of my previous questions (viewtopic.php?f=63&t=18701).
The problem is, whenever I try to read an analog signal (I read the analog signal the way it's explained in the Flowcode wiki) the internal ARef voltage changes from 2.56V to AVCC (4.68V in my case).
--(It's the GetByte component macro in the attachment which causes the problem)
Does anyone have any solution to this? Maybe the C-code of the GetByte command which reads the analog signal interferes with the register that sets the internal ARef voltage (ADMUX).
Thanks, Coensk
Problem with reference voltage on Arduino Mega
Moderator: Benj
Problem with reference voltage on Arduino Mega
- Attachments
-
- Capture.PNG
- (47.49 KiB) Downloaded 3763 times
- 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: Problem with reference voltage on Arduino Mega
Hello,
The Arduino Mega uses ADC type 10 so if you look in the "Flowcode 7\CAL\AVR\AVR_CAL_ADC.c" file using a text editor then ADC type 10 starts at around line 673.
Save the CAL C file to your desktop and add your voltage reference modification to the ADC_Enable routine.
Copy the file back to it's original location using Windows explorer. Be sure to make a backup of the original file so you can easily go back if you need to.
Let us know how you get on.
The Arduino Mega uses ADC type 10 so if you look in the "Flowcode 7\CAL\AVR\AVR_CAL_ADC.c" file using a text editor then ADC type 10 starts at around line 673.
Save the CAL C file to your desktop and add your voltage reference modification to the ADC_Enable routine.
Copy the file back to it's original location using Windows explorer. Be sure to make a backup of the original file so you can easily go back if you need to.
Let us 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
Re: Problem with reference voltage on Arduino Mega
Hello,
Thanks for your reply Benj, is the line I should change under the 'ADC type 10 Supported Devices'? (Arduino Mega) I changed the value there but now the voltage over the ARef pin just measures 0V..
Later I changed the value in every type of "Supported Devices", still the same outcome..
Thanks Coensk
Thanks for your reply Benj, is the line I should change under the 'ADC type 10 Supported Devices'? (Arduino Mega) I changed the value there but now the voltage over the ARef pin just measures 0V..
Later I changed the value in every type of "Supported Devices", still the same outcome..
Thanks Coensk
Re: Problem with reference voltage on Arduino Mega
I have changed it in the AVR CAL ADC file but still the same problem persists, whenever an analog signal is read by the Arduino Mega, the reference voltage present at the ARef pin changes.
When done with a C-code component in the flowchart it changes from 2.56V to UVcc => 5V.
When changed in the AVR CAL ADC file it changes from 2.56V to 0V.
You can find the edited file under attachments in this response
Does anyone have an idea on how to solve this?
Thanks, Coensk
When done with a C-code component in the flowchart it changes from 2.56V to UVcc => 5V.
When changed in the AVR CAL ADC file it changes from 2.56V to 0V.
You can find the edited file under attachments in this response
Does anyone have an idea on how to solve this?
Thanks, Coensk
- Attachments
-
- AVR_CAL_ADC_changed.c
- (25.23 KiB) Downloaded 328 times
- 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: Problem with reference voltage on Arduino Mega
Hello Coensk,
Is the problem that the ADC peripheral is being switched off after an ADC sample?
See this line in the ADC_Disable function for ADC type 10.
You could try commenting out the line to see if this makes any difference.
Is the problem that the ADC peripheral is being switched off after an ADC sample?
See this line in the ADC_Disable function for ADC type 10.
Code: Select all
ADCSRA &= ~(1 << ADEN);
Code: Select all
//ADCSRA &= ~(1 << ADEN);
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