QTC-UMD / dds-sweeper

Raspberry Pi Pico interface for the AD9959 DDS
BSD 2-Clause "Simplified" License
5 stars 2 forks source link

Expand Memory #14

Open ehuegler opened 2 years ago

ehuegler commented 2 years ago

As it currently stands, the pico can store about 8000 instructions in sweep mode. If using all 4 channels it would only be 2000 instructions. If the pico is timing itself, it loses 25% of its instruction storage.

If single stepping frequency, phase and amplitude, the max number of instructions would be about 15000.

It could be possible in the future to utilize the flash memory on the pico to store significantly more instructions, but that would add decent amount more complexity.

ehuegler commented 2 years ago

@dihm Here are the number of steps the pico can store when using all available RAM:

*If the pico is timing itself internally it can only hold about 85% as many steps.

ehuegler commented 2 years ago

I have been able to get it working so the pico stores the table in the flash memory. That allows the pico to hold 6 times as many steps across the board.

The downside is that writing to the pico's flash is really expensive, so it takes about a quarter of a second to program EACH instruction, seems like it could be too slow to be useful. (It is so expensive because in order to write to flash you have to erase then rewrite entire 4kB blocks at a time).

Reading from the flash is not expensive though, so reading back a table from flash performs just as well as reading it back from RAM.

dihm commented 2 years ago

Thinking about this briefly, I wonder if we could do something like having a special table programming mode that could help with these things. When you are in this mode, the pico insists on only accepting set commands and can do some optimizations as a result.

For instance, we could have a special binary block set command for writing long tables as a single command with minimal overhead. More importantly, maybe we could have all table set commands initially to RAM, then have the pico automatically move full 4kb sized chunks to flash as needed. This may be hard to handle well since you'd need to handle writing to flash while accepting more set commands to RAM, which sounds hard. Maybe in special programming mode you could allow direct 4kb block writes to the flash? Anyway, just spit-balling ways to up the numbers in a way that is functional.

In any case, even 2000 instructions per channel is actually a lot given that includes sweeps. I'll admit that it sounds a bit far-fetched that we really need to allow for so many sweeps at a given time.

ehuegler commented 1 year ago

There are several active issues in the pico-sdk repo which might make this more feasible in the future.
https://github.com/raspberrypi/pico-sdk/issues/758 https://github.com/raspberrypi/pico-sdk/issues/1169