Keep getting errors when trying to determine if the difference between 2 variables is >= or <= then a constant. all variables are byte type.
Here's the code
s0 and s1 are from cds sensors being read thru the adc. d1 is the difference between the two sensors. r1 is the constant (10). Depending what the difference is, and if it exceeds the range (constant) determines which routine follows. Thanks
40: If s0 = s1 Then goto Step2
41: If s0 > s1 Then
42: d1 = difference s0 - s1
43: end if
44: if d1 >= r1 then goto right
45: If s0 < s1 then
46: d1 = difference s1 - s0
47: end if
48: If d1 >= r1 then goto Left
49: goto Step2:
Here's the errors
(44): Error: Missing value for parameter SYSINSTRING
(44): Error: Missing value for parameter SYSCHARCOUNT
(48): Error: Missing value for parameter SYSINSTRING
(48): Error: Missing value for parameter SYSCHARCOUNT
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
#chip16f818,8#configboden=on,'Dir Portb out 'setportbtooutputsDirPortain'set poeta to inputs''Dim s0 as byte 'readingfromfirstsensorDims1asbyte'reading from second sensorDim d1 as byte 'differencefromsensor1and2Dims3asbyte'reading from third sensorDim s4 as byte 'readingfromfourthsensorDimd2asbyte'difference from sensor 3 and 4''#define AD_Delay 10ms 'DelayforADConversion#defineuse_ad0true#defineuse_ad1true#defineuse_ad2true#defineuse_ad3true#defineuse_ad4false#definer1#definer110''Start:s0=ADRead_porta.0(an0)'Read first CdS sensors1 = ADRead_porta.1 (an1) 'ReadsecondCdSsensors3=ADRead_porta.3(an2)'Read third CdS sensors4 = ADRead_porta.4 (an3) 'ReadfourthCdSsensorgotoStep1:''Step1:Ifs0=s1ThengotoStep2'If equal, next stepIf s0 > s1 Then 'Ifgreater,checkhowmuchgreaterd1=differences0-s1'Find the differenceend ifif d1 >= r1 then goto right 'Isitwithinrange?Ifnot,gotorightIfs0<s1then'If less, check how much lessd1 = difference s1 - s0 'FindthedifferenceendifIfd1>=r1thengotoLeft'Is it within range? If not go to leftgoto Step2:''Right: 'Turnthesensorarrayrightsetportb.7on'Turn on H-bridgeWait 100 ms 'Letitturnforamomentsetportb.7off'Turn off H-bridgegoto Step2: 'Checkagain''Left:'Turn the sensor array leftset portb.6 on 'TurnonH-bridgeWait100ms'Let it turn a momentset portb.6 off 'TurnoffH-bridgegotoStep2:'Check again''Step2:if s3 = s4 then goto Start 'Ifequal,donothingifs3>s4then'If greater, check how much greaterd2 = difference s3 - s4 'Findthedifferenceendififd2>=r1thengotoUp'Is it within range? If not, go to upif s3 < s4 then 'Ifless,checkhowmuchlessd2=differences4-s3'Find the differenceend ifif d2 >= r1 then goto Down 'Isitwithinrange?IfnotgotodowngotoStart:''Up:'Turn the sensor array upset portb.5 on 'TurnonH-bridgeWait100ms'Let it turn a momentset portb.5 off 'TurnoffH-bridgegotoStart:'Start again''Down: 'Turnthesensorarraydownsetportb.4,on'Turn on H-bridgeWait 100 ms 'Letitturnamomentsetportb.4,off'Turn off H-bridgegoto Start: 'StartagainEnd'Here'stheerrorsI'mgettingSolarlighttracker.gcb(42):Error:MissingvalueforparameterSYSINSTRING
(42): Error: Missing value for parameter SYSCHARCOUNT
(46): Error: Missing value for parameter SYSINSTRING
(46): Error: Missing value for parameter SYSCHARCOUNT
(46): Error: Array/Function : has not been declared
(53): Error: Array/Function : has not been declared
(53): Error: Missing value for parameter SYSCHARCOUNT
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem here might be the use of Left and Right as label names. These names are used for string handling functions, and the compiler is thinking that you want to use them.
Try renaming Left and Right to something else and see if that helps?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Wow, That did it! Thanks, but now i'm getting this
Error:GCASM:SymbolADREAD_PORTAhasnotbeendefined
Error: GCASM: Symbol 0(0) has not been defined
Error: GCASM: Symbol 1(1) has not been defined
Error: GCASM: Symbol 3(2) has not been defined
Error: GCASM: Symbol 4(3) has not been defined
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
(30): Error: Array/Function ADREAD has not been declared
(30): Error: Invalid variable name: ADREAD(0)
(31): Error: Array/Function ADREAD has not been declared
(31): Error: Invalid variable name: ADREAD(1)
(32): Error: Array/Function ADREAD has not been declared
(32): Error: Invalid variable name: ADREAD(2)
(33): Error: Array/Function ADREAD has not been declared
(33): Error: Invalid variable name: ADREAD(3)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@Mark, just scanning your code I noticed you used "difference". This is new to me so I searched the help file and found a command (function) I never knew about. I think you are using it incorrectly based on the help. You have....
I don't get any errors the way it is, but I did try changing it like you showed, and do get errors. The way you show is more inline with the manual so I'm not sure why. I ended up just changing it to d2 = s3 - s4 and it compiles fine.
Got the ADRead problem fixed thanks to Kent. Changed it to ReadAD and bingo! No excuse for that sorry.
Interesting though is now it says "delay units not specified". However if I change
#define AD_Delay 10ms, to #define AD_Delay 10 ms it works. Neither way really matches the manual.
👍
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you got errors using the "difference" function by how it is shown to use it in the help, then there must be something wrong with that function or the manual. Again, this is a new one to me, and I have never used it, but it should work based on the way it is shown in help, and should have thrown some kind of error the way you were using it, I think...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The errors I was getting were assiciated with me using "Right" and "Left" as labels. Once I changed that the difference command worked fine. Sorry for the confusion.
Everything seems to be working just fine now.
Thanks to everyone for their help and comments.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Keep getting errors when trying to determine if the difference between 2 variables is >= or <= then a constant. all variables are byte type.
Here's the code
s0 and s1 are from cds sensors being read thru the adc. d1 is the difference between the two sensors. r1 is the constant (10). Depending what the difference is, and if it exceeds the range (constant) determines which routine follows. Thanks
40: If s0 = s1 Then goto Step2
41: If s0 > s1 Then
42: d1 = difference s0 - s1
43: end if
44: if d1 >= r1 then goto right
45: If s0 < s1 then
46: d1 = difference s1 - s0
47: end if
48: If d1 >= r1 then goto Left
49: goto Step2:
Here's the errors
(44): Error: Missing value for parameter SYSINSTRING
(44): Error: Missing value for parameter SYSCHARCOUNT
(48): Error: Missing value for parameter SYSINSTRING
(48): Error: Missing value for parameter SYSCHARCOUNT
"difference s1 - s0" is not valid operator or GCB syntax. Cut and paste mistake or maybe that is supposed to be a d1 = s0 - s1 or d1 = s1 - s0?
The version I'm using is v98.01
Here's the whole code.
(42): Error: Missing value for parameter SYSCHARCOUNT
(46): Error: Missing value for parameter SYSINSTRING
(46): Error: Missing value for parameter SYSCHARCOUNT
(46): Error: Array/Function : has not been declared
(53): Error: Array/Function : has not been declared
(53): Error: Missing value for parameter SYSCHARCOUNT
The problem here might be the use of Left and Right as label names. These names are used for string handling functions, and the compiler is thinking that you want to use them.
Try renaming Left and Right to something else and see if that helps?
Wow, That did it! Thanks, but now i'm getting this
Error: GCASM: Symbol 0(0) has not been defined
Error: GCASM: Symbol 1(1) has not been defined
Error: GCASM: Symbol 3(2) has not been defined
Error: GCASM: Symbol 4(3) has not been defined
Try:
As per: http://gcbasic.sourceforge.net/help/_readad.html
Changed that now I get these errors
(30): Error: Array/Function ADREAD has not been declared
(30): Error: Invalid variable name: ADREAD(0)
(31): Error: Array/Function ADREAD has not been declared
(31): Error: Invalid variable name: ADREAD(1)
(32): Error: Array/Function ADREAD has not been declared
(32): Error: Invalid variable name: ADREAD(2)
(33): Error: Array/Function ADREAD has not been declared
(33): Error: Invalid variable name: ADREAD(3)
ADREAD is a new function so I have not personally used it, that is why I
posted the Link to the HELP Entry.
You could use ReadAD10(AN0) which is the old command.
I know that some work has gone into the ADC functions of late so a reread
of the Help Sections to learn the new features may be in order.
The Help listing is here: http://gcbasic.sourceforge.net/help/_readad10.html
@Mark, just scanning your code I noticed you used "difference". This is new to me so I searched the help file and found a command (function) I never knew about. I think you are using it incorrectly based on the help. You have....
d2 = difference s3 - s4
but I think it should be...
d2 = difference (s3, s4)
This is from the help section...
Difference
Syntax:
Command Availability:
Available on all microcontrollers.
Explanation:
A function that returns the difference between of two numbers. This only supports byte or word variables.
Example:
I don't get any errors the way it is, but I did try changing it like you showed, and do get errors. The way you show is more inline with the manual so I'm not sure why. I ended up just changing it to d2 = s3 - s4 and it compiles fine.
Got the ADRead problem fixed thanks to Kent. Changed it to ReadAD and bingo! No excuse for that sorry.
Interesting though is now it says "delay units not specified". However if I change
#define AD_Delay 10ms, to #define AD_Delay 10 ms it works. Neither way really matches the manual.
The HELP is confusing if not incorrect. In regards to the ReadAD function it states:
Where does "ReadAD_port" come from? This will not work It should instead read:
.
There is no new "ADREAD" function that I am aware of.. Use ReadAD.
Is someone willing to go to GitHub and change this?
Ummmm. I guess that is a no then.
If you got errors using the "difference" function by how it is shown to use it in the help, then there must be something wrong with that function or the manual. Again, this is a new one to me, and I have never used it, but it should work based on the way it is shown in help, and should have thrown some kind of error the way you were using it, I think...
The errors I was getting were assiciated with me using "Right" and "Left" as labels. Once I changed that the difference command worked fine. Sorry for the confusion.
Everything seems to be working just fine now.
Thanks to everyone for their help and comments.