Searching \ for '[PIC]: fast easy DAC with PIC' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'fast easy DAC with PIC'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: fast easy DAC with PIC'
2000\12\20@105953 by Roman Black

flavicon
face
Hi, I need to implement 2 DAC with one PIC,
preferably a 16F84, and I need reasonably
fine resolution, at least 64 levels, pref
128.

I have tried the PWM options, but I need more
speed, like the ability to adjust from full
to zero output 32,000 times/sec. Using 20MHz
PIC and home made PWM I can't even come close.

So, any suggestions on getting 2x analogue
output from a small PIC at high speed??
:o)
-Roman

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\20@111228 by Ray Gardiner

flavicon
face
What about just using a couple of R-2R ladders? Then the problem mutates into
how to get 2 x 6 bit latches with limited IO pins :-)

>Hi, I need to implement 2 DAC with one PIC,
>preferably a 16F84, and I need reasonably
>fine resolution, at least 64 levels, pref
>128.
>
>I have tried the PWM options, but I need more
>speed, like the ability to adjust from full
>to zero output 32,000 times/sec. Using 20MHz
>PIC and home made PWM I can't even come close.
>
>So, any suggestions on getting 2x analogue
>output from a small PIC at high speed??
>:o)
>-Roman
>
Ray Gardiner spam_OUTrayTakeThisOuTspamdsp.com.au
mail from: dsp systems

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\20@111243 by Alan B. Pearce

face picon face
>I have tried the PWM options, but I need more
>speed, like the ability to adjust from full
>to zero output 32,000 times/sec. Using 20MHz
>PIC and home made PWM I can't even come close.

Does this mean you want to generate 8khz sinewaves (32000 quarter sines /sec) or
is it a step function between 2 levels at up to 32000 times/sec?

I would have thought that Maxim would have suitable 8 bit serial DACs. I guess
the limiting factor would be if you can feed the serial data fast enough to
achieve the 32000 times/sec.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\20@113236 by Roman Black

flavicon
face
Alan B. Pearce wrote:
>
> >I have tried the PWM options, but I need more
> >speed, like the ability to adjust from full
> >to zero output 32,000 times/sec. Using 20MHz
> >PIC and home made PWM I can't even come close.
>
> Does this mean you want to generate 8khz sinewaves (32000 quarter sines /sec) or
> is it a step function between 2 levels at up to 32000 times/sec?
>
> I would have thought that Maxim would have suitable 8 bit serial DACs. I guess
> the limiting factor would be if you can feed the serial data fast enough to
> achieve the 32000 times/sec.


There are a number of 8-bit DAC units, but I would need
two, and cost and size are both options. I want to do
it with one chip, that's why I like microcontrollers! :o)

I need to drive a two-phase stepper motor (hence two DAC)
at speeds of up to 20 revs/sec with 1/8th stepping, which
is 32,000 current adjustments per second. I can do it with
28-pin PIC and resistor networks, but the product won't
stand the cost and size gets messy with the larger chip and
all those resistors.

Any suggestions? I am thinking about using 3 PIC pins as
3 PWM outputs, gives me analogue and digital switching
all in one with minimum pins and max speed. But it gets
messy!
:o)
-Roman

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\20@120357 by Alan B. Pearce

face picon face
>I can do it with
>28-pin PIC and resistor networks, but the product won't
>stand the cost and size gets messy with the larger chip and
>all those resistors.

Hmm, I would have thought that an F87x and a F84 would have been very similar in
cost, but then I have not gone looking for production quantities.

How about an F87x with SIP resistors. If you can get SIP networks with the R
value in a 10 pin pack, would give 5 individual resistors, and another similar
with 2R, giving a total of 4 SIP packs. Have only done a quick mental think
about what is required for R/2R networks, you may still need a couple of single
resistors, but then you will be making zillions of them, so surface mount won't
be a problem?? Certainly you can get 4 isolated resistors of the same value in a
1206 size package priced at GBP0.055 ea. for 50 off (minimum order) from RS
Components, with a fair range of values available.

If you get real lucky you may be able to get an R/2R network in a single
package, although I could not find one on a quick sweep through the RS
Components CD.

But seriously I doubt you will get much cheaper for combined board space/cost
combination.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\20@123434 by Olin Lathrop

face picon face
> Hi, I need to implement 2 DAC with one PIC,
> preferably a 16F84, and I need reasonably
> fine resolution, at least 64 levels, pref
> 128.
>
> I have tried the PWM options, but I need more
> speed, like the ability to adjust from full
> to zero output 32,000 times/sec. Using 20MHz
> PIC and home made PWM I can't even come close.
>
> So, any suggestions on getting 2x analogue
> output from a small PIC at high speed??

The easy solution is to use a PIC with two PWM modules or use external D/As.
However, you might be able to do this if you're very careful.  With 20MHz
clock and 32,000 analog out updates per second, you have 156 instructions
per update.  Doing one PWM at this rate isn't too hard, especially if there
are no other interrupts.

Doing two is going to be tricky, because handling of one will result in
latency (and therefore wrong value) in the other.  You'd pretty much have to
dedicate the PIC to doing nothing else.  In that case you probably need
another PIC to do the stuff this PIC can't do, in which case it would be
cheaper and easier to just get a PIC with two PWM outputs in the first
place.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, .....olinKILLspamspam@spam@embedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\20@123851 by Marcelo Yamamoto

flavicon
face
How about a digital pot.? You'll need only 3 pin to control it (SPI).

http://www.microchip.com/10/lit/pline/analog/anicateg/digipot/index.htm

Marcelo Y.


> >I can do it with
> >28-pin PIC and resistor networks, but the product won't
> >stand the cost and size gets messy with the larger chip and
> >all those resistors.
>
> Hmm, I would have thought that an F87x and a F84 would have been very
similar in
> cost, but then I have not gone looking for production quantities.
>
> How about an F87x with SIP resistors. If you can get SIP networks with the
R
> value in a 10 pin pack, would give 5 individual resistors, and another
similar
> with 2R, giving a total of 4 SIP packs. Have only done a quick mental
think
> about what is required for R/2R networks, you may still need a couple of
single
> resistors, but then you will be making zillions of them, so surface mount
won't
> be a problem?? Certainly you can get 4 isolated resistors of the same
value in a
> 1206 size package priced at GBP0.055 ea. for 50 off (minimum order) from
RS
> Components, with a fair range of values available.
>
> If you get real lucky you may be able to get an R/2R network in a single
> package, although I could not find one on a quick sweep through the RS
> Components CD.
>
> But seriously I doubt you will get much cheaper for combined board
space/cost
> combination.
>
> --
> http://www.piclist.com hint: The PICList is archived three different
> ways.  See http://www.piclist.com/#archives for details.
>
>

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\20@124109 by Marcelo Yamamoto

flavicon
face
How about a digital pot.? You'll need only 3 pin to control it (SPI). You
spent a little more on the pot butreduce cost using an smaller chip and an
smaller PCB.

Marcelo Y.


> >I can do it with
> >28-pin PIC and resistor networks, but the product won't
> >stand the cost and size gets messy with the larger chip and
> >all those resistors.
>
> Hmm, I would have thought that an F87x and a F84 would have been very
similar in
> cost, but then I have not gone looking for production quantities.
>
> How about an F87x with SIP resistors. If you can get SIP networks with the
R
> value in a 10 pin pack, would give 5 individual resistors, and another
similar
> with 2R, giving a total of 4 SIP packs. Have only done a quick mental
think
> about what is required for R/2R networks, you may still need a couple of
single
> resistors, but then you will be making zillions of them, so surface mount
won't
> be a problem?? Certainly you can get 4 isolated resistors of the same
value in a
> 1206 size package priced at GBP0.055 ea. for 50 off (minimum order) from
RS
> Components, with a fair range of values available.
>
> If you get real lucky you may be able to get an R/2R network in a single
> package, although I could not find one on a quick sweep through the RS
> Components CD.
>
> But seriously I doubt you will get much cheaper for combined board
space/cost
> combination.
>
> --
> http://www.piclist.com hint: The PICList is archived three different
> ways.  See http://www.piclist.com/#archives for details.
>
>

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\20@124116 by Marcelo Yamamoto

flavicon
face
How about a digital pot.? You'll need only 3 pin to control it (SPI). You
spent a little more on the pot but reduce cost using an smaller chip and an
smaller PCB.

Marcelo Y.


> >I can do it with
> >28-pin PIC and resistor networks, but the product won't
> >stand the cost and size gets messy with the larger chip and
> >all those resistors.
>
> Hmm, I would have thought that an F87x and a F84 would have been very
similar in
> cost, but then I have not gone looking for production quantities.
>
> How about an F87x with SIP resistors. If you can get SIP networks with the
R
> value in a 10 pin pack, would give 5 individual resistors, and another
similar
> with 2R, giving a total of 4 SIP packs. Have only done a quick mental
think
> about what is required for R/2R networks, you may still need a couple of
single
> resistors, but then you will be making zillions of them, so surface mount
won't
> be a problem?? Certainly you can get 4 isolated resistors of the same
value in a
> 1206 size package priced at GBP0.055 ea. for 50 off (minimum order) from
RS
> Components, with a fair range of values available.
>
> If you get real lucky you may be able to get an R/2R network in a single
> package, although I could not find one on a quick sweep through the RS
> Components CD.
>
> But seriously I doubt you will get much cheaper for combined board
space/cost
> combination.
>
> --
> http://www.piclist.com hint: The PICList is archived three different
> ways.  See http://www.piclist.com/#archives for details.
>
>

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\20@142714 by Roman Black

flavicon
face
Marcelo Yamamoto wrote:
>
> How about a digital pot.? You'll need only 3 pin to control it (SPI).
>
> http://www.microchip.com/10/lit/pline/analog/anicateg/digipot/index.htm
>
> Marcelo Y.

Tank you Marcelo, that is a very clever solution. I didn't
know about these single/dual pots in a chip! I do remember
something but didn't take notice last time they were mentioned.

The thing that puts me off is the SPI thing. I have a very
high speed requirement and it would be total disaster if a
bit was missed/error when controlling current and position
of big stepper motors.

I will look at these chips more closely for some future
projects though! :o)
-Roman

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\20@145034 by Roman Black

flavicon
face
Alan B. Pearce wrote:
{Quote hidden}

Thanks Alan, yep, i've done a lot of thinking re resistor
ladders and networks, got catalogues all over the room.
Actually in thinking about the resistor solution I think
I found my final solution, will post it in a minute.
:o)
-Roman

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\20@155214 by Roman Black

flavicon
face
Olin Lathrop wrote:

> > So, any suggestions on getting 2x analogue
> > output from a small PIC at high speed??
>
> The easy solution is to use a PIC with two PWM modules or use external D/As.
> However, you might be able to do this if you're very careful.  With 20MHz
> clock and 32,000 analog out updates per second, you have 156 instructions
> per update.  Doing one PWM at this rate isn't too hard, especially if there
> are no other interrupts.
>
> Doing two is going to be tricky, because handling of one will result in
> latency (and therefore wrong value) in the other.  You'd pretty much have to
> dedicate the PIC to doing nothing else.  In that case you probably need
> another PIC to do the stuff this PIC can't do, in which case it would be
> cheaper and easier to just get a PIC with two PWM outputs in the first
> place.


Thanks Olin, I think I have a final solution and I came
to the same comclusion that you did, that PWM is best.

My problem is that the PWM voltage is used for current
regulation, and needs to be fairly ripple free. So that
means filter RC at least at 10x the PWM period, so that
meant VERY high speed PWM if I need to get 32,000 actual
current levels/sec, that's maybe 320,000 Hz PWM.

I was looking at resistor ladder solutions to give the
different analogue outputs and found I was looking at it
from the wrong direction. To get 2-phase 8 microsteps
I don't need two high resolution DACs, I need one
DAC with 9 steps and 2 outputs. I can do that with 9
PIC pins and a bunch of resistors. I even had circuit
and parts values worked out, but this pin count forced
me to F87x series parts, which I didn't want (and lots
of resistors).

Once I had the 9-stage 2-output thing happening, I thought
about PWM again. Why use PWM modules? Why even use the
TIMER? Why limit PWM to the 256 count fixed frequency
concept?

What about something like this:

;-----------------------------------------------
; Stage 1 of 9 (example)

stage_1_loop:

       movlw b'00000011'       ; both AB phases on
       movwf PORTB             ; change output pins
       nop                     ; delays as needed
       nop                     ;

       movlw b'00000010'       ; turn phase A off
       movwf PORTB             ; change output pins
       nop                     ; delays as needed
       nop                     ;

       movlw b'00000000'       ; turn phase B off
       movwf PORTB             ; change output pins
       nop                     ; delays as needed
       nop                     ;
       nop                     ; delays as needed
       nop                     ;
       nop                     ; delays as needed
       nop                     ;

       goto stage_1_loop       ; loop forever
;-----------------------------------------------


This tight loop gives *very* high freqeuncy PWM, so
I can meet my spec of small RC constant/ripple and
also give very fast response.

Using infinite loop gives rock solid timing for
accurate PWM voltage of both motor phases. I can use
interrupt on change feature on the "step" control
input pin to simply count up or down and then goto a
new code loop, one loop for each of the 9 voltage
levels I need, to control BOTH phases in each tight
loop. Extending the theory, I can handle all four
quadrants for all 32 possible 8-microstep variations,
using four PIC pins. So I no longer have to use one
set of pins for current and four more pins for phase
direction switching, I can just use the 4 PWM pins
to directly contol the h-bridge halves. Nice. Parts
count just went down again.

To get my required 9 sets of voltages, I think every
voltage can be done using hardcoded blocks of about
20 to 30 instructions. So although there will be
different pwm FREQUENCY for the differing 9 stages,
it gives all required voltage variances at a fast
enough speed. At 20MHz the 30 instruction loop still
gives 170,000 Hz pwm, and this lets me use a small
enough RC to get the result. Another advantage is
that the interrupt on the "step" input command,
then jumping to tight hardcoded loops gives fairly
instant control of the PWM voltages...

Now my next challenge is to read up on hardware
errors re fast port changing and pin capacitance,
but I can design it to only write to the 4 pins
(the whole port) in one hit, and use the other 4
pins as inputs, and hope this will keep me out of
trouble if I don't load the pins too much.

Many thanks to everyone who offered help with this
one! :o)
-Roman

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\20@155609 by Michael Rigby-Jones

flavicon
face
{Quote hidden}

Hmm..quite a high bit rate.  If you use (say) an 8 bit SPI DAC, readily
available in dual packages this will work out to 8 x 2 x 32000 = 512kbits/s.
Most SPI DACs will be easily able to handle this.  I wrote a bit bashed SPI
routine in HiTech C and using 20Mhz clock gave around 700Kbits/s.  Even
assuming this could be optimised in ASM, you aren't going to have an awfull
lot of CPU time left for anything else.  If you choose a PIC with an SSP
module you can offload a LOT of cpu time.

A lower resolution DAC woul eas the problem slightly, but I'm not aware of
anything below 8 bits with an SPI interface, maybe someone else does?

A better solution would be you use a straight parallel DAC if you can afford
the pins.

Mike

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\20@160938 by Dave Mumert

flavicon
face
Maxim makes a 6 bit DAC with either 2 wire or 3 wire interface.  It comes in a 6
pin SOT23 package.  SPI operates at 10Mhz.  The MAX 5363 has a internal
reference of 2 Volts.

Dave Mumert

{Original Message removed}

2000\12\20@213522 by Dan Michaels

flavicon
face
Roman wrote:
......
>So, any suggestions on getting 2x analogue
>output from a small PIC at high speed??

Yeah, use a scenix.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\21@012837 by Russell McMahon

picon face
If I may be the heresy, one of the Philips LPC series (8051 core) has 4 x
PWM which can be run from 2 to 10 bits accuracy and with rates AFAIR up to
around 1 MHz.
Not a PIC though :-(.
Development  system with true ICE costs under $NZ1000 ($US400).
(Made by Philips in NZ)

More heresy suggests that a Scenix would give you about 50/20 * 4 = 10 times
the throughput of a PIC,
Heavy on power and $ though. .



regards



     Russell McMahon



From: Roman Black <EraseMEfastvidspam_OUTspamTakeThisOuTEZY.NET.AU>
To: PICLISTspamspam_OUTMITVMA.MIT.EDU <@spam@PICLISTKILLspamspamMITVMA.MIT.EDU>
Date: Thursday, 21 December 2000 05:01
Subject: Re: [PIC]: fast easy DAC with PIC


{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


2000\12\21@064637 by Roman Black

flavicon
face
Russell McMahon wrote:
>
> If I may be the heresy, one of the Philips LPC series (8051 core) has 4 x
> PWM which can be run from 2 to 10 bits accuracy and with rates AFAIR up to
> around 1 MHz.
> Not a PIC though :-(.
> Development  system with true ICE costs under $NZ1000 ($US400).
> (Made by Philips in NZ)
>
> More heresy suggests that a Scenix would give you about 50/20 * 4 = 10 times
> the throughput of a PIC,
> Heavy on power and $ though. .


Thanks Russell (and everyone who helped) I have
already found a software solution using my favorite
16F84 (which we buy in bulk and always have stocks).

You don't need fast chip for fast PWM, just some
clever software and lateral thinking. :o)
-Roman

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2000\12\21@065510 by Alan B. Pearce

face picon face
>You don't need fast chip for fast PWM, just some
>clever software and lateral thinking. :o)

yes I am always amazed what one can do with some lateral thinking, even on a
slow processor and non-realtime op system.

(from one who has done background system monitoring using VB3 on Win 3.11 on 486
processor, while handling foreground commands)

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservspamBeGonespammitvma.mit.edu with SET PICList DIGEST in the body


2000\12\21@111111 by jamesnewton

face picon face
Good advice. Its not that hard to make the transition to the "dark side"
<GRIN>

See:
http://www.sxlist.com

---
James Newton
1-619-652-0593
TakeThisOuTjamesnewtonEraseMEspamspam_OUTsxlist.com
SX FAQ: http://www.sxlist.com



{Original Message removed}

2000\12\21@123431 by Dan Michaels

flavicon
face
James Newton wrote:
>Good advice. Its not that hard to make the transition to the "dark side"
><GRIN>
>
>See:
>http://www.sxlist.com
>

So you wish to be known as "Dark [Vader]" Newton now?
[I think it fits you, Mr Dark :)].

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body


2000\12\21@124302 by Dan Michaels

flavicon
face
Roman Black wrote:
>Russell McMahon wrote:
........
>> More heresy suggests that a Scenix would give you about 50/20 * 4 = 10 times
>> the throughput of a PIC,
>> Heavy on power and $ though. .
>
>
>Thanks Russell (and everyone who helped) I have
>already found a software solution using my favorite
>16F84 (which we buy in bulk and always have stocks).
>
>You don't need fast chip for fast PWM, just some
>clever software and lateral thinking. :o)


SX's cost $4-5 USD in smallish quantities.

Also, months ago, I invented a routine for doing hi-speed
multi-channel PWM via lookup table stored in RAM. For 64 bits
bits, with 20mhz PIC, you could go about 1Mhz/64 = 16Khz, but
you get to 8 channels. With SX, it goes 10x faster. You do have
to slow down of course to reload table values.

- danM

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservEraseMEspam.....mitvma.mit.edu with SET PICList DIGEST in the body


2000\12\22@033626 by Michael Rigby-Jones

flavicon
face
{Quote hidden}

So how fast did you get your two PWM channels to run in the end?  Obviously
much faster than the 32000 Hz step frequency you want to use.

Mike

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspam_OUTspamKILLspammitvma.mit.edu


2000\12\22@064645 by Roman Black

flavicon
face
Dan Michaels wrote:
{Quote hidden}

My new design is up and running, and getting 150kHz
2 channels with a 16F84. And rock solid! :o)
-Roman

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspamspammitvma.mit.edu


2000\12\22@070151 by Roman Black

flavicon
face
Michael Rigby-Jones wrote:

> >
> > Thanks Russell (and everyone who helped) I have
> > already found a software solution using my favorite
> > 16F84 (which we buy in bulk and always have stocks).
> >
> > You don't need fast chip for fast PWM, just some
> > clever software and lateral thinking. :o)
> > -Roman
> >
> So how fast did you get your two PWM channels to run in the end?  Obviously
> much faster than the 32000 Hz step frequency you want to use.
>
> Mike


Hi Mike, getting 150kHz with rock solid stability, the
secret is to use small hard coded loops for the different
voltage levels (I have 8 possible levels, 4 output pins
= 2:4 channel) and with the 4 stepper quadrants is 32 total
hard-coded loops. Each loop just writes to the whole
port, and I use NOPs to tune it. Software sets the exact
8th stepping positions so it can be tuned perfectly to
each size/inductance stepper motor. I think i'm using
450oz/in 34 frame 6 amp steppers.

The loops are selected by GOTO insts. I use interrupt
on change feature on the "step" pin to use interrupt
to change the position index, and then just jump to a
new goto loop. Very fast, very bulletproof, also has
ability to software tune currents and use low current
"hold" mode after one second, and even "boost" mode
for special occasions. The 16F84 has 3 pins to control
it, step, direction, enable/hold. I use 4 pins to output
to the 4 h-bridge sides. A few pins left over for dipsw
to tune full/half/1:4/1:8 step modes and hold current
options.

Looks very nice, will be releasing it as a 8th ustep
LINEAR! 24v 6A motor controller module. Almost no-one
does a good linear bipolar microstep but we do now.
I'm sick of tinny "singy" little chopper drives sold
as 4A but blow up if operated at 4A continuous. Like
everything I build these drives will run 24 hours/day
for the next 20 years. The way it should be. Our
next project, for early February. :o)
-Roman

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspamspamspamBeGonemitvma.mit.edu


2000\12\22@131450 by Dan Michaels

flavicon
face
Roman Black wrote:
>
>My new design is up and running, and getting 150kHz
>2 channels with a 16F84. And rock solid! :o)
>-Roman
>

how many bits of resolution? [4, maybe :)]

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2000\12\27@023345 by Roman Black

flavicon
face
From:
       Dan Michaels <oricomSTOPspamspamspam_OUTUSWEST.NET>
Roman Black wrote:
>
>My new design is up and running, and getting 150kHz
>2 channels with a 16F84. And rock solid! :o)
>-Roman
>

how many bits of resolution? [4, maybe :)]


Actually, resolution is very good, similar to
10bit for my purposes. Everyone thinks FIXED
FREQUENCY when they think PWM.

It was just that type of limited thinking that
stumped me for 4 days on what was essentially a
two hour job.

My PWM is generated by tight hard coded loops.
Since it is filtered by RC circuit the freq is
NOT important, as long as it is above about 100kHz.
My slowest loop is about 150kHz, the fastest
about 250kHz. Being able to adjust the ON and the
OFF period each as a separate hard-coded few cycles,
means you can get very fine PWM adjustment with
only 35 cycles or so.

Each hard coded loop runs both phases of the
stepper motor, and even runs all 4 h-bridge drives
so I have almost no external circuitry needed.

Some people might initially think that varying PWM
AND frequency to get the exact ratios might sound
like butchery, but why not do it? It allows very
fast PWM frequencies and very fine adjustment with
quite a crude PIC.
:o)

-Roman

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestSTOPspamspamEraseMEmitvma.mit.edu


2000\12\27@065706 by Andrew Kunz

flavicon
face
It also makes it near impossible to get through FCC because you have a very wide
band of frequencies to annihilate.

Andy









Roman Black <KILLspamfastvidspamBeGonespamEZY.NET.AU> on 12/27/2000 02:32:27 AM

Please respond to pic microcontroller discussion list <EraseMEPICLISTspamEraseMEMITVMA.MIT.EDU>








To:      @spam@PICLIST@spam@spamspam_OUTMITVMA.MIT.EDU

cc:      (bcc: Andrew Kunz/TDI_NOTES)



Subject: Re: [PIC]: fast easy DAC with PIC








From:
       Dan Michaels <spamBeGoneoricomspamKILLspamUSWEST.NET>
Roman Black wrote:
>
>My new design is up and running, and getting 150kHz
>2 channels with a 16F84. And rock solid! :o)
>-Roman
>

how many bits of resolution? [4, maybe :)]


Actually, resolution is very good, similar to
10bit for my purposes. Everyone thinks FIXED
FREQUENCY when they think PWM.

It was just that type of limited thinking that
stumped me for 4 days on what was essentially a
two hour job.

My PWM is generated by tight hard coded loops.
Since it is filtered by RC circuit the freq is
NOT important, as long as it is above about 100kHz.
My slowest loop is about 150kHz, the fastest
about 250kHz. Being able to adjust the ON and the
OFF period each as a separate hard-coded few cycles,
means you can get very fine PWM adjustment with
only 35 cycles or so.

Each hard coded loop runs both phases of the
stepper motor, and even runs all 4 h-bridge drives
so I have almost no external circuitry needed.

Some people might initially think that varying PWM
AND frequency to get the exact ratios might sound
like butchery, but why not do it? It allows very
fast PWM frequencies and very fine adjustment with
quite a crude PIC.
:o)

-Roman

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestspam_OUTspammitvma.mit.edu

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-request.....spamTakeThisOuTmitvma.mit.edu


2000\12\27@081235 by Roman Black

flavicon
face
Andrew Kunz wrote:
>
> It also makes it near impossible to get through FCC because you have a very wide
> band of frequencies to annihilate.
>
> Andy


Good point, but consider that in my app the PWM
is instantly converted to DC analogue voltage
via RC network, all the power control parts
are run linear, with less radiation than any
chopped driver. What I wanted was a very fast
response DAC with two channels and only 9 crude
voltage levels. Using a very high freq PWM was
the best solution. :o)
-Roman

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestKILLspamspamspammitvma.mit.edu


2000\12\27@082319 by Bob Ammerman

picon face
Roman,

Very impressive idea.

Do I understand correctly:

-- The PWM PIC has no responsibility other than genearating the PWM signals.

How does the PWM PIC know what value to output at any given time?

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestspamRemoveMEmitvma.mit.edu


2000\12\27@084426 by Roman Black

flavicon
face
Bob Ammerman wrote:
>
> Roman,
>
> Very impressive idea.
>
> Do I understand correctly:
>
> -- The PWM PIC has no responsibility other than genearating the PWM signals.
>
> How does the PWM PIC know what value to output at any given time?


The system was needed for a low cost 8th step
microstepping stepper motor driver.

I needed to control the current in two phases,
ie two h-bridges, so that is 9 possible current
"sets" of combinations, (9x2 matrix) which can
give all 8 microsteps. I wanted to avoid a hardware
solution as that would eliminate tuning for
torque and degree compensation with large motors.

The PIC chip (16F84) has 3 pins for the 3 industrial
standard step/direction/enable inputs. It then
drives the 4 halves of the 2 h-bridges directly via
4 output pins, each through a simple RC integrator.
Using hardcoded PWM loops of differing frequencies
allowed fine tuning of the PWM voltages. I also used
32 actual PWM settings, to give all 4 quadrants
so there is no phase direction switching needed.
The PIC runs very simple firmware to step forward
or back, and also can select full/half/4/8 steps
via dipswitches. Options include auto current
reduce mode and boost and software anti-resonance
(not really needed with 4 or 8 ustep though!)

Using 4 PIC pins and 4 RC networks means that I
don't need much external hardware, otherwise it needs
some pins for PWM and others for phase direction
switching.

The power stage uses hardware current feedback,
so the PIC only provides a reference voltage, the
hardware then adjusts current to match. This is
lightning quick and gives fabulous motor performance
compared to chopper systems that rely on L of the
motor in the feedback loop.

I have had arguments re the chopper/linear issue
before, but the motor performance of a microstepping
linear driver and a big motor is something else! :o)

I always use hardware current feedback as it provides
a lot of safety. In the event that the two h-bridge
halves might both be turned on, the whole bridge will
still limit to the correct current. Also will limit
to the correct current if one of the 4 switches in the
h-bridge goes short circuit.
-Roman

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspamspamBeGonemitvma.mit.edu


2000\12\27@111826 by Dan Michaels

flavicon
face
Roman Black wrote:
.........
>Some people might initially think that varying PWM
>AND frequency to get the exact ratios might sound
>like butchery, but why not do it? It allows very
>fast PWM frequencies and very fine adjustment with
>quite a crude PIC.


Sounds like a classical accumulation algorithm. This is
probably good when you are running a motor and want to
even out the energy in the PWM wave, but for 10-bit PWM,
for instance, your "fundamental" frequency can vary by
up to 512:1, and this can cause problems in some cases.
[although, for a motor, it would never turn a lick with
PWM=1 part in 1024 anyway].

Varying fundamental would ruin operation of the PWM-controlled
LED intensity ckt I posted last week, where the fine point
of operation was the playoff between pulsewidth and rise time
of the RC filter.

- danM

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-request@spam@spamspam_OUTmitvma.mit.edu


2000\12\27@112241 by Dan Michaels

flavicon
face
Roman Black wrote:

What I wanted was a very fast
>response DAC with two channels and only 9 crude
>voltage levels. Using a very high freq PWM was
>the best solution.


So not really 10-bit after all. 3.1 bits [about
what I said :)]

- danM

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestspamspammitvma.mit.edu


2000\12\27@122131 by Lawrence Glaister

flavicon
face
Hi Roman
your stepper pic project sounds very intriguing. I am working on a drive
system for a new home project and would love to try out your system for
running some 150oz-in steppers. Any chance you would be willing to share
your design? I have a 16f84 programmer and am handy enough to build from a
schematic and pic listing.
regards from the great soggy north
=======================================================
Lawrence Glaister VE7IT             email: lgEraseMEspamjfm.bc.ca
1462 Madrona Drive                  http://jfm.bc.ca
Nanoose Bay BC Canada
V9P 9C9
=======================================================
{Original Message removed}

2000\12\27@191053 by David P. Harris

picon face
Hi Roman-
If I follow this correctly, then you have done a really nice solution with minimal
hardware.  I would like to see the schematic :-)
David


Roman Black wrote:

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestRemoveMEspamEraseMEmitvma.mit.edu


2000\12\27@212335 by Bob Ammerman

picon face
> So not really 10-bit after all. 3.1 bits [about
> what I said :)]

No: Far better than 3.1 bits.

Duty cycle is expressed as N/M, where _both_ N and M are variable, tho' M is
constrained on the high end by a minimum frequency requirement.

You can get a lot of closely spaced values when you can vary both numerator
and denominator, tho'  I imagine there might be some small holes in the
spacing.

Q: Given N and M with N > 0, N < M, M <= maxcount, what is the largest space
between realizable duty cycles?

This is really a _great_ scheme!

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam@spam@mitvma.mit.edu


2000\12\28@094120 by Roman Black

flavicon
face
Lawrence Glaister wrote:
>
> Hi Roman
> your stepper pic project sounds very intriguing. I am working on a drive
> system for a new home project and would love to try out your system for
> running some 150oz-in steppers. Any chance you would be willing to share
> your design? I have a 16f84 programmer and am handy enough to build from a
> schematic and pic listing.
> regards from the great soggy north


Thank you for showing an interest in the project.
As it is a commercial project that will cost me
100+ hours I will not be releasing full source
code or circuit diagram.

But I am happy to discuss the general principles
with you and any other piclist members, and hope
that will help you with your home project. Maybe
you will discover something I missed and our
interaction will benefit both of us! :o)

Contact me on or off list and I will be pleased
to help. I have been doing more work on the
firmware and hardware and although it is not the
ultimate DAC solution it does look quite promising
for my application.
-Roman

PS. 150oz steppers sound like the typical home
CNC setup??

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2000\12\28@190126 by Peter L. Peres

picon face
>variable frequency PWM

I think that I did not understand the solution properly, because the
smoothed (integrated) output of PWM depends only on the voltage of the
source and its duty cycle. Not on frequency. Did I miss anything ?

Peter

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2000\12\28@190141 by Peter L. Peres

picon face
>Q: Given N and M with N > 0, N < M, M <= maxcount, what is the largest
>space between realizable duty cycles?

The smallest step (delta) is 1/N where N is the maximum divider. There is
no way around this, unless. The o/p of a PWM waveform is integrated
directly. The value of the integral is written V = V1*M/N where V1 is the
amplitude of the PWM voltage and M<=N. There is NO way to reduce the step
below Nmin/M which is 1/M.

What you *can* do is use the tristate facility of the output pins. This
effectively increases the number of output encoding states. With this you
can have three output states so the output could be manipulated more
accurately OR faster with the same number of IO operations.

For example if you have to output a value N then decide if N is above M/2
(where M is the maximum output), or below, set output bit=((N - M/2) >=
0)?1:0; and output unipolar pulses using the tristate control only (i.e.
set bit value and turn on/off using tristate control). You can have 9 bits
resolution on an output with timing as for 8 bits (N = 256), or 8 bits
with timing for 7. Of course this assumes that the external hardware
cooperates and the output tends 'to' 1/2Vcc when the pin is not driven.
There are some more problems with this, so I have simplified here.

Peter

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2000\12\28@201033 by Dan Michaels

flavicon
face
Peter Peres wrote:
>>variable frequency PWM
>
>I think that I did not understand the solution properly, because the
>smoothed (integrated) output of PWM depends only on the voltage of the
>source and its duty cycle. Not on frequency. Did I miss anything ?
>

Time constant of the smoothing filter.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2000\12\29@011824 by Roman Black

flavicon
face
Peter L. Peres wrote:
>
> >variable frequency PWM
>
> I think that I did not understand the solution properly, because the
> smoothed (integrated) output of PWM depends only on the voltage of the
> source and its duty cycle. Not on frequency. Did I miss anything ?

The trick is to vary both the on period and the
off period, to give fine adjustment with quick
software loop. Frequency varies, but for my app
f only had to be over 100kHz, so any f over that
is fine. :o)
-Roman

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\12\29@012310 by Roman Black

flavicon
face
Peter L. Peres wrote:
>
> >Q: Given N and M with N > 0, N < M, M <= maxcount, what is the largest
> >space between realizable duty cycles?
>
> The smallest step (delta) is 1/N where N is the maximum divider. There is
> no way around this,

Sure, but for my app, stepper motor current control,
there is no need for an extremely small current, in
fact there are only 7 current levels (and 100% and OFF)
needed for 8th step microstepping control. And the
smallest current level is about 19%, the largest
about 92%.
-Roman

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\12\29@015216 by Robert A. LaBudde

flavicon
face
At 05:15 PM 12/29/00 +1100, you wrote:
>Peter L. Peres wrote:
> >
> > >variable frequency PWM
> >
> > I think that I did not understand the solution properly, because the
> > smoothed (integrated) output of PWM depends only on the voltage of the
> > source and its duty cycle. Not on frequency. Did I miss anything ?
>
>The trick is to vary both the on period and the
>off period, to give fine adjustment with quick
>software loop. Frequency varies, but for my app
>f only had to be over 100kHz, so any f over that
>is fine. :o)
>-Roman

Isn't this technique called a "phase-locked-loop"?


>--
>http://www.piclist.com hint: The list server can filter out subtopics
>(like ads or off topics) for you. See http://www.piclist.com/#topics

================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: @spam@ralspam_OUTspam.....lcfltd.com
Least Cost Formulations, Ltd.            URL: http://lcfltd.com/
824 Timberlake Drive                     Tel: 757-467-0954
Virginia Beach, VA 23464-3239            Fax: 757-467-2947

"Vere scire est per causas scire"
================================================================

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\12\29@081051 by Andrew Kunz

flavicon
face
Maybe.  He changes duty as well as frequency because it works that way too,
rather than a fixed frequency (the common way of doing it).

Andy









"Peter L. Peres" <spamBeGoneplpEraseMEspamACTCOM.CO.IL> on 12/28/2000 04:58:28 PM

Please respond to pic microcontroller discussion list <PICLISTspamBeGonespamMITVMA.MIT.EDU>








To:      RemoveMEPICLIST@spam@spamspamBeGoneMITVMA.MIT.EDU

cc:      (bcc: Andrew Kunz/TDI_NOTES)



Subject: Re: [PIC]: fast easy DAC with PIC








>variable frequency PWM

I think that I did not understand the solution properly, because the
smoothed (integrated) output of PWM depends only on the voltage of the
source and its duty cycle. Not on frequency. Did I miss anything ?

Peter

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\12\29@185626 by Peter L. Peres

picon face
>Time constant of the smoothing filter.

Which must be chosen such that at the minimum frequency component the
ripple on it will be <= 1/2 LSB. I still think that I am missing
something.

The only way to increase resolution with frequency is to use an active
smoothing filter and increase frequency until its 6dB corner is met. Then
the output will effectively be halved so you gain one bit of resolution
and lose one of range.

Peter

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\12\30@063127 by Roman Black

flavicon
face
Peter L. Peres wrote:
> I still think that I am missing
> something.
>
> The only way to increase resolution with frequency is to use an active
> smoothing filter and increase frequency until its 6dB corner is met. Then
> the output will effectively be halved so you gain one bit of resolution
> and lose one of range.

You are thinking too "square" like I was. I only need
7 pwm voltage levels, which need to be finely adjustable
(set by software once). I also needed very fast pwm
frequency to give fast response when changing levels.

Imagine a stepper motor that needs to be set at 20%
analogue voltage. The pwm is made in a tight software
loop of:
20 cycles on, 80 cycles off = 20%

Easy, and fast, only 100 instruction cycles.

Now imagine this;
20 cycles on, 79 cycles off = 20.202%
20 cycles on, 81 cycles off = 19.802%

Is it making more sense now?? If you are willing to
work within a frequency band (depends on your
requirements) you can get fast response pwm
with finely tunable analoge levels as the result.

Now imagine you can work with BOTH on and/or off
timing, from f to 2f or even 4f. This gives
the ability to get almost any ratio (voltage).

For my app, I could get the 7 levels I needed
pretty easily with the biggest loop about 35
cycles, on 20MHz PIC that is pwm frequency of
150kHz upwards. Don't forget the pwm drives a RC
integrator to give analogue DC levels. (But at
+150kHz I can change between levels very quickly
because the RC time constant is small).
Make sense?
:o)
-Roman

PS. I forgot to mention that I deliberately designed
the analogue hardware so that for 0% to 100% range
of motor current I need about 3.5v to 4.5v analogue
voltage range, not 0v to 5v as you would probably
expect with PIC pwm. This suits this software technique
well and allows me minimum parts count, although is
not totally linear (but I am manually tuning it
anyway). Phew! :o)

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\30@120603 by Olin Lathrop

face picon face
> Which must be chosen such that at the minimum frequency component the
> ripple on it will be <= 1/2 LSB. I still think that I am missing
> something.
>
> The only way to increase resolution with frequency is to use an active
> smoothing filter and increase frequency until its 6dB corner is met. Then
> the output will effectively be halved so you gain one bit of resolution
> and lose one of range.

No, he's not using varying frequency to achieve different filtered levels.
His filter corner frequency is well below the slowest PWM frequency so that
what comes out of the filter is the PWM average value.

What he is doing is varying both the PWM on fraction (as usual), but also
the overall period.  The final output is the ratio of on time versus off
time.  This gives him two different variables to control to achieve the
desired ratio, which allows for more choices of final output given a limited
set of discrete choices for each variable.  It just happens that frequency
shifts around as a result, but this is irrelevant because the filter is set
so that the signal from all possible resulting frequencies is averaged well
enough for the application.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens MassacZAi8tts
(978) 772-3129, .....olin@spam@spamEraseMEembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\30@183832 by Scott Dattalo

face
flavicon
face
On Wed, 27 Dec 2000, Bob Ammerman wrote:

> > So not really 10-bit after all. 3.1 bits [about
> > what I said :)]
>
> No: Far better than 3.1 bits.
>
> Duty cycle is expressed as N/M, where _both_ N and M are variable, tho' M is
> constrained on the high end by a minimum frequency requirement.
>
> You can get a lot of closely spaced values when you can vary both numerator
> and denominator, tho'  I imagine there might be some small holes in the
> spacing.
>
> Q: Given N and M with N > 0, N < M, M <= maxcount, what is the largest space
> between realizable duty cycles?

I haven't followed this thread (or any for that matter lately) too closely. But
to answer your question: 1/M(max). The easiest way to see this is imagine M is
the maximum value. Now, what would be the minimum pulse width? 1/M. Similarly,
if you try to obtain the maximum pulse width, you'll discover the 1/M
quantization limitation. So the largest space between realizable duty cycles is
1/M.

The distribution of ratios IIRC is triangular with a maximum in the
middle. Which is to say that the number of N/M expressions that can produce
something close to 1/2 is maximum (M/2 in fact). [The next closest PW to 1/2 is
(M/2)/(M-1) and is about 1/(2*(M-1)) away.]


>
> This is really a _great_ scheme!

Perhaps (but I didn't see it). The PWM resolution is ultimately related to the
clock. If you have an algorithm that can produce changes for any arbitrary clock
edge then you're not going to get any better than that. Here's a software PWM
that has single instruction cycle resolution:

http://www.dattalo.com/technical/software/pic256.txt

Scott

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\30@192119 by Robert A. LaBudde

flavicon
face
At 05:39 PM 12/30/00 -0600, Scott wrote:
{Quote hidden}

People seem to have difficulty understanding this scheme, which is
essentially trading high-frequency bandwidth for low-frequency accuracy.

View the problem as that of a PID controller. The I term (integral) will
correct for low-frequency offset & drift.

By dithering duty cycle on a 1-instruction basis, resolution can average to
much better than 1-instruction times, if the averaging period is long.

Here's a simple adaptive algorithm:

1. Start an accumulator on duty cycle during the averaging period, or a
moving average across periods.

2. If accumulator/average is low, turn on duty cycle.

3. If accumulator/average is low, turn off duty cycle.

Essentially this is a simple bang-bang comparator controller with an
integrator. The error is on the order of an instruction cycle time, which
diminishes as the averaging interval becomes longer, due to randomization
of the timing error.

This will give better results than a non-adaptive scheme which will have a
fixed discretization error of an instruction time that is deterministic.

This is also similar to the dithering approach to ADCs to get an extra bit
or two resolution at the expense of bandwidth.

PS. There is a sort of Heisenberg Uncertainty Principle acting here:
precision x bandwith = constant (similar to selectivity x bandwidth =
constant). The constant is based on the maximum sampling interval involved.

================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: .....ralRemoveMEspamlcfltd.com
Least Cost Formulations, Ltd.            URL: http://lcfltd.com/
824 Timberlake Drive                     Tel: 757-467-0954
Virginia Beach, VA 23464-3239            Fax: 757-467-2947

"Vere scire est per causas scire"
================================================================

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\30@215534 by Scott Dattalo

face
flavicon
face
On Sat, 30 Dec 2000, Robert A. LaBudde wrote:

> At 05:39 PM 12/30/00 -0600, Scott wrote:
>
> >Perhaps (but I didn't see it). The PWM resolution is ultimately related to the
> >clock. If you have an algorithm that can produce changes for any arbitrary
> >clock
> >edge then you're not going to get any better than that. Here's a software PWM
> >that has single instruction cycle resolution:
> >
> >http://www.dattalo.com/technical/software/pic256.txt
>
> People seem to have difficulty understanding this scheme, which is
> essentially trading high-frequency bandwidth for low-frequency accuracy.

?

I assume people refers to me in particular. How does a single instruction cycle
resolution PWM preclude you from dithering? In fact, I've done just that with
the routine referenced above. I've got a version that will produce a 12-bit
analog value by "dithering" 16 consecutive 8-bit values.

> View the problem as that of a PID controller. The I term (integral) will
> correct for low-frequency offset & drift.
>
> By dithering duty cycle on a 1-instruction basis, resolution can average to
> much better than 1-instruction times, if the averaging period is long.

Exactly...

<snip>

BTW, If you want, another way to increase the dynamic range is combine PWM with
a D/A. For example, a simple R2R network can provide M-bits, while the PWM
portion can provide the remaining N-bits. However, like the N/M PWM this will
have several combinations of M and N that produce the same value.

Scott

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\30@221911 by Robert A. LaBudde

flavicon
face
At 08:55 PM 12/30/00 -0600, Scott wrote:
>I assume people refers to me in particular. How does a single instruction
>cycle
>resolution PWM preclude you from dithering? In fact, I've done just that with
>the routine referenced above. I've got a version that will produce a 12-bit
>analog value by "dithering" 16 consecutive 8-bit values.

Also, a 1-instruction accurate starting point would beat an adaptive
technique due to lost instruction cycles.


================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: .....ralSTOPspamspam@spam@lcfltd.com
Least Cost Formulations, Ltd.            URL: http://lcfltd.com/
824 Timberlake Drive                     Tel: 757-467-0954
Virginia Beach, VA 23464-3239            Fax: 757-467-2947

"Vere scire est per causas scire"
================================================================

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\31@015708 by Bill Westfield

face picon face
> > > So not really 10-bit after all. 3.1 bits [about
> > > what I said :)]
> >
> > No: Far better than 3.1 bits.

So although you only have 7 levels plus full on/off (9 levels, 3.1 bits
worth of unique states), each level is individually tunable to a level
that would have required ~10bits of resolution to specify via a normal
linear D-A converter.

A very interesting disctinction.  I wonder how often something like that IS
useful.  Certainly, for your typical n-channel x-bit converter, you don't
need more than n simultaneous levels even if 2^x is much larger than n.
Back when we were talking about the 8-channel, 8-bit, 50kHz (? IIRC?) PWM
controller, I was coming up with LOTS of ways that could work if you could
carefully pick the 8 levels to not conflict with each other, but you can't
do that for the normal case...

BillW

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservEraseMEspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body


2000\12\31@104914 by Olin Lathrop

face picon face
> By dithering duty cycle on a 1-instruction basis, resolution can average
to
> much better than 1-instruction times, if the averaging period is long.
>
> Here's a simple adaptive algorithm:
>
> 1. Start an accumulator on duty cycle during the averaging period, or a
> moving average across periods.
>
> 2. If accumulator/average is low, turn on duty cycle.
>
> 3. If accumulator/average is low, turn off duty cycle.

Bresenham's algorithm seems appropriate since it was originally developed as
a higher speed alternative to this sort of slope/accumulator calculation.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, RemoveMEolinspamspamBeGoneembedinc.com, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservKILLspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body


2000\12\31@154814 by Peter L. Peres

picon face
>pulse accumulator technique, switch duty cycle in pwm often

Ah, now it starts to make sense. but I still think that the integration
period will be larger and require a longer time constant, and Roman wanted
fast response ? In fact, to obtain the same ripple if the period of PWM is
M and the period of the pwm modulation of the pwm (now I named it) is N
which is necessarily K*~M (~M is M averaged) then the integrator will need
a time constant at least K times greater than for a direct pwm (in M)
approach.

It would be possible to obtain more fine divisions, but in the end they
would be as fine as a simple PWM with period K*M, and have the same low
frequency components to be filtered.

I think that Roman chose certain pairs of M/N that correspond to his
desired, fixed output values, and switches between them to change the
output voltage, not to increase accuracy. This is what I understood so
far. And that those pairs of M/N happened to match his desired PWM output
duty cycles best.

Peter

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspam_OUTspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body



'[PIC]: fast easy DAC with PIC'
2001\01\01@003225 by Roman Black
flavicon
face
Peter L. Peres wrote:

> It would be possible to obtain more fine divisions, but in the end they
> would be as fine as a simple PWM with period K*M, and have the same low
> frequency components to be filtered.
>
> I think that Roman chose certain pairs of M/N that correspond to his
> desired, fixed output values, and switches between them to change the
> output voltage, not to increase accuracy. This is what I understood so
> far. And that those pairs of M/N happened to match his desired PWM output
> duty cycles best.


To get best performance out of this it needs to be done
holistically, ie, hardware and software.

Assuming you can allow freq variance up to 100%, say from
100kHz to 200kHz. That is 50 to 25 PIC instructions at 20MHz.

Now lets start at the bum end, (always a good idea).
You need to drive a few, accurate, preset currents in
a load. And switch between these quickly. You need a
very high pwm frequency with small RC time constant.

The load is driven by a NPN transistor, with a 1 ohm
emitter resistor, so a base voltage of 1.6v gives one
amp (allowing 0.6v to turn on the transistor).

Table:
1A      = 1.6v (analogue pwm output)
0.8A    = 1.4v
0.6A    = 1.2v
0.4A    = 1.0v
0.2A    = 0.8v
0A      < 0.6v

Note that we have designed the hardware to suit this
software, we avoid the need to produce a very low
analogue voltage, or a midrange voltage. Our PIC pwm
can output between 0v-5v, but we choose the band
0.6v - 1.6v. This is significant!

So running a freq of 25 PIC instructions we output
5 on/20 off to get 20% duty cycle, giving us 1.0v
(simple!) we have 0.4A load current, a midrange
figure for example. And at 200kHz, nice fast
resonse. :o)

Now we change the ratio to give fine adjustment:

5:20    1.0000v         (highest allowed freq)
5:21    0.9615v
5:22    0.9259v
<snip>
5:44    0.5102v
5:45    0.5000v         (lowest allowed freq)

So now we have 25 separate values from 1v to 0.5v
still within our allowed freq range. There is almost
0.04v per division at the high end and 0.01v
per division at the low end.

Now try this:
6:19    1.2000v         (max f)
6:20    1.1538v
<snip>
6:43    0.6122v
6:44    0.6000v         (min f)

So now we have another 25 values from 1.2v to 0.6v.
You might also notice that the range that does not
overlap between these two examples is the 0.5v to
0.6v range in example 1, which just happens to be
the part of that range that has the finest resolution
and the most samples. :o)

Due to the ratiometric nature of this spread, there
is a nice spread of possible values with minimal
double values. And of course we can go to 4:x, 3:x,
7:x etc etc to get a very fine range of adjustment.
:o)
-Roman

PS. Did you know that the part of your brain that
understands formulae/math is a direct enemy to the
smart lateral thinking bit that provides the clever
solutions? Einstein was clever but never achieved
his major goals. Da Vinci was clever using the other
side of his brain, and would have been flying around
in the sky if the technology could have kept up with
his invention. Given a choice of being like Einstein
or Da Vinci, I would have to choose the smart one!
I'm bored, sorry. ;o)

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-request@spam@spammitvma.mit.edu


2001\01\01@170617 by Bob Ammerman

picon face
> > Q: Given N and M with N > 0, N < M, M <= maxcount, what is the largest
space
> > between realizable duty cycles?
>
> I haven't followed this thread (or any for that matter lately) too
closely. But
> to answer your question: 1/M(max). The easiest way to see this is imagine
M is
> the maximum value. Now, what would be the minimum pulse width? 1/M.
Similarly,
> if you try to obtain the maximum pulse width, you'll discover the 1/M
> quantization limitation. So the largest space between realizable duty
cycles is
> 1/M.
>
> The distribution of ratios IIRC is triangular with a maximum in the
> middle. Which is to say that the number of N/M expressions that can
produce
> something close to 1/2 is maximum (M/2 in fact). [The next closest PW to
1/2 is
> (M/2)/(M-1) and is about 1/(2*(M-1)) away.]
>

Yep, of course that is pretty obivious in retrospect. But what really
matters is:

Q: What is the largets space between realizable duty cycles in the range of
interest?

> >
> > This is really a _great_ scheme!
>
> Perhaps (but I didn't see it). The PWM resolution is ultimately related to
the
> clock. If you have an algorithm that can produce changes for any arbitrary
clock
> edge then you're not going to get any better than that. Here's a software
PWM
> that has single instruction cycle resolution:

Yep, if you need an arbitrary output this is certainly true. But if your
output tends to fit the possible duty cycles (and Roman's stepper drive
values do, it seems) it lets you get much higher effective accuracy
(precision?) than you could otherwise get.


> http://www.dattalo.com/technical/software/pic256.txt

I've looked at this and it to qualifies as _great_ in its own domain of
application :-)

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestEraseMEspamKILLspammitvma.mit.edu


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...