smartpin pwm
AndyProp
Posts: 60
in Propeller 2
Seen some very exciting high speed MHZ waveforms generated on a smartpin but I only saw these going as slow as 1hz.
Could it be slower, like to generate a signwave for example running as slow as a one cycle over a minute.
Comments
The DOCs do not seem to have a formula or limits on the opcode
SETXFRQ {#}D Set streamer NCO frequency to D.
At low frequencies you could run an interrupt and do LUT -> DAC on a INT+SW DDS down to any low milliHz value.
There is a 16-bit prescaler and 16-bit range in PWM mode which gives 0.058 Hz at 250 MHz CPU clock,
A real-time computed sine wave could be programmed into a DAC dithering smartpin. Slowest sample rate using a 4 MHz sysclock is 61.3 Hz but there's no upper limit to the number of computed samples per sine cycle.
@evanh, you might be tired.
How do you exactly sample a DAC?
Mike
A friend wanted to generate some lowish (< 1kHz) sine waves for a simple audio project -- I came up with this (intended to run in its own cog). As Evan points out, changing the timing between the steps affects the frequency, so this could be modified to go slower.
They're still called samples whether coming from an ADC or going to a DAC.
Hmmm,
I see that @JonnyMac is using P_DAC_DITHER_PWM
Is this not what I was asking about in my FlexBasic-PWM thread re: generating 16bits at higher frequencies?
There are 2 modes of DAC 8-to-16 bit extension in P2: PWM and random dither.
PWM needs sample rate=clock/(256*n) but it is very precise, gives over 1 MHz sample rate at 16 bit resolution and is simply noise free. Connect it to an audio amplifier: this is the best DAC I ever connected to the audio amplifier. You can get over 24bit resolution in accoustic band using a noise shaper, but who cares, at 1.25 MHZ sample rate you have 110 dB SNR in accoustic band without any tricks. This thing doesn't have any noise you can hear unless you set your 200 W amplifier to the full volume. I tried 3-bit sine wave on such an amplifier, the sound was stil pure. With a noise shaper in theory these DACs can give SNR over 160 dB (!!!). Compared to analog circuit noise, power supply noise, etc, this is simply zero.
This mode switches between 2 adjacent 8-bit levels using PWM, that is why this 256 divider is needed
Random dither is... random. The average value is 16 bit, but the noise is equally spread in the band instead of being 1.25 MHz and its harmonic as in PWM mode . This means you can hear a part of this noise. A very rough calculation - this is 1 bit noise at 8-bit resolution, but it is spread equally into 150 MHz band, so the hearable noise is something about -83 dB The "full power amplifier test" gives something like this. Also, the "3 bit sine wave test" was not as good as in PWM mode: there were distortions hearable.
This mode doesn't require any particular sample rate. I have a Paula emulator started: it needs 3.5 MHz sample rate, so I will use this mode there. Good enough for Amiga modules and other retrocomputer audio things.
@pik33
The OP was a question of how slow it can be, not how fast.
Still very Interesting info, thank you.
It can be as slow as you want Set an interrupt from the timer, up to several seconds is available, then make a software counter as long as you wish,