It's been a long time since I've done any coding, and you can tell. trying to get a pin to turn on wait for a period of time then turn off. I've been modiying a working program from another basic program, and have worked out most the errors, but this one baffles me for some reason. any help would be appreciated.
Here's the routine
52: Up:
53: set portb.5 on
54: Wait 100 ms
55: set portb.5 off
56: goto Start:
the error comes when turning off the pin
Here's the error I get.
(55): Error: Array/Function : has not been declared
Last edit: Mark 2017-12-05
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This code compiles fine, there is no goto label "Start" in the above code.
#chip16f877a,8Up:'Turn the sensor array upStart:'<======setportb.5on'Turn on H-bridgeWait100ms'Let it turn a momentsetportb.5off'Turn off H-bridgegotoStart:'Start again
The problem is probably associated to some other code?
The standard questions are which compiler version you are using, the device and full code if not too long, or the cut down version that shows the compiler error.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I cannot replicate your error with short bit of code you supplied. Please supply the complete code exactly as it appears in the IDE. And as Kent requested, we need to know what version of GCB you are using.
The more info you provide the better the help you will receive.
When posting code to the forum, indent it by 4 spaces and it will be formatted as "code". I ususally indent it 4 spaces in the IDE and then copy and paste in the forum post. If the code really big then include it as an attachment
William.
Last edit: William Roth 2017-12-05
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
#chip16f818,8#configboden=on,DirPortbout'set portb to outputsDir Porta in 'setpoetatoinputsDims0asbyte'reading from first sensorDim s1 as byte 'readingfromsecondsensorDimd1asbyte'difference from sensor 1 and 2Dim s3 as byte 'readingfromthirdsensorDims4asbyte'reading from fourth sensorDim d2 as byte 'differencefromsensor3and4#defineAD_Delay10ms'Delay for AD Conversion#define use_ad0 true#define use_ad1 true#define use_ad2 true#define use_ad3 true#define use_ad4 false#define r1#define r1 10''Start:s0 = ADRead_porta.0 (an0) 'ReadfirstCdSsensors1=ADRead_porta.1(an1)'Read second CdS sensors3 = ADRead_porta.3 (an2) 'ReadthirdCdSsensors4=ADRead_porta.4(an3)'Read fourth CdS sensorgoto Step1:''Step1:If s0 = s1 Then goto Step2 'Ifequal,nextstepIfs0>s1Then'If greater, check how much greaterd1 = difference s0 - s1 'Findthedifferenceendififd1>=r1thengotoright'Is it within range? If not, go to rightIf s0 < s1 then 'Ifless,checkhowmuchlessd1=differences1-s0'Find the differenceend ifIf d1 >= r1 then goto Left 'Isitwithinrange?IfnotgotoleftgotoStep2:''Right:'Turn the sensor array rightset portb.7 on 'TurnonH-bridgeWait100ms'Let it turn for a momentset portb.7 off 'TurnoffH-bridgegotoStep2:'Check again''Left: 'Turnthesensorarrayleftsetportb.6on'Turn on H-bridgeWait 100 ms 'Letitturnamomentsetportb.6off'Turn off H-bridgegoto Step2: 'Checkagain''Step2:ifs3=s4thengotoStart'If equal, do nothingif s3 > s4 then 'Ifgreater,checkhowmuchgreaterd2=differences3-s4'Find the differenceend ifif d2 >= r1 then goto Up 'Isitwithinrange?Ifnot,gotoupifs3<s4then'If less, check how much lessd2 = difference s4 - s3 'Findthedifferenceendififd2>=r1thengotoDown'Is it within range? If not go to downgoto Start:''Up: 'Turnthesensorarrayupsetportb.5on'Turn on H-bridgeWait 100 ms 'Letitturnamomentsetportb.5off'Turn off H-bridgegoto Start: 'Startagain''Down:'Turn the sensor array downset portb.4,on 'TurnonH-bridgeWait100ms'Let it turn a momentset portb.4,off 'TurnoffH-bridgegotoStart:'StartagainEnd
Here's the errors
(42): Error: Missing value for parameter SYSINSTRING
(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
Edited for code formatting - Removed line numbers -WR
Last edit: William Roth 2017-12-05
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just noticed that I posted the code after I took out the led code to work on the another problem i was having. if you look at my first post you can see where the leds were in the code. There was that same led code for each of the labels of up:, down:, left:, and right: different pins for each label but the same error.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When I debug with an led I use a wait period after both On and Off.
By the looks of the code the only time the led would be off for an appreciable time is when both sensors are equal. This equal condition seems very unlikely to happen? would introduce some hysteresis in the form of a band of readings.
Simplify the problem. Start with only blinking an led with your device. Then move on to reading an ad port, display on terminal screen, etc.
I am unfamiliar with the AdRead, try like ReadAD(AN0) as in help, when you test this function of GCB.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Kent you fixed my "readad" problem. Boy, talk about having dyslexia. I should have known something was wrong when the code helper window didn't pop up.
The leds should only be on when the motor runs (100ms at a time) you probably wouldn't see much I only added them because I had the extra pins, and thought it would be easy.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sounds like you are starting to get the hang of it, good luck with your solar tracker project. You could also use the comparator module to do that with a little bit of software tweaking, like using with a timeout period.
Once upon a time I did an analog version of a two axis tracker.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's been a long time since I've done any coding, and you can tell. trying to get a pin to turn on wait for a period of time then turn off. I've been modiying a working program from another basic program, and have worked out most the errors, but this one baffles me for some reason. any help would be appreciated.
Here's the routine
52: Up:
53: set portb.5 on
54: Wait 100 ms
55: set portb.5 off
56: goto Start:
the error comes when turning off the pin
Here's the error I get.
(55): Error: Array/Function : has not been declared
Last edit: Mark 2017-12-05
This code compiles fine, there is no goto label "Start" in the above code.
The problem is probably associated to some other code?
The standard questions are which compiler version you are using, the device and full code if not too long, or the cut down version that shows the compiler error.
Hi Mark.
I cannot replicate your error with short bit of code you supplied. Please supply the complete code exactly as it appears in the IDE. And as Kent requested, we need to know what version of GCB you are using.
The more info you provide the better the help you will receive.
When posting code to the forum, indent it by 4 spaces and it will be formatted as "code". I ususally indent it 4 spaces in the IDE and then copy and paste in the forum post. If the code really big then include it as an attachment
William.
Last edit: William Roth 2017-12-05
Don't forget the other way to format code - use a line of ~ characters before and after the code. Usually three of them is enough (~~~)
Here's the code. I'm using v.98.01
Here's the errors
(42): Error: Missing value for parameter SYSINSTRING
(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
Edited for code formatting - Removed line numbers -WR
Last edit: William Roth 2017-12-05
I just noticed that I posted the code after I took out the led code to work on the another problem i was having. if you look at my first post you can see where the leds were in the code. There was that same led code for each of the labels of up:, down:, left:, and right: different pins for each label but the same error.
When I debug with an led I use a wait period after both On and Off.
By the looks of the code the only time the led would be off for an appreciable time is when both sensors are equal. This equal condition seems very unlikely to happen? would introduce some hysteresis in the form of a band of readings.
Simplify the problem. Start with only blinking an led with your device. Then move on to reading an ad port, display on terminal screen, etc.
I am unfamiliar with the AdRead, try like ReadAD(AN0) as in help, when you test this function of GCB.
Thanks Kent you fixed my "readad" problem. Boy, talk about having dyslexia. I should have known something was wrong when the code helper window didn't pop up.
The leds should only be on when the motor runs (100ms at a time) you probably wouldn't see much I only added them because I had the extra pins, and thought it would be easy.
Sounds like you are starting to get the hang of it, good luck with your solar tracker project. You could also use the comparator module to do that with a little bit of software tweaking, like using with a timeout period.
Once upon a time I did an analog version of a two axis tracker.
Thanks again Kent, and to everyone for their help, and comments
Also now with all the other errors fixed the leds work like a champ