Log in

View Full Version : Help with Errors


Team 3023
15-02-2016, 15:17
Hey, we are new to programming and when we run the code, we get this error.
ERROR Unhandled exception: java.lang.RuntimeException:
Code: -1029. HAL: Resource already allocated at [edu.wpi.first.wpilibj.hal.PWMJNI.allocatePWMChanne l(Native Method),
edu.wpi.first.wpilibj.PWM.initPWM(PWM.java:117),
edu.wpi.first.wpilibj.PWM.<init>(PWM.java:134),
edu.wpi.first.wpilibj.SafePWM.<init>(SafePWM.java:35),
edu.wpi.first.wpilibj.Talon.<init>(Talon.java:51),
org.usfirst.frc.team3023.robot.DriveTrain.<init>(DriveTrain.java:10),
org.usfirst.frc.team3023.robot.Robot.robotInit(Rob ot.java:122),
edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:72),
edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:241)]
We are wondering if anyone has a solution to this

kmodos
15-02-2016, 15:26
Hey, we are new to programming and when we run the code, we get this error.
ERROR Unhandled exception: java.lang.RuntimeException:
Code: -1029. HAL: Resource already allocated at [edu.wpi.first.wpilibj.hal.PWMJNI.allocatePWMChanne l(Native Method),
edu.wpi.first.wpilibj.PWM.initPWM(PWM.java:117),
edu.wpi.first.wpilibj.PWM.<init>(PWM.java:134),
edu.wpi.first.wpilibj.SafePWM.<init>(SafePWM.java:35),
edu.wpi.first.wpilibj.Talon.<init>(Talon.java:51),
org.usfirst.frc.team3023.robot.DriveTrain.<init>(DriveTrain.java:10),
org.usfirst.frc.team3023.robot.Robot.robotInit(Rob ot.java:122),
edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:72),
edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:241)]
We are wondering if anyone has a solution to this

You are trying to allocate the same PWM more than once.

TimTheGreat
15-02-2016, 15:43
You are trying to allocate the same PWM more than once.

For clarification, somewhere in your code you have

motor = Talon(0) //or a different number

then later in your code you have


motor = Talon(0)//or a different number, but same number as before


You can't assign two motor to the same PWM in code. If it so happens that you want to run two motors the exact same way (for a gearbox perhaps?) then you should use a pwm splitter (KOP I believe)

spacepenguine
15-02-2016, 22:57
I'm guessing you already fixed this problem with previous comments. An alternate to the PWM splitting in hardware is to map it in software. This can make life easier for your mechanical/electrical teams because they just plug each motor into a PWM slot and then you write the same value out multiple times in each software iteration:

init:
motor1 = Talon(0);
motor2 = Talon(1);

loop:
desiredMotor = 250;
motor1.Set(desiredMotor);
motor2.Set(desiredMotor);