View Single Post
  #4   Spotlight this post!  
Unread 22-11-2014, 21:02
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

Quote:
Originally Posted by Jared View Post
I'm not sure this will work for a few reasons. First, I doubt that our setup with Java on the cRIO (or Java running on anything) will time the 30 microsecond pulse very accurately if you set it up the way you have it now.

Also, you'd need to run this loop really quickly to capture the pulse. If you're one inch away, your pulse is less than a millisecond away. It's possible to miss pulses entirely.

You really should use interrupts for this, or you should just add an arduino board that communicates with the cRIO with serial. I bet somebody has written an arduino library for this sensor. ... I don't think your two while loops will work the way you'd like them to.
I wasn't sure how effective this code would be. I was just trying to provide a starting point for the OP.

Quote:
Also, your timing method doesn't seem to compare the two FPGA timestamps to find the duration of the pulse.
I should have subtracted starttime. Added now.
__________________
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)