This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4 Motion Controller Fault Handling



I am having a hard time initializing my fault handling on the TM4 processor. I have 8 outputs that have a fault pin (active low) when the circuit goes into over current conditions. These 8 fault pins are located in M0FAULT0-3 and M1FAULT0-3. I would like for the fault pins to register a fault and latch the pwm channel low. I am currently trying to get it working just on one channel and when I run the code, the Fault Configure function seems to be latching my output low immediately disabling the output completely before I ever turn it on. I am using the following configuration commands in my initialization scheme.

ROM_PWMGenConfigure (PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC | PWM_GEN_MODE_DBG_STOP | PWM_GEN_MODE_FAULT_LATCHED | PWM_GEN_MODE_FAULT_NO_MINPER);

ROM_PWMGenFaultConfigure (PWM0_BASE, PWM_GEN_0, 0, PWM_FAULT0_SENSE_LOW);

ROM_PWMGenFaultTriggerSet (PWM0_BASE, PWM_GEN_0, PWM_FAULT_GROUP_0, PWM_FAULT_FAULT0);

ROM_PWMOutputFaultLevel (PWM0_BASE, PWM_OUT_0_BIT, FALSE);

ROM_PWMOutputFault (PWM0_BASE, PWM_OUT_0_BIT, TRUE);

  • Suspect that we've (past) done very much what you seek - although w/older LX4F MCU and the following (slight) changes:

    a) we control 3 phase, BLDC motors - thus we "fault-gate/protect" 6 PWM Outputs from 3 PWM generators

    b) we employ a single MCU PWM_Fault input pin - which effectively "kills" PWM output across ALL 6 PWM Outputs

    c) this happens entirely w/in the MCU hardware - after we set-up & initialize - no (further) software intervention is required.  (clients & regulatory agents love this!)

    I'll have to dig up this code - we've substantially migrated to newer/better/faster ARM MCUs - cannot "survive" w/M4 only "selection" here...

    Might my (further) effort be worthwhile - meet your approval?

  • If it is not too much effort for you, I would like to see what you did to initialize your fault handling. I will probably be able to learn a lot from seeing how others have done it.

    Thank you!
  • OK - will do. But - as I'm @ "paid job" have to, "put in occasional appearance" to justify inflated/ongoing rate...

    In addition to what you seek - it is possible to implement a clever, "cycle by cycle" current-limiting - which proves a great safety factor as well as leading to an effective torque control...

    Give me an hour or two - promise to return...

  • One more thing - my small tech firm did all BLDC motor development w/a "motor simulator" I designed/developed.

    Motor's produce nasty spikes - distort your waveforms - prove sub-optimal during basic development. You may consider developing something similar.  (ours proved invaluable - greatly speeded, enhanced, & eased our ongoing development!)  

    And - always helpful if you better detail your application: (i.e. motor type, motor voltage,current, target RPM range, general description of application...)

  • Quick text to remote (yet crack) staff yields the following.   (these functions - in this order - should yield the PWM effects I earlier noted - which meet your objective)

    I've highlighted what my (very quick) read of your code may have missed.  (double check - I'm multi-tasking - in a meeting)

    ROM_PWMGenConfigure(PWM0_BASE, PWM_GEN_0, (PWM_GEN_MODE_UP_DOWN |
                            PWM_GEN_MODE_GEN_SYNC_LOCAL |
                            PWM_GEN_MODE_DB_SYNC_LOCAL |  
                            PWM_GEN_MODE_FAULT_EXT | PWM_GEN_MODE_FAULT_MINPER |
                            PWM_GEN_MODE_DBG_STOP));

    ROM_PWMGenFaultConfigure(PWM0_BASE, PWM_GEN_0, 2500, PWM_FAULT0_SENSE_HIGH);

    ROM_PWMGenFaultTriggerSet(PWM0_BASE, PWM_GEN_0, PWM_FAULT_GROUP_0,
                                  PWM_FAULT_FAULT0);

    // Set all six PWM outputs to the inactive state when a fault event occurs

    ROM_PWMOutputFault(PWM0_BASE, (PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_4_BIT |
                           PWM_OUT_5_BIT | PWM_OUT_6_BIT | PWM_OUT_7_BIT), true);

    Note 1: for clarity/simplicity I've shown just one PWM Generator and Fault Handling functions.  We are KISS fans - after you verify one PWM generator you can (easily) extend to 2nd (and beyond) PWM generators.   (that hand-holding - not my interest)

    Note: it's inefficient to employ more than one PWM_Fault pin to cause all six PWM outputs to extinguish!   We accomplish this via single pin - you should too.

    We trigger the PWM_Fault pin (this is critical) via the MCU's analog comparator output - which (ties directly) to the PWM_Fault input - via our custom pcb.  (in our case these pins are just 2 MCU pins apart!)  When our op-amp's current sense, amplified output - crosses our current-set trip point - the MCU comparator toggles high - and that activates the MCU's PWM Fault mechanism.   Simple, precise - and software free!   Even better - when the fault resolves - comparator toggles low - the PWM resumes as normal - no operator intervention required/wanted!

    Your award of "Verify Answer" gratefully accepted.  (clearly earned)  I gotta go...

  • cb1_mobile,

    Thank you for your help! I tried your suggestions and they appear to be just the fix I needed. Now I can move on to further investigate your suggestion of a current-limiter (I like that idea).

    Thanks again.
  • KM01 said:
    I tried your suggestions and they appear to be just the fix I needed.

    What appear - swear to God - they work - and damn well!   We pay the bills w/Control design/development via ARM - should have some (albeit slight) ability.

    On better read - your initial post - you were closer than I first thought.   You "must" insure that the PWM_Fault pin is properly set up - prior to the configuration of that pin as PWM_Fault input.   And - delightfully - in our LX4F (may they rest in non-tiva, working StellarisWare peace) that pin defaulted into NMI.   (we were among the first to "discover" that (not well managed) "special feature!"   And - by luck or skill - we were not forced to "unlock" that pin for it to serve as PWM_Fault.  (go figure)

    If you choose not to employ BLDC simulator as we did - plain-jane Leds may monitor PWM outputs - and prove quite effective as PWM monitors.  (current limiting resistors "extend" their life)   Then you may "play" w/PWM_Fault input - those Leds should immediately extinguish upon proper signal level introduced on/upon PWM_Fault input.   And those Leds should glow immediately upon the release of the PWM_Fault input - provided you've created a positive means for the voltage upon PWM_Fault input to return to, "Non-triggered/faulted state!"

    This is a powerful feature - having one MCU pin fully control 3-4 PWM Generators - and "automatically" kill or enable PWM output - is quite terrific...

  • When I initialize all of my GPIO, what initialization must I use on my input pins designated as my PWM Fault_In pins so that they will trigger when a fault is present?
  • KM01 said:
    what ...  PWM Fault_In pins initialization must I use... so that they will trigger when a fault is present?

    Why "pins" - did I not make the case for SINGLE PWM_Fault input pin - able to control ALL SIX PWM Outputs?

    Using (more) pins - when fewer (especially one) will do is inefficient - is it not?

    Plz standby - I'll post the config for PWM_Fault soon as work-load slows/allows.   (w/in the hour)

    Now back - here's your requested detail:

         ROM_GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_2);
         ROM_GPIOPinConfigure(GPIO_PF2_M0FAULT0);

    Now - to get that single pin to control all six (in our case) PWM Outputs:  (using more than the single pin disturbs...)

        ROM_PWMGenFaultConfigure(PWM0_BASE, PWM_GEN_0, 1000, PWM_FAULT0_SENSE_HIGH); 
        ROM_PWMGenFaultConfigure(PWM0_BASE, PWM_GEN_2, 1000, PWM_FAULT0_SENSE_HIGH);   
        ROM_PWMGenFaultConfigure(PWM0_BASE, PWM_GEN_3, 1000, PWM_FAULT0_SENSE_HIGH);
       
        ROM_PWMGenFaultTriggerSet(PWM0_BASE, PWM_GEN_0, PWM_FAULT_GROUP_0,
                                  PWM_FAULT_FAULT0);
     
        ROM_PWMGenFaultTriggerSet(PWM0_BASE, PWM_GEN_2, PWM_FAULT_GROUP_0,
                                  PWM_FAULT_FAULT0);   
       
        ROM_PWMGenFaultTriggerSet(PWM0_BASE, PWM_GEN_3, PWM_FAULT_GROUP_0,
                                  PWM_FAULT_FAULT0);

    What say you?  

    Note that the "1000" value (parameter 3, PWMGenFaultConfigure()) was experimentally determined and coordinates w/the "PWM_GEN_MODE_FAULT_MINPER" to vary the "hold-off" time of the PWM outputs...

  • I agree with you that using one pin would be idea; however, my application actually requires me to turn off only the PWM output that is exhibiting the fault. The other channels need to remain active since they are controlling hydraulic coils running a handful of tasks and it would be dangerous to the end user to lose all functionality. So I have to use a unique pin to every PWM channel to trigger a fault.

    I went back to my original message and I did not make this very clear. Apologies.

    Thank you for your help.
  • KM01 said:
    application actually requires ...extinguishing only the PWM output ... exhibiting the fault.

    That's new (and perfectly valid) justification for your use of multiple fault inputs. 

    To achieve your goal (and I'm sure you can do this) simply replace:

        ROM_PWMGenFaultConfigure(PWM0_BASE, PWM_GEN_2, 100, PWM_FAULT0_SENSE_HIGH);

    with it's related, "    "PWM_FAULTx_SENSE_HIGH"

    Clear enough my friend?   (you are aware that "multiple" Verify Answer awards are proper!)

  • Would you still be able to provide me an example of the PWM_Fault pin configuration? I am still slightly stuck on how to initialize my fault pin.
  • This setup for multiple fault pins make sense. I will implement this once I am able to get my one PWM faulting system up and running as expected. Thanks for the explanation!