Exemple #1
0
/**
 * @return The voltage being output by the Talon, in Volts.
 */
float CANTalon::GetOutputVoltage() const {
  int throttle11;
  CTR_Code status = m_impl->GetAppliedThrottle(throttle11);
  float voltage = GetBusVoltage() * (float(throttle11) / 1023.0);
  if (status != CTR_OKAY) {
    wpi_setErrorWithContext(status, getHALErrorMessage(status));
  }
  return voltage;
}
/**
 * Get the voltage being output from the motor terminals of the Jaguar.
 * 
 * @return The output voltage in Volts.
 */
float CANJaguar::GetOutputVoltage()
{
	UINT8 dataBuffer[8];
	UINT8 dataSize;
	float busVoltage;

	// Read the bus voltage first so we can return units of volts
	busVoltage = GetBusVoltage();
	// Then read the volt out which is in percentage of bus voltage units.
	getTransaction(LM_API_STATUS_VOLTOUT, dataBuffer, &dataSize);
	if (dataSize == sizeof(INT16))
	{
		return busVoltage * unpackPercentage(dataBuffer);
	}
	return 0.0;
}
bool BusVoltageCheck(void)
{
 bool Fail = false;
 // Die Überwachung auf Busspannungsausfall ist zweigeteilt:
 // - Unterschreitung einer absoluten Mindestspannung auf dem Bus
 // - Absinken der Busspannung unter ein Level, wo ein Halten der Mindestreserve für Schaltaktionen bei
 //   Busspannungsausfall nicht mehr sichergestellt ist.
 if (GetBusVoltage() < (int)MINUBUSVOLTAGEFALLING)
  Fail = true;
 // Im Disable-Zustand oder während MeasMode liefert BusVoltageFailRailLevel() keine sinnvollen Ergebnisse,
 // da die Energiemenge noch unbekannt, die für einen Schaltvorgang notwendig ist.
 if (relay.IsOperating())
 {
  if (relay.BusVoltageFailRailLevel())
  {
   Fail = true;
  }
 }
 if (Fail)
 {
  relay.BusVoltageFailed();
 }
 return not Fail;
}
/*
 * Rückgabewert True, wenn die Busspannung nicht mehr ausreichend ist, um die Speicherrail auf
 * Mindestwert (in Bezug auf BusVoltageFailSwitching) zu laden. Dies ist dann bereits ein
 * BrownOut-Kriterium.
 */
bool Relay::BusVoltageFailRailLevel(void)
{
 int zw = max(GetBusVoltage() - ADCRAILVOLTAGELOSS, 0);
 return ((unsigned)(zw*zw) < (SingleSwitchEnergy*__builtin_popcount(BusVFailMask)+ADC12VOLTSQR));
}