Ireland
Asked — Edited

Ez Script

A little help with Ez Script Please

I am using four ADC inputs to ezb to control two servo motors. see sample Ez Script

only one adc will have a low value at any given time all others will be high. a low on any adc input should give a specific value to the two servo motors.

Using repeat this scans the adc inputs ,but I need to address the second servo also if(adc(adc0) < 100) servod(do, 20) if(adc(adc1) < 100 servo(d0, 30) if(adc(adc2) < 100 servo(d1, 25) if(adc(adc3) <100 servo(d1, 35)

Appreciate any assistance you could give

Pat


ARC Pro

Upgrade to ARC Pro

Don't limit your robot's potential – subscribe to ARC Pro and transform it into a dynamic, intelligent machine.

PRO
Synthiam
#1  

Are you trying to move the servo into a position relative to the adc input value?

Ireland
#2  

No Dj Using the adc as a trigger only

Pat

PRO
Synthiam
#3  

For example, you'd like to use the ADC for push-buttons to move the servos into different positions?

Ireland
#4  

Please let me outline its purpose

I have four IR sensors on my Robot ( IR Beacons)

Front Back Left Right

Normall high output (4.8v) until one detects IR then that sensor goes low, other 3 sensors rermain high.

Sensor outputs are connected to ADC ports on EZb. I require Ez Script to Constantly monitor ADC inputS. Detect which one is low,and then send commands to two servos (d0,d1)

e.g Hold a ir transmitter in front of robot it can move forward, hold ir sensor at back of robot it will turn around , same with left & right

program requirement, must constantly monitor inputs & if low send command to servo d0 & d1 simultaniously

Monitor ADC0 if low, output servo(d0, 20) & servo(d1, 30) monitor ADC1 If low, output servo(d0, 30) & servo(d1, 40) monitor adc2 if low ,output servo(d0, 5) & servo(d1, 15) monitor adc3 if low,output servo(d0, 25) & servo(d1, 35) repeat

Thank You Pat

PRO
Synthiam
#5  

Ah brilliant!

Try this..



:start

# check rear sensor and turn 180 degrees if detected
if (adc(adc0) < 100)
 left(2000)

# check right side sensor and turn 90 degrees if detected
if (adc(adc1) < 100)
 right(1000)

# check left side sensor and turn 90 degrees if detected
if (adc(adc2) < 100)
 left(1000)

# check front sensor and move forward
if (adc(adc3) < 100)
 goto(ForwardDetected)

# pause for 1 second
sleep(1000)

# loop
goto(start)

# called when detected
:ForwardDetected

# move forward
 forward()

# pause for 1 second
 sleep(1000)
 
# check if there is still IR in front sensor
 if (adc(adc3) < 100)
  goto(ForwardDetected)

# stop moving forward
 stop()

# loop
goto(start)


Ireland
#6  

excellent

One last question not sure where to enter the actual mulible servo commands as I am using indivdual servo,s to operate a joystick. Have tried to enter in movement script but no joy. Sorry I know its probably in how to

confused

PRO
Synthiam
#7  

Under Tutorials, you will find a "Continuous Servos" guide. You may follow that video to see how to use modified servos to control your robot. Then, you can use commands such as "Forward(), Left(), Right(), STop(), etc"

Ireland
#8  

sorry forgot to mention my Robot has an electric wheel chair base . User-inserted image

SAMPLE SCRIPT

forward

if(adc(adc0) < 100) servo(d0, 37) if(adc(adc0) < 100) servo(d1, 34)

reverse

if(adc(adc1) < 100) servo(d0, 30) if(adc(adc1) < 100) servo(d1, 40)

no marks for my programming skills ,but it seems to work as I move two servos with one adc input

Thanks DJ

#9  

GREAT looking bot!!! Would love to see him in action. How about a video?

PRO
Synthiam
#10  

HOOOOOOOOOLY!!! That IS a fantastic bot!!

Man, i really better step it up a notch... you are all showing me up! or down, which ever way it works hahaha

Ireland
#11  

ye its ongoing Exhibited a number of times at national "Young Scientist Exhibition" fantastic response. one of its features is it is touch sensitive . eg tickle its neck and you get a hilarious laugh ,kids loved this

With 16 servos controlling its movements its some fun to programme. Now with EZB,I wonder will it always be a work in progress.Maybe if you ( DJ ) took a holiday ,and decided no more new features for Ezb that may help me !!!. As mentioned previously seriously thinking of adding Brain control ,through the EZB of course . Let the cloning from human to Robot begin.

Pat

PRO
Synthiam
#12  

Haha, well just wait Pat... I have a new release with some neat features that you're going to become addicted too. I already know! :)