Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: auxiliary SD card drive Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
chronic
Guru
Guru


Joined: 21 January 2012
Location: Australia
Online Status: Offline
Posts: 564
Posted: 15 May 2018 at 6:36pm | IP Logged Quote chronic

As part of incorporating file I/O and more datatypes into my interpreter program I have been able to set up a SD card as an auxiliary drive.
It uses a small uno for the drivers/housekeeping, and is driven with single 16-bit spi words to open, read, write, and close bytes and csv file as necessary. This means any four micro pins that can bit-bang some spi can be used to connect it.

eg to write a line of some test variables into a csv file:

PROGRAM testwrite
C
      CHARACTER*20 s
      INTEGER*1 a
      INTEGER*4 b, n
      REAL c
      DOUBLE d
      UNSIGNED*1 e
      a = 123
      b = 1222333444
      c = 1.123456
      d = 1.12345678
      e = 234
      s = 'squarkoid'
      OPEN WRITE
      CALL longd()
      WRITE (1,*) a, b, c, d, e, s
      CLOSE
      END
...


and then read it



      PROGRAM testread
C
      CHARACTER*20 s
      INTEGER*1 a
      INTEGER*4 b, n
      REAL c
      DOUBLE d
      UNSIGNED*1 e
      OPEN
      CALL longd()
      READ (1,*) a, b, c, d, e, s
      PRINT a," ",b," ",c," ",d," ",e," ",s
      CLOSE
      END
...



displays the line


123 1222333444 1.123456 1.12345678 234 squarkoid



A main advantage is that using a uno means the SD drivers are separately maintainable .
Any errors are reported back via the word exchange. On power-up a check is done for directory access etc. I found a small delay was needed between opening a file and accessing it.
So far I have run files of 185k without problems, it should be good for 4Gb. It might be useful for other systems, if there is further interest.


Back to Top View chronic's Profile Search for other posts by chronic
 
Quazee137
Senior Member
Senior Member


Joined: 07 August 2016
Location: United States
Online Status: Offline
Posts: 121
Posted: 15 May 2018 at 8:05pm | IP Logged Quote Quazee137



Thanks.
As I understand it this is an SPI based SD raw drive?
And will/is there file handling?

Using this will use less of the 170's flash to store
setup or log files on SD. I have been looking into I2C/SPI
fram / flash for this but your way allows so much more storage
and is removable. Looking forward for more.

Quazee

any thoughts on I2C as thats what I playing with now.
Back to Top View Quazee137's Profile Search for other posts by Quazee137
 
chronic
Guru
Guru


Joined: 21 January 2012
Location: Australia
Online Status: Offline
Posts: 564
Posted: 15 May 2018 at 11:10pm | IP Logged Quote chronic

The data is saved as strings of bytes, the files are csv files and can be seen/used as text or excel etc. [I did have an early version that could save values as native binary eg 4 bytes for a 32bit value but it is not developed.]
So far it uses two preset filenames, one for reading, another for writing; writing will create a new file if it is not already present, or append data to a file already present.
It is fairly slow - there is a preset delay in the uno which I have not changed - but it chugs away logging gps values well enough.

ed - re I2C - I have tried to stay clear of it, there seemed to be problems in the early versions but it looks popular now. I have stuck with spi as it offers higher speed maximums, it too has had its gotchas though.

Edited by chronic on 16 May 2018 at 9:55am
Back to Top View chronic's Profile Search for other posts by chronic
 


If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Search the forums using Google.
In the news...
 
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.1094 seconds.
Privacy Policy     Process times : 0, 0, 0, 0.11