PDA

View Full Version : SD card improved



Klap
03-31-2009, 07:52 AM
Now that I finally have the SD Card Adapter working I have re-created parts of files from Radical Eye Software
http://forums.parallax.com/forums/default.aspx?f=25&m=162235
into a set of SD card programs which should be much easier to understand and use. If you have never used an SD card program before or didn't quite understand it, then this is the program for you.

I will be creating some applications that will use these files in the future (inspired from PASMStore). I will be creating a program that will store LED blinker data, Ping))) sensor data, and finally storing data from a Wii Nunchuck.

Mike Green
03-31-2009, 08:07 AM
If you haven't looked at them already, you might look at one or more of the FemtoBasic derivatives. These are based on Rokicki's mid-level routines, but use a different low-level SPI package written in assembly and integrated with an I2C driver. You can read and write data files as well as Basic and Spin programs on the SD-card as well as directly access the I/O pins. There's one version (BoeBotBasic) that can handle a PING))) sensor and servo motors.

Oldbitcollector (Jeff)
03-31-2009, 08:11 AM
@Klap:

The updated page for page 5 of the Cookbook is here...
www.warrantyvoid.us/tiki-index.php?page=Interfacing+SD+media (http://www.warrantyvoid.us/tiki-index.php?page=Interfacing+SD+media)

Also, you might find the "SD Trainer" might be of interest to you.
www.warrantyvoid.us/tiki-index.php?page=Objects (http://www.warrantyvoid.us/tiki-index.php?page=Objects)

Glad to see you are enjoying it now. The SD is one of the best addons for Propeller.

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?

Visit the: The Propeller Pages (http://www.warrantyvoid.us/tiki-index.php?page=Propeller) @ Warranty Void.

Klap
03-31-2009, 10:27 AM
Thank you for the suggestion Mike.

I already downloaded the FemtoBasic file and all the stuff that comes with it. I just don't understand it or even how to use it. I was thinking it might be covered in the Hydra Book but that book is not in PDF format and I can't afford to buy it. Perhaps one day when I get really good at programming or can afford to buy it I will be able to use it. Until that time comes it is just too far over my head. I just started programming in Propeller three weeks ago so I try to stick with the simple stuff.

Mike Green
03-31-2009, 11:11 AM
FemtoBasic is just a simple Basic interpreter written in Spin. FemtoBasic itself uses a keyboard and either a VGA or TV display. BoeBotBasic is for use on a BoeBot chassis and can use either an xBee wireless serial link for its console or the debugging/download port to a PC. DongleBasic is a stripped down version originally intended for Bean's (Hitt Consulting's) Prop Dongle, but will work on any Prop setup with at least a debugging/download serial port. All of these have statements that will allow direct access to the I/O pins, cog counters, system clock as well as an SD card and any attached EEPROMs. They all come with precompiled binary versions that can be immediately downloaded. There's an included documentation file.

Cluso99
03-31-2009, 10:35 PM
Thanks OBC (and other authors) - got it running in minutes with my microSD. I changed the I/O pins and upped the baudrate to 115200 and it worked (except the TestMountSD seemed to hang). I read the card (file) back on the PC just to be sure http://forums.parallax.com/images/smilies/smile.gif

Solution: In SD_Trainer.spin the TestMountSD statement does not work. Here is a suggested fix.

PUB Main | r,data

debug.start(31,30,0,115200) '' Open serial communication with PST <=== 115200 (was 57600)
waitcnt(clkfreq*4 + cnt) '' delay (so you can get PST active) <=== 4 secs (was 2)

debug.tx(Debug#CLS)
debug.str(string("Running the propeller SD training program",13,13))

''TestSerial '' Uncomment this line to test your communication setup.

''sd.start(@ioControl) '' \\ ** Start the SD Routines **
''TestMountSD '' || Uncomment these lines to test your SD setup.
''sd.stop '' // ** Stop the SD Routines **

''repeat '' Uncomment this line to loop here - prevents writing to the SD card

''************************************************ ****************************


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBladeProp (http://forums.parallax.com/showthread.php?p=786418), SixBladeProp (http://forums.parallax.com/showthread.php?p=780033), website (Multiple propeller pcbs) (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index (http://forums.parallax.com/showthread.php?p=778427))
· Search the Propeller forums (via Google) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBladeProp is: www.bluemagic.biz/cluso.htm (http://www.bluemagic.biz/cluso.htm)

Post Edited (Cluso99) : 4/1/2009 10:51:58 AM GMT

Klap
03-31-2009, 11:02 PM
As promised here is my first application using the SD Card.

I decided to skip the LED datalogging and go strait to the Ping))) sensor. Even if you don't own a ping sensor though just as long as you own a sensor that outputs numbers this code should give you the template you need. I pride myself in making this code easy to use and to understand. Even if you have never used the ping sensor this should only take about 15 minutes at the most to get completely up and running.

http://forums.parallax.com/images/smilies/hop.gif I am very excited to start using the SD card for actual applications. Next is the Wii Controller.

Klap
03-31-2009, 11:38 PM
I almost forgot to post this:
I am rewriting all of the files I obtained from

http://forums.parallax.com/forums/default.aspx?f=25&m=162235

for three main reasons.
(1) The basepin terminology is confusing: You have to figure out which pin is the base pin then you have to figure out which way the pin numbers are increasing: for example you may have the right base pin but if you flip the SD Card Adapter around then the pins will not line up to the code. In addition to that if a person was to make their own connect to the SD card then they may not have the pins line up the exact same way. Lining up the clk pin to the clk pin, the do pin to the do pin, etc. I think would be much easier to understand.
(2) I am using the Serial Terminal so I had to at least edit the top file.
(3) The naming system for the files I thought was very confusing. I am an ME so it took me a while to understand everything that was going on and how to use the programs. I always try to dumb my code down so that I will remember what I am doing when I come back to this several years from now.

Klap
04-01-2009, 08:03 AM
Here is the Wii Nunchuck SD Card application.

This program takes values from the Wii Nunchuck and stores them onto an SD card. I am using this application at CSU, Sacramento for my Sr. Project. My group is strapping a Wii/propeller onto a helicopter to get accelerations between -2g and 2g's which we will then use to calculate the forces on the frame where we are adding a helicopter pod.

Features of this program include:
The sample frequency and total time for sampling can be input as constant parameters.
The object StringToASCII.spin is included which transfers any and all characters to ASCII.
This object can also be run completely independently which makes the time to test and debug
this file literally seconds. All the user has to do is hit run and the debugging is done!
Lastly WiiToSdCard.spin contains ample amounts of notes so if a user ever wants to alter this code
that can be done in a snap!

The next thing I have to do is to take the Piezo Film Vibra Tab Mass

http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/flex/List/0/SortField/4/ProductID/89/Default.aspx

and use it to measure the natural frequencies induced in the aircraft. Has anyone used this sensor before? Or will I be creating my own code from scratch this time?

Hope you all enjoy this code!

Klap
04-02-2009, 06:22 AM
I just got a chance to look at SD_Trainer.spin. This is perfect for beginners. It is exactly what I had in mind for those beginning to use the SD card for the first time. I was able to make the changes that Cluso99 mentioned and wrapped the whole package, with some added documentation, into the file SD_Trainer_imporved.zip (see attachment). This is by far the easiest way to learn to use the SD card that I have ever encountered.

Once done with this program though the file SD_Card_Introduction.zip (see first post) will be useful for its faster speed. Enjoy.

Cluso99
04-03-2009, 01:44 PM
Just a heads up...
I have spent the last few days chasing a bug that looks like the SD card is not being shut down properly on a sd.close call (fsrwFemto.spin & sdspiFemto.spin) - DI and/orDO is interfering with the bus.

sdspiFemto.spin does not have any author's names. Is it yours OBC??

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBladeProp (http://forums.parallax.com/showthread.php?p=786418), SixBladeProp (http://forums.parallax.com/showthread.php?p=780033), website (Multiple propeller pcbs) (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index (http://forums.parallax.com/showthread.php?p=778427))
· Search the Propeller forums (via Google) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBladeProp is: www.bluemagic.biz/cluso.htm (http://www.bluemagic.biz/cluso.htm)

Cluso99
04-03-2009, 04:02 PM
Here is a link to a description of the SD SPI commands, etc
http://elm-chan.org/docs/mmc/mmc_e.html

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBladeProp (http://forums.parallax.com/showthread.php?p=786418), SixBladeProp (http://forums.parallax.com/showthread.php?p=780033), website (Multiple propeller pcbs) (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index (http://forums.parallax.com/showthread.php?p=778427))
· Search the Propeller forums (via Google) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBladeProp is: www.bluemagic.biz/cluso.htm (http://www.bluemagic.biz/cluso.htm)

Cluso99
04-03-2009, 07:26 PM
Here is a bugfix for the sdspiFemto.spin driver.·The fix is to the spiDoStop command. It is required that the CS pin be set high and a set of clocks be sent to the SD card to force the SD card to tristate the D0 pin.

I have also added the fix to the TestMountSD routine in SD_Trainer.spin,·added a routine to display the directory, and a slight modification to the code layout.

OBC or Klap: Would you like to update the obex??

For anyone wanting to try it on the TriBladeProp Blade #2 the D0/CLK/DI/CS pins are 9/28/8/14· http://forums.parallax.com/images/smilies/cool.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBladeProp (http://forums.parallax.com/showthread.php?p=786418), SixBladeProp (http://forums.parallax.com/showthread.php?p=780033), website (Multiple propeller pcbs) (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index (http://forums.parallax.com/showthread.php?p=778427))
· Search the Propeller forums (via Google) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBladeProp is: www.bluemagic.biz/cluso.htm (http://www.bluemagic.biz/cluso.htm)

Post Edited (Cluso99) : 4/3/2009 11:32:21 AM GMT

Klap
04-04-2009, 06:54 AM
Thank you very much for the input. I will be incorporating your changes into my programs and will re-post them. I also found some more example programs on some of the forums and am already in the process of altering my code to be even easier to read. The next post I make will include all of my past codes in order of easiest to hardest with a lot more notes and corrections to make the program that much easyier to understand, accurate, and easy to use/modify.