How do I sync ADC conversion to my PWM wave form?

In my motor control prototype, I have a 28335 ePWM running at 20 KHz for my motor drive. I want to see how accurately I can determine motor torque by measuring the motor current. On one ADC input I have motor current and on another ADC input I have a transducer to measure torque. I want to sample the motor current and torque transducer in the middle of the PWM period to avoid measurement contamination from switching noise. In the ePWM block configuration, I can choose to have the ePWM trigger an ADC start of conversion under various conditions, and I believe the correct condition is to trigger SOCA under the condition CTR=PRD. The problem is, I’m not sure how to use VisSim to read the ADC once the conversion has been completed so that I can plot motor current (or a filtered version of motor current) and torque.

You are half way there

To sync ADC measurements to the ePWM unit, you must send a SOCx (start of conversion) pulse from the ePWM unit to the ADC like you have done and also configure the ADC unit to use the SOCx pulse as the ADC Sample Trigger. In the F280x and Delfino you can send a SOCA pulse to trigger the 8 ADC channels on bank A, and SOCB to trigger the 8 channels on bank B. The Piccolo parts allow each PWM unit to send a SOC pulse to each ADC channel.

Your choice of ePWM SOC trigger event to measure current flow depends on your count mode (up, down or up/down), Action Qualification used to create the PWM (active high vs active low) and inverter topology. Assuming that you use up/down count and active high current flow (CMPA up match on CTR => 0/CMPA down match on CTR => 1), then selecting send SOCA on CTR=zero will send the SOCA on the center of the current flow. If you are measuring current on the lower leg of a complementary half H-bridge, then you would use send SOCA on CTR=PRD. If you are unsure, just try both as see which gives you better results. The difference is usually very obvious.

The next step is to configure the ADC unit to start conversions on receipt of the SOCx pulse. To do that, invoke VisSim/DSP > F280x > ADC Config... and under Sample Trigger ADCA0-ADCA7 select SOCA (or SOCB for Sample Trigger ADCB0-ADCB7).

To access the ADC value, wire in a VisSim/DSP > F280x > digital/analogInput block and set the channel to correspond to your ADC channel. VisSim reads the channel from the ADCRESULT memory vector. By default, channel ADCA0-7 map to VisSim analog channels 0-7, and ADCB0-7 map to VisSim analog channels 8-15. However, the TI hardware allows you to change the mapping of the analog input channels to the ADCRESULT vector. This mapping can be changed in the ADC Config... dialog under Channel Sample Order...

If you select ADC Config... > Full scale value = 1, the ADCRESULT register is accessed directly in the generated code and the ADC result has a full scale value of 1, otherwise a function is called and the resulting full scale value is 3.