Can not allocate a second AddressableLED PWM port

Just wondering if anyone else has hit this. I’m guessing this is a WPI bug in the new AddressableLED() routines.

This is what I get and the code:

  • Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -1004. HAL: No available resources to allocate
  • Error at frc.robot.subsystems.DisplayLEDs.(DisplayLEDs.java:29): Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -1004. HAL: No available resources to allocate
  • at edu.wpi.first.hal.AddressableLEDJNI.initialize(Native Method)

public class DisplayLEDs extends SubsystemBase {
private AddressableLED m_led01;
private AddressableLED m_led02;
private AddressableLEDBuffer m_Buffer01;
private AddressableLEDBuffer m_Buffer02;

// ** Initialize the Sensors.
public DisplayLEDs() {
// *** PWM port 0
m_led01 = new AddressableLED(0);
// *** PWM port 1
m_led02 = new AddressableLED(1); [this is line 29 from above]

m_Buffer01 = new AddressableLEDBuffer(60);
m_led01.setLength(m_Buffer01.getLength());

}
I’m not using PWM ports anywhere else. I can move the LED to the other channels but as soon as I try to declare another instance of AddressableLED I get the error.
I would think I could declare 10 of these (0-9) but I’m guessing the routine only let’s you declare one.

Frustrating since the first one works really well. I would just like to do some more things on our robot so I’ll have to try another alternative.

Thanks,
Petrie

There is only one LED driver on the roboRIO, so only one PWM will work. They have to be in series.

1 Like

Wow. Thanks for confirming and that was really quick;-)

I’m not sure that you can, one of the devs will have to comment to be sure. but you can just take the data out from the last led of the string you have and send it to the first led of the next string. I’m not sure if there is a limit to the number of LEDs you can have with WPIlib, but i’d bet that you will run out of power / kill your battery before you get to that point.

I think the limit was above 5000 leds, maybe I saw that in the Java API.

I was confused about it, thinking that I could just use multiple LED segments coming back to different PWMs, but was corrected. It makes plenty of sense once you consider the hardware requirements, but the other way could be nice for keeping things separate. Instead you have to chain the segments together and also keep track of the segments in the buffer.

1 driver, 5460 LEDs

4 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.