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.

UCC21732: monitor the temperature using AIN and APWM

Part Number: UCC21732

Tool/software:

Hello Experts,


I am working to measure the temperature using a 10K thermistor in UCC21732. What do I miss in my circuit?

How can I relate the AIN and APWM? How do I monitor the temperature using APWM and the microcontroller?
Should I use the ADC pin or any GPIO pin on the microcontroller to read the APWM?



  • Hi Biruk, 

    You can refer to this page of the UCC21732 datasheet. Circuit looks ok to me, just make sure the AIN voltage stays between 0.6V and 4.5V across all your operating conditions.

    You can either use the microcontroller to measure the duty cycle of the APWM pin, or use an RC circuit to filter the APWM signal for the microcontroller to read a voltage only. 

    Thanks, 

    Vivian

  • Hi Vivian

    With the above circuit, I try to monitor the temperature with the microcontroller by connecting the APWM of the gate driver with the ADC pin of the microcontroller. But the microcontroller does not read anything on the APWM pin. On the data sheet, APWM converts analog input from AIN into PWM, so the microcontroller should connect to the DAC pin, right? If so, how this PWM is converted into temperature ?


  • Hi Biruk, 

    What is the sampling frequency of the microcontroller? The APWM pin has an output frequency of 400kHz, so it's possible that the microcontroller is not sampling fast enough to read the PWM duty cycle. Are you seeing a PWM with the corresponding duty cycle directly at the APWM pin? 

    To convert the PWM duty cycle to temperature, you will need a formula or lookup table of some kind. It needs to first convert temperature to thermistor resistance, calculate the AIN voltage from that thermistor resistance, and then convert the AIN voltage to APWM duty cycle. 

    Thanks, 

    Vivian

  • Hi Vivian,

    Sorry for late reply. I am using ESP32 WROOM Microcontroller, I did not know its sampling frequency exactly. I did not see directly at APWM pin.
    Can you share me the formula to convert the PWM duty cycle to temperature? The AIN voltage seem Ok. 
    And the APWM is a digital out put, so why we use the ADC pin of Microcontroller cause ADC accepts analog input ?

  • Hi Biruk, 

    Like mentioned above, you need to calculate the AIN voltage based on the thermistor properties. There's a 500uA internal current source, so the AIN voltage would be VAIN = 500uA*(10kOhm+Rthermistor). Then, APWM duty cycle can be calculated by 

    How long is your simulation run? I tried running the UCC21732 model and found a bug - there's a delay between AIN going high and APWM starts outputting signal. See waveform screenshot below. 

    Maybe running the simulation longer can produce an APWM output. 

    Also, 

    You can either use the microcontroller to measure the duty cycle of the APWM pin, or use an RC circuit to filter the APWM signal for the microcontroller to read a voltage only. 

    If you use the RC circuit to convert PWM duty cycle to a voltage, then you can use a regular GPIO to read the analog voltage. If you want to directly read the duty cycle, you can search how to read PWM with ESP32 on Google - I found plenty of resource but am not an expert on microcontroller, so you can experiment with those. 

    Thanks, 

    Vivian

  • Hi Vivian,

    Thanks for your reply.

    I have used 10k thermistor, so the VAIN​=500×10^−6 × (10×10^3  * 10×10^3) = 10V

    But the AIN voltage input range is from 0.6V to 4.5 V, from the data sheet. 

    Could you please share with me the circuit you tried, just to see the APWM and AIN connections?



  • Hi Biruk, 

    I was just using the encrypted UCC21732 PSpice model available on ti.com. 

    To make sure the AIN-APWM function works normally, you can try to temporarily disconnect the AIN pin from the thermistor network, and directly feed in a voltage to AIN (for example 2.5V). See schematic attached below. 

    You can also choose a smaller R1 and/or parallel a resistor to the thermistor to make sure AIN pin voltage stays within the operating range. 

    Thanks, 

    Vivian

  • Hi Vivian,

    Thanks for sharing us.

    Did you use a simple low-pass filter for the APWM pin before connecting to V_Pulse?

    For the AIN pin, may I use a zener diode to clamp the overvoltage that would exceed the AIN voltage input range? 

  • Hi Biruk, 

    No, in the simulation I directly probed the APWM output. There's no RC network tied to APWM. You can see the output is indeed a PWM with 50% duty cycle (I was testing with 2.5V of VAIN). 

    You can use a zener, however you'll lose the ability to detect the temperature change beyond 4.5V of AIN. For example, your AIN voltage would always equal to the zener diode reverse breakdown voltage, no matter if your thermistor is 10kOhm or 8kOhm, which might correspond to a large temperature change. 

    Vivian

  • Hi Vivian, 

    I got the following waveform in the APWM pin (green) and AIN (yellow). The width will change depending on the AIN voltage. And I have used a 50% duty cycle; why the big gap and small gap in the waveform? 



  • Hi Biruk, 

    I'm not sure - I don't see this behavior with the unencrypted PSpice model. The duty cycle is constant. I want to say the short pulse correspond to the ~400kHz APWM frequency, but I don't know where the wise pulse is coming from. 

    Are you using the model provided by Sean? If so I'll loop him in so he can take a look. 

    Vivian

  • Hi Vivian,

    I am using PSpice for TI (which is encrypted and default tools), I did not use Sean or any customable model or files.

    I also noticed that the APWM voltage is 5V; is that a fixed value for APWM? If I am not mistaken, I did not see APWM voltage level in the data sheet.

  • Hi Biruk, 

    APWM output voltage is the same as VCC; if VCC=5V, then APWM voltage high would be 5V. 

    I did not modify anything in the unencrypted model and got the waveform I shared with you. The unencrypted model downloaded into a zip folder called "slum663", and I unzipped, then opened the .opj file and schematic. I then put two probes onto AIN and APWM. See schematic and waveform below. 

    Also, I realized the ~40us delay is normal - that's the VCC UVLO delay. 

  • Hi Vivian,

    Now, I got a clear understanding. 

    I just want to decode the duty cycle to measure the temperature. I need to use the duty cycle at the APWM pulse signal. How can I do that? 
    I know that the APWM output's corresponding duty cycle ranges from 88% to 10%, based on AIN voltage. Is there a mathematical equation to find the temperature? or coding is recommended? 

  • Hi Biruk, 

    There's no set equation to find the temperature. It all depends on your circuit and thermistor. 

    For example, thermistor is 1kOhm at 25C. You put a 4kOhm resistor in series. So at 25C the AIN voltage is 500uA*(1kOhm+4kOhm) = 2.5V. That corresponds to 50% duty cycle. That's how you know 50% duty cycle->25C. 

    At 50C the thermistor will be another resistance and corresponds to another duty cycle. 

    You need to check what temperature corresponds to what thermistor value. Then calculate AIN voltage and duty cycle from that. 

    Of course you can derive your own equation or code.