PBP Version 2.3 is probably well over six years old (it's time MeLabs put a Date against the version releases on their website) and has many issues that have been fixed and improvements made over the subsequent years. You should seriously consider upgrading. Forum members here would be hard pressed to try to second-guess problems when you're using a product that old and you could spend many hours chasing a problem that has been long fixed and forgotten in the mists of time.
I agree that the version I'm using is old but the program I tried to compile was also more or less 6 years old.anyway im pasting the whole program here for you to inspect. Thanks!
'Read Cds cell #1 on port b line 1
'Read Cds cell #2 on port b line 7
v1 var byte 'Variable v1 holds Cds #1 information
v2 var byte 'Variable v2 holds Cds #2 information
v3 var byte 'Variable for calculation
s1 var byte 'Variable s1 holds servomotor #1 pulse width info
s2 VAR word 'variable for random function
rv var byte 'variable rv holds the range value
s1 = 150 'initialize steering servomotor facing forward
rv = 10 'Adjust as needed for operation
ct var byte 'counter
start:
pot portb.2,255,v1
pot portb.3,255,v2
'Check bumper switch "Did I hit something?"
if porta.0 = 0 then avoid 'Hit obstacle go into avoid mode
'Is it sleepy time?
if v1 <= 230 then skp 'Is it dark enough to sleep?
if v2 > 230 then slp 'Yes
'Is it too bright to see?
skp:
if v1 >= 12 then skip2
if v2 < 12 then avoid
'Which way do I go?
skip2:
if v1 = v2 then straight
if v1 > v2 then greater
if v1 < v2 then lesser
straight:
pulsout portb.6, s1
pulsout portb.7, 157
goto start
greater:
v3 = v1 - v2
if v3 > rv then right
goto straight
lesser:
v3 = v2 - v1
if v3 > rv then left
goto straight
right:
s1 = s1 + 1
if s1 > 225 then s1 = 225
pulsout portb.6, s1
pulsout portb.7, 165
goto start
left:
s1 = s1 - 1
if s1 < 65 then s1 = 65
pulsout portb.6, s1
pulsout portb.7, 165
goto start
slp:
pulsout portb.6, s1
pulsout portb.7, 167
goto start
avoid:
random s2
s1 = s2 / 256
if s1 < 65 then s1 = 65
if s1 > 225 then s1 = 225
for ct = 1 to 125
pulsout portb.6, s1
pulsout portb.7, 177
pause 18
next ct
s1 = 150
goto start
Compiled it for 16F84, still no errors.
You might consider
http://www.compilespot.com
It's a low monthly subscription that will allow you to use the latest compiler version. If you're fast enough, you may only need to pay for 1 month.
regards,
DT
[QUOTE=Darrel Taylor;32729]Compiled it for 16F84, still no errors.
QUOTE]
in that case, could you please send me the .HEX file so that I could load it to my PIC micro if that is ok with you?
P.S. I sent you a PM
:-D
I've quoted the code I've posted in one of the previous replies. the program is supposed to make the servomotor #1, which is connected to RB7 stop when in total darkness. I'm confused why the motor still continues on turning even if it is supposed to stop. Please anyone enlighten me on this. Thanks very much!![]()
Last edited by scaenix; - 19th February 2007 at 09:09.
I didn't read the whole thing but here's one fast suggestion for you.
Pulsout have to return the pin to it's previous state right? but nowhere the initial state have been set. When you turn on a PIC, the state of all pin is hard to predict. add those lines at the top of your code.
if it doesn't work, you could still place a LOW PORTB.7 after each PULSOUT.Code:PORTB=0 ' Clear all PORTB pin TRISB=0 ' Set all PORTB pins to output
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
My guess is the values in v1 and v2 are are not as expected. Pot command can be a pain at times. Do you have anyway of sending these values to an LCD to debug?'Read Cds cell #1 on port b line 1
'Read Cds cell #2 on port b line 7
v1 var byte 'Variable v1 holds Cds #1 information
v2 var byte 'Variable v2 holds Cds #2 information
.................................................. ..........
start:
pot portb.2,255,v1
pot portb.3,255,v2
Wisdom is knowing what path to take next... Integrity is taking it.
Ryan Miller
With the current program, clearing the all PORTB pins and setting them all for output couldn't seem to work since portb.2 and portb.3 are used for storing the Cds values which serve as input. I've tried adding LOW PORTB.7 after each pulsout but it still doesn't work. About the LCD thing, I'll try it when I get to school since that is the only place where the LCD is available. I'll update you when I get the results.![]()
Bookmarks