
leonardo46
Italy
Asked
— Edited

I'm a basic and assembler programmer ( PIC MCUs).
I'm trying to put ezb scripts at work.
I have a pot connected to adc0 (i.e. 0-3.3 V) and move the pot. I write this easy script in movement script, triggered by "forward" action panel :
sayezbwait("man")
:auto
$av=getadc(adc0)
if $av>20
sayezbwait("dog")
else
sayezbwait("cat")
endif
goto(auto)
"man" is spoken once. Nothing else happens.
I should have missed some banal detail
Please help.
Code tested. It does no more than stop at once after the forward command. I eliminated the stop() command at the beginning.
After that it goes forward, until the front sensor gets near an obstacle and then it stops, after several seconds (a long time!...). The voltage in READ ADC control panel, instead, changes immediately.
Other sensors seem to have no influence in what's going on. No change in direction triggered by left/right sensors.
I saw in the code there is some average of adc reads. Could this help ?
What had this code to do? Why side sensors not working?
I have in ezb screen a voltage panel for each sensor, correctly measuring each distance in real time.
It only says "stop", because I have sayezb ("STOP") in stop script.
Can you upload/attach your project ?
I eliminated the 2nd stop() statement, (it stopped there !). now it reacts to the side sensors, turning right or left as required.
But it keeps turning for ever, even when the loop is executed again with the front sensor without obstacles ("far" situation).
It never says near or far. Only says what's in right,left,or stop scripts.
But the worrying issue is : response time is extremely long !
Note that the 3 READ ADC control panels for sensors change in realtime.
EZBv4 , instead, reacts after some 2-3 seconds !...
I DON'T UNDERSTAND WHY IT'S SO SLOW.
This way is useless for controlling a robot !
roby.EZB
Anyway, ignore me now. Sounds like the op is getting close to resolution. I wish him luck.
Please try:
test_r1.EZB
But the problem now is : WHY it's so slow ? it takes at least 3 seconds to actually change the direction.
Within that time the robot will crash against the wall !
The same robot , with a PIC, reacted in milliseconds.
Please try:
test_r1.EZB
Changes:
1) vocal messages removed from the main script
2) Decreased the delay to 50
*** #1 edit:begin ***
3)
Dave suggestion, is very relevant.
I paused all the analog controls, they have short (<1000ms) refresh intervals .
Our focus is to troubleshoot the navigation script. You can try later activate one by one to see if they affect the performance
*** #1 edit:end ***
4) Important:
as it is, is using a single read on adc0 to use average readings you will need change the code to:
Code:
Please let me know if the results are better.
PS: Congratulations Soccer Euro 2016 - Italy is moving forward !
Conte did a fantastic job beating Spain is not easy!
I don't understand what's going on.
It connects to other ezbs, #1,2,etcthat I don't have.
No test possible.
Thanks for our soccer team. They were really convinced to win.
My ezb has a different address, when you save a project the ip address goes in.
You see a textbox before the connect button, you will need to change the ip address from 192.168.18.84 (mine) to 192.168.1.1 (yours).
Then save the project.
It's almost ok. I'll experiment for even better performance.
Another issue for this robot was some code to avoid endless oscillations between right and left occurring in some circumstances.
It's necessary, when ,for example, turning right, to disable any attempt to turn left until the front sensor has a free space before it. Turning left should be enabled only after the rover has started to go straight. Same thing should happen for turning left. To do this there were two flags FL and FL1, as you see in the attached flowchart.
Can you implement this function in your code ? This would be enough for this thread.
iniz=initialization
libero av=free space before me
av =go straight
ostac dx=osbtacle at right
ostac sx=obstacle at left
dx=right
sx=left
ost= a label
FL and FL1 = Flags
My logic is already doing that, look the code:
Code:
I put some comments #1-#6
The current logic is:
1) when the robot detects an obstacle will enter #3
2) if robot is driving forward not spinning will enter #4, stop, starts spinning left or right based on adc1 or adc2 values
robot keeps spinning same direction (no oscillation) until the forward sensor is ok, once is ok will enter #1 and drives forward.
I added some logic to avoid oscillation going left, forward, right, forward, left.
Code:
you will need to tweak the value 20 based on your observations, can be higher or low.
relevant lines:
Code:
Thank you for having shown me what ezb can do. i'll study your code. Programming that way is different from basic or assembly on pics I was used to. I'll try to get the relevant know-how.
One last detail. I'd like to avoid those annoying windows coming out when you start ezb i.e. mounting instructions, fine tune profile, tutorials for robots I will never have,etc. I have to skip or close them every time.
After this thread I will experiment with servos, actions and frames, and will certainly ask for support in other threads.
I'll be reading you there.
Now I understand how to use adc reading.
To have fast results it's better to use a hardware comparator on board . It can make such operations in 100 nS !.....