SD Card Speed
Discovery
Posts: 606
in Propeller 1
Using the Propeller development card that includes a microSD memory chip...how fast can the propeller write and read data from the device?
Sincerely,
Discovery
Sincerely,
Discovery
Comments
I was wondering if anyone has experience using one Cog of the propeller to read out data as fast as it can. The data also must be uniformly spaced in time, i.e. no data bursts.
My application is written in C.
Sincerely,
Discovery
I can throw some numbers at you, but it will be apples to oranges at the moment. Are you writing raw blocks to the SD card (without regard for a filesystem), or do you need your SD card to be formatted as FAT 16/32 so that a computer or other system can read the data at a later point? The benchmark results are drastically different depending on your answer.
Also, thank you for providing your application's language. The SD card and FAT routines that are shipped with PropGCC and the Simple Libraries are not very fast. No matter your answer to my above question, you will probably want to either use PropWare (if it's fast enough for you), convert an existing Spin object with Spin2cpp, or roll your own, highly-optimized version.
Maximum clock speed for an SD card in SPI mode is 25MHz although the most that the Prop can do is 20MHz @80MHz clock. However SD cards by their very nature do not output a continuous regular stream of data, the Flash memory is managed by a controller chip on the card which maps and wear levels sectors etc. So at the SPI layer commands are issued to the SD card controller (SD we'll call it) and then waits for however long that SD needs after which the SD sends back a token to say it's ready. Then and only then do you get to read the sector. If the file is non-fragmented then the sectors or blocks can be addressed sequentially without having to read the FAT table.
If you really want sustained high speed reads I suggest that you try dual QSPI Flash but then you might only have 256M bytes or so even with high density chips.
I know that when I play back WAV audio files from an SD that you can't have any breaks so after one buffer is filled and being played back another buffer is being filled so that they alternate functions. This is fine as long as the playback or read out rate is slower than the average SD read data rate. So if you are able to ensure contiguous blocks in a FAT32 file which is normally the case anyway, you could write a highly optimized driver over a couple of cogs to do what you want and maybe run the Prop at 100MHz and maybe it might work.....maybe.
I will be out of contact with the Forum for February and a few days into March. Then I will get back and try to work with you on writing the spin code. I have never written spin programs only C.
Sincerely,
Discovery
Sorry - I guess my real question got a bit lost in there. Do you need the SD card to be read by a computer or other system after the Propeller writes to it?
You need 500KHz for a machine tool? Doesn't sound right.
In answer to DavidZemon...I was hoping to use the propeller to readout the words from the SD as implemented in the Propeller Activity Board. As a test, I loaded a series of "1s" and "0s" in the SD then clocked them out to an oscilloscope to measure the speed. The output speed was 39.0625 kHz.
My interest now is to locate a shift register that is four bits (a nibble) by 46 giga nibbles deep. The propeller would do the calculations and load the shift register to the depth necessary to cut out the part and the readout would use a dedicated circuit. I noticed a German CMOS shift register of 128 bits deep. A really big shift register would be perfect but I have not located one.
I wonder if the propeller could write the nibbles to a large SD memory and a dedicated circuit could rapidly (say a 500 kHz clock) readout the values. I don't know what the dedicated circuit would entail.
Any ideas.
Discovery
46 giga nibble shift register hey? Do you know what you are doing? I'd say you are trying to describe the problem by a method that you think is best, a common mistake and one that will paint you into a corner. How about just describing the application, what the current problems are, and what you would like to achieve. You talk of a read data rate of 500kHz but is that bits or bytes and why is this necessary and how much data before you stop or repeat etc?.
Discovery
What you are looking for is a "FIFO", First In First Out, and I have not heard of one even close to the size you want.
Large FIFO's can be built using ram chips and some logic chips or a fast micro, or an FPGA.
"I noticed a German CMOS shift register of 128 bits deep. A really big shift register would be perfect but I have not located one."
This is what I mean by "do you know what you are doing".
46 giga nibbles would be 23 GB of memory which is totally impractical in terms of RAM for instance where you could have programmable logic cycling through the memory. In terms of SD memory it is achievable but then you would have to buffer it with one processor and read it out with DMA at the desired rate after a large enough amount has been buffered.
When you can only think "lots of nibbles" as a way to solve the problem it just means you haven't thought the problem through enough. Think outside the square even if it seems far fetched.
It is possible to read out data from an SD card at this rate but of course you would have one cog filling the buffers and another cog reading alternate nibbles from a long in the buffer and outputting that every 2us. But then you also have to tell the SD cog to wait as well to allow the "nibbler" to finish with its current buffer etc.
BUT, this is where you need to think this through. You are talking about writing 23GB to the SD card. Even at 250kB/sec that would take a full day to write. Do you really mean 46 "giga nibbles"?
http://forums.parallax.com/discussion/146447/what-is-the-current-state-of-sd-card-interface-driver-implementations
Your requirements started at 1 megaword (word?), then somehow evolved to 46 giga-nibbles. Quantitative disconnect. Huh?
There is no reason that separate cutting passes can be made and keep the single cutting pass at 1.075 mega nibbles.
Discovery.
BTW, some SD card drivers may even read a sector using a 20MHz clock but the limit is mainly the latency of the SD card getting the sector ready and also the overhead of the software in processing the data.
Here's the output:
and the code
So as long as you can feed the data into the prop fast enough, you can convert and output it fast enough.
As Peter has said, describe your actual requirements because you're not thinking about your problem properly.
Often a stepper motor driver is used to take a little load off the controller. It translates simple 'step' and 'direction' into the necessary coil drives rather than tasking the main controller with that mundane and granular task. I didn't see the pattern I was expecting with your step sequences of 2,3..14,15 and cant tell if you know about step and direction driver boards. In the off chance that you don't, and for the benefit of others, there is a hobby friendly board for $20 here https://www.sparkfun.com/products/12859 'big easy driver' 2A/Phase.
Just because you can see the peak and the whole side of the mountain, doesn't mean there isn't a better way to conquer it even if it involves what is unknown.
The propeller is an amazing and very powerful processor, you won't be disappointed. Consider investing some of that energy into reading G Code, or learning more about how to unleash the power of the prop. In case you haven't, check out Don Starkey's Propeller CNC control package. You are sure to learn from it. http://obex.parallax.com/object/85
Do I know what I am doing? I don't know, this is my first post ever on any forum. I offer some secret insight to the high project success rate that I now enjoy when working with electronics: The ugly frustrations and failures of the present, stand to make you beautiful in the future, if you persevere. Don't give up!
Use the SD card only to uplodade a ram/ eeprom @ low speed. And do the job from the faster ram /eeprom after the uploade ?
Or use two SD cards and mix the data to get the speed ?
When I make the upgrade to my CNC plasma cutter I will use very high speed step and direction stepper motors produced by ClearPath which have built-in algorithms for controlled direction reversal without missing a beat. They operate on 75 VDC with 5 volt logic control.
DavidZemon...that is what I am looking for. 278 kB/sec. That is good enough for my application. I will try to duplicate your SD driver code above on my Propeller Activity Board and send driver signals to my ClearPath stepper motor as a test. Thank you.
David...I don't have your ability to sit down and write code from scratch. All of the code that I use is from users who supply a piece of code that I integrate into my controls.
Sincerely,
Discovery
Upon running your code on my machine...I get an error stating that #include <PropWare/utility/utility.h> can not be found.
What do you suppose is the problem?
Discovery
I will try another source.
Discovery
What is your programming environment? If you're using SimpleIDE, you should following the instructions at the very top, with the heading "SimpleIDE (Any Operating System)". The file you downloaded is only if you're using a command line for compiling your code, or an IDE such as CLion or Eclipse.
Also, I'm a fan of keeping threads clean and on-topic. So if you have any more issues with PropWare, let's talk about them in this thread.
Discovery
I am thinking about purchasing a small laptop and using it for PropWare project development...just to be absolutely safe.
Discovery