Exemple #1
0
        private static void fixMotorLimits(SmcMotorLimits ml, string directionName, List <String> warnings)
        {
            if (ml.maxSpeed > 0 && ml.startingSpeed > ml.maxSpeed)
            {
                warnings.Add("The " + directionName + " max speed was non-zero and smaller than the " + directionName + " starting speed.  " +
                             "The " + directionName + " max speed will be changed to 0 and the motor will not be " +
                             "able to drive in the " + directionName + " direction.");
                ml.maxSpeed = 0;
            }

            if (ml.maxSpeed > 3200)
            {
                warnings.Add("The " + directionName + " max speed was greater than 3200 (100%) so it will be changed to 3200.");
                ml.maxSpeed = 3200;
            }

            if (ml.maxAcceleration > 3200)
            {
                warnings.Add("The " + directionName + " max acceleration was greater than 3200 so it will be changed to 3200.");
                ml.maxAcceleration = 3200;
            }

            if (ml.maxDeceleration > 3200)
            {
                warnings.Add("The " + directionName + " max deceleration was greater than 3200 so it will be changed to 3200.");
                ml.maxDeceleration = 3200;
            }
        }
Exemple #2
0
        /// <summary>
        /// Compares this object to another to see if they have the same values.
        /// </summary>
        public override bool Equals(object x)
        {
            SmcMotorLimits s = x as SmcMotorLimits;

            if (s == null)
            {
                return(false);
            }
            return(this.convertToStruct().Equals(s.convertToStruct()));
        }
Exemple #3
0
 private static void parseLimits(Tag tag, string name, SmcMotorLimits ml, List <string> warnings)
 {
     if (assertChild(tag, name, warnings))
     {
         Tag limitsTag = tag.children[name];
         parseU16(limitsTag, "MaxSpeed", ref ml.maxSpeed, warnings);
         parseU16(limitsTag, "MaxAcceleration", ref ml.maxAcceleration, warnings);
         parseU16(limitsTag, "MaxDeceleration", ref ml.maxDeceleration, warnings);
         parseU16(limitsTag, "BrakeDuration", ref ml.brakeDuration, warnings);
         parseU16(limitsTag, "StartingSpeed", ref ml.startingSpeed, warnings);
     }
 }
Exemple #4
0
        /// <summary>
        /// Constructs a new SmcSettings object that has the default settings for a particular product.
        /// </summary>
        /// <param name="productId">The product ID of the device.  This determines the initial value of
        /// some product-dependent parameters like highVinShutoffMv.  Pass this argument as 0 if the
        /// product ID is unknown at this time.
        /// </param>
        public SmcSettings(UInt16 productId)
        {
            rc1           = SmcChannelSettings.defaultRCSettings();
            rc2           = SmcChannelSettings.defaultRCSettings();
            analog1       = SmcChannelSettings.defaultAnalogSettings();
            analog2       = SmcChannelSettings.defaultAnalogSettings();
            forwardLimits = new SmcMotorLimits();
            reverseLimits = new SmcMotorLimits();

            if (productId == 0x99 || productId == 0x9D)
            {
                // For the versions with 40V MOSFETs:
                this.highVinShutoffMv = 35000;
            }
            else
            {
                // For the versions with 30V MOSFETs:
                this.highVinShutoffMv = 25000;
            }
        }
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);
 }
Exemple #6
0
 private static void WriteElementMotorLimits(this XmlWriter writer, String localName, SmcMotorLimits ml)
 {
     writer.WriteStartElement(localName);
     writer.WriteElementU32("MaxSpeed", ml.maxSpeed);
     writer.WriteElementU32("MaxAcceleration", ml.maxAcceleration);
     writer.WriteElementU32("MaxDeceleration", ml.maxDeceleration);
     writer.WriteElementU32("BrakeDuration", ml.brakeDuration);
     writer.WriteElementU32("StartingSpeed", ml.startingSpeed);
     writer.WriteEndElement();
 }
Exemple #7
0
 private static void WriteElementMotorLimits(this XmlWriter writer, String localName, SmcMotorLimits ml)
 {
     writer.WriteStartElement(localName);
     writer.WriteElementU32("MaxSpeed", ml.maxSpeed);
     writer.WriteElementU32("MaxAcceleration", ml.maxAcceleration);
     writer.WriteElementU32("MaxDeceleration", ml.maxDeceleration);
     writer.WriteElementU32("BrakeDuration", ml.brakeDuration);
     writer.WriteElementU32("StartingSpeed", ml.startingSpeed);
     writer.WriteEndElement();
 }
Exemple #8
0
 private static void parseLimits(Tag tag, string name, SmcMotorLimits ml, List<string> warnings)
 {
     if (assertChild(tag, name, warnings))
     {
         Tag limitsTag = tag.children[name];
         parseU16(limitsTag, "MaxSpeed", ref ml.maxSpeed, warnings);
         parseU16(limitsTag, "MaxAcceleration", ref ml.maxAcceleration, warnings);
         parseU16(limitsTag, "MaxDeceleration", ref ml.maxDeceleration, warnings);
         parseU16(limitsTag, "BrakeDuration", ref ml.brakeDuration, warnings);
         parseU16(limitsTag, "StartingSpeed", ref ml.startingSpeed, warnings);
     }
 }
Exemple #9
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 #10
0
        /// <summary>
        /// Constructs a new SmcSettings object that has the default settings for a particular product.
        /// </summary>
        /// <param name="productId">The product ID of the device.  This determines the initial value of
        /// some product-dependent parameters like highVinShutoffMv.  Pass this argument as 0 if the
        /// product ID is unknown at this time.
        /// </param>
        public SmcSettings(UInt16 productId)
        {
            rc1 = SmcChannelSettings.defaultRCSettings();
            rc2 = SmcChannelSettings.defaultRCSettings();
            analog1 = SmcChannelSettings.defaultAnalogSettings();
            analog2 = SmcChannelSettings.defaultAnalogSettings();
            forwardLimits = new SmcMotorLimits();
            reverseLimits = new SmcMotorLimits();

            if (productId == 0x99 || productId == 0x9D)
            {
                // For the versions with 40V MOSFETs:
                this.highVinShutoffMv = 35000;
            }
            else
            {
                // For the versions with 30V MOSFETs:
                this.highVinShutoffMv = 25000;
            }
        }
Exemple #11
0
        private static void fixMotorLimits(SmcMotorLimits ml, string directionName, List<String> warnings)
        {
            if (ml.maxSpeed > 0 && ml.startingSpeed > ml.maxSpeed)
            {
                warnings.Add("The " + directionName + " max speed was non-zero and smaller than the " + directionName + " starting speed.  " +
                    "The " + directionName + " max speed will be changed to 0 and the motor will not be " +
                    "able to drive in the " + directionName + " direction.");
                ml.maxSpeed = 0;
            }

            if (ml.maxSpeed > 3200)
            {
                warnings.Add("The " + directionName + " max speed was greater than 3200 (100%) so it will be changed to 3200.");
                ml.maxSpeed = 3200;
            }

            if (ml.maxAcceleration > 3200)
            {
                warnings.Add("The " + directionName + " max acceleration was greater than 3200 so it will be changed to 3200.");
                ml.maxAcceleration = 3200;
            }

            if (ml.maxDeceleration > 3200)
            {
                warnings.Add("The " + directionName + " max deceleration was greater than 3200 so it will be changed to 3200.");
                ml.maxDeceleration = 3200;
            }
        }