View Single Post
  #2   Spotlight this post!  
Unread 22-11-2014, 17:56
cgmv123's Avatar
cgmv123 cgmv123 is online now
FRC RI/FLL Field Manager
AKA: Max Vrany
FRC #1306 (BadgerBOTS)
Team Role: College Student
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Madison, WI
Posts: 2,084
cgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond repute
Re: Parallax PING))) Java Coding

Code:
DigitalOutput.set(true); //Needs to be a properly constructed DigitalOutput object.
Timer.delay(0.00003); //This is a static method.
DigitalOutput*.set(false); //Same object from above.
while {DigitalInput.get()=false} ////Needs to be a properly constructed DigitalInput object.
double starttime=Timer.getFPGATimestamp(); //This is a static method. You can use a Timer object, but I like this method better.
while{DigitalInput.get() = true} //Same object from above.
double pingtime = Timer.getFPGATimestamp() - starttime; //Same method from above.
double distance = pingtime * (appropriate scalar);
This should be separately threaded so the microsecond timing doesn't depend on the control loop and so the wait loops don't cause a loss of robot control.
__________________
BadgerBOTS Robotics|@team1306|Facebook: BadgerBOTS
2016 FIRST Championship Tesla Division | 2016 Wisconsin Regional Engineering Inspiration Award

2015 FIRST Championship Carson Division | 2015 Wisconsin Regional Chairman's Award

2013 FIRST Championship Curie Division | 2013 Wisconsin Regional Chairman's Award

2012 FIRST Championship Archimedes Division | 2012 Wisconsin Regional Engineering Inspiration Award, Woodie Flowers Finalist Award (Lead Mentor Ben Senson)


Last edited by cgmv123 : 22-11-2014 at 21:00.