Falcon zeroing

Falcon experts: I have a semi-crazy idea, and I need some knowledgeable advice on the firmware/software side!
I’d like to make a dual Reed switch widget that plugs into the Falcon limit socket and provides a way to accurately zero a mechanism. Maybe coding the two switches so rotation goes 00, 01, 11, 01, 00. As you cross it. Or 00, 01, 11, 10, 00.

Can the programming side use those limit inputs to do a zeroing operation?

Swerve drive azimuth would be a great target for this…

Little confused. If you are trying to just find zero on a swerve azimuth, wouldn’t you just need one limit switch?

What is the minimum amount of time do you anticipate the mechanism will spend in each state? Reed switches (all switches) will have a few milliseconds where the contacts are bouncing as they open or close. This will lead to unstable states until the bouncing stops, limiting the rate one can go through the states and the maximum possible “speed”.

This is known as Gray code. Encoders often output this sequence. You should be able to detect one particular transition in S/W and zero things when this is hit, but it will work best if things are turning pretty slowly at the time. This is because you will very likely have to do this S/W on the RIO.

Looking for zero! Since there are two inputs I was thinking in terms of traverse fast until the outer limit is hit, slow down, and find the center transition.
With two I could manage a narrower 11 zone than I could with a single switch. That said, you really just want to use one side of the zone for crisper location.

Bounce is a challenge, but hard to avoid with the “dry contact”. Anybody know if those inputs are denounced?

At least for a while the zeroing code will have to live on the RIO, but later on we might get a firmware mode on the Falcon!

At this point you’re basically building a low resolution absolute sensor. Would it not be easier to just use a higher resolution absolute sensor? There are so many good options in the FRC market these days that I don’t know what is gained by going a custom made route?

I’m considering this as a replacement for an absolute encoder that is only used at startup, uses CAN bandwidth, and needs access to the swerve centerline.

You could try replacing the reed switches with hall sensors. They ought to change states more cleanly so that a simple R-C low-pass filter would clean up the signal. If you are going to move it slowly, a simple noise filtering algorithm that looks for several successive samples in the same new state should be sufficient. One of my sons used such an algorithm on the data from an ultrasonic sensor on his FLL robot and found it easy to implement and that it worked well.

The challenge is that there’s no power available on the Falcon limit switch inputs, and you’re not supposed to run power into them. They don’t publish what the pins go to.

1 Like

I think just looking for a “falling edge” when spinning the motor in a given direction will lead to a more consistent zero position. I don’t think there’s a great reason to grey code this, especially with there being automatic zeroing options built into the Falcon limit switch functionality.

IIRC, they’re basically high-impedance inputs with internal pullups, and a ground to connect them to. If you’re feeling brave, you could pull the power and ground for your circuit from somewhere else, and short the Falcon inputs to your ground, relying on the grounds to not be that different. It’d be better to have optoisolators that connect the Falcon input to Falcon ground based on signals from your circuit.

1 Like

@asid61 ; THAT’S why I was asking the oracle! I didn’t know about the firmware zero function! Sweet! Thank you!!

@Joe_Ross this section seems to apply to the Talon SRX and FX, and specifically calls out for pins 4, 8, and 10. The CTRE documentation doesn’t have much that specifically refers to the Falcon.

Can someone confirm that the “In addition to manually changing the sensor position, the Talon SRX supports automatically resetting the Selected Sensor Position to zero whenever a digital edge is detected.” Clear Pos function works on the Falcon limit switch input?

CNCs use this method to zero themselves. The FRC typical grade uses mechanical limit switches. The software is looking for the first break so bounce is not so much an issue. The problem with using it on a FRC robot is it requires the robot to be enabled to do it automatically. That will take time out of your autonomous routine

Yes, that’s definitely a positive factor for the absolute encoder; you just check it and its calibrated!