
Bravia
Ireland
Asked
— Edited

Attempting to control a motor with potentiometer (adc) and get it to move in correct direction (using hbridge) to a specified ADC position
ideally I want the motor to operate like a servo ,give it a value and it will find that position and stop, this adcspecified would vary.
script if ($adcSpecified = 135) (Get error "variable not defined on this line ")
endif
:start
$adcCurrent = GetADC(adc7)
if ($adcCurrent $adcSpecified) goto( Right) endif if ($adcCurrent = $adcSpecified) goto( Stop) endif goto(Start)
: Left Set(d23, on) Set(d22, off) Return() : Right Set(d23, off) Set(d22, on) Return() : Stop Set(d22, off) Set(d23, off) Halt()
Very rewarding evening of scripting with the support of this communities resident experts I can now instruct a dc motor ( using a hbridge ) to move to any desired position by even voice commands. Will publish more details to assist others in the near future. Many thanks to all who assisted Pat
:)


Bravia, I for one am very interested in how this was done. Im currently using wheelchair motors for shoulders, and timed commands are just not accurate enough. PLease keep me in the loop on this. Thanks
Sorry I missed this thread till now. I overcame this issue a couple years ago. At the time I was using a V3 ezb and was having problems with over shooting my specified variable. I had to use a little math in my scripts to get the motor to center properly without rocking. The V4 may not suffer from this adc lag but if you find this a problem then read over my old and ancient thread. I may be worth reading anyway as it has some scripting you don't see everyday in usual ez scripts. DC Motors, pots & ADC ports
Dave That is one issue I was working on will incorporate your script and see how it works Thank You