Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   General Forum (http://www.chiefdelphi.com/forums/forumdisplay.php?f=16)
-   -   Help with Errors (http://www.chiefdelphi.com/forums/showthread.php?t=143908)

Team 3023 15-02-2016 15:17

Help with Errors
 
Hey, we are new to programming and when we run the code, we get this error.
Code:

ERROR Unhandled exception: java.lang.RuntimeException:
 Code: -1029. HAL: Resource already allocated at [edu.wpi.first.wpilibj.hal.PWMJNI.allocatePWMChannel(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(Robot.java:122),
 edu.wpi.first.wpilibj.IterativeRobot.startCompetition(IterativeRobot.java:72),
 edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:241)]

We are wondering if anyone has a solution to this

kmodos 15-02-2016 15:26

Re: Help with Errors
 
Quote:

Originally Posted by Team 3023 (Post 1540695)
Hey, we are new to programming and when we run the code, we get this error.
Code:

ERROR Unhandled exception: java.lang.RuntimeException:
 Code: -1029. HAL: Resource already allocated at [edu.wpi.first.wpilibj.hal.PWMJNI.allocatePWMChannel(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(Robot.java:122),
 edu.wpi.first.wpilibj.IterativeRobot.startCompetition(IterativeRobot.java:72),
 edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java: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

Re: Help with Errors
 
Quote:

Originally Posted by kmodos (Post 1540699)
You are trying to allocate the same PWM more than once.

For clarification, somewhere in your code you have
Code:

motor = Talon(0) //or a different number
then later in your code you have

Code:

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

Re: Help with Errors
 
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:

Code:

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

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



All times are GMT -5. The time now is 07:45.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi