
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
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
Where did you get the multi turn pot from I might have to use that to.
thanks for the help
I use the robot shop too so I'll look them up.
Have fun and no driving.
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
Thanks in advance ds!
Glen(FRED)
#########################################################################
:Start
$adcSpecified = 90
1.$adcCurrent = GetADC(adc1)
if ($adcCurrent $adcSpecified)
goto(RotateLeft)
If (($adcCurrent >($adcSpecified - 20) and $adcCurrent ($adcSpecified - 5) and $adcCurrent <($adcSpecified + 5)))
goto(RotateStop)
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