Talons without libraries?

I want to wire some Talons up to my XMOS microcontroller, but I’m unable to use any of the large libraries because of its architecture. Is it possible to simple throw a PWM signal at the Talon and expect a linear output?
I also want to use an incremental encoder with it. Is there a way to bit-bang to get the output speed of an encoder using the quadrature input on the Talon?

Are you speaking of a Talon SR or SRX? The SR accepts PWM input (that is, pulse duration, not duty cycle) but does not have any sensor inputs, so you can’t use it to query the encoder. The SRX is a CAN bus controller which does have sensor inputs, including an encoder port. I have not yet used CAN apart from monitoring current use on the PDB; I have no idea how difficult it would be to create a CAN port on a microcontroller. If you licked that problem, then yes, you would be able to monitor the encoder through the same CAN bus that you used to control the motor. The neat thing about CAN is that if you build a single CAN controller, you can use it to drive several devices. You would not be using PWM, however.

Yes to running it on PWM without a CAN bus. Details on implementation and response data is in the user manual.

The “PWM” signal into an FRC speed controller is actually a “hobby servo” signal. It’s nominally a pulse width of 1 ms for full reverse, 1.5 ms for neutral, and 2 ms for full forward; the pulse repeats every 5 to 20 ms. If you provide that, the Talon should work just fine.

Reading sensor inputs on a Talon SRX is not going to be straightforward. I would expect it to be far beyond the scope of your project.

Okay, thank you. I was thinking about the SRX, as we used them this year for encoder values. I can do the servo-PWM control quite easily, but if I have to hardcode a CAN bus then I might just have to switch to a RIO.

I suspect that you wouldn’t be able to get it to work with CAN using your own controller. A security/safety feature requires special communication from the Driver Station through the roboRIO in order to enable the output.

The Talon SRX is supposed to support SPI and I2C, at least according to the initial information sheet. However, I have never seen any documentation telling how to use those communication protocols.

Dang, that’s even worse. A friend of mine recommended I use a CAN controller IC, but I need to read up a lot more on CAN before I make that jump.

It may be easier to use pwm to communicate to the talon, and read the encoder on your micro controller. If your micro controller supports interrupts you can read the encoder easily. There’s examples of this for the arduino that could be ported.

I was going to use the XMOS microcontroller to do it, and I guess it’s possible to read the encoder on that. That seems like the easier way to do it at this point.

Check to see what the maximum reliable reporting rate of your microcontroller is, and make sure your encoder won’t overwhelm it when running at free speed. If it does, you may need a counter divider as an input prefilter, though that will likely ruin the quadrature function of your encoder. This won’t be much of a problem if your goal is to set speed, but it could prevent you from specifying an output position based on the encoder.

Runs at 100MHz each for 4 cores, but I need to do port read/write tests. It should only take one clock tick per reading, but now I’m wondering how I would report results without losing some functionality. I could just add another XMOS and run encoder readings on 4 cores.

If that specific chip won’t work, there are other chips out there that support hardware quadrature decoding, and some of them support decoding multiple encoders at once.

For a Cortex-M3 (100 mhz), I’ve been able to decode around 500,000 edges/sec reliably in software using edge triggered interrupts.

Really? That’s a pretty fancy chip.

On the Cortex-M3, it takes 3 cycles to access the AHB bus on the fast GPIO, and on older generation chips, slow GPIO would take north of 10 cycles (if I remember right).

Peripheral accesses tend to be pretty slow, even on embedded chips. CAN receiving code that I have used on a i7 over PCI takes a very long time. The CPU busy waits while that is happening. The result is that it takes about 1 core to read CAN messages (!).

It’s not a Cortex chip, interestingly enough, and it has a fast pin read/write speed compared to an ARM. I’m not sure what architecture it uses, if not its own proprietary architecture.
The chips are super cheap, around $5 for the cheaper ones and $15 for the super fancy ones. The Startkit is $15, but has everything on an Arduino-size board and headers for pins, plus an (inconvenient but usable) USB interface.