transceiver: rework digital gain settings
The output of the modulator or resampler is scaled and converted from floating point to fixed point. The scaling factor is the leftover dB in RF attention (relative to max transmit power), which is handled prior to the integer conversion. This should work across all daughterboards and non-UHD installations. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
This commit is contained in:
parent
b7c09bba14
commit
055af67a4e
|
@ -58,7 +58,7 @@ RadioInterface::RadioInterface(RadioDevice *wUsrp,
|
|||
receiveOffset = wReceiveOffset;
|
||||
samplesPerSymbol = wSamplesPerSymbol;
|
||||
mClock.set(wStartTime);
|
||||
|
||||
powerScaling = 1.0;
|
||||
}
|
||||
|
||||
RadioInterface::~RadioInterface(void) {
|
||||
|
@ -82,7 +82,12 @@ double RadioInterface::fullScaleOutputValue(void) {
|
|||
|
||||
void RadioInterface::setPowerAttenuation(double atten)
|
||||
{
|
||||
usrp->setTxGain(usrp->maxTxGain() - atten);
|
||||
double HWatten = usrp->setTxGain(usrp->maxTxGain() - atten);
|
||||
atten -= HWatten;
|
||||
if (atten < 1.0)
|
||||
powerScaling = 1.0;
|
||||
else
|
||||
powerScaling = 1.0 / sqrt(pow(10, (atten / 10.0)));
|
||||
}
|
||||
|
||||
short *RadioInterface::USRPifyVector(signalVector &wVector)
|
||||
|
@ -150,8 +155,7 @@ void RadioInterface::pushBuffer(void) {
|
|||
delete inputVector;
|
||||
|
||||
// Set transmit gain and power here.
|
||||
scaleVector(*resampledVector,13500.0); ///2.25); // this gets 2W out of 3318PA at 885Mhz
|
||||
//scaleVector(*resampledVector,100.0);
|
||||
scaleVector(*resampledVector, powerScaling * usrp->fullScaleInputValue());
|
||||
|
||||
short *resampledVectorShort = USRPifyVector(*resampledVector);
|
||||
|
||||
|
|
|
@ -142,6 +142,8 @@ private:
|
|||
|
||||
bool mOn; ///< indicates radio is on
|
||||
|
||||
double powerScaling;
|
||||
|
||||
/** format samples to USRP */
|
||||
short *USRPifyVector(signalVector &wVector);
|
||||
|
||||
|
|
|
@ -513,7 +513,7 @@ void Transceiver::driveControl()
|
|||
sprintf(response,"RSP SETPOWER 1 %d",dbPwr);
|
||||
else {
|
||||
mPower = dbPwr;
|
||||
mRadioInterface->setPowerAttenuation(pow(10.0,dbPwr/10.0));
|
||||
mRadioInterface->setPowerAttenuation(dbPwr);
|
||||
sprintf(response,"RSP SETPOWER 0 %d",dbPwr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,11 +110,11 @@ double RadioInterface::fullScaleOutputValue(void) {
|
|||
void RadioInterface::setPowerAttenuation(double atten)
|
||||
{
|
||||
double HWatten = mRadio->setTxGain(mRadio->maxTxGain() - atten);
|
||||
atten -= (-HWatten);
|
||||
atten -= HWatten;
|
||||
if (atten < 1.0)
|
||||
powerScaling = 1.0;
|
||||
else
|
||||
powerScaling = 1.0/sqrt(atten);
|
||||
powerScaling = 1.0 / sqrt(pow(10, (atten / 10.0)));
|
||||
}
|
||||
|
||||
short *RadioInterface::radioifyVector(signalVector &wVector, short *retVector, double scale, bool zeroOut)
|
||||
|
|
Reference in New Issue