Hi!
If I want to use a 1.5 V battery as trigger source to make PWM action.
How to do that?
Can anyone help me?
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.
Hi!
If I want to use a 1.5 V battery as trigger source to make PWM action.
How to do that?
Can anyone help me?
Hi,
You can use external interrupts for this purpose, but still I'm not sure what exactly you need to do. Is it just triggering PWM wrt the battery voltage?
Also, while using external interrupt as battery, at least 3V is required to detect logic high(2 batteries in series).
Regards,
Gautam
If I want to use battery touch ADC pin as a trigger source.
What should I do?
You mean to say, measure voltage of battery through ADC and then trigger PWM accordingly? Yes, you can do that too but if compared to external interrupt, this will add a lot of delay for the PWM event to occur.
Regards,
Gautam
So how to use ADC pin to measure voltage of battery?
I saw the ti example code. There are not talk about this.
How to set the ADC register?
Thanks
I saw the ti example code. There are not talk about this.
Yes, there are examples in controlSuite. Try working with the one available here:
C:\ti\controlSUITE\device_support\f2803x\v127\DSP2803x_examples_ccsv5\adc_soc
You've to connect the battery to one of the adc pin and ground the other with mcu gnd pin. You'll be then able to observe ADC digital values in AdcResult registers. Then you can convert these digital values to analog values using formula available in controller's ADC documentation.
Regards,
Gautam
I follow you say try in examples_adc_soc.
But I can't observe AdcResult registers value change in debug mode.
Because I use DRV8312-C2-KIT.
I have to modify "AdcRegs.ADCSOC0CTL.bit.CHSEL =7".
This value is correspond to ADC-Vhb2.
Where do I have wrong?
But I can't observe AdcResult registers value change in debug mode.
You can observe the same in the Watch Window under Global Variables.
Regards,
Gautam
Is the ADC connected to the battery? Also, I hope you've not modified the example code.
Yes, the ADC is connect to the battery.
And I just modified like this
/*example code
AdcRegs.ADCSOC0CTL.bit.CHSEL = 4; //set SOC0 channel select to ADCINA4(dummy sample for rev0 errata workaround)
AdcRegs.ADCSOC1CTL.bit.CHSEL = 4; //set SOC1 channel select to ADCINA4
AdcRegs.ADCSOC2CTL.bit.CHSEL = 2; //set SOC2 channel select to ADCINA2
*/
AdcRegs.ADCSOC0CTL.bit.CHSEL = 1; //set SOC0 channel select to ADCINA1 (CHSEL = 1 = IA-FB pin)
AdcRegs.ADCSOC1CTL.bit.CHSEL = 1;
AdcRegs.ADCSOC2CTL.bit.CHSEL = 1;
This is the result.
ADC no connected to the battery
ADC connected to the battery
It's work.
Thank you help.
But I don't know when I mark ADCSOC1CTL, ADCSOC2CTL and remain ADCSOC0CTL.
The code like this
AdcRegs.ADCSOC0CTL.bit.CHSEL = 1; //set SOC0 channel select to ADCINA1 (CHSEL = 1 = IA-FB pin)
// AdcRegs.ADCSOC1CTL.bit.CHSEL = 1;
// AdcRegs.ADCSOC2CTL.bit.CHSEL = 1;
Why the AdcResult register value has no change?
That's great its working now. Yes, while modifying the code you need to understand basic ADC concepts and how things work. I would want you to refer and study this doc thoroughly:
Regards,
Gautam