Variable Voltage Signal using PWM

For MIAC users to discuss projects, applications, and any other issues related to the MIAC unit.

Moderators: Benj, Mods

Post Reply
james87price
Posts: 14
Joined: Thu Nov 10, 2011 12:51 pm
Has thanked: 2 times
Contact:

Variable Voltage Signal using PWM

Post by james87price »

Hi,

I am fairly new to flowcode and the electronic side of things so please bear with me if my questions are obvious! Couldn't find a straightforward in the forum...

I am trying to control a voltage signal (0-10v) using the transistor outputs and PWM. I understand how to set all the dutycycle properties but can't work out what is going on with the "ChangePeriod" option. What are the limitations with this? Could you give me a quick guide how to set a pwm output up entirely so I can check I am doing it right?

Thanks in advance

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Variable Voltage Signal using PWM

Post by Benj »

Hello,

Here is a quick explanation of how the parameters work.

Period Value - This controls the maximum count value of the PWM duty cycle and therefore the overall PWM cycle period. eg if you input a value of 10 then you can have a PWM duty cycle of 0 to 10. This can also be seen in the PWM component properties as the Period Register setting.

Prescaler Value - This controls how many clock cycles are used to determine a single PWM unit. eg for a period of 255 there are essentially 256 multiples of the PWM unit. For most PIC devices prescalers of 1, 4 and 16 are available. Again this setting can be seen in the properties window as the Clock Source setting.

Playing with both these values in the component properties will allow you to see the overall PWM period and frequency values change.

james87price
Posts: 14
Joined: Thu Nov 10, 2011 12:51 pm
Has thanked: 2 times
Contact:

Re: Variable Voltage Signal using PWM

Post by james87price »

Hi Ben,

I've recently been able to record the PWM signal I am getting from my MIAC. I have been trying to optimise the PWM output which goes to a filter to achieve an analogue signal.

I dont seem to be able to change the period of the signal despite playing with prescaler and period values. Also, I am putting a steady 10v supply (with plenty of current available) into the transistor channels but the signal is only switching between 0 and 9 v.

Am I missing something...? Would be happy to share the PWM trial code if you want to see it.

Kind regards,

James

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Variable Voltage Signal using PWM

Post by dazz »

Hi James

have a look at this thread http://www.matrixmultimedia.com/mmforum ... 46&t=10889,
I posted a simple flowchart that cycles through all the available dutycycles and periods, it may help to visualise the relationship between the two hth

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Variable Voltage Signal using PWM

Post by LeighM »

Hi James,
There is a reverse voltage protection diode in the circuit to the ABCD motor drivers that will be the cause of your voltage drop.
Regards,
Leigh

james87price
Posts: 14
Joined: Thu Nov 10, 2011 12:51 pm
Has thanked: 2 times
Contact:

Re: Variable Voltage Signal using PWM

Post by james87price »

Thanks for replies. Very much appreciated.

Leigh: If I simply increase the input voltage to 11V will I get my required 10v output?

dazz: I've posted the little script which I have been using to vary the 2 variables as a reply to the thread you mentioned. I am tempted to have a go at varying the duty cycle sinusoidally as well to see how my set-up responds to that.

Regards,

James

james87price
Posts: 14
Joined: Thu Nov 10, 2011 12:51 pm
Has thanked: 2 times
Contact:

Re: Variable Voltage Signal using PWM

Post by james87price »

Ah can't seem to post on that one. Here's the code...!
Attachments
PWM_Optimisation.fcf
(24.07 KiB) Downloaded 443 times

User avatar
petesmart
Valued Contributor
Valued Contributor
Posts: 395
Joined: Thu May 06, 2010 11:42 am
Location: Sydney, Australia
Has thanked: 187 times
Been thanked: 140 times
Contact:

Re: Variable Voltage Signal using PWM

Post by petesmart »

Hi James,

I have used this technique a few times to generate a variable voltage...

The best way to provide control over the output voltage is to use an op amp. This way you can choose the rail voltage and by playing withe the gain of the amplifier you can manage the size of the output swing vs the input.

Place the filter ( RC ) on the input of the amp...depending on the amp you can get a reasonable current drive if you require.

Any single rail op amp will do the trick......I usually employ a dual 8 pin device...LM 358. It's output will swing up to VCC -1.5 volts.

So if you need to get to a 10 volt output, the set the rail at 12volts, set the gain and drive it with filtered pwm

The upside of the op amp is that it provides isolation from the filter..

Good luck, let me know how you get on..

Best

Pete
sorry about that Chief!

Post Reply