Problem with PWM!

Moderator: Benj

Post Reply
alaahima
Posts: 6
Joined: Fri Apr 11, 2014 12:54 pm
Has thanked: 3 times
Been thanked: 2 times
Contact:

Problem with PWM!

Post by alaahima »

In flowcode the output is a train of pulses with an adjustable duty cycle through an adc input and the PWM can be enabled or disabled via another adc input ... When simulated on proteus the output signal can be enabled and disabled BUT the output isn't a train of pulses , It's a continuous DC signal as if the duty cycle is 100% all the time , I would've risked trying this directly on hardware but I'm dealing with huge capacitors and inductors and this could be extremely hazardous.
Please help , and thanks in advance ... Cheers!

Here are the flowcode program and a snapshot of the proteus schematic.
Attachments
PWM controlled by adc for boost topology.fcf_avr
(16.49 KiB) Downloaded 311 times
boost isis problem.JPG
boost isis problem.JPG (87.58 KiB) Viewed 5624 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Problem with PWM!

Post by medelec35 »

Hi alaahima,
I would say it's part of your formula:
ADC_INPUT_VOLT * 3 * 1024
That's at fault.
first if using int (-32768 to 32767) then you must be careful not to exceed the ranges at any time during all the calculations.
INT from ADC is going to be 0 to 1023, so for a test we will take the highest number:

1023*3*1024 = 3142656
Well in excess of 32767
The other thing you have that's wrong is:
/ 204.8

With Bool,byte,Int,UInt, Long and Ulong only whole numbers can be used
So 1023 *0.999+100 =
1023*0+100 =
100
If you wish to use decimal numbers then they will only work with float variables.
Floats take up a lot of storage space, so before going too far, it's best to compile to hex regularly.
At lest then you know you have the ROM & RAM to continue, and not realise you are out of memory right at the very end of your project.

I'm not the worlds greatest with formula's but if I can help I will.
If you can let me know the ADC value V required Duty,
then I will see if I can come up with a formula for you to use.

Martin
Martin

alaahima
Posts: 6
Joined: Fri Apr 11, 2014 12:54 pm
Has thanked: 3 times
Been thanked: 2 times
Contact:

Re: Problem with PWM!

Post by alaahima »

Thanks Martin , You already helped me out so much ... I can do it from here ... Have a great day/night C:

Post Reply