View unanswered posts | View active topics It is currently Tue Jul 22, 2014 9:30 am






Reply to topic  [ 8 posts ] 
Multiple Ultrasonics with RobotC 
Author Message
Rookie

Joined: Thu Oct 09, 2008 8:11 pm
Posts: 4
Post Multiple Ultrasonics with RobotC
Is there any way to only enable one Sonar/Ultrasonic sensor at a time?

We need to use multiple Ultrasonic Sensors at different heights and want to minimize the interference between each of the sensors on a Cortex Vex controller.

Ideally, we would like a way to enable one sensor, wait for the reading, then disable the pings from that sensor, then enable a 2nd sensor.

Is there any way to do this?

Thanks.

Paul Tan.
Coach of Polar Bear Robotics
VRC Team 2027


Mon Oct 18, 2010 10:23 pm
Profile
Expert

Joined: Wed Jun 30, 2010 7:15 am
Posts: 181
Post Re: Multiple Ultrasonics with RobotC
Ok, I'm not really sure about this, but I think the US sensors only give out/ receive signals when they're told to, and won't interfere with other ones when activated at different times. As they take one reading per 70 mSecs, it might be best to let them function with about 75 mSecs in between them, I suppose. To do that, I think you could just make one variable per sensor, make a (while) loop to let it repeat until that variable is filled (which is once), and make the variable become the reading from the US sensor at the end of the loop. Example:
Code:
task main(){

  int valueOne = 0;
  int valueTwo = 0;
  int valueThree = 0;

  while(valueOne == 0){
    valueOne = SensorValue (SonarSensor);
    wait1mSec (5);
  }

  while(valueTwo == 0){
    valueTwo = SensorValue (SonarSensor);
    wait1mSec (5);
  }

  while(valueThree == 0){
    valueThree = SensorValue (SonarSensor);
    wait1mSec (5);
  }
}


You could also do that with a for loop, if you want. Hope this helps,

DiMastero

_________________
leonoverweel.com


Tue Oct 19, 2010 2:56 am
Profile WWW
Rookie

Joined: Thu Oct 09, 2008 8:11 pm
Posts: 4
Post Re: Multiple Ultrasonics with RobotC
DiMastero wrote:
Ok, I'm not really sure about this, but I think the US sensors only give out/ receive signals when they're told to, and won't interfere with other ones when activated at different times.
...
DiMastero



Thanks for the thoughts, DiMastero, but can someone confirm or deny the above? I was told (I think the posts are still on this forum for NXT/FTC) that at least for RobotC on the NXT this was not possible, and that the Ultrasonics would be on continuously.

Can someone confirm that this is not the case for Vex/Cortex, and that we could use several Ultrasonics as DiMastero has suggested we could?

Thanks.


Tue Oct 19, 2010 4:34 am
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 403
Post Re: Multiple Ultrasonics with RobotC
Multiple ultrasonic sensors (unless aimed directly at one another) should not interfere with each other. However, they do operate using sound waves which are subject to interference and can bounce off in various directions.

There is a way to turn on and off sensors in ROBOTC. Below is a program that turns on sensor 1 for 5 seconds, then turns on sensor 2 for 5 seconds, over and over. Note that I have ultrasonic sensor 1 plugged into digital ports 1 and 2, and ultrasonic sensor 2 plugged into digital ports 3 and 4.

Code:
task main()
{
  while(true)
  {
    SensorType[dgtl1] = sensorSONAR_cm;  //Configure Digital ports 1 and 2 as a sonar (cm) sensor
    wait1Msec(5000);                     //Wait 5 seconds
    SensorType[dgtl1] = sensorNone;      //Turn off Sonar Sensor on Digital ports 1 and 2
   
    SensorType[dgtl3] = sensorSONAR_cm;  //Configure Digital ports 3 and 4 as a sonar (cm) sensor
    wait1Msec(5000);                     //Wait 5 seconds
    SensorType[dgtl3] = sensorNone;      //Turn off Sonar Sensor on Digital ports 3 and 4
  }
}


Hope that helps!

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Tue Oct 19, 2010 9:43 am
Profile
Rookie

Joined: Fri Oct 09, 2009 9:21 am
Posts: 28
Post Re: Multiple Ultrasonics with RobotC
Jesse,
Can you use more than 2 ultrasonic sensors on the Cortex? I believe RobotC is only set up for 2 on the Pic.

_________________
Jon Thompson
Coach - Twisted Bots
VRC 177


Tue Oct 19, 2010 1:11 pm
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 403
Post Re: Multiple Ultrasonics with RobotC
Currently you can still only use two ultrasonic sensors. That said, we're looking into what impact (if any) adding more will have on the system as a whole, so that may change in the future.

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Tue Oct 19, 2010 6:27 pm
Profile
Rookie

Joined: Thu Oct 09, 2008 8:11 pm
Posts: 4
Post Re: Multiple Ultrasonics with RobotC
jbflot wrote:
Currently you can still only use two ultrasonic sensors.


Is that only two (2) ultrasonics sensors active at at time? I.e. can I have two ultrasonic sensors on ports 1/2, 3/4, and then have two more at 5/6, 7/8, and activate the first set, deactivate it, and then activate the second set?

Do I have to wait any settling times between activations/deactivations?

Thanks.

Paul Tan.


Tue Oct 19, 2010 8:26 pm
Profile
Rookie

Joined: Tue Sep 07, 2010 10:56 am
Posts: 43
Post Re: Multiple Ultrasonics with RobotC
Hi, to test if they are on while in not in use, use your ear, and place it to the emitter, it's a very low noise, if in silence you can hear it, i already tried, but i wasn't doing that task...
put it to check constantly and see if you can hear the sound, test it with no data being received in the program, and have a conclusion :)
Ivan

_________________
My creations: techlego.blogspot.com


Wed Oct 20, 2010 10:43 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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:  



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