View Single Post
  #1   Spotlight this post!  
Unread 18-01-2017, 07:37
AtomicBrawlers's Avatar
AtomicBrawlers AtomicBrawlers is offline
Registered User
FRC #5401
 
Join Date: Feb 2016
Location: Bensalem
Posts: 5
AtomicBrawlers is an unknown quantity at this point
Trying to count EVERY cycle of a photoelectric sensor in your program

My team wants to use a photoelectric sensor or photoswitch to measure and manage the rpm of a flywheel shooter. So there'd be something such as retro-reflective tape on the wheel that would trigger the sensor every rotation. The issue we don't see anyone else talking about is how to get 6,000+ readings per programming cycle. By this, I mean the ~20ms it takes for an FRC Robot to run through it's commands.

For example, if the wheels are rotating ~6,000 rpm, that means 100 rotations a second that must be counted. If a robot can only retrieve data every ~20ms (it's not consistently 20ms) , that means there's ~2 rotations every second.

However, the wheels are not at a constant 6,000 rpm and the data isn't processed at a constant 20ms, so how do you get around the issue of the wheels rotating too fast for the code to read?

One option is a hardware counter, something the photoelectric sensor connects to that keeps track of how many times it's triggered and then sends that number when the code asks for it every ~20ms. If this is your solution, do you have the name of the part you used to do this?

Does anyone know of any teams that have done this who's code is available to read?

Last edited by AtomicBrawlers : 18-01-2017 at 07:52.
Reply With Quote