Go to Post Why climb up to the scaling rungs when you can move the entire field down to your robot's height? - marcusbernstein [more]
Home
Go Back   Chief Delphi > Technical > Control System > Sensors
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #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
  #2   Spotlight this post!  
Unread 18-01-2017, 08:16
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is online now
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,729
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Trying to count EVERY cycle of a photoelectric sensor in your program

Quote:
Originally Posted by AtomicBrawlers View Post
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?
What you'll actually need to do is configure a counter or encoder to the digital input that the sensor is plugged into. This will take care of all of the counting through the FGPA and you just read it like it is a normal encoder.

You can see an example of how we did it here.
Reply With Quote
  #3   Spotlight this post!  
Unread 18-01-2017, 09:21
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 395
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Trying to count EVERY cycle of a photoelectric sensor in your program

If you're using Talon SRXs, they can also read encoders at high speed - plus connecting encoders directly to the SRXs allows you to do cool things like onboard high rate PIDF control. You can read the encoder from the SRX using CANTalon.getPosition()
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #4   Spotlight this post!  
Unread 18-01-2017, 09:41
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,906
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Trying to count EVERY cycle of a photoelectric sensor in your program

The FPGA in the roboRIO runs at 40MHz (25ns/sample)
Use an input configured as an FPGA counter.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 18-01-2017 at 09:52.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:42.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi