EmbeddedRelated.com
Forums

Implementing DAC using PWM

Started by Mike Raines February 5, 2009
Hi Folks,
We are considering moving a project from the 4xx board to the 5xx
board to get more memory and speed. The 5xx board doesn't have a DAC
and some of our customers require a 4-20 mA output for legacy
equipment. Is it possible to use one of the timer PWM outputs to
implement this. Has anyone done it? What are the pitfalls and/or
limitations from a high level view? We know we can use the msp430 to
write to an external DAC but was wondering if there are other
approaches that might work. The analog output will only have to be
updated at 1 Hz, although one model updates at 8Hz...
Thanks,
Mike Raines

Beginning Microcontrollers with the MSP430

My current project also use 5xx's PWM output to control backlight and
contrast of LCD modules.
The board is being faboricated, I think it will work properly.

2009/2/6 Mike Raines

> Hi Folks,
> We are considering moving a project from the 4xx board to the 5xx
> board to get more memory and speed. The 5xx board doesn't have a DAC
> and some of our customers require a 4-20 mA output for legacy
> equipment. Is it possible to use one of the timer PWM outputs to
> implement this. Has anyone done it? What are the pitfalls and/or
> limitations from a high level view? We know we can use the msp430 to
> write to an external DAC but was wondering if there are other
> approaches that might work. The analog output will only have to be
> updated at 1 Hz, although one model updates at 8Hz...
> Thanks,
> Mike Raines
>

--
Best Regards
Qiuhua
h...@gmail.com


But to supply 4-20mA without external active components may be difficult.

--- In m..., Qiuhua wrote:
>
> My current project also use 5xx's PWM output to control backlight and
> contrast of LCD modules.
> The board is being faboricated, I think it will work properly.
>
> 2009/2/6 Mike Raines > Hi Folks,
> > We are considering moving a project from the 4xx board to the 5xx
> > board to get more memory and speed. The 5xx board doesn't have a DAC
> > and some of our customers require a 4-20 mA output for legacy
> > equipment. Is it possible to use one of the timer PWM outputs to
> > implement this. Has anyone done it? What are the pitfalls and/or
> > limitations from a high level view? We know we can use the msp430 to
> > write to an external DAC but was wondering if there are other
> > approaches that might work. The analog output will only have to be
> > updated at 1 Hz, although one model updates at 8Hz...
> > Thanks,
> > Mike Raines
> >
> >
> > --
> Best Regards
> Qiuhua
> hua.qiu@...
>
>

Some OPAMPs, resistors, and caps are required, contact your analog engineer.

2009/2/6 old_cow_yellow

> But to supply 4-20mA without external active components may be
> difficult.
>
> --- In m... , Qiuhua
> wrote:
> >
> > My current project also use 5xx's PWM output to control backlight and
> > contrast of LCD modules.
> > The board is being faboricated, I think it will work properly.
> >
> > 2009/2/6 Mike Raines
> >
> > > Hi Folks,
> > > We are considering moving a project from the 4xx board to the 5xx
> > > board to get more memory and speed. The 5xx board doesn't have a DAC
> > > and some of our customers require a 4-20 mA output for legacy
> > > equipment. Is it possible to use one of the timer PWM outputs to
> > > implement this. Has anyone done it? What are the pitfalls and/or
> > > limitations from a high level view? We know we can use the msp430 to
> > > write to an external DAC but was wondering if there are other
> > > approaches that might work. The analog output will only have to be
> > > updated at 1 Hz, although one model updates at 8Hz...
> > > Thanks,
> > > Mike Raines
> > >
> > >
> > >
> >
> >
> >
> > --
> > Best Regards
> > Qiuhua
> > hua.qiu@...
> >
> >
> >
> >
>

--
Best Regards
Qiuhua
h...@gmail.com


Hello Mike

Yes it's a good way if you have a free timer for this function or if you
can share an already used timer.
How to do : Configure the Compare register of Timer in mode 7 (PWM). The
output signal is set when the timer goes from 0xFFFF to 0x0000 (CCR0)
and it is cleared when the timer becomes equal to one of the Compare
Register (CCRx). One important point not to forget is the way you update
CCRx. When the new value written in CCRx is less than the actual one,
the output may stay at '1' for a whole cycle. In this case you'd better
to stop the timer before writing the updated value in the CCRx.
My application uses a 333ns clock cycle (power is not an issue for me)
and thus refreshes the load at 45Hz. I'm not driving a 4-20mA loop but I
still use a good op-amp with a low pass filter to drive my load.

Hope this will help you..

Claude Buchilly
Sylvac SA
Ch. du Closalet 16
1023 Crissier - Switzerland
tel +41 21 637 67 57
fax +41 21 637 67 40
http://www.sylvac.ch
c...@sylvac.ch

Le 05.02.2009 21:34, Mike Raines a rit :
>
> Hi Folks,
> We are considering moving a project from the 4xx board to the 5xx
> board to get more memory and speed. The 5xx board doesn't have a DAC
> and some of our customers require a 4-20 mA output for legacy
> equipment. Is it possible to use one of the timer PWM outputs to
> implement this. Has anyone done it? What are the pitfalls and/or
> limitations from a high level view? We know we can use the msp430 to
> write to an external DAC but was wondering if there are other
> approaches that might work. The analog output will only have to be
> updated at 1 Hz, although one model updates at 8Hz...
> Thanks,
> Mike Raines
Thanks to all who replied,
Thanks for all the good advice. Yes, I know the hardware guys will
have to manipulate the PWM to get the 4-20 mA output. I was concerned
to determine if the PWM would give them what they needed. With the DAC on the 4xx board,
I'm only feeding them a voltage between 0.25 and 2.5 volts. Hopefully, they
can adapt and use the PWM signal. We usually work together well, which is
nice and helps the final product,

Thanks again,
Mike Raines

________________________________
From: m... [mailto:m...] On Behalf Of Claude Buchilly
Sent: Friday, February 06, 2009 2:02 AM
To: m...
Subject: Re: [msp430] Implementing DAC using PWM
Hello Mike

Yes it's a good way if you have a free timer for this function or if you
can share an already used timer.
How to do : Configure the Compare register of Timer in mode 7 (PWM). The
output signal is set when the timer goes from 0xFFFF to 0x0000 (CCR0)
and it is cleared when the timer becomes equal to one of the Compare
Register (CCRx). One important point not to forget is the way you update
CCRx. When the new value written in CCRx is less than the actual one,
the output may stay at '1' for a whole cycle. In this case you'd better
to stop the timer before writing the updated value in the CCRx.
My application uses a 333ns clock cycle (power is not an issue for me)
and thus refreshes the load at 45Hz. I'm not driving a 4-20mA loop but I
still use a good op-amp with a low pass filter to drive my load.

Hope this will help you..

Claude Buchilly
Sylvac SA
Ch. du Closalet 16
1023 Crissier - Switzerland
tel +41 21 637 67 57
fax +41 21 637 67 40
http://www.sylvac.ch
c...@sylvac.ch

Le 05.02.2009 21:34, Mike Raines a rit :
>
> Hi Folks,
> We are considering moving a project from the 4xx board to the 5xx
> board to get more memory and speed. The 5xx board doesn't have a DAC
> and some of our customers require a 4-20 mA output for legacy
> equipment. Is it possible to use one of the timer PWM outputs to
> implement this. Has anyone done it? What are the pitfalls and/or
> limitations from a high level view? We know we can use the msp430 to
> write to an external DAC but was wondering if there are other
> approaches that might work. The analog output will only have to be
> updated at 1 Hz, although one model updates at 8Hz...
> Thanks,
> Mike Raines



In the hardware part a low pass filter and a voltage controled current source will do the job.
You will need a calibration procedure. So think about including an ADD and MULTIPLY operations using some data you can store in FLASH.
Set the PWM to 0 and measure the output current. Then set the PWM to the maximum value and read again. Use these two values to calculate the correction values (offset and gain).
Check if the hardware has a linear response (at least under the final product especifications). If not you may need a look-up table in order to have an effective linear output. Of course, with a table you may not need the calibration values since you can set a new table to every product unit you make therefore adjusting the system to get 0mA with value zero in the PWM and so on.
-Augusto

De:m...

Para:"m..." m...

Cia:

Data:Fri, 6 Feb 2009 08:36:25 -0500

Assunto:RE: [msp430] Implementing DAC using PWM

Thanks to all who replied,
Thanks for all the good advice. Yes, I know the hardware guys will
have to manipulate the PWM to get the 4-20 mA output. I was concerned
to determine if the PWM would give them what they needed. With the DAC on the 4xx board,
I'm only feeding them a voltage between 0.25 and 2.5 volts. Hopefully, they
can adapt and use the PWM signal. We usually work together well, which is
nice and helps the final product,

Thanks again,
Mike Raines

________________________________
From: m... [mailto:m...] On Behalf Of Claude Buchilly
Sent: Friday, February 06, 2009 2:02 AM
To: m...
Subject: Re: [msp430] Implementing DAC using PWM

Hello Mike

Yes it's a good way if you have a free timer for this function or if you
can share an already used timer.
How to do : Configure the Compare register of Timer in mode 7 (PWM). The
output signal is set when the timer goes from 0xFFFF to 0x0000 (CCR0)
and it is cleared when the timer becomes equal to one of the Compare
Register (CCRx). One important point not to forget is the way you update
CCRx. When the new value written in CCRx is less than the actual one,
the output may stay at '1' for a whole cycle. In this case you'd better
to stop the timer before writing the updated value in the CCRx.
My application uses a 333ns clock cycle (power is not an issue for me)
and thus refreshes the load at 45Hz. I'm not driving a 4-20mA loop but I
still use a good op-amp with a low pass filter to drive my load.

Hope this will help you..

Claude Buchilly
Sylvac SA
Ch. du Closalet 16
1023 Crissier - Switzerland
tel +41 21 637 67 57
fax +41 21 637 67 40
http://www.sylvac.ch
c...@sylvac.ch

Le 05.02.2009 21:34, Mike Raines a rit :
>
> Hi Folks,
> We are considering moving a project from the 4xx board to the 5xx
> board to get more memory and speed. The 5xx board doesn't have a DAC
> and some of our customers require a 4-20 mA output for legacy
> equipment. Is it possible to use one of the timer PWM outputs to
> implement this. Has anyone done it? What are the pitfalls and/or
> limitations from a high level view? We know we can use the msp430 to
> write to an external DAC but was wondering if there are other
> approaches that might work. The analog output will only have to be
> updated at 1 Hz, although one model updates at 8Hz...
> Thanks,
> Mike Raines