Vex Note: Motor power required to launch balls

April 23, 2015

The new vex game , Nothing but Net, could utilize a design similar to a two wheel tennis ball launcher.

Question: how many motors are required on the launcher?

The after a launch, the energy lost from the spinning wheels is transformed into ball kinetic energy and heat due to friction and ball compression.

After each shot the wheels are brought back to initial spin speed by the power of the motors.   The maximum time allowed for respinning is the cycle time of the firing sequence.    Lets take a look at the Vex game derived requirements:

Ball mass, m = 60 grams

Ball launch Speed, v =  6 m/s

Ball kinetic energy:K =  1/2*mass*v^2 = .5*.06*6^2 = 1.08 joules

Energy loss due to compression : E_c

Energy loss due to friction :  E_f

Time between shots: 1 sec

Average power required  p_avg = ( K + E_c + E_f)/ t

Force on ball during acceleration:

F =  d(m*v)/dt    or the change in momentum of the ball over the time of acceleration., dt.

dt can be approximated as the contact distance / tangential speed of the wheel , v.

The contact distance is about 3 cm so

dt= .03/6= .005 s

d(m*v) = .06*6 = .36 kg*m/s

hence F = .36/.005 =   72 newtons

Normal force on ball F_n = F/u_friction .    The normal (compression)  force on the ball is then

F_n = 72 newtons  assuming a u_friction = 1 which is possible with a sticky wheel.

The assumed  compression distance is about 1 in or 2.54 cm.  (To be verified later)

Hence Ec = F_n*d/2 = 72*.0254/2 = .91 joules. 

With good design, the friction loss in the drive train can be small (maybe .1 joules) so lets assume that E_c + E_f  are about equal to the K= 1.06 j so

p_avg = 2*K/t = 1.06*2= 2.12 watts   or 1.06 watts per motor.

We know the vex 393 motors have a max power = max_speed*max_torque/4 or about 4.5 watts  but they will overheat if run continuously at this power.   The PTC fuses will stop the motors if they run continuously with currents equivalent to more than  25% maximum torque (speeds less than 75% max speed).    At this operating point, the motors only deliver  3/4 max power or 3.4 watts.

There are also friction losses from the teeth of the spur gears.   I usually assume about 5% per 5:1 ratio.    A shooter wheel with a 25:1 gearing would lose 10% torque or energy at a given speed.

So the net power to the shooter wheel will be  .9*3.4 =  3.0 watts which is more than the 1 watt that we require.         

Extra friction?    

If the gear train has pressure on the axles from bearing blocks and possibly the collars are too tight so the wheels slow down quickly when coasting with motors disconnected, then over heating can easily occur.   e.g.  if friction uses up just 15% of the available torque, the motors will have to provide about 1 watt extra. which cuts our margin considerably.

Faster shot rate?

We assumed 1 shot per second…what happens with 2 shots per second….   Well, the power requirements almost double since we are using twice as much energy per unit time.    We would likely have to add extra motors.


Proposed method of incorporating PTC resistance into my Vex motor models

November 24, 2012

rev 11/25/2012

The motor model uses two resistances: motor resistance Rm and  series resistance Rs.   These are used to compute time constants and current contstants for generating waveforms for the Hbridge ON phase and OFF phases.

tau_ON = L/(Rm + Rs)

tau_OFF = L/(Rm)

Also the steady state current constants are affected by resistances:

i_ss_ON = (V_battery – V_bemf)/(Rm +Rs)

i_ss_OFF = -(V_diode + Vbemf)/Rm

These constants basically assume that the PTC resistances are incorporated into Rs during the ON phase and negligible for the OFF phase.   Typically, Rs that best fits test data is .3 ohms according to Jpearman.   The Rm  is 1.5 ohms for a 393 and 2.5 for a 269 motor.

Incorporating the PTC requires an understanding of the Vex power distribution schematic shown below:(Click to expand)

The two PTC resistances involved are the Cortex Rptc_c and the motor PTC resistance Rptcm.  They affect the controller voltage and the time constants of the H-bridge.

Voltage Drop: Rptc_c causes a voltage drop between V_battery measuring point and the controller.  The voltage drop is Rptc_c*i_1_5 where i_1_5 is the sum of the current draws from ports 1-5 on the cortex.  These currents have been assumed to be the average currents from each of the motors in the PTC monitor software.   This however is very conservative since the current draw from the battery is zero for a motor during the OFF phase of the PWM controller cycle.      For example, when the motor current of a 393 is at its safe current of .9 amps, the ON phase current is about 0.33 amps or 37% of i_m.

The current model  computes the average current per PWM cycle as

i_avg = i_ss_ON*duty_ON + i_ss_OFF*duty_OFF

where  i_ss_ON*duty_ON  is the average current over a PWM cycle caused by the ON PWM pulse.  This should be used in the computation of the cortex currents rather than the total motor current i_avg.


Vc = V_battery – Rptc_c*i_1_5

should be used as the input voltage to the current model rather than V_battery which we are using now.

Rptc_c for the HR16-400 is only 18 mohms.  Typically the maximum current for a cortex bank is from 3 motors at stall or 4.8*3 = 14.4 amps.   This can lead to a voltage drop of  .26 volts.       One might argue that Rptc_c effects can be ignored.

Time Constants: By inspection from the figure we can see that the series resistances in the controller-motor loop in series with the motor resistance Rm are slightly different for the ON and OFF phases.

R_s_ON = Rptcm + 2*Rwire +  2*Rfet.

R_s_OFF = Rptcm + 2*Rwire + Rfet.   (it has one less FET in its path)

The time constants are :

tau_OFF = L/(Rm + R_s_OFF)

tau_ON = L/(Rm + R_s_ON)

where :

Rwire is the wire resistance down stream of the controller.  The upstream wire resistance is assumed negligible.    1 foot of wire is assumed for each power and ground leg and at 10 mohms per ft, Rwire = 10 mohms.

Rfet is the ON source-drain resistance of the MOSFET.  This is about 20 mohms for both the high and low side MOSFETs.

Rptcm is the motor PTC reference resistance at 25 deg C.   For the 393 Rptcm = 140 mohms and for the 269 Rptcm = 110 mohms.

Plugging in to the above formulas for a 393 motor gives

R_s_OFF = 140 + 20 + 40 = 200 mohms (.2 ohms)

R_s_ON =  140 + 20 + 20 = 180 mohms (.18 ohms)

Since there is only 20 mohms difference and these are added to Rm which is 1500 mohms I would recommend using one time constant:

tau = tau_ON = tau_OFF = L/(Rm + R_s)   where R_s = 200 mohms.

Using a similar argument for the 269 we would have R_s = 170 mohms

Current constants:

The current constants are modified similar to the time constants:

i_ss_ON = (V_c – V_bemf)/(Rm +Rs_on)  …. using V_c rather than V_battery

i_ss_OFF = -(V_diode + Vbemf)/(Rm + Rs_off)

We can also use the approximation Rs_on = Rs_off = Rs  as we did for the time constants.


Having said all this , the differences discussed may or may not be noticible in the results and I wouldn’t be too uncomfortable keeping things the way they are since much of the testing done by Jpearman has shown adequate results with the present model.
Relevant links:

smart_PTC_monitor beta code release

August 31, 2012

Ok, I’ve got the RobotC code used in my smart_PTC_monitor developed to a point where I would let others play with it.   I originally used a single timed iterative loop that ran in the same task as  autonomous and user modes.  I decided to create a separate task that simplifies the user interface so normal programming can occur without any of my constraints.  When done, the user functions are easily inserted into my template to seamlessly add the PTC monitor protection capability.    The program is self documented with liberal commenting but I am sure people will have a lot of questions.   I am putting it out without fully testing all the functions to get early user feedback and if it proves to have utility, I will put out a more mature version that includes user feedback.

Please post your comments to the Vex forum thread where the program is introduced.   Thanks




Below is a copy of the introduction comments in the program:

//*************************************************************************************************************** // smart_PTC_monitor_template.beta.8.27.2012.c   Rev 0

// This program is an open source beta version of a competition template for Sack Attack.  It adds a task // called smart_PTC_monitor which uses current and PTC temperature models to manage a current_limiter function // which can keep hardware PTC fuses in the motors,cortex and power expander from ever tripping.

// Program Author: Chris Siegert aka Vamfun on the Vex forums. // see my blog:  for model details and vex forum threads on subject // email: // Mentor for team 599 Robodox and team 1508 Lancer Bots

// Teams are authorized to freely use this program , however, it is requested that improvements or additions be // shared with the Vex community via the vex forum.  Please acknowledge my work when appropriate.  Thanks

// Scope and limitations: // Program assumes that servo currents are zero.  If servo position is known, then currents can be modeled. // Testing has been limited to 393 motors and 3wire motors, however, the program handles  269 motors. // Periodic updates to the models will be made and posted on the Vex forum as more testing is done. // Program handles the Power Expander PTC when the ports are entered with provided #defines // All other motor ports are automatically configured to calculate the correct currents for each PTC

// Basic Instructions: // Write your program as you normally would.  When done, put your autonomous code in place of my_autonomous() // and your user code in place of my_user().  Then do a find and replace to change all the “motor” functions to // “motor_input” i.e.  motor[Left_motor] –> motor_input[Left_motor].

// Put all your encoder speed calculations into  void compute_speeds() function and assign speeds to M[port].speed variable. // You can read these speeds from the global array whenever you need them.  This loop runs at about 100ms update rate.

// Use a #define or switch to create a // PTC_monitor_engage boolean and set true to engage the monitor.

// Tell the program which ports are used by the Power Expander as shown in the example below: // #define PE_CH1  UNUSED // if used put port number …. i.e. PE_CH1  port1  else put the #define UNUSED

// #define PE_CH2  Right_drive_motor  //use setup names

// #define PE_CH3  port3  //use port name

// #define PE_CH4  1  // use integer = to port number -1.  This is motor port2

// Initialize the PTC temperatures using these #defines: // #define T_0_DEG_F  (72.) //Set robot ambient temperature here.  If you are in a hot gym…this might be 85 deg

// #define T_M  (100.) //100 deg C =Setpoint temperature for the PTC current monitor.

// Motor currents and PTC temperature data are held in a global state matrix M[] which is a structured array that contains // the motor PTC/current data in the first 10 elements (index 0 to 9) and the non motor PTC’s data in the next three elements. // M[10] , M[11] and M[12] pertain to the cortex1_5,cortex6_10 and power expander PTC states respectively.

// Program uses two update rates: The current_limiter updates at PTC_TASK_DELAY_MS which is 15ms // and the temperature calculations are set to run at about 6 times {PTC_TASK_DELAY_MS + subtasks delays) ~= 100ms. //****************************************************************************************************************

Derivation of formulas to estimate H bridge controller current (Vex, JAGUAR,Victor)

July 21, 2012

I Introduction:

In 2009 I spent a lot of time in a First Chief Delphi forum thread  with some motor experts figuring out why a JAGUAR controller was linear in speed with duty cycle and a Victor was non_linear.   An example of this phenomenon is shown here for a Vex 269 motor being driven by several types of controllers.   Data is from my Excel H_bridge model All controllers have basically the same design except for the PWM frequency.  The extremes are for the JAGUAR is 15k hz and the Victor 884 is 120 hz.

Turns out that the motor time constant tau = L/R (motor inductance/motor resistance)  relative to the PWM pulse period T is key to the phenomenon.  I call the ratio of these lamda = T/(L/R).

I developed some analytical models for this forum which can predict the waveforms and average currents with good accuracy for various types of controllers and I want to show the basic mathematical derivation in this post.   I have updated the equations to include the Vex controller which has a PWM frequency near 1250 hz which is in between the JAGUAR and the Victor 884.

It is assumed that the reader has a basic knowledge of how an H bridge works.  If not, there are many good references on the internet and I might suggest the following:

 Hbridge  Secrets

H bridge Wikipedia

The type of H bridge that I am assuming is often called a high side switcher  or  asynchronous sign magnitude H bridge.   Basically, for a given motor direction, two switches are used while the others remain open.

General note.. clicking on any figure will expand it to maximum size.

On the high side switcher, a lower switch  is closed and the upper switch  is driven by a PWM waveform and opens and closes with period T and duty cycle D.

When the PWM pulse is high, the ON current flows from the battery  through the motor as shown.

When the PWM pulse is low, the OFF phase current flows through the diode as shown.

II  H bridge Equivalent Circuit

The equivalent circuit for one motor direction of the H bridge is just a switch and a battery in series with system resistance R_s and a motor (This is modeled as an  inductor , resistor R , voltage source = V_bemf in series) as shown in the “Simplified DC motor switching model.”

There is also a diode that is across the motor to allow current to flow when the switch is opened. The switch opens and closes with a PWM drive with duty cycle D and  period T.

(click figure to expand)When the switch is closed current increases exponentially from its last value toward a steady state value of i_ss_on.   When the switch is opened, current decays through the diode toward i_ss_off.  If it reaches zero then current stops and remains at zero until the next on pulse.


We can write the differential equations for these two phases.   It is important to note that these equations are for the controller direction that puts a positive voltage across the motor.   When the motor is commanded in the opposite direction some sign changes must be made to the equations.   Where ever you see a V_b and a V_d  simply change the signs and the equations will be correct for the current.  The steady state speeds also require replacing i_free with -i_free.    These will be added in the software implementation by using the sign(command) which tests the sign of the command.   Duty is always positive and for Vex is defined as D =  abs(command/127) where the command ranges between -127 and + 127.

III ON phase Current

When the switch is closed, the voltage across the motor V_m = -V_d > 0 so the diode is reversed biased and i_d = 0 .  Using Ohms law  and the fact that i = i_L  ( no current is flowing through the diode in this phase) gives

0 = V_b – V_bemf – V_L   – i*(R +R_s).

But the voltage in the inductor V_L = L*di/dt    So we have a differential equation

di/dt = ( V_b – V_bemf – i*(R +R_s) )/L

In the steady state, di/dt–>0  so the steady state current

i_ss_on = (V_b – V_bemf)/(R +Rs)

Putting it in terms of motor time constant

di/dt = (i_ss_on – i)/tau_on   where tau_on = L/(R_s + R) .

The ON closed form solution of the differential equation can be shown to be

i_on =  i_0*exp(-t/tau_on)  + i_ss_0n *(1 – exp(-t/tau_on)) 

where  i_0 is the initial current.

At t = DT  the maximum occurs and using the substitution  lamda = T/tau_on  we can write

i_max = i_o*exp(-lamda*D) + i_ss_on*(1 – exp(-lamda*D))

IV OFF phase current

When the switch is opened current in the motor coil finds a path through the diode.

i_L = i_diode

0 = V_bemf + V_L + i_L*R  + V_d

Substituting for V_L = L*di_L/dt  gives the differential equation

di_L/dt =- (V_bemf + V_d  + i_L*R)/L        and

i_ss_off = -(V_d + Vbemf)/R             when di_L/dt –> o.

The OFF closed form solution is

i_off =  i_max* exp(- t’/tau_off) +  i_ss_off *(1 – exp(- t’/tau_off))

where again tau_off = L/R .    Here i_max is the maximum current of the ON phase which occurs at the exact point that the switch opens or at t = D*T so   i=max is the initial current for the OFF phase.    t’ is the time from the switch opening.   I. E.   t’ = t – D*T  for t> DT.

V Approximation for Vex motors

The  time constants  for the ON and OFF  phases are slightly different due to the addition of Rs during the switch ON phase.    I.e.  tau_on = L/(R+Rs)   and  tau_off = L/R.   For the Vex motors, Rs << R so the following equations will use the approximation  tau= L/R = tau_on =tau_ off.

VI Final Current Value,  i_final

During the OFF phase the current will decay to a final value of current.  The point  in time where it reaches it final value will be defined  t'(final) = D’T .   Substituting t’ = D’T  and lamda = T/tau  into i_off  equation gives

i_final  =  i_max*exp(- lamda*D’) + i_ss_off*(1 – exp(-lamda*D’)

VII Initial current i_0

A steady state solution requires that

i_0 = i_final

otherwise after a cycle is completed  the next initial condition will be different from the initial condition for the last cycle.

Using this equality and substituting i_max into the i_final equation gives

i_0 =( i_o*exp(-lamda*D) + i_ss_on*(1 – exp(-lamda*D))*exp(-lamda*D’) + i_ss_off*(1 – exp(-lamda*D’)

Solving for i_0 gives

i_0 = ( i_ss_on*(1 – exp(-lamda*D))*exp (-lamda*D’) + i_ss_off*(1 – exp(-lamda*D’))/(1 – exp(-lamda*D)*exp(-lamda*D’))

(Click to expand figures)

Recall as shown in this figure, the current can be continuous or discontinuous.

Case A: Continuous current

If the diode conducts during the whole OFF phase then steady state current requires i_0 = i_final and

D’ = 1-D .  That is i_final occurs exactly at the end of the period.  Substituting for D’ and i_final in the i_o equation gives

i_0 = ( i_ss_on*(1 – exp(-lamda*D))*exp (-lamda*(1-D))+ i_ss_off*(1 – exp(-lamda*1-D)))/(1 – exp(-lamda*D)*exp(-lamda*(1-D)))

Case B: Discontinuous current

In Case B, the current tries to reverse sign during the OFF phase but is clamped to zero by the diode for the remainder of the PWM period.   So both the final and initial currents are zero in the steady state.

i_final = i_0  = 0

With this constraint, we can solve the i_0 equation for D’ at the point where the waveform reaches 0.

0 =  i_ss_on*(1 – exp(-lamda*D))*exp (-lamda*D’) + i_ss_off*(1 – exp(-lamda*D’)

exp(-lamda*D’) =  -i_ss_off/(i_ss_0n*((1-exp(-lamda*D) – i_ss_off))

and taking the ln of both sides

D’ =  – ln( -i_ss_off/(i_ss_on*((1 – exp(-lamda*D) – i_ss_off)* lamda)

Or in terms of i_max,

 D’    =  – ln( -i_ss_off/(i_max – i_ss_off)* lamda)


Our primary interest in developing current equations is to determine an expression that can be used to control the long-term behavior of a motor relative to a slow PTC fuse or setting a the steady state speed for a robot.    What we want is the equivalent DC current over a cycle  which is the average current per cycle.   This is computed by integrating the area under the current response and dividing by a cycle time.  If the times are normalized to the controller period T then the average current

i_avg = Area_on + Area_off

where Area_on and Area_off are the areas under their respective current responses in the ON and OFF phases.  By integrating the i_on with respect to t and normalizing to the period T gives

Area_on = i_ss_on*D – (i_ss_on – i_0)*(1 – exp(-lamda*D)/lamda

Similarly for the off phase we have the same form except i_o for the off phase = i_max.

Area_off = i_ss_off*D – (i_ss_off – i_max)*(1 – exp(-lamda*D’)/lamda

Believe it or not  , the second term in the Area_on equation cancels the second term in the Area_off equation.   Both these terms can be related to i_max – i_0  by using the fact that i_o = i_final.   With some substitutions and math manipulations it can be shown that:

(i_ss_on – i_0)*(1 – exp(-lamda*D)   =  -(i_ss_off – i_max)*(1 – exp(-lamda*D’) = i_max – i_o.

This leaves

i_avg = i_ss_on*D + i_ss_off*D’ 

We can substitute for i_ss_on and i_ss_off and get i_avg in terms of voltages.

i_avg = (V_b – V_bemf)*D/R  – (V_d + V_bemf )*D’/R

For a given D  , D’ can vary from 0 to 1 – D  depending upon the value of D and lamda.   The current waveforms take on essentially three shapes:  rectangular, triangular  or exponential saw tooth shapes depending on how D’ is characterized.

XI   Vamfun rectangular approximation      lamda>>1 , D’= 0.

Under this condition the motor responds very quickly with respect to the PWM pulse.  It essentially reaches I_ss_on  and stays there for the duration of the ON pulse and quickly decays to zero during the OFF phase.   Thus the current waveform approaches a rectangular shape and so we can compute i_avg accurately with this formula when D’ = 0 :

i_avg = (V_b – V_bemf)*D/R

This leads to a steady state speed vs duty that is inversely proportional to duty.   We know that the free speed of a motor occurs when i_avg = i_free.  Rearranging the current equation with this equality gives

V_bemf(steady state)  = V_b – i_free*R/D      for    D>= i_free*R/V_b

= 0     for    D < i_free*R/V_b  

which says that if the current doesn’t exceed i_free then the drag torque holds the motor speed to zero.

This figure shows a typical rectangular waveform produced by a Victor 884 controller  ( PWM frequency = 120 hz , lamda = 30) controlling a Vex 269 motor. (click to expand)

This curve was generated with a Labview program I wrote which is a simple integration of the L R response to various duty cycle inputs.

X  Vamfun triangular approximation        lamda <<1     ,  D’ = 1 – D

This approximation occurs when the PWM frequency is much higher than the motor response frequency and many PWM cycles occur in one tau for the motor.    Both the ON and OFF phase waveforms are approximated by linear slopes and the waveform is triangular.     The approximate formula becomes

i_avg = (V_b – V_bemf)*D/R  – (V_d + V_bemf )*(1-D)/R   or collecting D terms

i_avg = (V_b +V_d)*D/R  – (V_d + V_bemf)/R 

This leads to a linear steady state speed vs duty  when i_avg = i_free.   I. E.

V_bemf(steady state) =  (V_b + V_d) *D    –  i_free*R  – V_d   

for  D    >  (i_avg*R  + V_d)/(V_b  +V_d)


V_bemf = 0.

This equation  becomes  the standard DC motor current model when V_d = o .

This linear speed response would be typical of a Vex 269 being driven by a TI  JAGUAR  controller  that operates with a PWM frequency of 15 kHz which makes lamda = .24 .  The JAGUAR controller is used in First robotic competitions.  It  produces  a typical triangular waveform as shown here (click to expand figure):

XI  Non extreme lamda produces exponential saw tooth:

This figure shows an example of an exponential saw tooth waveform produced by Vex controller (PWM frequency 1250 hz , lamda = 3) driving a Vex 269 motor with a .3 duty.      (click to expand)

Notice that the first trace which is the motor voltage has three distinct levels.  During the ON phase it equals V_b.  During the off phase while the diode is conducting it equals       -V_d and when the current goes to zero it then  reads the back emf voltage V_bemf.   During this period some controllers actually sample V_bemf to estimate motor speed without encoders.  If the diode always conducts like the previous figure, then the controller must periodically use a special pulse to sample V_bemf.

XII Computational Proceedure:

Ok, we have lots of formulas and here are the steps to put them to use.

0) Gather inputs: V_b,V_bemf,V_d, lamda, R, command

1) Compute the input duty D and direction dir

D = abs(command/127)

dir = sign(command)

2) Compute  i_ss_on and i_ss_off from known voltages.

i_ss_on = (V_b*dir – V_bemf)/R

i_ss_off = -(V_d*dir + V_bemf)/R

3) Compute i_0 and test if current is continuous or discontinuous.

i_0 = ( i_ss_on*(1 – exp(-lamda*D))*exp (-lamda*(1-D))+ i_ss_off*(1 – exp(-lamda*1-D)))/(1 – exp(-lamda*D)*exp(-lamda*(1-D)))

If the sign(i_0) is opposite the sign (i_ss_on).   I.e.

if( sign(i_0) *sign(i_ss_on) < 0 ) then  current is discontinuous and  set i_o = 0.

4)  Compute i_max

i_max = i_o*exp(-lamda*D) + i_ss_on*(1 – exp(-lamda*D))

5) Compute D’

if(discontinuous) then

D’    =  – ln( -i_ss_off/(i_max – i_ss_off)* lamda)


D’ = 1-D 

6) Compute i_avg

i_avg = i_ss_on*D + i_ss_off*D’

Thats it.   See link below for a RobotC implementation of these equations.

Related Links:

Vex 269 Current data based upon Excel Hbridge Model

proposed-method-of-incorporating-ptc-resistance-into-my-vex-motor-models/RobotC subroutine to compute Vex 269 motor currents


Vex threads:

Estimating 269 Motor Current based on H bridge models

Estimating motor current

Estimating the PTC t_trip and temperature using motor current (third try a charm)

July 18, 2012

1) Introduction:

The PTC temperature T(R) is very nonlinear with resistance.  The Steinhart-Hart equation is a widely used third-order approximation:


 There is a critical temperature  Tc above which the resistance increases dramatically and hence allows a PTC resistor to be used to limit current.  If we can calculate T(R) we could predict  the time to trip, t_trip, which is the time it takes the PTC to start from its present temperature T_init and reach Tc.  Here,  R would be high enough to shut down the circuit hence creating a thermal fuse.  The specifications for PTCs have  t_trip as a function of PTC current assuming you start at T_init = T_0 = 23 C  where T_0 is the ambient temperature.     This is easy to curve fit, but it doesn’t help us if the ambient temperature T_0 is different or we have previously heated up the PTC by running at high currents for a while and T_init > T_0.    It is possible to model the thermal response of the PTC to take into account the variation in initial conditions and ambient temperature.

This figure shows a close model match to published t_trip for a Bourne  (.9, 1.8) (I_hold, I_trip) PTC similar to the Vex PTC.  This is calculated at the standard T_0 with T_init = T0.

So I have a technique to model PTC currents and  t_trip .   Given some more lab tests with actual PTC installations I am fairly certain a working RobotC model can be synthesised for management of current .  Test data would be needed for the Cortex PTC which is the most likely fuse to trip when running 4 393 motors.

It is not clear exactly how we could use t_trip but it can be estimated in real-time by software with some TBD accuracy.

Software monitors could have the following functions:

i_amps =Compute motor current (Vb,speed,duty)

T = Compute PTC Temp (i_amps, T_0=ambient temperature)

t_trip = Compute time to trip(T, Tc = critical temperature)

duty_out = Current limiter( duty_in, i_amps, speed , t_trip)

The current limiter would look at t_trip… if it was shorter than  say 4 seconds, it would reduce the command duty_in to a safe value of duty_out for the motors.  When t_trip increased to say 10 seconds, the limit would be lifted.  This creates a hysteresis to allow some cooling before max commands are allowed.

Note: the i_amps calculation assumes that PTC resistance is constant.  As R rises with temperature, its effects should be included in  i_amps.   This can be done by having changing i_amps function to include a last temperature, T_last,  input:

i_amps = Compute motor current (Vb,speed, duty, T_last=last PTC temperature )

The equation for PTC R can be included in the Hbridge formulas.  It essentially has two effects: 1) decreases the voltage across the motor coil and also decreases the ON phase time constant speeding up the rise of current.

2) Calculating T(R)

Before going on, you might want to review some tutorials on PTC:

Thermistors Wikipedia

Tyco (I got R vs Temperature from Fig 7)

Epcos (I got C_p from here)

In addition here are the spec sheets for the PTCs

393 PTC HuiRui HR30-090

Bourne (Example MF-R090 .9 amp hold, 1.8 amp, I took t_trip data from this to match)

A quick review of  Wikipedia on Thermistors  suggests that Newton’s law of cooling can be used to compute the power flowing out of a  resistor.  This power  is proportional to the temperature difference between the ambient temperature T0 and  the resistor temperature T(R).

P_out = K*(T(R) – T0) where the temperatures are in degrees  Rankine and K is the dissipation constant in watts per deg C.

The power coming into the PTC  P_in = I_ptc*V_ptc where I_ptc is the current and V_ptc is the voltage drop across the PTC respectively.  In general we do not have a measure of the voltage across the PTC but we can calculate the voltage using ohms law  or  V_ptc = I_ptc*R .  So

PTC       P_in = I_ptc^2*R

If we know the specific heat of the PTC  at constant pressure ,C_p = delta Q/delta T , then the rate of change in temperature can be given by the equation

C_p*dT/dt = P_in – P_out

Here we have used the approximation that the heat absorbed = delta Q = dt*(P_in-P_out) and  delta T = dT.


dT/dt = 1/C_p*(I_ptc^2*R – K*(T – T0))  .

This is a first-order non-linear differential equation because R changes with T.   This can be solved with numerical integration but a closed form can be used if the equation is linearized.  Normally, R = R_0*exp(beta*(T-T_ref).     We can use a Taylor approximation to linearize this.

3. Linearization of R with T

Assume that R is linear function of T in the following form:

R  =  R_0* (1+m*(T -T_ref))  where m = the slope of a best fit line to a nonlinear R(T) curve vs T-Tref.  T_ref  and R_0 are the reference T that R_0 is specified at.   Figure 7 of this Tyco tutorial gives a typical curve of R vs T.

dT/dt = 1/C_p*(I_ptc^2*R_0*(1+m*(T -T_ref)) – K*(T – T_0))  .

expanding and collecting terms gives

dT/dt = 1/C_p*( I_ptc^2*R_o*(1-m*T_ref )+ K*T_0 – (K -I_ptc^2*R_0*m )*T)

Writing this in a simpler form gives the first order linear form:

***************** Linear now******************

dT/dt = (T_ss – T)/tau’


Where T_ss = ( I_ptc^2*R_o*(1-m*T_ref) + K*T_0) *tau’/C_p

and tau’ =tau/(1 -I_ptc^2*R_0*m *tau/C_p)

and tau = C_p/K

4. Finding t_trip

Getting T_trip is easy once we have a linear differential equation and know T_ss  and our current temperature T_init

The closed form solution of the differential equation is

T = T_ss + (I_init – T_ss)*exp(-t/tau’)

When T = Tc  then t = T_trip .

Tc = T_ss +(T_init – T_ss)*exp(-t_trip/tau’)

Solving for t_trip

t_trip = -tau’*ln( Tc -T_ss)/(T_init-T_ss) )

This is simple to calculate in RobotC.   If we used the nonlinear equation we would have had to do a time prediction t_trip using numerical integration.  This would be computationally expensive since we might have to do say 200 integration steps to get one value of t_trip.   This of course is more accurate and is similar to a technique use in bombing algorithms to find the exact time to release a bomb to hit a target several seconds in the future.  I plan to do both solutions in RobotC to see which is better.

5. PTC known parameters

Here is what we know about the 393 PTC

Product Model

􀋖PPTC Model􀋖HR30-090

Electrical Characteristics

I_H =0.90 , I_T =1.80 V_max= 0.60  I_max = 30  P_D =40  T_trip =7.1s 

R_min = 0.140  R_max = 0.230  R_ tmax = 0.350

IH =  Hold current: maximum current at which the device will not trip at 25􀄇 still air.

IT = Trip current: minimum current at which the device will always trip at 25􀄇 still air.

Vmax=Maximum voltage device can withstand without damage at rated current.

Imax = Maximum fault current device can withstand without damage at rated voltage.

Pd= Power dissipation: typical amount of power dissipated by the device when in tripped state in 25 dec C still air.

Ttrip= Maximum time to trip(s) at 5*IH.

Rmin = The smallest zero power resistance under the ambient temperature of 25􀄇.

Rmax = The biggest zero power resistance in the ambient temperature of 25􀄇.

R1max = Maximum device resistance one hour after it is tripped at 25􀄇.

Since the web site doesn’t have the time to trip vs current graphs,  we can  get very similar data from other PTC’s that are rated the same but have the data.  E.G.  A Bourne MFR090

The time to trip read from the web  site graph are:

I(amps) T_trip

1.7, 100

1.85, 50

2.0, 30

2.2, 20


3.0, 7.5

3.5, 5.6

4.0, 4.2

4.5, 3.0

5.0, 2.2

6.0, 1.5

5. Estimating Model parameters

There are a bunch of unknown parameters in the equations. Namely:

C_p, R0,m,Tc, K.

I estimated these from a variety of sources just to get started and adjusted them slightly to get a good match in an Excel model.

C_p = C_p_per vol * vol

C_p_per_vol  = 2.7 Ws/Kcm3 for a titanate material (see epcos reference)

Using the vol for  the Bourne R090  (8mm diameter, 1.5 mm thick) gives .0754 cm3

So C_p  =.203

R_0 is  .14 ohms from the PTC spec at 23 deg C.

m = slope of R curve vs T-Tref.  This is .727 ohms per 100 deg C from Fig 7 of Tyco tutorial.

Once I had the linear approximation to R = R_0*(1 + m*(T-T_ref))  an Rc  based upon jpearman PTC trip in this post was calculated.   I picked a current just before the nonlinear jump in resistance… this was 1.5 amps for an input of 4 volts.   This = the total drop across R and Rm.   So R  = V/I – Rm  = 4/1.5 – 1.5 = 1.17 ohms.   Plugging back into the R equation and solving for T gives

Tc =( Rc/R_0-1.)/m + T_ref =( 1.17 /.14 -1)/ .00727 + 23 = 1031 deg C   Although this seems high, it is really a fictious number  that makes Rc come out correctly for the linear approximation for R.     If R was exponential , Tc would be smaller.    I will revisit this later when I do not make the linear assumption.   I suspect that the linear assumption desensitizes the effect of external temperature changes when the temperatures approach Tc.  I.e.  a 10 degree change will not increase R as much it would if an exponential was used to approximate R in the Tc region.

K was more difficult… so I assumed a value of tau = C_P/K  and adjusted that until the Excel data matched the t_trip data.   This essentially is adjusting the cooling time constant of the PTC.  The best value for tau = 8 sec ==> K = 1.52

6. Excel Model Data matching

So I wrote an Excel program to integrate the differential equation for T and calculated when the PTC would trip for various currents.   These were compared to the Bourne t_trip and the differences were minimized by adjusting tau and C_p a little.  The data matches reasonably for the uninstalled PTC.   It is almost amazing considering the amount of things involved in getting to the model.  We are primarily concerned about the t_trip in the region 4 to 30 seconds and here the model matches to within a 7% or  about .5 seconds.






































Matching the Cortex HR16-400 test data from James Pearman Feb 2012 data posted in the vex forum.

You may remember this thread from February where I was testing the 4A device used in the cortex, for whatever reason the trip times could vary by up to 100%, for example, with 3.5A current I saw times that varied from 48 seconds to 123 seconds in just a sample of three devices.

I thought I had read that post, but when I went back to review it, I realized that it was a free test and not in the cortex as I had thought. It is a great set of data. I took the Jpearman data and averaged it to get a t_trip vs current to try to match with my thermal model.
I used a linear model of PTC resistance vs temperature. I can do this because the Tc critical temperature that I define occurs just before the big nonlinear jump occurs. If you look at the voltage trace in your curves , it is the point that the voltage doubles. I assume that the voltage doubles because the resistance doubles since it should have a regulated current.
The procedure is basically this: Recall the basic equation describing the temperature dynamics is
dT/dt = 1/C_p*(I^2*R – K*(T – T_0))
Pick R_0 … equal to the no power resistance at 25C. Define R_c ..equal to twice R_0. This is the critical resistance that will trigger the T_trip event.
Choose a representative temperature that coincides with the R_c event. I use Tc = 100C based upon your thermal measurements. At some point I would like to get T vs time instrumented along with current.
This defines the slope of the change in R vs T … = (R_c-R_0)/(T_c-T_0) = R_o/75. So the equation for R = R_0*(1 + (T- T_0)/75)
Next, find the thermal dissipation constant K that will cause a steady state non trip when the current is set at I= 4 (spec) but I used I = 3 amps per your test. K = I^2*R_c/(T_c – T_0)= 3^2*2*R_0/75 = 18/75*R_0
Once we have K then adjust C_p until the T_trip matches at the highest current… i.e. 8 amps. This sets the time constant tau at about 15 seconds.
Now slightly adjust T_c until the low current longer T_trip matches closely. Very minor adjustments are required.. < 20%.
The procedure is simple and seems to work OK. All we need is a data set similar to what you generated , but with the PTC inside the cortex. If we cannot get the temperature measurement, then we can just assume a representative number… say 100C.

8/12/2012 Update:   Simplified Proceedure for finding PTC constants with R constant.

I decided to try a model that assumes R is constant with temperature .   It matches well in the low t_trip but it under estimates the longer t_trip.    Constant R simplifies the derivation of constants and the equation calculations and this is the model I selected for software implementation.

Recall the basic equation describing the temperature dynamics with R = R_0
dT/dt = 1/C_p*(I^2*R_0 – K*(T – T_0)) which can be rewritten using tau = C_p/K as

tau *dT/dt = (I^2*R_0/ K   –  (T – T_0)) or

tau*dT/dt = (T_input – (T-T0));   where T_input = I^2*R_0/ K,

We will use the steady state solution of this equation to find K and the initial rate with a large T_input to find tau=

steady state:  Tinput = T -T0  -> K = I^2*R_0/(T -T0)

Now a key assumption is that Tc occurs at I_hold when T0 = 25C.  That is with I = I_hold, the steady state tempurature will just reach Tc.  So this equation in terms of I_hold and Tc is

K = I_hold*R_o/(Tc – T0)

Initial rate:

tau = (T_input -T +T0)/(dT/dt)     evaluated with a large T_input from known large current I_trip, T = T0 and a known t_trip.

Now:    dT/dt ~=  (Tc-T0)/t_trip .   (key assumption that is valid with very large steps)

Substituting into tau equation and eliminating K gives:

tau = T_input/(Tc-T0)*t_trip  = (I_trip/I_0)^2*t_trip !!

Empirically I have found that this over estimates t_trip  in the region of shorter t_trip(<15 sec) and that reducing tau by factors of 75% and 50% can provide a better fit in the shorter t_trip region at the expense of the long t_trip.  I.e. as shown in this figure the HR16-400 is better fit with 75% tau.  The HR30-90 is better fit with 50% (not shown).

If we don’t have a best fit, I recommend using the 50% factor.  This is conservative in that the monitor will trip faster than the hardware PTC and take corrective action to prevent the hardware trip.    It will restore a high command sooner because it thinks the hardware is cooling faster but it is now in a closed loop control so it will still keep the hardware PTC from tripping.  The price paid is the lowering of motor current a little sooner than necessary.

So this is the formula unless curvefitting is done:

tau =.5* (I_trip/I_0)^2*t_trip

Software Implementation:

#define c1 = 1/tau_ms;

#define c2= (Tc -T0)/(I_hold)^2 ;

Need  a periodic or near periodic loop with loop time dt_ms in millisec.

Initialize T at T_0.



dt_ms = timer1[T1] ;

T = T + c1*(I*I*c2 -T +T0)*dt_ms




Here are typical constants used for each of the Vex motors , cortex and power expander;

/PTC Constant calculation****************************************** //R_0  No power PTC resistance at 25C still air // T_c Trip temperature degC, nom = 100C //T_ref = 25. //I_hold PTC hold current //tau is computed by putting a I_trip = 5*I_hold or something close.  The time to trip T_trip is // measured at this current and used to compute tau. // tau = .5*T_trip*(I_trip/I_0)^2   I_trip typically = 5*I_hold // K = I_hold*I_hold*R_0/(T_c -T_0); //PTC dissipation constant // c_1 =(T_c – T_ref)/I_hold/I_hold ;   // c1 = R_0/K = (T_c – T_ref)/I_hold/I_hold // c_2 = 1./(tau*1000.);

// PTC HR16-400 used in cortex and power expander // R_0_cortex = .018 ; // T_c_cortex = 100; // I_HOLD_cortex = 3.; // t_trip = 1.7 @ I_trip = 5*I_hold // TAU_cortex = 12.5*1.7= 21.25 sec; // c_1_cortex  75/9 = 8.3333 // c_2_cortex  1/21250= 4.7e-5

// PTC HR30-090 used in 393 // R_0_393 = .14 ; // T_c_393 = 100; // I_hold_393 = .9; // t_trip = 7.1 @ I_trip = 5*I+hold // tau_393 = 12.5*7.1= 88.75; // c_1_393  75/.81= 95.59 // c_2_393  1/88750= 1.1267e-5

// PTC HR16-075 used in 269 // R_0_269 = .11 ohm min   .2 ohm max ; // T_c_269 = 100; // I_hold_269 = .75; // t_trip = 2 sec @ I_trip = 5*I_hold // tau_269 = .5*(I_trip/I_hold)^2*2 sec= 12.5*2 = 25 sec; // c_1_269  75/(.75^2)= 133.33 // c_2_269  1/25000= 4.e-5

// PTC MINISMDC-075F used in three wire // R_0_3wire = .11 min; max = .45 // T_c_3wire = 100; //assume same as 269 // I_hold_3wire = .75; // I_trip_3wire= 1.5 amp; // t_trip_3wire = .2 sec @8 amps // tau_3wire = .5*(8amp/.75amp)^2*t_trip =.5*22.8 = 11.4 sec; // c_1_3wire  75/(.75^2)= 133.33 // c_2_3wire  1/11400.= .00008789

RobotC subroutine to compute Vex 269 motor currents

July 14, 2012

I have written a subroutine that implements the excel H bridge model equations in robotC.   I have not checked the computational time of the routine but it should be ok.  The program can be down loaded from here.  The program uses the exp() and log() features of RobotC.   It is a function that has a prototype like this:

float current_calc_269( float rpm, float cmd ,float v_battery) {

//subroutine written by Vamfun…Mentor Vex 1508, 599.

//7.13.2012… blog info

//Vex motor 269 assumed

// inputs:  rpm, motor speed in rpm  Note:***Program assumes that with positive command, rpm is positive.***

//          cmd, motor command [127 ,-127]

//          v_battery, average battery voltage >0

// Output:  i_bar ,average motor current per PWM cycle in amps



Estimating moment of inertia for Vex 269 and 393 motors

July 12, 2012

Jpearman has done some great lab testing with Vex motors.  This post shows the motor current response for both 269 and 393 motors to a step response.   The steady state is achieved in around 100ms for both motors.

Good data.   It appears that both motors have a time constant tau = 20 ms based upon the initial slope or using 100ms as a 5*tau value.

We can use this data to calculate the approximate moment of inertias of the motors.    Since the motor time constant  tau = max speed/max accel  and the max speed is the same for both motors … we know that the motor max accelerations are identical for both motors.    Since max speed = 10.4 rad/s   and max accel = stall torque/Izz   we can calculate Izz for a 269  as

Izz_269  = tau*stall torque/max speed  = 2.8 in_lb*.113 nm/in_lb*tau/10.4  = 6.085*E-4 kgm^2

Using the equality of motor max accelerations gives a  ratio to get  Izz_393  from Izz_269  and the motor torques.  So

Izz_393 = Izz_269*Istall_393/Istall_269 = 6.085E-4*14.7/2.8 =  3.19E-3 kgm^2

So we now have enough data to do a pretty good motor model.