FastSpin is really fast
Reinhard
Posts: 489
in Propeller 2
I thought I would have to use inline asm for a real-time digital filter. Then I tried it out in FLEXC anyway. I have a pulse as a test signal and put it in the high pass filter. In the picture below you can see the discrete impulse response. The pulse is output at a sample rate of 120,000 samples / sec. It is therefore approx. 8µs wide. As you can see from the oscillogram, the computing time for the filter is irrelevant.
Comments
1. This enables the osci to trigger better.
2. The pulse can subside, but the filter continues to calculate.
Here is the step response.
You could reduce the amount of inline assembly (if you'd like) by using <propeller2.h>; that has functions for smart pin read/write and setup, which should generally be inlined by the compiler automatically.
Also, a minor note: "xor a, ##$8000" may be written in P2 as "bitnot a, #15" to save an instruction (the ## form requires an AUGS for the long immediate). The 4.1.0 compiler will do this automatically when you write "a = a ^ 0x8000".
And without the help of @ariba, I couldn't go on here.
The program creates a ramp at P0. Connected to P2 as ADC input.
This signal is filtered low pass and output again at P4.
Now to Fastspin.
fastspin -2b ex1.c ---> fsignal = 802 Hz
fastspin -2b --fixedreal --code = cog ex1.c ---> fsignal = 20.833 kHz
(I think there is not much difference to pure p2asm)
By the way, in my first test I accidentally jumped P0 with GND.
I only noticed it after a few seconds and immediately cut off the USB power supply.
Thank God nothing happened (sweat)
The levels come because the filter input is very rough.
The generator DAC is incremented with 4096 steps up to 0xFFFF. That is 16 discrete steps. This is also reflected in the answer. Ramp and low pass is probably not the usual combination.
Soon I will do an example using the
Excitation function can be selected at runtime (pulse, step, ramp, sine) and also the filter type (LP, HP, BP, Notch ..)
I implement this
source: https://www.earlevel.com/main/