virtual void SetUp() { m_outputA = new DigitalOutput(TestBench::kLoop2OutputChannel); m_outputB = new DigitalOutput(TestBench::kLoop1OutputChannel); m_indexOutput = new AnalogOutput(TestBench::kAnalogOutputChannel); m_outputA->Set(false); m_outputB->Set(false); m_encoder = new Encoder(TestBench::kLoop1InputChannel, TestBench::kLoop2InputChannel); m_indexAnalogTrigger = new AnalogTrigger(TestBench::kFakeAnalogOutputChannel); m_indexAnalogTrigger->SetLimitsVoltage(2.0, 3.0); m_indexAnalogTriggerOutput = m_indexAnalogTrigger->CreateOutput(AnalogTriggerType::kState); }
Counter::Counter(AnalogTrigger &trigger) { InitCounter(); SetUpSource(trigger.CreateOutput(AnalogTriggerOutput::kState)); ClearDownSource(); m_allocatedUpSource = true; }
xCounter::xCounter(AnalogTrigger &trigger) : m_upSource(NULL), m_downSource(NULL), m_counter(NULL), m_encodingType(k1X) { InitCounter(); SetUpSource(trigger.CreateOutput(AnalogTriggerOutput::kState)); ClearDownSource(); m_allocatedUpSource = true; }
Robot() { #if BUILD_VERSION == COMPETITION forkMotor = new CANTalon(CHAN_FORK_MOTOR); #else forkMotor = new CANJaguar(CHAN_FORK_MOTOR); #endif toothTrigger = new AnalogTrigger(CHAN_GTC); toothTrigger->SetLimitsRaw(ANALOG_TRIG_MIN, ANALOG_TRIG_MAX); gearToothCounter = new Counter(toothTrigger); forkLimitSwitchMin = new DigitalInput(CHAN_FORK_MIN_LS); forkLimitSwitchMax = new DigitalInput(CHAN_FORK_MAX_LS); joystick = new Joystick(CHAN_JS); }
Robot() { #if BUILD_VERSION == COMPETITION forkMotor = new CANTalon(CH_FORK_MOTOR); #else forkMotor = new CANJaguar(CH_FORK_MOTOR); #endif toothTrigger = new AnalogTrigger(CH_TOOTH_TRIGGER); toothTrigger->SetLimitsRaw(GEAR_TRIGGER_MIN, GEAR_TRIGGER_MAX); gearToothCounter = new Counter(toothTrigger); // aIn = new AnalogInput(CH_TOOTH_TRIGGER); forkLimitSwitchMin = new DigitalInput(CH_FORK_LS_MIN); forkLimitSwitchMax = new DigitalInput(CH_FORK_LS_MAX); dsBox = new Joystick(CH_JS); }
void TeleopInit() { // Initialize the encoder sampleEncoder = new Encoder(0, 1, false, Encoder::EncodingType::k4X); sampleEncoder->SetMaxPeriod(.1); sampleEncoder->SetMinRate(10); sampleEncoder->SetDistancePerPulse(5); sampleEncoder->SetReverseDirection(true); sampleEncoder->SetSamplesToAverage(7); // Initialize the joystick joystick = new Joystick(0); // Initialize the motor motor = new Victor(9); // Initialize the gear tooth counter toothTrigger = new AnalogTrigger(3); toothTrigger->SetLimitsRaw(250, 3600); gearToothCounter = new Counter(toothTrigger); // gearToothCounter->SetUpDownCounterMode(); }
/** * Create an object that represents one of the four outputs from an analog * trigger. * * Because this class derives from DigitalSource, it can be passed into routing * functions for Counter, Encoder, etc. * * @param trigger A pointer to the trigger for which this is an output. * @param outputType An enum that specifies the output on the trigger to * represent. */ AnalogTriggerOutput::AnalogTriggerOutput(const AnalogTrigger& trigger, AnalogTriggerType outputType) : m_trigger(trigger), m_outputType(outputType) { HALReport(HALUsageReporting::kResourceType_AnalogTriggerOutput, trigger.GetIndex(), outputType); }
/** * Set the down counting source to be an analog trigger. * @param analogTrigger The analog trigger object that is used for the Down Source * @param triggerType The analog trigger output that will trigger the counter. */ void Counter::SetDownSource(AnalogTrigger &analogTrigger, AnalogTriggerOutput::Type triggerType) { SetDownSource(analogTrigger.CreateOutput(triggerType)); m_allocatedDownSource = true; }