Hi all,
I'm having a centering issue. I'm trying to have the waist of my B9 robot turn left, right and then go to center. Right now I have 3 scripts, one for each movement (left, right and center). My goal it to have one script that will let my waist move back and forth past center and then return to center.
The motor is a DC motor controlled with an H-Bridge and the position feedback is a multi-turn Pot. The Pot is attached to an ADC port to get Current feedback.
Each script is working but when I run the centering script the motor rocks back and forth past center till it finds the exact value. I'm using the = Condition in an "if" statement. Here's a section from my script:
#####################
:Start
1.$adcCurrent = GetADC(adc1)
if ($adcCurrent $adcSpecified)
goto(RotateRight)
if ($adcCurrent = $adcSpecified)
goto(RotateStop)
goto(Start)
###################
Here's the goto(RotateStop) section:
##################
:RotateStop
1.Set(d5, off)
1.Set(d4, off)
Halt()
##################
It seems like the = Condition is too tight of a tolerance for the pot feedback. Watching the Variable Watch panel the $adcCurrent value will rise past the $adcSpecified value and then the motor will reverse back to get back to the Specified value. Depending how fast the motor is going sometimes the motor will switch directions continuously trying to find center.
My Question; I there a way to state a way I can stop the motor between two value Current values and not a = value?This may give me more tolerance and the motor wont react to try to bring itself back to "Exact" center. Or.... is there a different way to write this scriptto keep the motor from rocking back and forth to find center?
Of course you can tell I'm new to any kind of script writing. Thanks for any help.
Dave Schulpius
Asked
— Edited
So, without my posting any code
Hope this makes sense
Actually Gunner, B9 could have 360 deg rotation but I have limit switches installed near the rear of the radius so he can only turn about 300 deg. They already have helped me avoid certain disaster.
Thanks again and I hope I can ask for more help on this later.
Dave Schulpius
Now I need to have a separate script for each point I want to stop at and then use the centering scripts to bring it home. I can then write another script useing the ControlCommand Entries for different routines. This seems like a lot of scripts. There must be a better way. Can I do the same thing with less scripts or better writing?
Thanks, Dave Schulpius
I'm making progress. I actually got a single script to work for centering without the rocking issue. I went back and tried gunner's suggestion again. Must have mistyped something or gave up too soon in frustration last night. Now it works perfectly! Here's what I came up with. Consider my mid value is 125:
If ($adcCurrent >120 and $adcCurrent <130)
goto(RotateStop)
I think I'm getting the hang of this a little. Now that I have the movement scripts working I need to figure out how to get them to stop at "center", multiple "quadrant" and "octant" points in a routine
like Gunner suggested. I still don't know how to do this without having one EZ Script for each stopping point as a call script with ControlCommand Entries for different rotation patterns.
The GetRandom and GetRandomUnique functions sound interesting here. However again I have no idea how to apply a randomly attained number to a stopping point on my waist rotation.
Thanks for listening to my ramblings.
Dave Schulpius
I'm not sure what event you are using to turn the body but lets say your using sound to determine a direction...
use IF statements for the event and then GOTO a routine to turn the body..
EI:
Sudo code:
:main
If sound is on the left then
left
If sound is on the right then
right
goto main
:left
turn body to POT reading ###
goto main
:right
turn body to POT reading ###
goto main
you could add in any number of positions you like by just naming them different like ....left1 , left2, ....
right1, right2....or center
put them all in 1 big script then call that script from say the personality script or wherever.
Use a variable (i.e. $stop) instead of numbers for your stopping point, then modify your script like this
Code:
This way you can adjust the value of $stop and B9 will stop wherever you want
I have found that every time you put a sub-grouped qualifier or math - Sorry I don't know the correct terms
These suggestions are just what I'm looking for and what I need to make B9 do what I want him to do. The waist rotation animation is going to be one of the most important movement processes so as to make him appear like the real thing. This process will also be used in his radar/bubble section above his collar. If you remember from the TV show Lost in Space, at times his waist would move one way and his radar/bubble section move the other and then go back the other way to catch up with the waist. Anyway, both sections had the same movement patterns but were very independent of each other.
Just a couple questions;
Gunner, if I follow you, the value of $stop needs to be stated somewhere at the start if the script? I'm thinking this should be my center value? So, if my center value is 125 the script may look like this?:
#############################
:Start
1.$adcCurrent = GetADC(adc1)
$stop= 125
If (($adcCurrent >($stop - 5) and $adcCurrent <($stop + 5)))
goto(RotateStop)
goto(Start)
:RotateStop
1.Set(d5, off)
1.Set(d4, off)
Halt()
############################
Putt Putt,
Pardon my ignorance but I see your suggestion looks totally different then Gunner's. Is it in a different language? I have read that EZ-B can understand different languages like C#, VB and C++. Is this what is happening here? I suspect this because I cant find a lot of these functions or qualifiers (? - I'm still learning the terminology) on the sidebar function list in an EZ Script window. Can I place these different languages in an EZ Script and get them to work? I see there is a C# Script choice in the Add Control tool in ARC. Do I need to use this instead?
Also I've noticed when people post scripts sometimes it's inserted in a Yellow window like I see in Gunner's post above. Where does that come from? Looks like it's added from outside somehow or cut and pasted from a different program.
Thanks again for all the help,
Dave Schulpius
Anyway Gunner's statement worked nicely and seems like a more of an elegant way to do it. Now I've got my movement scripts down to one. I just have to change the one variable (i.e. $stop) to get it to stop anywhere! Thanks!
Now I need to study and structure my script in a way like Putt Putt suggests. I hadn't really considered yet how I'd activate the script. Depending on how that will be done (ie. voice, personality of just at startup) I may have to have other call scripts (I think).
Anyway, things are progressing nicely. I'm learning slowly. Thanks for the help.
Dave Schulpius
One thing ( like you picked up on ) is that no that is not any code that you would use it is just a " Sudo Code " meaning that it is sort of how you would go about it but with all proper syntax for whatever variant of code a person would use.
Don't worry about your newness as you put it, you may not be able to write code yet but you can sure build one hell of a fantastic robot that probably most on here are drooling over every time they see it!
As for me I can glean information from everyone that contributes ( good or bad ) and then apply it to a bot but like you I need that push ( and sometime a swift kick ).
I look at some of my bots and think to myself " did i build that? " , I that that comes with age or lost brain cells but o-well.
Hey I just have fun and hope you do too.
Putt Putt
Dave
Thanks for the very kind words. It's good to know there are people out there like you willing to lend a hand to help a guy out bring his hard work and dreams to life. Yes, this is more fun then I've had in a long time and although it's frustrating at times I love the challange.
Thanks to you and Gunner I was able to figure out how to get my rotation working nicely and to also understand what I was doing. I now have just one script that will send the waist rotation to any point I need around the radius. All I have to do is have what ever activates the script send the Specified Variable of the point I want to stop at and the script name it's self (to start the script). I'll be able to set whole routines if and when needed.
So this may be my last entry to this thread discussing how to get it to work.
Many thanks again to both you and Gunner.
Dave Schulpius