Hi
I am using Mindstorms 2.0 and LabView to do a project but I am having a problem with the code I am using a case structure with string constant and the default is making the program at odd i.e if it is set to the drive case the sensor are ignored but if it is set to one of the sensors the rest for the program works but the sensor that is the default is ignored. I need some help with this as I have been working on it for two days now and no progress
Thanks for the help
Project Problem
-
- Posts: 346
- Joined: 27 Sep 2010, 03:05
- Contact:
Re: Project Problem
I don't have LV10 handy. Can you post a picture of the program?
Steve
Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
Re: Project Problem
Hi Steve
Here you go Thanks for the help
I just know it is just gonna to be a simple problem
Here you go Thanks for the help
I just know it is just gonna to be a simple problem
-
- Posts: 346
- Joined: 27 Sep 2010, 03:05
- Contact:
Re: Project Problem
Let me start by saying that I'm not trying to insult your programming. Just suggest ways you can improve it.
Ok, I can tell you a whole bunch of things that are wrong with your program, which combine to create an interesting effect. First, a fundamental "bad technique" used: It's not a good idea to use strings in your case statement. It's easy to make a spelling error that would cause invalid cases. Numbers work better (they're hard to misspell).
Problem 1: in the "check for sensors" case, there appears to be spaces after "Touch 1" (see technique above) That means when touch 1 is pressed, it will skip the touch 1 case, and go to the default case of touch 2
Problem 2: "Touch 2" checks port 1, not port 2. Also, not sure if it's a problem, but there is no port specified for the US sensor. It may already default to 4.
Problem 3: you're using different values for the US sensor range check. In one place, you use 10cm, and another you use 5cm. *note, the US sensor readings are not very accurate below 4", or about 10cm
Comment 1: the Initialize case is pretty much the same as the "drive" case. Personally, I'd just skip to the drive case, so you have one less case.
Comment 2: The "Check For Sensors" case checks all the sensors, then goes through cases that check each sensor. I don't think you need both types of checks.
Comment 3: Not sure if this was intended, but in one place your testing for sensor "bump" while in another place, your testing for "pushed".
Hope that helps.
Steve
Ok, I can tell you a whole bunch of things that are wrong with your program, which combine to create an interesting effect. First, a fundamental "bad technique" used: It's not a good idea to use strings in your case statement. It's easy to make a spelling error that would cause invalid cases. Numbers work better (they're hard to misspell).
Problem 1: in the "check for sensors" case, there appears to be spaces after "Touch 1" (see technique above) That means when touch 1 is pressed, it will skip the touch 1 case, and go to the default case of touch 2
Problem 2: "Touch 2" checks port 1, not port 2. Also, not sure if it's a problem, but there is no port specified for the US sensor. It may already default to 4.
Problem 3: you're using different values for the US sensor range check. In one place, you use 10cm, and another you use 5cm. *note, the US sensor readings are not very accurate below 4", or about 10cm
Comment 1: the Initialize case is pretty much the same as the "drive" case. Personally, I'd just skip to the drive case, so you have one less case.
Comment 2: The "Check For Sensors" case checks all the sensors, then goes through cases that check each sensor. I don't think you need both types of checks.
Comment 3: Not sure if this was intended, but in one place your testing for sensor "bump" while in another place, your testing for "pushed".
Hope that helps.
Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
Who is online
Users browsing this forum: No registered users and 2 guests