![]() |
AnalogChannel Already Allocated???
This year as part of our climber we want to hook up a Current Sensor to monitor when the motor hits the rung (to shut it off).
In my Subsystem I setup the sensor as an AnalogChannel on channel 1, However whenever I run said code it crashes and give a "Analog Channel 1 on Module 1 is already allocated. I have no idea why this is happening... Help is much appreciated!!!! I will post the important files below, need anymore and I will gladly post them too. Subsystem: Code:
/*Code:
package edu.wpi.first.wpilibj.templates.commands;Code:
/* |
Re: AnalogChannel Already Allocated???
In your posted code it's initializing to analog 2, but I assume that's either a typo or you put it in place for a test. If it says that analog 1 is already allocated, you must have another AnalogChannel in your code using that same port. It doesn't seem to be in your posted code, so you'll have to go through the rest of your code to check. Keep in mind that certain other things, like Gyros, also use AnalogChannels internally.
|
Re: AnalogChannel Already Allocated???
Oh yeah, I tried changing the port to see if it did the same thing (the port I used for the Current Sensor is the number that shows up in the error, always.)
There is only one other subsystem: SpikeLoad: Code:
/*RunSpike: Code:
/*Code:
/*Code:
package edu.wpi.first.wpilibj.templates;Code:
/*----------------------------------------------------------------------------*/ |
Re: AnalogChannel Already Allocated???
The problem here is that you are creating one instance of CurrentDetector for every instance of CommandBase.
Code:
// Create a single static instance of all of your subsystemsEach time you create a new instance of CurrentDetector, it tries to allocate Analog Channel 2. The error you are getting is that the channel is being allocated multiple times. To fix this problem, you should make the instances of CurrentDetector and SpikeLoad static: Code:
// Create a single static instance of all of your subsystems |
Re: AnalogChannel Already Allocated???
Thank you! I knew I was missing something VERY simple, something I normally do instinctively. ::ouch::
|
| All times are GMT -5. The time now is 10:13. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi