Can I Use PID and get PWM as output ?

Hello

I want to use Arduino to control my Buck Converter for charging the battery So I have to use a V,I from the battery as input to Arduino for CC/CV charging

But I don't really know how to write it out I just get some idea (I'm newbee)

Can anyone explain the commands and something that I can use in my project ? That would be useful for me

Thanks

The commonly used PID library has a default output of 0 to 255, perfect for Arduino PWM outputs. You just need to set the floating point "Setpoint" to the value you want to get (voltage or current) and set the floating point value "Input" to the value you are currently reading (voltage or current). The library will then adjust Output to try to get you to Setpoint.

Read Reply#24 of THIS post.

I want to use Arduino to control my Buck Converter for charging the battery

You don't need PID for a battery charger. You simply turn off the charger and measure the voltage. If it is charged you will be able to tell. PID is for feedback loop systems that need to keep a device (servo motor or heater element) at a particular point and control it in some specific pattern. A battery charger simply needs to supply some minimum charging current until the battery is charged. There is no similarity between the two scenarios.

Here's an example of a PID application: PID slow cooker