コード例 #1
0
/**
 * 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;
}
コード例 #2
0
ファイル: CANJaguar.cpp プロジェクト: errorcodexero/porting
/**
 * Get the recently set outputValue setpoint.
 *
 * The scale and the units depend on the mode the Jaguar is in.
 * In PercentVbus Mode, the outputValue is from -1.0 to 1.0 (same as PWM Jaguar).
 * In Voltage Mode, the outputValue is in Volts.
 * In Current Mode, the outputValue is in Amps.
 * In Speed Mode, the outputValue is in Rotations/Minute.
 * In Position Mode, the outputValue is in Rotations.
 *
 * @return The most recently set outputValue setpoint.
 */
float CANJaguar::Get()
{
    uint8_t dataBuffer[8];
    uint8_t dataSize;

    switch(m_controlMode)
    {
    case kPercentVbus:
	getTransaction(LM_API_VOLT_SET, dataBuffer, &dataSize);
	if (dataSize == sizeof(int16_t))
	{
	    return unpackPercentage(dataBuffer);
	}
	break;
    case kSpeed:
	getTransaction(LM_API_SPD_SET, dataBuffer, &dataSize);
	if (dataSize == sizeof(int32_t))
	{
	    return unpackFXP16_16(dataBuffer);
	}
	break;
    case kPosition:
	getTransaction(LM_API_POS_SET, dataBuffer, &dataSize);
	if (dataSize == sizeof(int32_t))
	{
	    return unpackFXP16_16(dataBuffer);
	}
	break;
    case kCurrent:
	getTransaction(LM_API_ICTRL_SET, dataBuffer, &dataSize);
	if (dataSize == sizeof(int16_t))
	{
	    return unpackFXP8_8(dataBuffer);
	}
	break;
    case kVoltage:
	getTransaction(LM_API_VCOMP_SET, dataBuffer, &dataSize);
	if (dataSize == sizeof(int16_t))
	{
	    return unpackFXP8_8(dataBuffer);
	}
	break;
    }
    return 0.0;
}