View previous topic :: View next topic |
Author |
Message |
jgschmidt
Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA
|
|
Posted: Sun Mar 28, 2021 12:57 pm |
|
|
Thank you T, for your continuing interest and help with this. Your next (favorite beverage/snack) is on me
I compiled and tested your code and not getting expected results, looks like you were trying for a 1KHz signal. Timer1 is ticking nicely at 40KHz, but DACOUT only has a low voltage (40mV) 100MHz signal coming out.
I'll look into your setup to understand what you did. Have to do some "real" work for a while.
Toggled output from Timer1 Interrupt:
[img]http://jgscraft.com/graphics/ds33DACTest1.bmp[/img]
DACOUT pin:
[img]http://jgscraft.com/graphics/ds33DACTest2.bmp[/img]
Cheers, _________________ Jürgen
www.jgscraft.com |
|
|
jgschmidt
Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Mon Mar 29, 2021 12:51 am |
|
|
That is right.
At the moment, the output is a 'density' pulse stream. The proportion
of 1's to 0's, gives the average voltage it is to produce.
You need to enable filtering on this to produce the voltage. Too high
level, and it won't change quickly enough. Too low, and you get the
waveform as you are currently seeing.
This is controlled here:
Code: |
setup_comparator_dac(COMP_COMMON_DAC_ENABLE | COMP_FILTER_CLK_DIV_1 | COMP_DAC_CLK_DIV_1 | COMP_DAC_CLK_SRC_FVCODIV, 600 1100); //This is the fastest clock settings.
|
Note the two numbers added at the end. The first specifies the 'TMODTIME'
as a 10 bit value. The second, the SSTIME. The SSTIME should always be
greater than the TMODTIME. The values I've put in, should give you a
good starting point. For faster changes, reduce the first number.
The formulae for these are:
Quote: |
TTR = TMODTIME[9:0] * 2/FDAC in Seconds
TSS = SSTIME[9:0] * 2/FDAC in Seconds
|
Given your signal changes after 1/40000th second, and the clock
is 100MHz, the maximum that can be used is 1250 for SSTIME, while
allowing perhaps half this for a smooth transition, would be sensible.
I've put just slightly lower values to ensure the transition does complete.
This is 'getting your head round' this 'DAC' actually generating a pulse
stream, not a steady voltage. |
|
|
jgschmidt
Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA
|
|
Posted: Mon Mar 29, 2021 11:09 am |
|
|
Thanks, that does produce a nice sine wave at 1KHz. Only 200mV peak to peak though. Even less after some modest filtering. A little weak for my usual amplifier.
Still waiting for my external rail-to-rail DAC, in the mean-time will experiment with the HSPWM module a bit to follow up on the "PWM to DAC" articles I found. There seem to be a few HSPWM posts here I can use for guidance. _________________ Jürgen
www.jgscraft.com |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Mon Mar 29, 2021 11:31 am |
|
|
OK. Try turning down the damping times. See what happens if you halve
them. |
|
|
jgschmidt
Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA
|
|
Posted: Mon Mar 29, 2021 12:16 pm |
|
|
Tried that already, made a little difference. Will experiment further.
On a side note, it looks like this CK series chip I selected is relatively bleeding edge. In looking at the PWM and HSPWM samples and posts, these use EP series and the registers and settings options are different. More study before returning to the workbench. _________________ Jürgen
www.jgscraft.com |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Tue Mar 30, 2021 12:27 am |
|
|
It actually seems to be a very 'odd' hybrid.
It has things that are normally only on the older chips (like the CCP). 99%
of the PIC 24/30/33's, don't have the CCP, instead having the separate
input capture and output compare modules. But then has this slope
compensation DAC, and supports 200MHz operation.
Generally with PIC's. versions are launched because one of the MicroChip
customers 'wants' this particular mix of features. Something over half the
PIC's show this, often having slightly strange mixes of features.
This shows exactly this type of mix.... |
|
|
jgschmidt
Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA
|
|
Posted: Tue Mar 30, 2021 11:06 am |
|
|
Yup, I read about the "special" versions in another post and suspected that myself. I also suspect that the CCS setup for this device is a little "off". The HSPWM functions mix setting global and unit registers. I tried various options for the HSPWM functions, without luck and then went for direct register writes, per an example in the reference manual. Worked first time. I may turn this into a musical tone generator yet
Hmmm, I have 4 PWM, at least that many timers... can I combine the outputs from multiple PWM via the CLC to essentially combine multiple notes to a single output? Need more time reading and staring at the ceiling. I always wondered what a CLC might be good for, that you couldn't do in software, but this might be an example. Way out of my comfort zone here, but gotta keep those grey cells alive.
Side note: My "afternoon project for a friend" needs a musical tone generator. I thought this would be easy to find but was disappointed. I did find 2 legacy chips, one the size of a Brazilian cockroach (AY38910), and the 16-pin TI SN76489. I tried out the smaller one, but it didn't sound all that great and it needs 5V. And so lets see what the Microchip DSP chips can do, and here I am. Hopefully there'll be a new entry in the code library soon.
Cheers, _________________ Jürgen
www.jgscraft.com |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Tue Mar 30, 2021 11:30 am |
|
|
The biggest problem is actually detail in the documentation.
Any 'non standard' part is rather dependant on the examples, and when
they are new, these don't exist. This was exactly what happened with the
DACOUT, where there were the extra bits needed to actually enable this,
and zero documentation on this. I suspect the same will be true with
the PWM.... |
|
|
|