Automous R/C Car
Scott Portocarrero
Posts: 72
Ok so here is the veeerrry beginning of my code. All I am trying to do here is steer the car out of the way of an object when the car gets close. I understand that the car doesn't move forward yet. My Issues:
1) The rawdata coming from the PING has a value of no more that 250 with a home made servo extension cable attached. When I plug the PING directly into the bread board it give me the correct readings up to 5000. The question is why would an extension cable give me such a variance?
2) I am very new to PBasic. Can somebody look over my code and tell me what I am doing wrong, maybe give me some pointers. All I want it to steer right when something is detected close to the left PING and to steer left when something is detected close to the right PING. To me this sounds very simple but it doesn't work.
Heeeeellllllllllppppp!
Post Edited (Scott Portocarrero) : 7/13/2009 4:39:46 AM GMT
1) The rawdata coming from the PING has a value of no more that 250 with a home made servo extension cable attached. When I plug the PING directly into the bread board it give me the correct readings up to 5000. The question is why would an extension cable give me such a variance?
2) I am very new to PBasic. Can somebody look over my code and tell me what I am doing wrong, maybe give me some pointers. All I want it to steer right when something is detected close to the left PING and to steer left when something is detected close to the right PING. To me this sounds very simple but it doesn't work.
Heeeeellllllllllppppp!
Post Edited (Scott Portocarrero) : 7/13/2009 4:39:46 AM GMT
Comments
About the PING sensor, do you have a Voltmeter? Then you can check the cable for resistance, maybe its broken. This shouldn't happen to a PING and if the cable is ok, the PING might be damaged.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't worry. Be happy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't worry. Be happy
This way, there is a slack of 50 before you start turning.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't worry. Be happy
Here it is
IF want go left THEN dir = SERVO_LEFT
ELSEIF want go straight THEN dir = SERVO_STRAIGHT
ELSEIF want go right THEN dir = SERVO_RIGHT
ELSE GOTO error
GOSUB steer
...
steer:
...
PULSOUT servo_pin, dir
...
want go left VAR BYTE
want go right VAR BYTE
want go straight VAR BYTE
What is GOTO error?
I feel like this is something very simple!
It's my lazy pseudo code...
"want go left" would be the condition that determines a left hand turn. From your code, you used the comparison "rawdata1 > rawdata2".
I put the GOTO error in there as a catch all for debugging: if the robot shouldn't go left, right, or straight, what's else is there to do? You could determine that you have an error at that point.
As a side note, you used "IF rawdata1 = rawdata2 THEN Steer_Center". This case will almost never be true since there are ~65,000 possible values for rawdata1 and ~65,000 values for rawdata2. The chances that they are equal are very small. Instead, what you might want to do is to use ranges. For example, if the right sensor distance is less than 12 cm and the left sensor is greater than 12 then turn left.
edit: dev/null posted something similar, using the term slack.