View unanswered posts | View active topics It is currently Sun Aug 28, 2016 6:21 am






Reply to topic  [ 5 posts ] 
EV3 ultrasonic sensor reading speed 
Author Message
Rookie

Joined: Sun Apr 06, 2014 2:07 pm
Posts: 9
Post EV3 ultrasonic sensor reading speed
Hi,
I need to trace object by Ultrasonic sensor from EV3. When I use standard RobotC
function getUSDistance and 3 value mean filter I sometimes miss object.
I have found "drivers library" with lego-ultrasound.h file and functions.
My problem is, when I use USreadDist(Us_Left); it in my project I allways get error

ERROR, You have not setup the sensor port correctly.
Please refer to one of the examples.
Detected SensorType on port[3]: 94

In source code I have
#pragma config(Sensor, S3, Us_left, sensorEV3_Ultrasonic)

And one more question.
I have 20 ms delay between reeding of sensor, is it correct or I can use shorter delay?
Whan I read 3 values it takes 60ms so my movable object is not easy to track.

Thanks a lot for help

Martin


Mon Feb 15, 2016 8:38 am
Profile
Expert

Joined: Thu Dec 01, 2011 12:07 am
Posts: 139
Post Re: EV3 ultrasonic sensor reading speed
Please post your code and explain if the error occurs during compile or while running.

Sound travels at about 340m/s. It will take 60ms for sound to travel out 1 meter and return. If you need a faster response you may have to consider an IR sensor.


Mon Feb 15, 2016 1:19 pm
Profile
Rookie

Joined: Sun Apr 06, 2014 2:07 pm
Posts: 9
Post Re: EV3 ultrasonic sensor reading speed
Hi, code is quite simple

#pragma config(Sensor, S4, Us_right, sensorEV3_Ultrasonic)
#pragma config(Sensor, S3, Us_left, sensorEV3_Ultrasonic)
#include "lego-ultrasound.h"

task main()
{
int USL0 = USreadDist(Us_left);
int USR0 = USreadDist(Us_right);
wait1Msec(20);
}//main

This code produces the error during runtime, just USreadDist cause error. Compilation is OK
Your computation of time seems to me not right.
If sound speed is 344m by 1000 ms, then detection 2 m distant obscale takes sound (4m) 11.62 ms so I can read distance by ultrasonic
at every 20ms to get right response from sensor. (I need detect distance up to 50 cm)


Mon Feb 15, 2016 1:48 pm
Profile
Rookie

Joined: Sun Apr 06, 2014 2:07 pm
Posts: 9
Post Re: EV3 ultrasonic sensor reading speed
I found problem :(
The EV3 ultrasonic sensors are UART not I2C as expected "lego-ultrasound.h" so the problem with error is solved but,
how can I get maximal refresh rate for reading EV3 US sensors?
Thanks again


Mon Feb 15, 2016 4:21 pm
Profile
Expert

Joined: Thu Dec 01, 2011 12:07 am
Posts: 139
Post Re: EV3 ultrasonic sensor reading speed
You are right. It would then take 15ms for the 2.5m limit. They must protect for worst case distance to get to 20ms.


Mon Feb 15, 2016 11:01 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.