Other Parts Discussed in Thread: C2000WARE
Hello, I have a project with 8 dc brush motors. Each has a bidirectional current sense in series with the coil. I need to have a cycle by cycle current limit for plus and minus current, based on the ADC input.
I've figured out a bunch of peripherals on C2000, but the trip zone stuff is the most confusing.
Each of 8 motors has two PWM's, one ADC and one compare.
One motor is setup so far, like this
XBAR_setEPWMMuxConfig(XBAR_TRIP5, XBAR_EPWM_MUX08_CMPSS5_CTRIPH_OR_L);
XBAR_enableEPWMMux(XBAR_TRIP5, XBAR_MUX08);
for(cnt = 0; cnt < 2; cnt++){ // each motor has two pwm's
EPWM_selectDigitalCompareTripInput(obj->pwmHandle[cnt],EPWM_DC_TRIP_TRIPIN5, EPWM_DC_TYPE_DCAH);
EPWM_setTripZoneDigitalCompareEventCondition(obj->pwmHandle[cnt], EPWM_TZ_DC_OUTPUT_A1, EPWM_TZ_EVENT_DCXH_HIGH);
EPWM_setDigitalCompareEventSource(obj->pwmHandle[cnt], EPWM_DC_MODULE_A, EPWM_DC_EVENT_1, EPWM_DC_EVENT_SOURCE_ORIG_SIGNAL);
EPWM_setDigitalCompareEventSyncMode(obj->pwmHandle[cnt], EPWM_DC_MODULE_A, EPWM_DC_EVENT_1, EPWM_DC_EVENT_INPUT_NOT_SYNCED);
EPWM_setTripZoneAction(obj->pwmHandle[cnt], EPWM_TZ_ACTION_EVENT_DCAEVT1, EPWM_TZ_ACTION_LOW);
EPWM_clearTripZoneFlag(obj->pwmHandle[cnt], (EPWM_TZ_FLAG_OST | EPWM_TZ_FLAG_DCAEVT1 | EPWM_TZ_FLAG_CBC ));
}
In my main loop, I can set the limit like this:
CMPSS_setDACValueHigh(obj->cmpssHandle, high); // cmpssHandle is set to CMPSS5_BASE to match with XBAR_TRIP5 above
CMPSS_setDACValueLow(obj->cmpssHandle, low);
When moving negative direction, so first PWM is 'on' and ADC drops from ref, I can see my raw ADC count at about 3500 (mid point is 3600), When I bring my 'low' limit up from zero, it starts to limit my pwm when it gets to around 3100.
Similarly, if I move positive, so second PWM is 'on', I see my raw ADC at about 3700, but my pwm only starts to chop when my 'high' limit gets below about 3300
I can't figure out why my DACValue doesn't match my ADC. I have confirmed my ADC count matches what I measure on the ADC input.
Am I setting the TripZone stuff up correctly?
I've found a couple of examples, but both are too different from what I'm trying to do.
thanks
Ken


