United Kingdom
Asked — Edited

Question About Scripting

Hi again guys, so i have another question, i am trying to write a roam script for my bot but im a little confused about how i write a script to read a sonar, below is what i have so far

I2CStart() I2CWrite(0x42, 5) I2CStop() sleep(2000) I2CRestart() I2CWrite(0x42, 0x20, "Robot Roam Mode") I2CStop()

:Main forward() sleep(2000) if(digital(D10) < 15) goto(stop) goto(Main)

:stop stop()

you can ignore the I2C stuff its just for the display, but with the echo port on D10 on my ping sonar basically if i run this script he starts moving and then stops, the sonar is reading 25 when he stops not 15 as in the script above, the main loop is what it says the main running loop the stop is well you guessed it stop, its just a test but like i said he starts of then stops, what am i doing wrong ?

Thanks Kurt


ARC Pro

Upgrade to ARC Pro

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.

PRO
Synthiam
#1  

You'll want to use the Ping_Wait (triggerPort, echoPort, [higher/lower/equals], inches) instead


forward()

sleep(2000)

Ping_Wait (d0, d1, lower, 15)

stop()

United Kingdom
#2  

ahh thanks alot

United Kingdom
#3  

Actually one more thing on this, is there no way i can use the if command with a ping ie, if ping is > 15 then forward else turn left, what im trying to do is this, create a loop for forward motion then if the ping sensor goes lower than 15 stop and scan ping left, if nothings there turn left and carry on, or if when it scan left there is something there scan the ping servo right and see if somethings there, and carry on if not, if there is obstructions both left and right turn around and carry on. kindof like the sweeping sonar but in script form, for doorway and hall navigation using the sonar.

PRO
Synthiam
#4  

maybe a ping for IF conditions will come your way for christmas:)

although it does sound like you want to use the Radar control

United Kingdom
#5  

Hehe well i do really but like we know it doesnt work with the sabertooth motor control, and also i like the fact that i can also include other variables in while he is in roam mode :-)

Thanks Kurt

PRO
Synthiam
#6  

I think the question is "why doesn't sabertooth motor controller work with ez-b". I've responded to a few things to try - but i don't manufacturer the sabertooth controller and therefore can't support it with technical issues, sorry:)

Have you considered contacting sabertooth? And has anyone done any of the "tests" that i've written in other posts? i.e. using the sabertooth in R/C mode with a Vertical servo Control

United Kingdom
#7  

I did try the other things in the other post, i responded to the post with the values you requested ie using servo panel what is stop, forward, reverse etc etc :-)

I have tried contacting them but as i said in my other post they are about as helpful as a chocolate teapot so thats why i have come to the master hehe

I think most of my issues would be solved if i could put an if statement in with the sonar, like you said you might add that in so i will wait and see.

Thanks Kurt

#8  

Saving Scripts

I'm sure there's an easy solution that I managed to overlook, but here goes

I open up EZ-B, click Add Control, then Misc, then Script and then Configure.

I type in a simple program and go to click on Save. Where does it (or should it) save the script?

Is the script only available for that session, as long as I have the EZ-B open?

Last but not least, is it possible to compose a script in Word and cut and paste into EZ-B?

Many thanks!

John