Subject:
|
Re: VB 6 subprocedure stumper
|
Newsgroups:
|
lugnet.robotics.rcx
|
Date:
|
Mon, 27 Mar 2000 23:42:20 GMT
|
Viewed:
|
2314 times
|
| |
| |
Hi Kathy,
No, Sub 0 shouldn't interfere with Task 0. If you want, you could e-mail me
the code and I'll take a look at it.
David Leeper
In lugnet.robotics.rcx, Kathy Brooks writes:
> David:
> Thanks for the tips - I really appreciate any pointers/help I can get.
>
> Actually, if I abandon the idea of subprocedures and move the code within my
> main task, it runs just fine. However, the whole idea of this "lesson" is to
> use subprocedures and multiple tasks (I haven't even tackled the multiple
> tasks yet).
>
> CHECK_LEFT and CHECK_RIGHT are set to 0 and 1 - so it's just subprocedure 0
> and subprocedure 1. Any chance a subprocedure numbered 0 could interfere with
> task 0?
>
> Could you answer: how come, in the code below, if I comment out the line from
> main that says: .GoSub CHECK_RIGHT
> the CHECK_RIGHT procedure still works (and of course the CHECK_LEFT still does
> not)?
>
> Also, I've downloaded the Softbricks zip file from your site; I'll give it a
> try.
>
> THANKS - Kathy B.
>
> In lugnet.robotics.rcx, David Leeper writes:
> > Hi Kathy,
> >
> > My first question would be "What are the values of CHECK_LEFT and
> > CHECK_RIGHT?" If they're the same, that would produce the behavior you're
> > getting. I know I often make a mistake like that when I copy and paste a line
> > of code.
> >
> > You also may want to try getting the code to work without using RCX
> > subroutines first. Once that's working, you could move the appropriate code
> > back to the RCX subs.
> >
> > And finally, if you're just interested in getting the bot to work, I've got a
> > DLL that has that functionality already, plus some other neat stuff as well.
> > You can find the download page for it, as well as links to on-line docs, here:
> > http://www.geocities.com/Athens/Column/2507/Download.htm
> >
> > David Leeper (hopes this helps)
> >
> > In lugnet.robotics.rcx, Kathy Brooks writes:
> > > I sure could use some help. I'm trying to recreate the BugBot program from
> > > the book "Definitive Guide to Lego Mindstorms" in VB 6. It's a simple program
> > > with a tank-like robot that has two "feelers" - one if the robot hits
> > > something on the right; one for the left. At this point I've simplified the
> > > program and there is a main task with an infinite loop - which constantly
> > > calls two subprocedures - one each to check the left sensor and the right
> > > sensor. The stumper is: whichever subprocedure is last is the one that
> > > works. If the check_left procedure is last in the code then just it works; if
> > > the check_right procedure is the last one then just it works. Strange and
> > > frustrating. Having the subprocedures above or below the "main" task makes no
> > > difference. In fact, the really odd thing is that if I comment out the code
> > > in "main" which calls the last subprocedure, that subprocedure still works!
> > >
> > > Omitting the normal code for exiting, downloading, etc., here's the heart of
> > > the program:
> > >
> > > Private Sub DownPrgm_Click()
> > > With PBrickCtrl
> > > .SelectPrgm 0
> > > .SetSensorType SENSOR_1, SWITCH_TYPE
> > > .SetSensorType SENSOR_3, SWITCH_TYPE
> > >
> > > .BeginOfSub CHECK_LEFT
> > > .If SENVAL, SENSOR_1, EQ, CON, 0 ' button is out
> > > .Off MOTOR_0
> > > .SetRwd MOTOR_2
> > > .While SENVAL, SENSOR_1, EQ, CON, 0 'button is still out
> > > 'just sorta spin & do nothing - motor_2 still in reverse
> > > .EndWhile
> > > .On MOTOR_0
> > > .SetFwd MOTOR_2
> > > .EndIf
> > > .EndOfSub
> > >
> > > .BeginOfSub CHECK_RIGHT
> > > .If SENVAL, SENSOR_3, EQ, CON, 0 ' button is out
> > > .Off MOTOR_2
> > > .SetRwd MOTOR_0
> > > .While SENVAL, SENSOR_3, EQ, CON, 0 'button is still out
> > > 'just sorta spin & do nothing - motor_0 still in reverse
> > > .EndWhile
> > > .On MOTOR_2
> > > .SetFwd MOTOR_0
> > > .EndIf
> > > .EndOfSub
> > >
> > > .BeginOfTask MAIN
> > > intCounter = 0
> > > .SetPower MOTOR_0 + MOTOR_2, CON, 3
> > > .SetFwd MOTOR_0 + MOTOR_2
> > > .On MOTOR_0 + MOTOR_2
> > > .Loop CON, forever 'keep looping forever
> > > .GoSub CHECK_LEFT
> > > .GoSub CHECK_RIGHT
> > > .EndLoop
> > > .EndOfTask 'main
> > > End With
> > > End Sub
> > > '-----------------------
> > > Any suggestions, help would be greatly appreciated!
> > > --Kathy Brooks
|
|
Message is in Reply To:
| | Re: VB 6 subprocedure stumper
|
| David: Thanks for the tips - I really appreciate any pointers/help I can get. Actually, if I abandon the idea of subprocedures and move the code within my main task, it runs just fine. However, the whole idea of this "lesson" is to use subprocedures (...) (25 years ago, 27-Mar-00, to lugnet.robotics.rcx)
|
5 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|