Asked — Edited
Resolved Resolved by Steve G!

What Is Matrix?

i get an error trying to use the ping sensor.something about matrix is not good.

User-inserted image

and the text is in nederlands written

bigger pic

User-inserted image


ARC Pro

Upgrade to ARC Pro

With Synthiam ARC Pro, you're not just programming a robot; you're shaping the future of automation, one innovative idea at a time.

United Kingdom
#1  

The index light outside the matrix boundaries

@nomad.

Can you post the script that has the error so we can have a look.

PRO
Belgium
#2  

steve g

i forgot how to do that,

United Kingdom
#3  

Select the script code, press CTRL and C together to copy it, and paste it on the forum thread inbetween the "Code" tags.

PRO
Belgium
#5  

ctrl+c and press copie to clipboard? paste is ctrl+v ?

#6  

@Nomad Open your script in ARC, highlight it all with your mouse, copy it... then come here and paste it into your post.... done

#7  

@Nomad you can also just give us a screen shot of your script...

#8  

You can also copy and paste by right clicking on your mouse

United Kingdom
#9  

@Richard.

I've never been able to copy or paste script to and from ARC using a mouse or trackpad.

#10  

@Steve Hmmm, that's weird... You're right... I pretty much use ctrl + C, V, X exclusively so I had never noticed right clicking doesn't work in ARC scripts

United Kingdom
#11  

@Richard.

Yeah, that's never worked. Well there's your "new thing I Iearned today".;)

PRO
Belgium
#12  

mine doesn copie eather.so here printscreen.

User-inserted image

whits i wanne try is the ping make sound i have on pc(sonar) and when he detects some say danger,danger,danger also sound file i have.

United Kingdom
#13  

Shouldn't there be an "If" and "EndIf" code in there, like "if ping is lower than 50, do or say this"?

PRO
Belgium
#14  

i dont know anything about scripting.

#15  

@Nomad... Does your ping work and is it attached to ports D22, D21 when you run the script?

PRO
Belgium
#16  

rr

yes and i checked the volt regulator too.

United Kingdom
#17  

I think I'll leave this to Richard as I'm not near a Computer right now.

United Kingdom
#18  

@nomad.

See what you gone and did... You went and broke the EZ Robot website, lol.:P

Anyway back to your problem. Try this...

:loop
Ping_wait(D21,D22,Lower,50)
Servo(D3,90)
SayEZB("Danger, danger, danger")
Sleep(3000)
Goto(loop)

When you start the script the Ping sensor will start detecting distance. Now when the value goes below 50, the EZ-B will say Danger. It will sleep for three seconds and start start detecting distance again.

Hope it helps.

PRO
Synthiam
#19  

ooops, a bug in Ping_Wait() .. I'll fix it right away

Temporary work around: Use ports between D0 - D21

PRO
Belgium
#20  

hi guys

sorry late respons.i couldn get on the forum here.

rr

yes the ping works at port D22 AND D22 but not the script thanks averyone

#21  

@nomad... Just after the site went down I remembered there is a bug that DJ knows about... Some ping commands (haven't checked all of them) do not work on ports 23 and 22... As DJ mentioned, you need you use ports 21 or lower...

United Kingdom
#22  

@nomad.

If my script doesn't work for you (it does work as I tested it) then it maybe what Richard said about using port 22.

PRO
Belgium
#24  

allright it works,just need some volume

thanks you all

United Kingdom
#25  

@nomad.

Glad you got it sorted. Yeah, having volume when it's trying to speak helps:P. You don't have to leave the loops in my script, but I prefer to have it in there.

PRO
Belgium
#26  

steve g

do i need to ad in the script for more volume

#27  

You can setvolume(1xx) higher than 100, but it will begin to distort the higher you go as it will basically be overdrive above 100

United Kingdom
#28  

EDIT: Richard just posted what I was going to say.

PRO
Belgium
#29  

rr

can i set it any where in the script

#30  

@nomad set it before the say() command ... try setVolume(200)

PRO
Belgium
#32  

got it just using 100 .now i need just two things and that is when he 's, not detecting something then play sound file i got whit sonar sound. and second when he detects something stop whit turning. sorta watsh the intruder.

User-inserted image

United Kingdom
#33  

@nomad.

Good to see it working. I won't give you the script to do what you asked, but I'll give you some clues to what you need so you can Give it a try.

If the ping sensor reads over 50, play sonar sound and rotate the servo.

or else if ping sensor reads below 50, stop sonar sound effect and say "danger".

Put in a sleep command.

Go to the start of the script and do the process again.

The clues of what script commands you need are written above. Give it a try and report back.

Good luck.

PRO
Belgium
#34  

steve g thats a huge task for me ,give me a couple off months haha just kidding. i like the way you teach.ok let see wht i can find. eek

United Kingdom
#35  

@nomad.

No problem. Truth be told, I'm not 100% sure how to write the script as im still learning too, but I understand the principles and what's needed...

If over 50, scan and play sonar sound

Elseif under 50, stop scan and sonar sound and say "Danger".

If I had my laptop with me I could probably write the script okay, but I'm away for the weekend so can't give you more than that for now.

#36  

setVolume(100)
repeatuntil(1=2)
$distance=GetPing(D20,D21) #check ping
if ($distance<50)
servo(D3,90)
sayEZBwait("danger, danger, danger")
else
ControlCommand(Soundboard V4, Track_4)
#may need a sleep command here
endif
sleep(250)
endrepeatuntil

PRO
Belgium
#37  

rr

steve g gonna like this code

#38  

Maybe a better script..


setVolume(100)
:top
ControlCommand(Soundboard V4, Track_4)
repeatuntil(1=2)
$distance=GetPing(D20,D21) #check ping
if ($distance<50)
ControlCommand("Soundboard v4", Stop)
servo(D3,90)
sayEZBwait("danger, danger, danger")
goto(top)
endif
sleep(250)
endrepeatuntil

United Kingdom
#39  

@Richard.

That's a new one for me. I haven't come across that before.

PRO
Synthiam
#40  

Steve, :Top is a label for the Goto command

Goto will "jump" to the label

A script starts from the top and reads each line downward

When the line reads GOTO(label), then the script will jump to the label. In this case, the label is called TOP. You can name the label anything you want.

You can name the label CHICKEN, if you like chickens. Or you can name it something that identifies what it is for, in which case CHICKEN wouldn't make sense.

Richard used TOP because it's the top of the script. He could have named it anything, but it's nice to name it something that us humans can understand when reading the code back.

For more information, load the GOTO RETURN STACK.EZB project located in Examples\EZ-Script Function Syntax folder

United Kingdom
#41  

@DJ.

That's cool. I guessed it was a GOTO but didn't realise you could rename, or should I say label it with a custom named. I'll have a look at the examples folder.

Thanks.

PRO
Synthiam
#42  

Anytime dude:D

I think my random selection of CHICKEN was due to how hungry I am... oh so hungry. Skipped lunch!

United Kingdom
#43  

Mmmm. I was thinking pizza myself, lol. Go get something to eat buddy.

PRO
Belgium
#44  

so above loop comes chicken?or any name.

United Kingdom
#45  

@nomad.

From how I understanding now, that's not correct. In your example, :loop doesn't go above :chicken, :loop is :chicken (or :whatever you name it).

Quote from the script manual...

Defines a label for a GOTO() command Example: :My_Label [/quote]

#46  

For you guys that are hungry....:)


setVolume(100)
:chickenandpizza
ControlCommand(Soundboard V4, Track_4)
repeatuntil(1=2)
$distance=GetPing(D20,D21) #check ping
if ($distance<50)
ControlCommand("Soundboard v4", Stop)
servo(D3,90)
sayEZBwait("danger, danger, danger")
goto(chickenandpizza)
endif
sleep(250)
endrepeatuntil

United Kingdom
#48  

@RichardR a little off topic but I've always wondered why you use the impossible statement in a repeatuntil rather than a label/goto loop?

PRO
Synthiam
#49  

Is the RepeatUntil() what Richard uses to exit a script?

You can exit a script with HALT()

#50  

@Rich For obvious reasons I use an impossible statement to have the repeatuntil loop repeat forever... When I first stated using ez robot about a year and a half ago, I did use goto loops instead of repeatuntil... However, it might be just with the ezb3 (because this is what I was using) after a minute or two in a goto loop the ping would fail to fire. With a sleep set at 100 between checks, the ping would just stop working for some reason... I replaced my "read ping goto loops" with a repeatuntil loops and it immediately fixed the ping/firing problem...

To be honest I feel the repeatuntil statement is just a better way to do infinite loops. Goto statements are more meant to jump from place to place in your code...

#51  

@nomad.... Try this and let me know if it does what you want... I had to fix my if statement... forgot the brackets...


setVolume(100)
:chickenandpizza
ControlCommand(Soundboard V4, Track_4)
repeatuntil(0)
$distance=GetPing(D20,D21) #check ping
if ($distance<50)
ControlCommand("Soundboard v4", Stop)
servo(D3,90)
sayEZBwait("danger, danger, danger")
goto(chickenandpizza)
endif
sleep(250)
endrepeatuntil

#52  

@nomad... Try this one too... see what works better...


setVolume(100)
repeatuntil(0)
$distance=GetPing(D20,D21) #check ping
if ($distance<50)
servo(D3,90)
sayEZBwait("danger, danger, danger")
else
ControlCommand(Soundboard V4, Track_4)
#may need a sleep command here
endif
sleep(250)
endrepeatuntil

PRO
Belgium
#53  

rr goodmorning

danger danger danger is track-4 actully sonar is track-5

it did nothing just lot off heavy noise this is what i want to have.

first ping goes left and right whithout detect any and play sound file (sonar)

then when he spot something stand still and play danger danger danger. when the object leaves he goes back to left and right whit sonar sound.

#54  

@nomad... Play with this one to see if you can get it to work the way you want...


setVolume(100)
repeatuntil(0)
$distance=GetPing(D20,D21) #check ping
if ($distance<50)
servo(D3,90)
ControlCommand("Soundboard v4", Stop)
ControlCommand(Soundboard V4, Track_4)
sleep(3000) # change to what works best
ControlCommand("Soundboard v4", Stop)
else
ControlCommand(Soundboard V4, Track_5)
#may need a sleep command here
endif
servo(D3,50)
sleep(250)
servo(D3,130)
sleep(250)
endrepeatuntil

PRO
Belgium
#55  

rr the previous one stops rotating and disconnects the ezbv4

#56  

Which script? What post #?

How long are those sound files 4 and 5 when you play them on their own? 1,2 or more seconds long?

Take out the ControlCommand("Soundboard v4", Stop commands and see if it still disconnects... Make sure you battery is good as well... a weak battery would cause your ezb to disconnect while moving or attempting to move servos...

PRO
Belgium
#57  

rr i just try post #55 and post #53 bolt doesn move the servo and disconnect the ezbv4

PRO
Belgium
#58  

batt are fully charged

sound files are 4 seconds each. took the command stop out. last little longer but disconnect ezbv4

#59  

It works for fine for me albeit I am using different sound files and a fresh battery...

You'll to write your own then because I don't know your set up so that's the best I can do... Like I said... check your battery

#60  

One last try... see if this works ... problem will be it will only play track 5 once until it sees an object...


setVolume(100)
:top
ControlCommand(Soundboard V4, Track_5)
repeatuntil(0)
$distance=GetPing(D20,D21) #check ping
if ($distance<50)
servo(D3,90)
ControlCommand("Soundboard v4", Stop)
sleep(25)
ControlCommand(Soundboard V4, Track_4)
sleep(4000) # change to what works best
ControlCommand("Soundboard v4", Stop)
sleep(25)
goto(top)
endif
servo(D3,50)
sleep(500)
servo(D3,130)
sleep(500)
endrepeatuntil

PRO
Belgium
#61  

rr

#you may need a sleep command here.i put one in and it doesn disconnect the, ezbv4.ok i will test further.thank you

#62  

Ok, work with that one then... the one I just in posted in post #61 probably will work, but it won't play track 5 continually...

#63  

@Nomad maybe a possible feature request is to be able to have tracks in the soundboard auto replay so you don't have the call it to play continually in a program repeatuntil or goto loop...... In your case track 5 is only 4 seconds long so having it auto replay would make what you want to do much easier... So this way you start track 5 (ping sound) and it plays over and over until you see an object that is detected with the ping ... Then track 4 plays... When the object is no longer in range your program starts track 5 again...

PRO
Belgium
#64  

rr

i jus found it the code do just that.am uploding a video. so one thing to be found is when he spot an object servo must stay , in the direction off the object

#65  

Get rid of servo(D3,90) in my code and the ping should point to the object it sees..

PRO
Belgium
#66  

dj has fix the bug on port d22 and i downloded the new version. here the video what we have sofar.

#67  

Looks like you almost got it working... awesome...:)

PRO
Belgium
#68  

yes now looking to make the servo stop when he detects an object and say. stop surrender now ,got the sound file. gonna make a motion for the ping make a special movement when he detects, the anemy.

PRO
Belgium
#69  

i made a video.what i want him to do when he spotted an object. can i wright that in the script next to a soundfile?

User-inserted image

#70  

@nomad you can add a new line anywhere you want... see below


setVolume(100)
repeatuntil(0)
$distance=GetPing(D20,D21) #check ping
if ($distance<50)
servo(D3,90)
ControlCommand(Soundboard V4, Track_4)

#new line
#new line
#another new line

sleep(3000) # change to what works best
else
ControlCommand(Soundboard V4, Track_5)
#may need a sleep command here
endif
servo(D3,50)
sleep(250)
servo(D3,130)
sleep(250)
endrepeatuntil

PRO
Belgium
#71  

and it will play soundfile and motionfile same time?

#72  

It depends on what you are doing and how you code it...

PRO
Belgium
#73  

next to the soundfile danger danger i want that he does the movement like in the last video.same time.

#74  

Just code the movement on the next line after track 4 (danger, danger, danger)...