Rural Geek
Canada
Asked
— Edited
When I get my EZ-B and start building my robot "Experiment 333" I am going to be using some variables from encoders to calculate distances.
What I am wondering is to declare a variable you always need a $ at the start of it correct? Also can you set up a variable to get info directly from an input like an encoder count?
Thanks for the help.
P.S. @DJ can't wait for the Revolution
Hi Rural Geek, Are you using a servo or a DC motor and H-Bridge? If it's a DC motor I just learned how to do just this. I'll be glad to help as much as I can. I'm still very new and in the learning curve but I'll help with what I do know. With the help of a couple of other members here that pointed me in the right direction I just completed a script that stopped my DC motor at any point I want on a radius. I'm using a potentiometer as a feedback attached to an ADC Port of EZ-B. I wanted to use an optical encoder counter that was already built into my motor but I really don't think EZ-B supports this. I asked several times and searched this forum and only found statements that it was not supported. PLEASE someone tell me if I'm incorrect! Anyway, I ended up using multi turn potentiometers. It really works slick and very accurate. I'm going to take a video tonight and post here "just to show off a bit".
If you want to view the scripts you can open my project from EZ-Cloud in the "Incomplete Robot" section named "B9 Robot Control". Open the script called "Move Waist". It's setup to listen for a call from another script stating the $adcSpecified values where I want the waist to stop rotating. Right now I have a different script sitting right next to it called "Waist Routine 1" that sends different $adcSpecified values, one at a time after a little Sleep period so the motor has time to move there. I also have different PWM levels set for each move so the speed will ramp up as it starts up. The torso of my B9 Robot is very heavy (I think around 70 lbs) and I don't want it jerking to a start or stop. Works great!
If you're using a servo you should not need any kind of an external encoder.
Have fun, Dave Schulpius
Dave. The drive unit I am going to use is from Parallax and they come with encoders so I am hoping to use them I was just wondering about the variables so I'll have to take a look at your project I know it will help me out big time.
Where did you get the multi turn pot from I might have to use that to.
thanks for the help
If you find a way to use an encoder with EZ-B PLEASE LET ME KNOW. I've got 1 motor on my B 9 That has a built in and encoder but I cannot use. That's why I ended up using a pot. I got my multi turn pot from the robot store. they have 2 of them 1 is selling for about 6 dollars and the other for about 40 dollars. I got the 6 dollar one and it works great. I will send you the link when I get home tonight. If I haven't had too many adult beverages.
LOL If/when i figure it out (with help) how to use the encoder, I'll let you know.
I use the robot shop too so I'll look them up.
Have fun and no driving.
Well made it home safe and had a good time.
Here's the link to both choices:
http://www.robotshop.com/productinfo.aspx?pc=RB-Phi-24&lang=en-US : $25 USD http://www.robotshop.com/dfrobot-rotation-sensor-v2.html : $5 USD (I'm using this one. Has a metal shaft. Works nice but don't know if it will last. Time will tell).
Good Luck, Dave
Thank you dschulpius for providing examples of code for us newbots. I was trying to copy your Move waist script and use/adapt for my FRED and it came back with an error saying udefined varible on line 6 " $adcSpecified" ? As far as I can see (with my LIMITED knowledge) the varible looks fine and is used correctly. Sorry to have to make/ask you to debug again. perhaps you could shed some light on that for me/us.
Thanks in advance ds! Glen(FRED)
Well, I'm a newbie also but I'll try. I also had the same return error. I had to run the call script first before I could modify the main script. Also temporally try placing the $adcSpecified value statement below the :Start label to see if it will work that way. Iike this:
######################################################################### :Start
$adcSpecified = 90
1.$adcCurrent = GetADC(adc1)
goto(Start) ###########################################################################
What makes my Move Waist work properly is the call script named "Waist Rutune 1). That call script sends the different $adcSpecified values (stop points) and PWM speeds.
Hope this helps