|
Page 1 of 1
|
[ 3 posts ] |
|
Using US Sensors in 'Single Shot Mode'
| Author |
Message |
|
sparramc
Rookie
Joined: Tue Aug 11, 2009 11:49 pm Posts: 36 Location: Tasmania, the Land Down Under, the Land Downunder!
|
 Using US Sensors in 'Single Shot Mode'
I'm trying to use multiple Ultrasonic Sensors on a project, programmed with RobotC. When using US Sensors in ' Event Capture Mode' with NXC I use: But when it comes to RobotC I'm stumped. The best I could come up with using RobotC that compiled was: Can anyone please point me in the right direction?
_________________ regards
Sparra Mc
Last edited by sparramc on Fri Jul 06, 2012 5:48 am, edited 2 times in total.
|
| Wed Jul 04, 2012 1:29 am |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2860 Location: Rotterdam, The Netherlands
|
 Re: Using US Sensors in 'Event Capture Mode'
Ray, Have a look at the LEGOUS driver that comes with my suite. I have two functions in there: I haven't tested this, but what you could do is simply set it up for event capture and then call USreadDist() to get the data from it. There is also: and a few others you might find useful  - Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Wed Jul 04, 2012 1:41 am |
|
 |
|
sparramc
Rookie
Joined: Tue Aug 11, 2009 11:49 pm Posts: 36 Location: Tasmania, the Land Down Under, the Land Downunder!
|
 Solved: Using US Sensors in 'Single Shot Mode'
Thanx Xander. Using Multiple Utrasonic (Sonar) Sensors together you need to configure the Sensors to use Single Shot Mode.  |  |  |  | Code: #pragma config(Sensor, S1, US1, sensorI2CCustom9V) #pragma config(Sensor, S2, US2, sensorI2CCustom9V) #pragma config(Sensor, S3, US3, sensorI2CCustom9V) #pragma config(Sensor, S4, US4, sensorI2CCustom9V) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/* Xander Soldaat's 'Third Party Driver' for the LEGO Sonar */ #include "drivers/LEGOUS-driver.h"
task main() { while(true) { nxtDisplayClearTextLine(5); USsetSingleMode(US1); // Set US1 Sensor in Single Shot Mode wait1Msec(50); // Wait to Capture Distance Value Dist1 = USreadDist(US1); // Read the Sonar Sensor's Distance Value nxtDisplayTextLine(5, "%d", Dist1); USsetOff(US1); // Turn off Sonar Sensor on Digital ports 1 } }
|  |  |  |  |
More details at ' Blog'.
_________________ regards
Sparra Mc
|
| Fri Jul 06, 2012 5:18 am |
|
|
|
Page 1 of 1
|
[ 3 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
|
|