Discussion in "Project Doubts" started by    Max    Oct 30, 2014.
Thu Oct 30 2014, 04:39 pm
Hello all,
before generating i have to give PWM period value from given input.
Now i want to divide this result to get PWM Period time.
if Input 0,2v then PWM_Period = 149...this value increses with upto 3,3 v.

Last value for PWM_Period = 479.

how can i do this?
```uint16 ADC_Max=65535;

uint16 Period1;

int main()
{
float Comp_Val; //,CMP;

// Start the components
Sys_Init();

while(1)
{

{

// Limit the result to 0..65535

/ Display ADC result in mVolts on LCD

LCD_Position(1u, 0u);

= 206)
Period1 = 149; // like this
}}}
```

pls share ur ideas & suggestions.

Regards
Max

[ Edited Thu Oct 30 2014, 07:11 pm ]
Sun Nov 02 2014, 12:03 pm
You need to make simple equation for PWM conversion. Here is a example:

Maxpwm - minpwm = pwmsteps
E.g 450 - 100 = 350 steps

Maxvolt - minvolt = voltsteps
E.g 3300 - 0 = 3300 mv

PWM Per step = pwmsteps/voltsteps = 350 / 3300 = 0.106

PWM = minpwm + (adc_mv * pwm per step) = 100 + (mv * 117) / 1000

You get your PWM value. Try it and let us know.

### Recent

RobertGug
Tue Jun 18 2024, 04:38 pm
Jasonabepe
Tue Jun 18 2024, 04:24 pm
Thomcyday
Tue Jun 18 2024, 08:38 am
WalterWib
Tue Jun 18 2024, 05:44 am
SialisshopWat
Mon Jun 17 2024, 09:22 pm
Thomasraima
Mon Jun 17 2024, 07:17 pm
EriksaLaf
Mon Jun 17 2024, 03:13 pm
Anthonyjinee
Mon Jun 17 2024, 06:23 am