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
Thanks for the help and suggestions Gunner and Putt Putt. As I said before; I need all I can get sometimes. I'd be dead in the water without it. A little push in the right direction is all I need sometimes.
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
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
OK Putt Putt, I think I may have showed my newness to this again. I think what you were trying to show me was how to structure a script with functions and statements that Gunner was showing. This way the script will work the way I want my robot to act? Not a different language. Duhh.
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
Hey Dave, no worries with anything..
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
Hi 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