
Bravia

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()
your first two lines in your script don't do anything, what do you need them?
Code:
Code:
Ah so thats where the $adcspecified comes from I presumed one entered a value
on that script
must experiment a little more so I can then enter my varing $adcspecified
Thank you so much that worked this is the working version that may be of use to others.You are a genius at programming.
Any pointers how one could get this script to accept a varing "$adcspecified "
$adcSpecified = 145
:start
$adcCurrent = GetADC(adc7)
if ($adccurrent > $adcspecified)
goto(left)
endif
if ($adcCurrent < $adcSpecified)
goto( Right)
endif
if ($adcCurrent = $adcSpecified)
goto( Stop)
endif
goto(Start)
: Left
Set(d22, on)
Set(d23, off)
Return()
: Right
Set(d22, off)
Set(d23, on)
Return()
: Stop
Set(d22, off)
Set(d23, off)
Halt()
*note* you will need to get rid of this line ($adcSpecified = 145) if you use the slide script... The slide script will provide your value from now on....
Basically, a main script which did the thinking, calculations, movements etc. which was triggered by a different script. The second script would first specify the variables, i.e. set the speeds for the motors then it would run the script which sent the commands to the sabertooth to gradually increase the speed of each motor until they reached the desired speeds.
Similar could be done with this. A script which moves the motor on the H-Bridge until the Pot on the ADC port reads the required value. That script is triggered by a different script using ControlCommand() after specifying the desired position.
For accurate positioning you may need the script which monitors the pot on the ADC port to check very quickly (depending on motor speed) though which may cause comms bottlenecks and increased CPU load. It may end up needing to be a bit of a compromise in areas.
Alan
Shall i say I was part of a discussion group that put forward ideas
I experimented with a polou ir beacon ( www.pololu.com/product/701)
which works well indoors
Its built into the upper part of" robot leonardo " which is pictured on my logo
Will demo some of its features once I have completed my present project
Pat
Will publish more details to assist others in the near future.
Many thanks to all who assisted
Pat
Chris
DC Motors, pots & ADC ports
That is one issue I was working on will incorporate your script and see how it works
Thank You