Exemple #1
0
        /// <summary>
        /// Sends a new set of settings to the device, to be written to flash.
        /// This takes about 26 ms.
        /// </summary>
        public unsafe void setSmcSettings(SmcSettings settings)
        {
            SmcSettingsStruct settingsStruct = settings.convertToStruct();

            try
            {
                controlTransfer(0x40, (byte)SmcRequest.SetSettings, 0, 0, &settingsStruct, (UInt16)sizeof(SmcSettingsStruct));
            }
            catch (Exception exception)
            {
                throw new Exception("There was an error writing settings to the device.", exception);
            }
        }
Exemple #2
0
        internal SmcSettingsStruct convertToStruct()
        {
            SmcSettingsStruct s = new SmcSettingsStruct();

            // [Add-new-settings-here]
            s.neverSuspend          = this.neverSuspend;
            s.uartResponseDelay     = this.uartResponseDelay;
            s.useFixedBaudRate      = this.useFixedBaudRate;
            s.disableSafeStart      = this.disableSafeStart;
            s.fixedBaudRateRegister = Smc.convertBpsToBaudRegister(this.fixedBaudRateBps);
            s.speedUpdatePeriod     = this.speedUpdatePeriod;
            s.commandTimeout        = this.commandTimeout;
            s.serialDeviceNumber    = this.serialDeviceNumber;
            s.crcMode              = this.crcMode;
            s.overTempMin          = this.overTempMin;
            s.overTempMax          = this.overTempMax;
            s.inputMode            = this.inputMode;
            s.pwmMode              = this.pwmMode;
            s.pwmPeriodFactor      = this.pwmPeriodFactor;
            s.mixingMode           = this.mixingMode;
            s.minPulsePeriod       = this.minPulsePeriod;
            s.maxPulsePeriod       = this.maxPulsePeriod;
            s.rcTimeout            = this.rcTimeout;
            s.ignorePotDisconnect  = this.ignorePotDisconnect;
            s.tempLimitGradual     = this.tempLimitGradual;
            s.consecGoodPulses     = this.consecGoodPulses;
            s.motorInvert          = this.motorInvert;
            s.speedZeroBrakeAmount = this.speedZeroBrakeAmount;
            s.ignoreErrLineHigh    = this.ignoreErrLineHigh;
            s.vinMultiplierOffset  = this.vinMultiplierOffset;
            s.lowVinShutoffTimeout = this.lowVinShutoffTimeout;
            s.lowVinShutoffMv      = this.lowVinShutoffMv;
            s.lowVinStartupMv      = this.lowVinStartupMv;
            s.highVinShutoffMv     = this.highVinShutoffMv;
            s.serialMode           = this.serialMode;
            s.rc1           = this.rc1.convertToStruct();
            s.rc2           = this.rc2.convertToStruct();
            s.analog1       = this.analog1.convertToStruct();
            s.analog2       = this.analog2.convertToStruct();
            s.forwardLimits = this.forwardLimits.convertToStruct();
            s.reverseLimits = this.reverseLimits.convertToStruct();
            return(s);
        }
Exemple #3
0
 internal SmcSettings(SmcSettingsStruct s)
 {
     // [Add-new-settings-here]
     this.neverSuspend         = s.neverSuspend;
     this.uartResponseDelay    = s.uartResponseDelay;
     this.useFixedBaudRate     = s.useFixedBaudRate;
     this.disableSafeStart     = s.disableSafeStart;
     this.fixedBaudRateBps     = Smc.convertBaudRegisterToBps(s.fixedBaudRateRegister);
     this.speedUpdatePeriod    = s.speedUpdatePeriod;
     this.commandTimeout       = s.commandTimeout;
     this.serialDeviceNumber   = s.serialDeviceNumber;
     this.crcMode              = s.crcMode;
     this.overTempMin          = s.overTempMin;
     this.overTempMax          = s.overTempMax;
     this.inputMode            = s.inputMode;
     this.pwmMode              = s.pwmMode;
     this.pwmPeriodFactor      = s.pwmPeriodFactor;
     this.mixingMode           = s.mixingMode;
     this.minPulsePeriod       = s.minPulsePeriod;
     this.maxPulsePeriod       = s.maxPulsePeriod;
     this.rcTimeout            = s.rcTimeout;
     this.ignorePotDisconnect  = s.ignorePotDisconnect;
     this.tempLimitGradual     = s.tempLimitGradual;
     this.consecGoodPulses     = s.consecGoodPulses;
     this.motorInvert          = s.motorInvert;
     this.speedZeroBrakeAmount = s.speedZeroBrakeAmount;
     this.ignoreErrLineHigh    = s.ignoreErrLineHigh;
     this.vinMultiplierOffset  = s.vinMultiplierOffset;
     this.lowVinShutoffTimeout = s.lowVinShutoffTimeout;
     this.lowVinShutoffMv      = s.lowVinShutoffMv;
     this.lowVinStartupMv      = s.lowVinStartupMv;
     this.highVinShutoffMv     = s.highVinShutoffMv;
     this.serialMode           = s.serialMode;
     this.rc1           = new SmcChannelSettings(s.rc1);
     this.rc2           = new SmcChannelSettings(s.rc2);
     this.analog1       = new SmcChannelSettings(s.analog1);
     this.analog2       = new SmcChannelSettings(s.analog2);
     this.forwardLimits = new SmcMotorLimits(s.forwardLimits);
     this.reverseLimits = new SmcMotorLimits(s.reverseLimits);
 }
Exemple #4
0
 internal SmcSettingsStruct convertToStruct()
 {
     SmcSettingsStruct s = new SmcSettingsStruct();
     // [Add-new-settings-here]
     s.neverSuspend = this.neverSuspend;
     s.uartResponseDelay = this.uartResponseDelay;
     s.useFixedBaudRate = this.useFixedBaudRate;
     s.disableSafeStart = this.disableSafeStart;
     s.fixedBaudRateRegister = Smc.convertBpsToBaudRegister(this.fixedBaudRateBps);
     s.speedUpdatePeriod = this.speedUpdatePeriod;
     s.commandTimeout = this.commandTimeout;
     s.serialDeviceNumber = this.serialDeviceNumber;
     s.crcMode = this.crcMode;
     s.overTempMin = this.overTempMin;
     s.overTempMax = this.overTempMax;
     s.inputMode = this.inputMode;
     s.pwmMode = this.pwmMode;
     s.pwmPeriodFactor = this.pwmPeriodFactor;
     s.mixingMode = this.mixingMode;
     s.minPulsePeriod = this.minPulsePeriod;
     s.maxPulsePeriod = this.maxPulsePeriod;
     s.rcTimeout = this.rcTimeout;
     s.ignorePotDisconnect = this.ignorePotDisconnect;
     s.tempLimitGradual = this.tempLimitGradual;
     s.consecGoodPulses = this.consecGoodPulses;
     s.motorInvert = this.motorInvert;
     s.speedZeroBrakeAmount = this.speedZeroBrakeAmount;
     s.ignoreErrLineHigh = this.ignoreErrLineHigh;
     s.vinMultiplierOffset = this.vinMultiplierOffset;
     s.lowVinShutoffTimeout = this.lowVinShutoffTimeout;
     s.lowVinShutoffMv = this.lowVinShutoffMv;
     s.lowVinStartupMv = this.lowVinStartupMv;
     s.highVinShutoffMv = this.highVinShutoffMv;
     s.serialMode = this.serialMode;
     s.rc1 = this.rc1.convertToStruct();
     s.rc2 = this.rc2.convertToStruct();
     s.analog1 = this.analog1.convertToStruct();
     s.analog2 = this.analog2.convertToStruct();
     s.forwardLimits = this.forwardLimits.convertToStruct();
     s.reverseLimits = this.reverseLimits.convertToStruct();
     return s;
 }
Exemple #5
0
 internal SmcSettings(SmcSettingsStruct s)
 {
     // [Add-new-settings-here]
     this.neverSuspend = s.neverSuspend;
     this.uartResponseDelay = s.uartResponseDelay;
     this.useFixedBaudRate = s.useFixedBaudRate;
     this.disableSafeStart = s.disableSafeStart;
     this.fixedBaudRateBps = Smc.convertBaudRegisterToBps(s.fixedBaudRateRegister);
     this.speedUpdatePeriod = s.speedUpdatePeriod;
     this.commandTimeout = s.commandTimeout;
     this.serialDeviceNumber = s.serialDeviceNumber;
     this.crcMode = s.crcMode;
     this.overTempMin = s.overTempMin;
     this.overTempMax = s.overTempMax;
     this.inputMode = s.inputMode;
     this.pwmMode = s.pwmMode;
     this.pwmPeriodFactor = s.pwmPeriodFactor;
     this.mixingMode = s.mixingMode;
     this.minPulsePeriod = s.minPulsePeriod;
     this.maxPulsePeriod = s.maxPulsePeriod;
     this.rcTimeout = s.rcTimeout;
     this.ignorePotDisconnect = s.ignorePotDisconnect;
     this.tempLimitGradual = s.tempLimitGradual;
     this.consecGoodPulses = s.consecGoodPulses;
     this.motorInvert = s.motorInvert;
     this.speedZeroBrakeAmount = s.speedZeroBrakeAmount;
     this.ignoreErrLineHigh = s.ignoreErrLineHigh;
     this.vinMultiplierOffset = s.vinMultiplierOffset;
     this.lowVinShutoffTimeout = s.lowVinShutoffTimeout;
     this.lowVinShutoffMv = s.lowVinShutoffMv;
     this.lowVinStartupMv = s.lowVinStartupMv;
     this.highVinShutoffMv = s.highVinShutoffMv;
     this.serialMode = s.serialMode;
     this.rc1 = new SmcChannelSettings(s.rc1);
     this.rc2 = new SmcChannelSettings(s.rc2);
     this.analog1 = new SmcChannelSettings(s.analog1);
     this.analog2 = new SmcChannelSettings(s.analog2);
     this.forwardLimits = new SmcMotorLimits(s.forwardLimits);
     this.reverseLimits = new SmcMotorLimits(s.reverseLimits);
 }