Searching for DAC
T Chap
Posts: 4,223
Is there a DAC object for using a Prop pin and no external hardware? I looked everywhere and don't see one. Searching Propeller + DAC didn't produce much. Here is the closest thing I can find using a recommended 10k and .1.
I need to set a voltage between 0 and 3 volts and change it as needed.
Thanks
Post Edited (originator) : 1/2/2007 6:46:44 AM GMT
PUB ADC_start(pin) dira := |< pin frqa := 0 ctra := %00111 << 26 + pin PUB ADC(value) frqa := value
PBaker said...
ADC_start initializes the ADC to output on pin and sets the inital value to 0V, ADC changes the output voltage to 3.3x(value/2^32).
I need to set a voltage between 0 and 3 volts and change it as needed.
Thanks
Post Edited (originator) : 1/2/2007 6:46:44 AM GMT
Comments
Look at the schematic for the Propeller Demo Board for an example (for the audio output) of this kind of DAC. There are some programs in the object library included with the Propeller Tool that copy sound from the microphone to the headphone output. This uses the DAC to produce the sound signal.
I'll check out the schematic mentioned.
i.e. PUB ADC(1.9)
I will test this myself tomorrow.
Is ADC universally accepted for both A to D or D to A? I'm puzzled why ADC is used in Pauls explanation when it is D to A.
I'm puzzled as well on that one.
Anyway the value would be from 0 to (2^32)-1.
(0) being 0 volts.
(4,294,967,295) being 3.3 volts.
(2,147,483,648) would be 1.65.
You might want to scale this to something else.
For scaling, if you use a number between 0 and 29 to represent voltages between 0.0 and 2.9, you could approximate the scaling by the following:
What this does is to position the 0-29 value in the upper 6 bits of a 32 bit signed long,
divide it by 33 to get a quotient that's a fraction of 33 with the binary point between the upper 6 bits and the lower 26 bits, then shift that fraction left to put the binary point all the way to the "left" end of the long word. This makes it a fraction of 2^32-1 which is what you want for the D-A process.· The reason for doing is this way is to get as accurate a fractional value as possible, yet to adjust for the fact that the division may be signed.
Post Edited (Mike Green) : 1/2/2007 6:27:43 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Can someone tell me where the error is? I get 3.3v on pin no matter what Value is from 0 - 3.3 equiv. I tried .1 and .01 with 10k.
Thanks
Then reverse the roles of p0 and p1.
Either one should give 50% duty cycle, but the one from the counter module will be much much faster (40mhz switching).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 1/5/2007 9:19:05 AM GMT
Sub'd %00110 for %00111
I had no idea you could set and forget counters like this, it's like having another set of semi-limited cogs to put to use. Pretty exciting discovery.
%00111 is the differential mode, where you have the true output on Apin and the complement of that on Bpin. You had originally set up pin p0 to be the output for both, by default. On the surface that is a conflict, because in differential mode that pin will want to be both high and low at the same time. Nonetheless, the propeller arbitrates the conflict and the final state of the pin is always high, 3.3 volts, as you observed.
The propeller i/o logic is wired OR for both DIRS and OUTS.
Paul, I see the same thing in the listing on page 13 of AN001, the counter doc. The counter mode is set to differential with both apin=0 and bpin=0, although the comment at the end of the line mentions bpin=1.
Post Edited By Moderator (Paul Baker (Parallax)) : 1/5/2007 9:48:36 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
That should be classified as a trap, to use any of the differential modes (pll, nco or duty) when you really need single ended. It won't work as expected if both apin and bpin are the same.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 1/5/2007 9:20:29 PM GMT
Sorry about editing the post I just quoted from, I accidently hit the edit post button instead of the quote post button. I restored your post to it's orginal form.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Thanks for pointing out the OR'ing of both counters and the clarofication. It appears that both counters could be used simultaneously on different pins in single ended mode, giving a total of 32 pins of DA as a real possibility, not for a specific application in mind.
It is confusing because both counter A and counter B each have an Apin and a Bpin.
There are a total of 16 counters in the 8 cogs. So they could affect 16 pins in single ended mode, or up to 32 pins in differential mode.
Paul, I know what you mean about code carryover! The bane of copy and paste. I added a little note to the "tricks and traps" sticky about that one.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com