go away spammer

Author Topic: AxonII based Robot: Will not read from an SD card  (Read 3019 times)

0 Members and 1 Guest are viewing this topic.

Offline SlightlyNormalTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
  • Aspiring Physicist
AxonII based Robot: Will not read from an SD card
« on: August 01, 2012, 11:28:39 PM »
I have built a robot with an Axon II microcontroller and several other components built on a LEGO chassis. Here is a pic of the bot: http://home.fossilfolk.com/_/rsrc/1341900528772/home/mike/mikerobot.jpg

I am testing out an sd card to store matrices for a mapping program that I am working on. The program I am using is just an sd card test. (the code is ugly) The robot will make folders and files and output, but it will not read text (even text that the robot itself outputted) into a string or char[].

I expect it to make two files, one with " Text Into A File! 123abc " and one with "Text Into ". The first one works, the other one is always blank. I have tried letting it read RTTTL files and play them but it won't read anything into the char[].

Here is my code:


#include "sys/axon2.h"
#include "Storage/sdCard.h"
#include "Storage/FileSystem/FAT.h"
#include "rprintf.h"
#include "spi.h"
#include "spisw.h"
#include "tone.h" //L5 is tone pin

#define MOSI B2
#define MISO B3
#define SCLK B1
#define CS L0

SD_CARD card = MAKE_SD_CARD(CS); //miso- orange, mosi- grey, clk- white, green L0, red 3.3+, arrows align.
SPI_DEVICE_LIST devices[] = { &card._device_};
SPI sd_spi = MAKE_SPI(devices);
DISK disk;
FILE test_file;
boolean written = 0;
boolean initRslt;

TONE_PLAYER testTone = MAKE_TONE_PLAYER(TIMER1, L5);

void appInitHardware(void)
{
   spiBusInit(&sd_spi,1);
   initRslt = sdCardInit(&card);
   diskInit(&disk, 10, sdCardGetStorageClass(), &card);
   segled_put_char(&led_display, 'A');
}

TICK_COUNT appInitSoftware(TICK_COUNT loopStart)
{
   segled_put_char(&led_display, 'B');
   rprintfInit(fileGetWriter(&test_file));   
   return 0;
}

TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart)
{   
   string tune;
   if (!initRslt)
      segled_put_char(&led_display, 'o');
   if(written)
   {
      return 500000;
   }
   
   diskMkdir(&disk, "test_folder");
   fileOpen(&disk, &test_file, "/test_folder/test_file.txt", 'r');
   fileReadNext(&test_file, 10, tune);
   fileClose(&test_file);
   segled_put_char(&led_display, 'C');
   fileOpen(&disk, &test_file, "/test_folder/test2_file.txt", 'w');
   rprintfStr(tune);
   fileClose(&test_file);
   tonePlay(&testTone, 1568, 200);//high G
   clockWaitms(200);
   written = 1;
   return 1000;
}

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: AxonII based Robot: Will not read from an SD card
« Reply #1 on: August 02, 2012, 02:27:32 PM »
There's quite a lot wrong with the code  :-X.
You seem to be using Version 1 of WebbotLib. Suggest you use Version 2 + Project Designer (from webbot.org.uk). It will then generate some example code in either C or C++ so you can see how you should be talking to the sdCard etc
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline SlightlyNormalTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
  • Aspiring Physicist
Re: AxonII based Robot: Will not read from an SD card
« Reply #2 on: August 03, 2012, 01:12:19 AM »
Thanks for the reply. I will try your suggestion and post my results. I had forgotten about the project designer lol. :-[

Offline SlightlyNormalTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
  • Aspiring Physicist
Re: AxonII based Robot: Will not read from an SD card
« Reply #3 on: August 06, 2012, 01:19:56 PM »
I used the project designer to create a new AVR project file for my robot, and it generated the example.txt that you mentioned. However, the example.txt does not mention how to use the SD card. I've included both the exported project file (just replace the .txt with .prj) and the example.txt , so you can verify.
Thanks again!

PS: I also was unable to change the L293D motor driver Supply:Motor Battery to my 4.8v drive battery. I am using the AxonII with the solder bridge cut for separate logic and drive batteries, is there any way I can specify that in the Project Designer?

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: AxonII based Robot: Will not read from an SD card
« Reply #4 on: August 07, 2012, 12:08:24 PM »
For the L293D just add a new power bus (half way down the left side) - and then tell the L293D to use that.

For the SDcard - just checkout the docs. If you are using C then: http://webbot.org.uk/WebbotLibDocs/34649.html and its link to FAT.h if you want PC readable files. For C++ then: http://webbot.org.uk/WebbotLibDocs2/46675.html and http://webbot.org.uk/WebbotLibDocs2/46708.html and http://webbot.org.uk/WebbotLibDocs2/46810.html
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: AxonII based Robot: Will not read from an SD card
« Reply #5 on: August 10, 2012, 07:45:13 AM »
The Axon Mote uses WebbotLibs uSD code.

See here for example usage:
http://societyofrobots.com/axon_mote/axon_mote_code.shtml#usd

Offline SlightlyNormalTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
  • Aspiring Physicist
Re: AxonII based Robot: Will not read from an SD card
« Reply #6 on: September 24, 2012, 07:47:43 PM »
Okay, Finally figured out what I needed to do after a break from robotics. updating my webbotlib fixed it all. I have to say that it is really helpful to have both the maker of my microcontroller and the writer of the software that I use, respond to my noob level question. Thank you both!

 


Get Your Ad Here