Go to Post CHALLENGE: A dozen Krispy Kreamers to the first team to make a three-pointer during a break at an NBA game. - Natchez [more]
Home
Go Back   Chief Delphi > Technical > Electrical
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-12-2016, 03:06
DaveL DaveL is offline
Registered User
FRC #2976
 
Join Date: Jan 2013
Location: WA
Posts: 171
DaveL is a jewel in the roughDaveL is a jewel in the roughDaveL is a jewel in the roughDaveL is a jewel in the rough
Wiring Talon SRX PID w/ Beam Break Sensor

I'm trying to help my team figure out how to wire an Adafruit 3mm beam break sensor to a Talon SRX motor controller to control a flywheel shooter.
The SRX is connected to the RIO via CAN.

I've looked thru a number of posts, but have not seen the details of which wire goes to what pin.

We currently are able to pass the sensor signal to the RoboRIO and calculate an RPM.
Now we want to send the sensor signal directly to the SRX and use its processor to generate the feedback signal to the motor.

From Adafruit:
For the receiver, connect red and black for power and then the yellow wire to the digital input.

From Talon SRX Use Guide:
The data port has the following pins:
1) +3.3V
2) +5V
3) Analog Input
4) Forward Limit
5) Quadrature B
7) Quadrature A
8) Reverse Limit
9) Quadrature Index

Should we connect the Yellow sensor wire to Pin 3 Analog input or to one of the Quadrature pins?

Build Mentor Dave
Reply With Quote
  #2   Spotlight this post!  
Unread 18-12-2016, 03:22
Jeremy Germita's Avatar
Jeremy Germita Jeremy Germita is offline
Co-Advisor/Lead Engineering Mentor
AKA: wood is good. plastic is fantastic.
FRC #5012 (Gryffingear) / (Antelope Valley FIRST Teams)
Team Role: Coach
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Lancaster, CA
Posts: 282
Jeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond repute
Re: Wiring Talon SRX PID w/ Beam Break Sensor

Page 49 of the Talon SRX Software Reference Manual says the Talon SRX can be put into counter mode where the edges on the input of Quadrature A are counted.

We've briefly tested a similar setup, except we used sparkfun's photointeruptor sensor connecting it to 5V, Gnd, and QuadA on the talon. Word of warning on using IR-based sensors. We've found that sunlight and venue lighting can often oversaturate the receiver, causing you to lose counts. If you must use an IR-based sensor, try your best to isolate it from ambient light.
__________________
Drive Coach Team 5012 Gryffingear / Antelope Valley FIRST teams / EWCP - (2013 - Current)
Student / Driver / Programmer / CAD - FRC Team 399: Eagle Robotics / FTC Team 72: GarageBots - (2009 - 2013)
Los Angeles Region FTC FTA/CSA/Head Ref
[FF] FIRST Pick
2014 FTC Los Angeles Regional Compass Award Winner.

2017 - Sacramento Regional / Las Vegas Regional
2016 - Los Angeles Regional Creativity + Winners (1197, 987, 5012) / Las Vegas Regional Team Spirit + SF (5012, 5851, 5049) / Galileo Subdivision
2015 - Inland Empire QF (597, 5012, 4413) / Las Vegas Imagery + Winners (148, 987, 5012) / Newton Subdivision and World Champions (118, 1678, 1671, 5012)
2014 - Inland Empire Rookie All Star + Highest Rookie Seed + SF (2339, 1967, 5012) / Las Vegas Rookie All Star / Galileo Division Imagery
Reply With Quote
  #3   Spotlight this post!  
Unread 18-12-2016, 16:24
DaveL DaveL is offline
Registered User
FRC #2976
 
Join Date: Jan 2013
Location: WA
Posts: 171
DaveL is a jewel in the roughDaveL is a jewel in the roughDaveL is a jewel in the roughDaveL is a jewel in the rough
Re: Wiring Talon SRX PID w/ Beam Break Sensor

Thanks for the wiring info and the advice on light shielding.
Dave
Reply With Quote
  #4   Spotlight this post!  
Unread 18-12-2016, 20:06
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,064
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Wiring Talon SRX PID w/ Beam Break Sensor

One quick word of warning...the Talon SRX calculates velocity as "change in position per 100ms". This works well for providing smooth velocity measurements with quadrature encoders (where you are generating tens or hundreds of thousands of pulses per second), but may result in poor velocity resolution with a break-beam sensor and number of counts per revolution. For example, a 5000 rpm flywheel with 2 pieces of retroreflective tape will generate ~167 counts per second, or ~17 counts per 100 milliseconds.

Usually for the latter configuration, you are better off measuring the time period between consecutive rising or falling edges rather than differentiating position over time. You can do this on the RoboRIO, but not on the Talon SRX (at least on current firmware as of today).

Last edited by Jared Russell : 19-12-2016 at 01:10. Reason: s/not//
Reply With Quote
  #5   Spotlight this post!  
Unread 18-12-2016, 21:14
DaveL DaveL is offline
Registered User
FRC #2976
 
Join Date: Jan 2013
Location: WA
Posts: 171
DaveL is a jewel in the roughDaveL is a jewel in the roughDaveL is a jewel in the roughDaveL is a jewel in the rough
Re: Wiring Talon SRX PID w/ Beam Break Sensor

Thanks for the advice.
However, I'm not sure what you are suggesting.

In our current setup we are using an old AM 8" wheel with 6 thin spokes.
I believe we are calling a count 1 on/off cycle (open space / spoke).
We are thus getting 6 counts per revolution.

Are you suggesting that this setup will have problems with Talon PID or that we should define a count as open/spoke (leading edge) - spoke/open (falling edge) to give us finer data resolution?

As a note, we are currently spinning the flywheel at 3,000 rpm but would want to be capable of spinning at up to 6,000 rpm.

Dave
Reply With Quote
  #6   Spotlight this post!  
Unread 19-12-2016, 07:18
phurley67 phurley67 is offline
Programming Mentor
FRC #0862 (Lightning Robotics)
Team Role: Mentor
 
Join Date: Apr 2014
Rookie Year: 2013
Location: Michigan
Posts: 62
phurley67 is an unknown quantity at this point
Re: Wiring Talon SRX PID w/ Beam Break Sensor

Not to speak for Jared, but this is my understanding of the issue.

The Talon is counting pulses and uses the pulse count as a proxy for velocity/rpm. In your scenario you are going to initially have ~30 pulses per 100ms (3000rpm / 600 = 50(revs/100ms) * 6 spokes = 30 pulses per 100ms.

Another way to think about this every pulse in a given 100ms window represents 100rpm. If you count pulses to determine, speed you are going to have +/-100 rpm accuracy if everything else is perfect (which it won't be).

Rather than using the Talon to run the PID, you determine velocity by measuring the time between spokes 100ms/30 = 3.3ms vs 100ms/2.9 = 2.9ms if you can reliably measure changes with more accuracy than 0.4ms (3.3-2.9=0.4ms) you should be able to determine velocity greater accuracy than the Talon.

I have not done this, but I would run some tests and probably use InterruptableSensorBase override and use the readRisingTimestamp call to collect the data.

If Java/Linux collude to reduce accuracy, I might also consider using an arduino/teensy to collect this information and report via spi/i2c back to the rio.
Reply With Quote
  #7   Spotlight this post!  
Unread 19-12-2016, 08:27
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,986
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Wiring Talon SRX PID w/ Beam Break Sensor

Quote:
Originally Posted by phurley67 View Post
I have not done this, but I would run some tests and probably use InterruptableSensorBase override and use the readRisingTimestamp call to collect the data.
WPILib uses the FPGA to timestamp the data.

FPGA samples the edges at 40MHz, and timestamps them with a 40MHz clock (25ns resolution) when detected.



Last edited by Ether : 19-12-2016 at 08:30.
Reply With Quote
  #8   Spotlight this post!  
Unread 19-12-2016, 08:28
tr6scott's Avatar
tr6scott tr6scott is offline
Um, I smell Motor!
AKA: Scott McBride
FRC #2137 (TORC)
Team Role: Mentor
 
Join Date: Dec 2007
Rookie Year: 2005
Location: Oxford, MI
Posts: 505
tr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond repute
Re: Wiring Talon SRX PID w/ Beam Break Sensor

https://www.chiefdelphi.com/forums/s...d.php?t=113954

We used a photoeye with two or three sections of reflector tape in 2013 full court shooter mode, speed set to 3700 rpm, max speed was around 4400 on the cim and wheel.

This year 2016 our shooter wheels used Andymark CIM encoder wired to the SRX and the using the PIDF on the srx. The CIM coder is 20 counts per Rev, from website, but the SRX counts the transitions on both channels, so 80 counts per rotation or the wheel. This was enough resolution to work well.

If you do this method, please read the SRX encoder manual and make sure you use the pull up resistors for the cimcoder.

You should probably review the hardware portion of the manual, as you may need pull up resistors for the sensor you are using too.
__________________
The sooner we get behind schedule, the more time we have to catch up.

Reply With Quote
  #9   Spotlight this post!  
Unread 29-12-2016, 00:01
neilh neilh is offline
Registered User
FRC #2976
 
Join Date: Dec 2016
Location: Washington
Posts: 1
neilh is an unknown quantity at this point
Re: Wiring Talon SRX PID w/ Beam Break Sensor

Hi, I’m the lead programmer of Team 2976, same team as DaveL. I have never experimented with velocity calculations with an encoder since I have always used the premade one in the encoder library. Normally I find the change in position in a constant time period…say 100 milliseconds. This usually works well for regular encoders that return 360 ticks per revolution. However, in the hardware setup we have, as DaveL explained we only have 6 spokes and 6 ticks per revolutions. Reading through your suggestions I have found namely 3 solutions:
1) Measure the change in position with constant time (100ms). However, as phurley67 pointed out this only gives us +- 100 rpm and the uncertainty increases with smaller sample times
2) Measure the change in time between 2 successive pulses or ticks. Although I haven’t tried this I calculate about 3 ms change in time and I feel this will give lots of noise. Furthermore, I also am worried about CPU usage when throwing interrupts ever 3 ms.
3) Use an encoder. This is a good solution, except, our team wants it to be done using a beam break. Nevertheless, it will be interesting to work with this.
My solution is using a tracking loop, similar to a Kalman filter. The principle behind this is our knowledge of the relationship between position and velocity—I.e. integrate position to get velocity—can allow us to estimate the velocity with less noise.
Here is the outline of a tracking loop:
Basic physics tells us that integrating velocity results in displacement, or position. So I do that and integrate a variable I call velocity_estimated. The result of this integration will be the estimated position.
I feed this into a PI controller as the input and set its setpoint to the measured position and the controller will try to minimize the error by giving me more accurate values of velocity_estimated.
In a way this is recursive. I first calculate the estimated position by integrating the estimated velocity. I compare this value to the measured position and using a feedback loop get a more accurate estimate for velocity which I integrate once again…and the cycle continues.
Even though this is a roundabout way to get at the velocity, this is good. By integrating position, we absorb error and hope that it will cancel.
See for yourself here is a link to my github page where I created a simulation of a spinning wheel with the extra time I have since school is out for winter break.
https://github.com/neilhazra/Simulat.../Simulate.java
If you run it, you will notice estimated position is almost always closer to the hypothetical position_exact than measured position is. And that velocity_estimated is more precise and consistent (with much less noise) than delta position/ delta time.
This is not a perfect simulation, I assumed our error would be randomly distributed which it will definitely not be. I will need to test it on a real robot soon.
Reply With Quote
  #10   Spotlight this post!  
Unread 29-12-2016, 01:09
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,064
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Wiring Talon SRX PID w/ Beam Break Sensor

Quote:
Originally Posted by neilh View Post
2) Measure the change in time between 2 successive pulses or ticks. Although I haven’t tried this I calculate about 3 ms change in time and I feel this will give lots of noise. Furthermore, I also am worried about CPU usage when throwing interrupts ever 3 ms.
The RoboRIO can timestamp pulses to about 25ns accuracy (in FPGA hardware, with no CPU overhead). With 3ms between pulses, this is an absolute ton (O(10^-6)) of precision.
Reply With Quote
  #11   Spotlight this post!  
Unread 29-12-2016, 21:37
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,986
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Wiring Talon SRX PID w/ Beam Break Sensor



Hi neilh.. I see this is your first post. Welcome to Chief Delphi !



Last edited by Ether : 29-12-2016 at 21:40.
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 04:30.

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