Shop OBEX P1 Docs P2 Docs Learn Events
FastSpin is really fast — Parallax Forums

FastSpin is really fast

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

  • cgraceycgracey Posts: 14,133
    That's great! It looks like it's doing 32 loops every 8us?
  • ReinhardReinhard Posts: 489
    edited 2020-01-20 12:19
    Yes, the pulse repeats every 32 * 8µs.
    1. This enables the osci to trigger better.
    2. The pulse can subside, but the filter continues to calculate.


    Here is the step response.
    400 x 240 - 28K
  • That's a cool demo, @Reinhard! Glad you're enjoying fastspin :).

    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".
  • Thanks for the hints, from today I will use the functions / macros of propeller2.h. I somehow overslept that.
  • ReinhardReinhard Posts: 489
    edited 2020-01-24 11:27
    I would like to continue the discussion here. I've hijacked the thread, which is about NCO mode, for too long.
    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)
    400 x 240 - 31K
    c
    c
    1K
  • cgraceycgracey Posts: 14,133
    Reinhard, you can connect an I/O pin to GND or 3.3V all day long, no matter what it's outputting. It won't hurt it. Just don't apply over 4V, as that can break it.
  • ErNaErNa Posts: 1,742
    Hi Reinhard, the noise we see in the filtered and unfiltered signal seems about the same level. So I imagine, it's the noise from the scope. Could 'nt you please upload pictures with higher resolution?
  • @ErNa
    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 ..)
    800 x 480 - 90K
  • ReinhardReinhard Posts: 489
    edited 2020-01-24 17:01
    for all they interest in filter.
    I implement this
    source: https://www.earlevel.com/main/
    1024 x 576 - 52K
Sign In or Register to comment.