Hi, I can't get a-d data as in this code,just prints 0. It's copy pasted. Any advice welcome. I'm using A0 on arduino uno and don't know why the example uses dir c.0 in. Dir a.0 gives an error DRRA not explicitly defined.
Right. Did you look at the Help? I did.
Did you look at the demos? Search the demos for ..\GCB@Syn\GreatCowBasic\Demos\Vendor Boards\Arduino LCD Shields\Full Demo of LCD Shield Capabilities_mega328p.gcb
The file Full Demo of LCD Shield Capabilities_mega328p.gcb has a working and tested ADC.
read_LCD_buttons = btnNONE
adc_key_in = ReadAD10(AN0) ' read the value from the sensor
So, when you change the port to AN0 things will start to work - hopefully.
Please Help us help others by improving the Help. This may be the documentation - what can we change to ensure others do not get stuck in the future? Write a few works to be added to the Help - community knowledge is all powerful.
Evan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I googled Full Demo of LCD Shield Capabilities_mega328p.gcb and can't find \GCB@Syn\GreatCowBasic\Demos\Vendor Boards\Arduino LCD Shields\Full Demo of LCD Shield Capabilities_mega328p.gcb
A http:// link please. It's not a lcd problem. I copied the code from a post by joe rocci who said thanks Kent, it worked but didn't say WHAT worked.
I changed the code to readadc10 and the display reads 65280 each power up. I'll try a 18f25k22 and see what happens. Why doesn't my code work? Using pin A0 uno board and latest GCB.
RE: \GCB@Syn\GreatCowBasic\Demos\Vendor Boards\Arduino LCD Shields\Full Demo of LCD Shield Capabilities_mega328p.gcb - look in your installation folders. Where the first \ is your choice of installation location
Please post details of your circuit as this should work. I do not know but if you are getting Zero returned then something is not ok as a floating input would yield different results.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for replying. There is no wiring. The lcd works. Just a wire into A0 to pick up noise. I don't know how to use gcb terminal or windows terminal in cmd. It should work with lcd the same as terminal. I'll try a pic.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is nothing wrong with the AVR ADC Functions. They work fine. The most likely cause of your problem is incorrect or bad connections.
The Arduio uses wacky pin numbers/names that can be confusing. For example, if you look at the 6-pin analog header on the UN0 there are inputs A0 to A5. But these have nothing to do with PORTA. These are actually connected to PORTC.0 to PortC.5.
With Great Cow Basic, analog inputs AN0 to AN5 are mapped to the correct port.pin. AN0 correlates to "A0" as printed on the UNO R3 Board.
I just set up an UNO R3 and it works correctly. Below is the code I used for testing and attached is a graphical diagram of the actual connections.
;SampleCode#chipMEGA328P,16;SoftwareI2CForLCD#defineI2C_MODEMaster#defineI2C_DATAPORTC.4#defineI2C_CLOCKPORTC.5#defineI2C_DISABLE_INTERRUPTSON#defineI2C_Bit_Delay2us#defineI2C_Clock_Delay1us#defineI2C_End_Delay1us#defineLCD_IO10#defineLCD_I2C_Address_10x7E;defaultto0x4E#defineLCD_SPEEDFAST#defineLCD_Backlight_On_State1#defineLCD_Backlight_Off_State0DIMTestValasWORD;ForADC10CLSPrint"Great Cow Basic"Locate1,0PRINT"ARDUINO UNO R3"Wait1sDo'SHOWREADADTestVal=READAD(AN0)Locate2,0Print"ADC8 =":LCDSPACE1PrintTestVal:LCDSPACE5'SHOWREADAD10TestVal=READAD10(AN0)Locate3,0Print"ADC10=":LCDSPACE1PrintTestVal:LCDSPACE5wait100msLoopEND
You have gone to so much effort,thanks..to avail. Imagine you were moi. Your code William Roth. I used x loader but that's working ok. The adc should jump around from noise when not tied. https://youtu.be/VsU8nP8v-pU
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the vid it was the wrong file flashed but I flashed William's code and nothing on the oled because I'm using SSD1306. I don't want to download the arduino c++ sketch thing to use an example and see adc working. 2 different unos 1 smd 1 dil28 can't be us. GLCDPrint 80,32,str(ReadAD(A.0))+" " don't work.
Yo'u'e seen the code and video so what next?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If the GLCD works then the ADC should display. I am not sure why you are trying to use a single line of code to display the ADC value. Keep it simple and break it down to several discrete lines to get it working. Then try your complex statements.
I have no clue why you are referring to Arduino C++ or why you think you may need to download it. I also have no clue wny mentioned xloader. We do not generally use xloader.
GCB includes AVRDUDE which uses the virutual USB com port set up by the Arduino driver. All you need to do is edit the flashAVR.bat file and then click oon hex/flash to program the UNO. If you do not have the arduino driver installed you will need to do so.
This should be the active line in the AVRProgram.bat file. ( Change the comport as needed)
Well I can appreciate Stan's problem, and frustration. No matter what I tried, I could not get the GCB Ver 0.96 ReadAD(), or the ReadAD10() functions to work. I am using a Chinese clone of the UNO R3 for hardware. Tried different ADSpeed's, different pins, nope. Even cut the Vcc Avcc trace and put in a 10uH inductor inline like the datasheet says, still no go.
Last ditch effort went back to GCB Ver 95.008 and a miracle happened. Both ReadAD() and ReadAD10() functions work properly. Output on terminal, or GLCD_SSD1306, all good.
So something is up between V95.008 and V96 versions, I'm just not sure what yet. The assembly for V96 seemed OK, have to compare with V95.008 and see what is missing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I agree with Kent. Something is not correct in v0.96.0 I would not worry about finding the root cause - I have a later build ready.
I have sent @Stan an email to pick up the latest build. I know this works as I verfied the issue as Kent describe and the fault is not present in v0.97 rc5 (still creeping to v1.0). PS I will release Tuesday after I have sorted one last piece of documention.
@Stan. Do test and let us know the result.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I installed v0.97 and arduino uno rev3 readad and readad10 now work! You thought I was an idiot...so did I :). There was a post by joe rocci about arduino uno readadc in 2014 and Kent posted a link to an update but again, it must have been forgotten.Thanks for the help Evan, Are there any other fixes in V0.97?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My apologies for not checking the change log. I foolishly tested on a development PC not a stock build of v0.96.00
Re the ohter fixes: All the fixes and updates are documented in the 'release note.txt' and updates to the Help are in the Help. When you install you are shown this file. :-)
Lots of changes - always is. Upwards and onwards.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I forget what happened yesterday, much less in 2014, lol. Glad it is fixed. V96 a-d.h too many alias's and definetely not assembling correctly, (i.e. the already noted register problem).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried 2 arduino unos with the same code and got different results. The 1st uno froze the display but the 2nd didn't freeze but looks differrent. please see videos and check my code for reason to freeze.
The second uno/video is still running. https://youtu.be/XV0RolbMG2U https://youtu.be/3gYgv4Lnnrg
#chip mega328p,16
#option explicit
#include <glcd.h>
#define HI2C_BAUD_RATE 400
#define HI2C_DATA
HI2CMode Master
#define GLCD_TYPE GLCD_TYPE_SSD1306
#define GLCD_I2C_Address 0x78
dir portc.0 in
dim volt as byte
dim xpos as byte
dim buffer1 (128)
dim buffer2 (128)
;
for xpos=0 to 127
volt = READAD (an0)
buffer1 (xpos)=volt/4
buffer2 (xpos)=volt/4
next xpos
;
GLCDCLS
main:
for xpos=0 to 127
pset xpos,buffer1(xpos),0 ;erase old data
pset xpos,buffer2(xpos),1 ;plot new data
next xpos
;
for xpos=0 to 127
buffer1 (xpos)=buffer2 (xpos) ;copy new data to old data
volt = READAD (an0)
buffer2 (xpos)=volt/4 ;save new data
next xpos
;
goto main</glcd.h>
Last edit: stan cartwright 2017-02-25
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
added and both diplays are still different. Again 2 videos to show what I mean if you don't think this thread is getting boring. There's a lot of unos out there. Details don't matter..said the African Manx cat dealer. https://youtu.be/3SJO1mT-pjg https://youtu.be/pkjuJwkbsv8
I suppose you don't get anomalies with pics. :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I can't get a-d data as in this code,just prints 0. It's copy pasted. Any advice welcome. I'm using A0 on arduino uno and don't know why the example uses dir c.0 in. Dir a.0 gives an error DRRA not explicitly defined.
Last edit: Anobium 2017-02-24
Right. Did you look at the Help? I did.
Did you look at the demos? Search the demos for ..\GCB@Syn\GreatCowBasic\Demos\Vendor Boards\Arduino LCD Shields\Full Demo of LCD Shield Capabilities_mega328p.gcb
The file Full Demo of LCD Shield Capabilities_mega328p.gcb has a working and tested ADC.
So, when you change the port to AN0 things will start to work - hopefully.
Please Help us help others by improving the Help. This may be the documentation - what can we change to ensure others do not get stuck in the future? Write a few works to be added to the Help - community knowledge is all powerful.
Evan
I googled Full Demo of LCD Shield Capabilities_mega328p.gcb and can't find \GCB@Syn\GreatCowBasic\Demos\Vendor Boards\Arduino LCD Shields\Full Demo of LCD Shield Capabilities_mega328p.gcb
A http:// link please. It's not a lcd problem. I copied the code from a post by joe rocci who said thanks Kent, it worked but didn't say WHAT worked.
I changed the code to readadc10 and the display reads 65280 each power up. I'll try a 18f25k22 and see what happens. Why doesn't my code work? Using pin A0 uno board and latest GCB.
Last edit: Anobium 2017-02-24
RE: \GCB@Syn\GreatCowBasic\Demos\Vendor Boards\Arduino LCD Shields\Full Demo of LCD Shield Capabilities_mega328p.gcb - look in your installation folders. Where the first \ is your choice of installation location
Please post details of your circuit as this should work. I do not know but if you are getting Zero returned then something is not ok as a floating input would yield different results.
@Stan. Using your code as the basis.
This returns volts as for various reading - these are the correct reading as the ADC is set by 4 test switches and assiocated resistors.
Thanks for replying. There is no wiring. The lcd works. Just a wire into A0 to pick up noise. I don't know how to use gcb terminal or windows terminal in cmd. It should work with lcd the same as terminal. I'll try a pic.
Are you saying the you do not understand the pin out of an Mega328p? The ports for a Mega328p are shown below - there is no porta.0. See http://www.learningaboutelectronics.com/images/Atmega328-pinout.png
Stan,
There is nothing wrong with the AVR ADC Functions. They work fine. The most likely cause of your problem is incorrect or bad connections.
The Arduio uses wacky pin numbers/names that can be confusing. For example, if you look at the 6-pin analog header on the UN0 there are inputs A0 to A5. But these have nothing to do with PORTA. These are actually connected to PORTC.0 to PortC.5.
With Great Cow Basic, analog inputs AN0 to AN5 are mapped to the correct port.pin. AN0 correlates to "A0" as printed on the UNO R3 Board.
I just set up an UNO R3 and it works correctly. Below is the code I used for testing and attached is a graphical diagram of the actual connections.
Last edit: William Roth 2017-02-24
You have gone to so much effort,thanks..to avail. Imagine you were moi. Your code William Roth. I used x loader but that's working ok. The adc should jump around from noise when not tied.
https://youtu.be/VsU8nP8v-pU
In the vid it was the wrong file flashed but I flashed William's code and nothing on the oled because I'm using SSD1306. I don't want to download the arduino c++ sketch thing to use an example and see adc working. 2 different unos 1 smd 1 dil28 can't be us. GLCDPrint 80,32,str(ReadAD(A.0))+" " don't work.
Yo'u'e seen the code and video so what next?
If the GLCD works then the ADC should display. I am not sure why you are trying to use a single line of code to display the ADC value. Keep it simple and break it down to several discrete lines to get it working. Then try your complex statements.
I have no clue why you are referring to Arduino C++ or why you think you may need to download it. I also have no clue wny mentioned xloader. We do not generally use xloader.
GCB includes AVRDUDE which uses the virutual USB com port set up by the Arduino driver. All you need to do is edit the flashAVR.bat file and then click oon hex/flash to program the UNO. If you do not have the arduino driver installed you will need to do so.
This should be the active line in the AVRProgram.bat file. ( Change the comport as needed)
"AVRdude\avrdude.exe" -c arduino -P COM3 -b 115200 -p AT%2 -U flash:w:%1:i
One suggestion, does adding this line help at all?
That will slow down the conversion speed, sometimes with a clock speed of 16 MHz on an AVR the ADC doesn't have enough time to convert properly.
Well I can appreciate Stan's problem, and frustration. No matter what I tried, I could not get the GCB Ver 0.96 ReadAD(), or the ReadAD10() functions to work. I am using a Chinese clone of the UNO R3 for hardware. Tried different ADSpeed's, different pins, nope. Even cut the Vcc Avcc trace and put in a 10uH inductor inline like the datasheet says, still no go.
Last ditch effort went back to GCB Ver 95.008 and a miracle happened. Both ReadAD() and ReadAD10() functions work properly. Output on terminal, or GLCD_SSD1306, all good.
So something is up between V95.008 and V96 versions, I'm just not sure what yet. The assembly for V96 seemed OK, have to compare with V95.008 and see what is missing.
I agree with Kent. Something is not correct in v0.96.0 I would not worry about finding the root cause - I have a later build ready.
I have sent @Stan an email to pick up the latest build. I know this works as I verfied the issue as Kent describe and the fault is not present in v0.97 rc5 (still creeping to v1.0). PS I will release Tuesday after I have sorted one last piece of documention.
@Stan. Do test and let us know the result.
Look at what we fixed ..... - Fixed AVR bug - SysReadAD variables were treated as registers incorrectly.
I should read the release notes... as I write them!
If Stan tests are ok. You need v0.97.00 or greater to resolve this issue.
Anobium
Last edit: Anobium 2017-02-25
I installed v0.97 and arduino uno rev3 readad and readad10 now work! You thought I was an idiot...so did I :). There was a post by joe rocci about arduino uno readadc in 2014 and Kent posted a link to an update but again, it must have been forgotten.Thanks for the help Evan, Are there any other fixes in V0.97?
Excellent.
My apologies for not checking the change log. I foolishly tested on a development PC not a stock build of v0.96.00
Re the ohter fixes: All the fixes and updates are documented in the 'release note.txt' and updates to the Help are in the Help. When you install you are shown this file. :-)
Lots of changes - always is. Upwards and onwards.
I forget what happened yesterday, much less in 2014, lol. Glad it is fixed. V96 a-d.h too many alias's and definetely not assembling correctly, (i.e. the already noted register problem).
The issue was in the compiler. .h was ok.
I need to use more ??? when tossing around loose theories :-)
It was your theory that got me thinking.... I should have engaged memory first..... ☺
I tried 2 arduino unos with the same code and got different results. The 1st uno froze the display but the 2nd didn't freeze but looks differrent. please see videos and check my code for reason to freeze.
The second uno/video is still running.
https://youtu.be/XV0RolbMG2U
https://youtu.be/3gYgv4Lnnrg
#chip mega328p,16
#option explicit
#include <glcd.h>
#define HI2C_BAUD_RATE 400
#define HI2C_DATA
HI2CMode Master
#define GLCD_TYPE GLCD_TYPE_SSD1306
#define GLCD_I2C_Address 0x78
dir portc.0 in
dim volt as byte
dim xpos as byte
dim buffer1 (128)
dim buffer2 (128)
;
for xpos=0 to 127
volt = READAD (an0)
buffer1 (xpos)=volt/4
buffer2 (xpos)=volt/4
next xpos
;
GLCDCLS
main:
for xpos=0 to 127
pset xpos,buffer1(xpos),0 ;erase old data
pset xpos,buffer2(xpos),1 ;plot new data
next xpos
;
for xpos=0 to 127
buffer1 (xpos)=buffer2 (xpos) ;copy new data to old data
volt = READAD (an0)
buffer2 (xpos)=volt/4 ;save new data
next xpos
;
goto main</glcd.h>
Last edit: stan cartwright 2017-02-25
add
or add,
the first will add the second command, but, the first will provide you all the UNO port names.
I have your code hooked up to scope and signal generator - no lockups with an UNO board with a PDIP, same display etc. I am using your code.
I have removed the command above on my PDIP board and it is still stable.
Got the power supply stable? Hooked up to your PC?
define ADSpeed LowSpeed
include <uno_mega328p.h></uno_mega328p.h>
added and both diplays are still different. Again 2 videos to show what I mean if you don't think this thread is getting boring. There's a lot of unos out there. Details don't matter..said the African Manx cat dealer.
https://youtu.be/3SJO1mT-pjg
https://youtu.be/pkjuJwkbsv8
I suppose you don't get anomalies with pics. :)