SD Card Speed

1356710

Comments

  • DavidZemonDavidZemon Posts: 2,224
    edited March 12 Vote Up0Vote Down
    Well... indeed I am having trouble getting this working in the latest SimpleIDE release. I don't know if it's because of changes in PropWare, changes in SimpleIDE, or both. I'll let you know via the PropWare thread whenever I get this figured out :(

    --Edit--
    Also created an issue in GitHub.
    David
    PropWare: C++ HAL (Hardware Abstraction Layer) for PropGCC; Robust build system using CMake; Integrated Simple Library, libpropeller, and libPropelleruino (Arduino port); Instructions for Eclipse and JetBrain's CLion; Example projects; Doxygen documentation
  • FYI - With a minor adjustment to my code I now read a sector every 1ms or around 500kB/sec. I expect to trim some off this too before I try multiblock mode for back to back sector read without the command overhead.
    useforthlogo-s.png
    LINKS
    Brisbane, Australia
  • Well done Peter :) Impressive
    David
    PropWare: C++ HAL (Hardware Abstraction Layer) for PropGCC; Robust build system using CMake; Integrated Simple Library, libpropeller, and libPropelleruino (Arduino port); Instructions for Eclipse and JetBrain's CLion; Example projects; Doxygen documentation
  • Thank you very much. David

    Say Peter...would you insert your minor adjustment in my code above so that I can run it on my Propeller Activity Board and get a look at the output to the motor?

    By the way, there appears to be an error in the for loop copied below:
    {
    val=1;
    val[i+1]=0;
    }

    Something happened to it during the upload to the Forum.
    {
    val=1;
    val[i+1]=0;
    }

    This is the way it is in my computer.

    Thank you.
    Discovery
  • Well, I'll be darned...the open bracket, i, closed bracket behind val did not print. I wonder why?

    Discovery
  • David...how do I get to your PropWare thread that you reference?

    Discovery
  • Discovery wrote: »
    David...how do I get to your PropWare thread that you reference?

    Discovery

    From the the "Related Links" page of PropWare's website. Also, here.

    Btw, I'm working on a completely different way to use PropWare from SimpleIDE. Hopefully it will be more reliable.
    David
    PropWare: C++ HAL (Hardware Abstraction Layer) for PropGCC; Robust build system using CMake; Integrated Simple Library, libpropeller, and libPropelleruino (Arduino port); Instructions for Eclipse and JetBrain's CLion; Example projects; Doxygen documentation
  • JasonDorieJasonDorie Posts: 1,809
    edited March 12 Vote Up0Vote Down
    The [ i ] thing, in the forums, means italics.

    If you use [ code ] and [ /code ] around stuff you want formatted correctly, like code, it will keep things like indenting and other stuff.
      val[i] = 1;
      val[i+1] = 0;
    
  • Oh...thanks.

    Discovery
  • Peter and David...How are you coming on your code?

    Sincerely,
    Discovery
  • PropWare won't run from SimpleIDE for quite some time. I can tell you it works great from Linux - that's where I do all of my development. It will work great from Windows too, but I've had terrible trouble getting GNU Make installed on Windows, and I'm using a CMake feature that is unsupported by Microsoft's NMake so that is out of the question. By far your best option is Linux... but I know switching operating systems just to use a library for the Propeller is not an acceptable solution.

    Cygwin on Windows ought to be a reasonable solution for getting GNU Make too... though I remember having trouble with that once. Basically, I despise Windows and it seems to have noticed, and only makes my life more difficult every time I try to help someone get going with PropWare.

    I finally thought life would be golden when Microsoft introduced the Windows Subsystem for Linux! But, alas, I have not found a way to program the Propeller from WSL. You can write the code, run the build system, compile the source from WSL... but you can't load the binary onto the Propeller. If you're willing to compile from WSL and load the binary from a standard Windows tool, that could work. But gross :(

    tl;dr
    I'm hoping Parallax respond to this issue soon, about updating the PropGCC version shipped with SimpleIDE. If they provide some hint as to what needs to be tested, then we can just fix SimpleIDE and continue using the PropWare solution that I've already documented on my website.
    David
    PropWare: C++ HAL (Hardware Abstraction Layer) for PropGCC; Robust build system using CMake; Integrated Simple Library, libpropeller, and libPropelleruino (Arduino port); Instructions for Eclipse and JetBrain's CLion; Example projects; Doxygen documentation
  • jmgjmg Posts: 9,645
    DavidZemon wrote: »

    tl;dr
    I'm hoping Parallax respond to this issue soon, about updating the PropGCC version shipped with SimpleIDE. If they provide some hint as to what needs to be tested, then we can just fix SimpleIDE and continue using the PropWare solution that I've already documented on my website.

    Is it practical to install SimpleIDE, and then patch over the top of that, as a workaround until Parallax fixes it ?

  • Peter JakackiPeter Jakacki Posts: 6,256
    edited March 15 Vote Up0Vote Down
    "FYI" is information only as all this runs in Tachyon well enough but it's more about all the layers of code which depend a lot upon implementation. So David may use this information as a guide as to what can be achieved but I don't know why you are requiring anything faster than what David mentioned was 278kB/sec in Propware which should be up to the task. Obviously don't use old SD cards, just spend five bucks and get a decent SanDisk Ultra. I have my sector read time down to 800us at present or around 640kB/sec ...... FYI.
    useforthlogo-s.png
    LINKS
    Brisbane, Australia
  • jmg wrote: »
    DavidZemon wrote: »

    tl;dr
    I'm hoping Parallax respond to this issue soon, about updating the PropGCC version shipped with SimpleIDE. If they provide some hint as to what needs to be tested, then we can just fix SimpleIDE and continue using the PropWare solution that I've already documented on my website.

    Is it practical to install SimpleIDE, and then patch over the top of that, as a workaround until Parallax fixes it ?

    I tried from Windows but wasn't able to get it to work. I'd love it if someone else that is more familiar with simpleide could give it a go and see what problems they run into
    David
    PropWare: C++ HAL (Hardware Abstraction Layer) for PropGCC; Robust build system using CMake; Integrated Simple Library, libpropeller, and libPropelleruino (Arduino port); Instructions for Eclipse and JetBrain's CLion; Example projects; Doxygen documentation
  • Oh boy...

    Discovery
  • Peter...Is there any way I can use your work to date to load onto my Propeller Activity Board and send step pulses to my stepper?

    Discovery
  • The file system already supports multiple files so therefore multiple buffers so that is an easy way to get it to fill one buffer while the nibbler works on the other. The nibbler would have to run in its own cog and be written in PASM but it would probably only take around 20 instructions or so that could easily be added as a RUNMOD in the kernel, a bit like the WAVE player RUNMOD which alternates through buffers. Even though this is all quite doable in Tachyon Forth and you could have it up and running in the hour it doesn't help you as your application is written in C.
    useforthlogo-s.png
    LINKS
    Brisbane, Australia
  • So, are you saying that there is no way that a "C" program can setup the SD memory and ping pong the Cogs to do what you have done?

    Discovery
  • Discovery wrote: »
    So, are you saying that there is no way that a "C" program can setup the SD memory and ping pong the Cogs to do what you have done?

    Discovery

    Not at all but you have to do it assuming the C library and tools are fully functional for your application. I might be tempted to test it out in Tachyon simply for my own curiosity though as I expect it to be quick and easy enough.

    useforthlogo-s.png
    LINKS
    Brisbane, Australia
  • It is possible to do this in C. However, you may have to write your own SD drivers to do it.
  • At this point...it is impossible for me to write an SD driver. My capability is limited to slightly modifying someones "C" code to fit my application.

    It appears that I will have to enlist the help of a hands on expert.

    I was hoping that I would be able to download SimpleIDE and PropWare to my brand new laptop purchased expressly for developing the Propware project. I understand that this is dependent upon Parallax Inc. making changes to SimpleIDE to accommodate PropWare or something to that effect.

    Peter...I would be interested in knowing if Tachyon satisfies your curiosity regarding stepping my ClearPath motors at 278 kHz to 500 kHz.

    Discovery
  • No problems with making it do what you want, and you only need anything capable of running a terminal such as teraterm or minicom. I'll check it all out later today when I get back. I'll be interested to see if it works for you too.
    useforthlogo-s.png
    LINKS
    Brisbane, Australia
  • jmgjmg Posts: 9,645
    .... Even though this is all quite doable in Tachyon Forth and you could have it up and running in the hour it doesn't help you as your application is written in C.
    In this use tho, the 'playback' and 'create record' do not have to be in the same language.
    The simplest Prop-side design would be Serial to SD for loading the card, and SD to Quad playback.
    'Something else' can create the streaming quad info.
    (maybe with a clock speed record in there somewhere, perhaps could pack invisibly into the spare records ?)

  • Loading the card would be best in the PC itself or I use FTP to loads and read files in some systems. Otherwise a simple serial loader which could easily run at 2M baud should help.
    useforthlogo-s.png
    LINKS
    Brisbane, Australia
  • Discovery wrote: »
    I was hoping that I would be able to download SimpleIDE and PropWare to my brand new laptop purchased expressly for developing the Propware project. I understand that this is dependent upon Parallax Inc. making changes to SimpleIDE to accommodate PropWare or something to that effect.

    Well if you want to try putting that laptop to good use, you could try your hand at Linux. Certainly, some laptops are easier to get working than others, so let me know the model number of the laptop and I can do some quick Googling for you to see whether or not you should expect any problems.
    David
    PropWare: C++ HAL (Hardware Abstraction Layer) for PropGCC; Robust build system using CMake; Integrated Simple Library, libpropeller, and libPropelleruino (Arduino port); Instructions for Eclipse and JetBrain's CLion; Example projects; Doxygen documentation
  • Peter...could you explain why the following is true?

    I wrote a really simple "C" program to test the speed of the propeller outputs. The program follows:

    while(1==1)
    {
    high(2);
    low(2);
    }

    The measured clock rate from out (2) was 39.0623 kHz and a perfect square wave. I can't imagine the "C" while instruction taking so much overhead. I expect a simple compare and do-loop.

    David...The new laptop is a Dell Inspiron 11 3000 series. I would like to try the Linux solution; however, I recall vividly several years ago I tried to use Linux for an application but to use Linux I had to make a few changes to the bios operating system. The bios changes screwed up the computer so I dropped the idea of learning Linux.

    Discovery
  • Dave HeinDave Hein Posts: 5,095
    edited March 16 Vote Up0Vote Down
    Discovery, the speed of a C program depends on the memory module. Which one are you using? The COG model is the fastest because it runs from cog memory. LMM would be the next fastest, and CMM would be the slowest. Also, you are calling the high and low functions, which incur calling overhead. It would be much faster if you wrote directly to the OUTA register.

    EDIT: Look at the toggle projects in the "Propeller GCC Demos" directory to get an idea on how to toggle a pin at a higher speed.
  • Discovery wrote: »
    Peter...could you explain why the following is true?

    I wrote a really simple "C" program to test the speed of the propeller outputs. The program follows:

    while(1==1)
    {
    high(2);
    low(2);
    }

    The measured clock rate from out (2) was 39.0623 kHz and a perfect square wave. I can't imagine the "C" while instruction taking so much overhead. I expect a simple compare and do-loop.

    First, keep in mind the difference between talking about C or C++ and talking about a specific library written in that language. The high() and low() functions are libraries provided with Simple, and they are indeed very simple to use. However, as you noticed, they're also terribly inefficient. Here's the implementation of high():
    void high(int pin)                            // high function definition
    {
      int mask = 1 << pin;                        // Set up mask
      OUTA |= mask;                               // Bitwise OR w/ OUTA & DIRA
      DIRA |= mask;
    }
    

    This compiles down to many more instructions than is necessary. Compare that to PropWare, where your code would look like this:
    Pin pin(Pin::P2, Pin::Dir::OUT);
    while(1)
    {
      pin.set();
      pin.clear();
    }
    

    And the implementation of pin.set() is much smaller than Simple's high():
    void set () const {
      OUTA |= this->m_mask;
    }
    

    And if you need anything faster than that, you'll have easy access to the hardware counter:
    Pin pin(Pin::P2, Pin::Dir::OUT);
    pin.start_hardware_pwm(80*1000); // Set PWM for 80kHz
    
    // Run other code...
    
    Discovery wrote: »
    David...The new laptop is a Dell Inspiron 11 3000 series. I would like to try the Linux solution; however, I recall vividly several years ago I tried to use Linux for an application but to use Linux I had to make a few changes to the bios operating system. The bios changes screwed up the computer so I dropped the idea of learning Linux.

    Discovery

    Looks like you should be fine with that laptop. Try downloading Ubuntu 16.10 (or 16.04 if you want the long term support release) and installing it. According to this thread, you should be good-to-go out of the box. Not sure if you got the 2-in-1 version that has the touch screen though... if you did, you'll have to deal without the OS autodetecting when you switch "tablet" mode.

    There is a chance you'll need to change the BIOS setting. I had to do that for my desktop, but not my brand new HP laptop. I don't know enough about UEFI and all the new fancy BIOS stuff to say with certainty whether or not you'll have to set BIOS to "legacy" mode. However... again, if you bought that laptop just for PropWare, where's the harm?
    David
    PropWare: C++ HAL (Hardware Abstraction Layer) for PropGCC; Robust build system using CMake; Integrated Simple Library, libpropeller, and libPropelleruino (Arduino port); Instructions for Eclipse and JetBrain's CLion; Example projects; Doxygen documentation
  • Peter JakackiPeter Jakacki Posts: 6,256
    edited March 16 Vote Up0Vote Down
    I booted into Linux Mint straight on my Dell XPS15 9550, created some EXT4 partitions and swap then installed using those partitions. I didn't have to modify the bios but I may have allowed legacy boot. I don't bother with ancient CDs for installation as I always load Linux onto USB Flash and it is much faster installing that way too.

    As for toggle speeds I can only tell you that the most inefficient way I can do it in Tachyon is this:
    BEGIN 19 HIGH 19 LOW AGAIN
    
    which produces a 207kHz square wave but if I do this:
    19 PIN BEGIN H L AGAIN
    
    then it jumps up to 667kHz but with another method I get 867kHz. None of these modes are coded in PASM but if you ever need a very fast square wave then
    19 APIN 12 MHZ
    
    will certainly be faster.

    Forgot this one which produces 1MHz in interpreted software
    19 PIN -1 FOR H L NEXT
    
    useforthlogo-s.png
    LINKS
    Brisbane, Australia
  • Thank you for the information. That clarifies things a great deal.

    I could really use your knowledge.

    I will be out of the laboratory for the next few days but I will see about downloading the Ubuntu 16.04 to the new laptop and run your earlier program in PropWare. The new laptop does have a touch screen feature.

    Dave Hein...the memory module is the SD memory that was shipped with the Propeller Activity Board. I probably should install an SD Ultra.

    Discovery
Sign In or Register to comment.