3

I am making an arduino project with a single lithium ion battery, and want to be able to maintain a constant PWM voltage, even when the battery goes from 4.2-3.2v. I have been able to read the Vcc using the internal 1.1v reference, so I am wondering if I can make some sort of feedback system to increase the duty cycle when the battery discharges, in order to keep the same average voltage on the PWM. I want to be able to make it 3.2v constant, which should be attainable on Vcc from 4.2-3.2, with 100% duty cycle when the battery is at 3.2v.

asked Sep 18, 2020 at 4:22
3
  • 5
    That's just a math problem, and a simple one at that. Read your voltage, calculate the PWM to get the average you want, then apply that PWM. What part is sticking you? Commented Sep 18, 2020 at 4:50
  • That would work. Just note that the 1.1V reference can differ slightly, from chip to chip. So depending on your margin of error, you might have to do a bit of calibration. PS it sound like you already know, but just to reiterate; PWM output doesn't give out an analog voltage, despite the misleading analogWrite function name. You'd have to do some filtering to convert the PWM to a analog voltage. Commented Sep 18, 2020 at 14:08
  • Wouldn't a voltage regulator do that better than an Arduino? Commented Sep 18, 2020 at 17:37

1 Answer 1

1

Simple: duty = (3.2 / vcc) * 255;

answered Sep 18, 2020 at 8:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.