Brushed Linear Actuator Programming

Hello,
I am a member of a college team in a NASA robotics competition, wherein we use the FRC ecosystem.

I am trying to program my team’s linear actuators, however I just can’t seem to get them to work. I can tell my controller input is being read from print testing, but I can’t get the actuator to actually extend. I believe something to be wrong in my Dumping.java file, but truthfully I am not sure what it could possibly be. My best guess would be something to do with the SparkMaxAnalogSensor. It is also possible that it may be a wiring issue, but I believe a coding issue is more likely.

Below is the GitHub branch with my most up-to-date code. If anyone could possibly help me to spot what I may be doing wrong it would be greatly appreciated.

PLEASE NOTE I AM STILL ON THE 2023 VERSION OF WPILIB:

For clarity with the wiring, here is a photo of the wiring based on labeling on the Linear Actuator itself. I am very new to the FRC wiring so it is still possible I messed this simple thing up.

From a quick skim of the code, it looks like your RaiseDumpingActuator command is written incorrectly. Motors outputs should be continuously updated in the execute method, they can’t be “set and forget”. (I’m assuming whatever platform you’re using has motor safety features. I don’t know if spark maxes have it built in). You’ll likely just need to move the code from initialize() into execute()

Just gave this a shot, unfortunately it did not work. It did however, cause the print statement in Dumping.java to continually run, meaning it is reading the input, just not performing the action. I believe my linearUp() function in Dumping.java is likely what is incorrect. My guess would be where the motor speed is being set. Any ideas about this?

If it is at all helpful, here is the Linear Actuator being used: Feedback Linear Actuators | 12v or 24v | Firgelli

Off the top of my head:

  • the motor is running backwards, and is attempting to retract instead of raise;
  • the spark max has a different CAN ID than what’s in the code;
  • the spark max is not on the CAN bus;
  • the sensor is returning bogus values;
  • the spark max is set to brushless mode but connected to a brushed motor (or in brushed mode for a BLDC motor)

Unfortunately none of these seem to be the case.

I tried running the motor in both directions, and have checked and the CAN is programmed correctly. The SparkMax is also correctly configured for a brushed motor, which is correct. As for the bogus values, this is possible however I am not too sure how to account for this to make the system work.

I am in the REV hardware client, and even trying to send a voltage to the device from the SparkMax on there is not working. This leads me to think the wiring may be at fault. I am wondering if I possibly put the sensor wire from the actuator’s hall effect sensor into the wrong port on the SparkMax Data Port Breakout board. I was unsure whether to connect to the ANA pin or P6. Could this possibly be the issue? I am still tempted to believe it is a code problem, but I agree with your analysis that those would be the most likely things that are wrong.

If it’s not moving when commanded from the hardware client, it’s likely an electrical issue. That’s fairly out of my wheelhouse at this point, but you could try disconnecting the motor controller and measuring the output voltage with a multimeter to check that the everything up to (and including) the spark is correct

I tried to switch the pin for the sensor wire and this changed nothing.

Nothing in the wiring seems incorrect, I even tried switching the sensor pin and still nothing. I tried a different port on my PDH, which was one that was working for another motor I had on it a minute ago, and still nothing worked, which brings me back to thinking it is a programming issue unfortunately.

Also to note, it still did not work in the REV hardware client.

We don’t use Rev devices on our team, however, I would bet that Sam’s intuition is correct. For our motor controllers from CTRE, they provide a piece of software that can actuate the motors and verify the wiring is correct.

I’m assuming that’s what the Rev hardware client is, and if you can’t actuate with that software, it’s more than likely not a programming issue. Get your wiring to the point you can actuate with the Rev software, note what voltage it takes to extend vs. retract, etc.

Then the code will be easy.

Its hard to tell in the picture, but you have the yellow wire soldered to the “P6” pin on the breakout board, right? And nothing else except power (5V) and ground?

What is the expected signal coming back from the actuator? Is it a limit switch (near or far)? Or is that 1 of the 2 channels for a encoder? P6 is likely the wrong pin either way.

I see that yellow wire is labeled as Hall 1 and white isn’t connected at all. If its an encoder feedback, youll need both wires soldered to the A and B pins. If its a limit switch, you’d likely be better off wiring it to the FWD or REV limit pins.

I would would:
(a) connect an ordinary brushed motor and not your actuator to see what happens . Comment out everything that has to do with sensors.
(b) use a multimeter or oscilloscope to look at what’s happening electrically.

It is in fact an encoder feedback. I just rewired it as you explained, but it still appears to not be working in the REV hardware client, any other possible ideas? I also tested the actuator by just powering it from a power supply and it worked with no problem, so I believe that the encoder is still the problem. The SparkMax itself is indicating that it should be working correctly, as it is flashing the proper color for a brushed motor.

The wiring is now as follows:

It works now, turns out I was sending the voltage positive when it needed to be negative. You are a life saver!

Unfortunately it now appears to still be a coding error, as the functionality it still not working when I run the full system with my code.

Just to confirm, does it work correctly in the REV Hardware Client? Driving the motor (or moving the actuator manually) should generate a signal on those encoder wires, which should be readable in the hardware client as “position”. Make sure this moves in sync with the motor (positive motor output == increasing position counter)

It appears to be inconsistent. I am able to get it work in the REV client by changing either percent or voltage. Then I try to run my code (which does not work), and then went back to the REV client and it then does not work. After resetting power to the system, it then worked again in the REV client. Very confused.