Shop OBEX P1 Docs P2 Docs Learn Events
PropDNA+RTC Board and SimpleIDE — Parallax Forums

PropDNA+RTC Board and SimpleIDE

RsadeikaRsadeika Posts: 3,837
edited 2013-12-20 09:34 in Propeller 1
Because this board has a built in RTC and some expanded RAM, I am trying to see what I can do with it. The question I have is, I noticed that SimpleIDE comes with dna.cfg and dna-nway.cfg preloaded, why doesn't it come up as a selection for board type? What is dna-nway.cfg? What can I do to make that visible for selection? I do not remember seeing any instructions in the documentation.

Ray
«1

Comments

  • jazzedjazzed Posts: 11,803
    edited 2013-12-06 08:03
    Hi Ray.

    Board Types on page 32 of the user guide mentions adding board types to boards.txt.
    Look at the heading Special Clock Boards. Item 3 says:
    3. If you want the board type to be available in the Project Manager’s Board Type dropdown (even
    in Simple View), open boards.txt (from the same folder) and add your custom board’s filename to
    the list. Boards.txt is a filter; if boards.txt is removed then all board types will be available in
    Simple View upon refresh.
    
    Board type dna-nway.cfg uses a more efficient caching algorithm for those who use the external SPI-FLASH memory.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-06 09:46
    Thanks jazzed, I am going to claim that I did not know what I was looking for.

    Ray
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-06 10:02
    So, I opened boards.txt with notepad, and Windows 7 would not allow me to save the changed text file. I am very sure that I have permissions to do just about anything except maybe change that file. Not sure what I should do next, what kind of lock did you put on that file?

    Ray
  • jazzedjazzed Posts: 11,803
    edited 2013-12-06 11:20
    Rsadeika wrote: »
    So, I opened boards.txt with notepad, and Windows 7 would not allow me to save the changed text file. I am very sure that I have permissions to do just about anything except maybe change that file. Not sure what I should do next, what kind of lock did you put on that file?

    Ray

    You need to be admin to change the file.

    The alternative is to copy the dna.cfg file to your project folder.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-06 11:54
    So, the easiest way to deal with changing the board.txt file, for me, was to create a new txt file, cut and paste the new changed file back into the folder, after the original file has been moved.

    I am not sure if everybody is going to rush out and buy one of these boards, some reminders:
    For the SD usage, when using Simple View - 'int DO = 0, CLK = 1, DI = 2, CS = 3' is needed to access the SD.

    I tried doing a simple blinker program in CMM mode, DNA-NWAY Board Type, which worked as expected. I also tried doing the blinker in XMMC External Flash Code... DNA-NWAY, which also worked as expected. The one thing that got my attention was the Code Size, it stayed the same as the CMM mode. On the Activity Board when you switched to the XMMC... mode, the program size increased by a substantial amount, I was expecting to see the same thing with the DNA board. Is there an inconsistency with the Code Size reporting with the DNA board?

    Back some time ago I wrote a program for accessing the RTC for this board, I will have to see if I still have the program somewhere, bring it up to today's standards, and see if it functions as expected in Simple View.

    Ray
  • jazzedjazzed Posts: 11,803
    edited 2013-12-06 12:06
    Hi Ray,

    Thanks for your notes on the board.txt file.

    XMMC is essentially stored as LMM with some extra code.

    I'm not sure about dna.cfg -vs- dna-nway.cfg sizes. SimpleIDE just reads the fields generated by propellergcc.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-06 12:29
    As for that RTC program that I had mentioned, it seems like the program has disappeared. I do recall though that I had found a Spin program, did a spin2cpp on it, and then proceeded to make a functioning C program. What it really needs is a new C driver for access to the RTC, has anybody done something like this? I looked on the MGH Designs site, and there are no C drivers for that board. Yes, I know this is a somewhat of an odd Propeller board platform, but I do like that it has an RTC and the Flash memory on board, although nobody is making any ready to use shields for it.

    Ray
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-07 03:51
    Doing some more experiments with the DNA+RTC board, I did a program that uses the sht11 module. When I ran the program in XMMC mode, the program worked as expected. When I tried the 'XMM-SINGLE External RAM' and 'XMM-SPLIT External Flash Code+RAM Data' I get:
    Project Directory: E:/PropGCC/PropDNA/sht11/

    propeller-elf-gcc.exe -v GCC 4.6.1 (propellergcc_v1_0_0_2162)
    propeller-elf-gcc.exe -I . -L . -I C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/xmm_split/ -I C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext -L C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext/xmm_split/ -I C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/xmm_split/ -Os -mxmm-split -m32bit-doubles -fno-exceptions -std=c99 -c sht11.c -o xmm_split/sht11.o
    propeller-elf-gcc.exe -I . -L . -I C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/xmm_split/ -I C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext -L C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext/xmm_split/ -I C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/xmm_split/ -o xmm_split/dnasht11.elf -Os -mxmm-split -m32bit-doubles -fno-exceptions -std=c99 xmm_split/sht11.o dnasht11.c -lm -lsimpletools -lsimpletext -lsimplei2c -lm -lsimpletools -lsimpletext -lm -lsimpletools -lm
    c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: cannot find -lsimpletools
    c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: cannot find -lsimpletext
    c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: cannot find -lsimplei2c
    c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: cannot find -lsimpletools
    c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: cannot find -lsimpletext
    c:/program files (x86)/simpleide/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: cannot find -lsimpletools
    collect2: ld returned 1 exit status
    Done. Build Failed!
    This error appears in both Simple View and Project View.

    In this program I also added SD support, and with that added in, and using the XMMC mode: Code Size 35,104 bytes (36,040 total). This is no problem because of the 1 megabyte flash ram, but I wonder if the program speed really starts to slow down when the program really gets big.

    As for the RTC, on this board, I am still trying to figure out what is the best approach for resolving this issue.

    Ray
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-07 06:00
    Just did another test, using the built in SD support, in CMM, it works as expected too record some data values. Using the XMMC mode, the SD support did not work, I guess that means that the built in SD support only works in CMM/LMM modes. I am getting the feeling that XMM mode is not really supported, which means that you will probably have to develop your own drivers for the different devices that you will be using. I could be wrong about this, and I am not using the XMM modes correctly. Why is this starting to remind me of Intel protected mode program development...

    Ray
  • jazzedjazzed Posts: 11,803
    edited 2013-12-07 07:53
    Ray,

    Andy does not provide xmm-single and xmm-split libraries in Simple Libraries. You can't use them with just flash anyway.

    Post your xmmc sd code please. I'll look at it this evening.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-07 12:01
    Below is the program I used to test out XMMC mode, which did not work as expected. But the strange part is that it was able to create test.txt, but was not able to write anything to the file. If you just switch to CMM mode, and do nothing else, the program works as expected. Not sure what is going on.

    I found my original program for setting the clock for this board, and it is still working as expected considering it was develop well over a year ago, not sure what version of SimpleIDE I used. Now I have a starting point, the main RTC program, and the necessary I2C part. I noticed that there is a libsimplei2c in the Simple library; I believe I did a spin2cpp on Dave Hines version of I2C, wonder if simplei2c is a good substitute?

    Ray
  • jazzedjazzed Posts: 11,803
    edited 2013-12-07 16:20
    Ray, Help me understand your setup.

    Which BoardType are you using for XMMC? DNA, DNA-HI, DNA-SQI, or DNA-SQIHI?

    Also, where is your Flash Chip? U9 or U12?

    Can you run any program at all like Welcome.side using XMMC?
  • jazzedjazzed Posts: 11,803
    edited 2013-12-07 18:04
    Ray,

    I had no problems using the SDCard with XMMC on my DNA board.

    It has this configuration:

    - Quad SPI Flash in U12 next to XTAL
    - SDCard on pins 16,17,18,19 - DO jump to P16, CLK to P17, etc...
    - Use DNA:SQIHI board type

    dna:dna_jumpers.png
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-08 03:36
    Thanks jazzed for taking the time to look into the problem I am having. I moved my Flash chip over next to the xtal (u12), and I am using the default SD setting P0,P1,P2,P3. With this set up I still cannot get SD too work in the XMMC mode. Now, you describe your set up to be, SD - P16,P17,P18,P19, did you cut the solder bridges too P0,P1,P2,P3, on the backside to accomplish this? I did try changing the cfg file SD settings to P16,P17,P18,P19, but that did not remedy the situation. So, it seems that when you have the SD at P16,P17,P18,P19, however you accomplished that, the XMMC mode works for you, but SD at P0,P1,P2,P3, it does not work for me. Are the pin settings hard coded in the driver for P16,P17,P18,P19? As for cutting the solder bridges, if that what it takes, I do not want to do that. The other thing that I do not have is the resistor pack installed, since mine seems to be lost, does that make a difference?

    Ray
  • jazzedjazzed Posts: 11,803
    edited 2013-12-08 07:29
    Ray,

    For your configuration, you need to use board type DNA:SQI (not DNA:SQIHI). I'll change my board and test this morning.

    The solder bridges can be removed by heating them and tapping the board on a table on the reset button side. Cutting is not necessary.

    In some ways this board is too flexible.
  • jazzedjazzed Posts: 11,803
    edited 2013-12-08 07:51
    Moving the jumpers works.

    However apparently it doesn't matter if DNA:SQI or DNA:SQIHI is used - presumably because of the explicit sd_mount.

    I would still choose DNA:SQI for the SD Card pins on 0,1,2,3 though.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-08 10:21
    Moving the jumpers works.
    You have jumpers on your board? I am looking at my board and I do not see anything that would look like a jumper that could be moved. So I take it that using P0,P1,P2,P3 works on your board for working with SD in XMMC mode?

    Ray
  • jazzedjazzed Posts: 11,803
    edited 2013-12-08 10:30
    Rsadeika wrote: »
    You have jumpers on your board? I am looking at my board and I do not see anything that would look like a jumper that could be moved. So I take it that using P0,P1,P2,P3 works on your board for working with SD in XMMC mode?

    Ray
    Solder jumpers. Yes, it works fine.

    I recommend however that you always close a file before reopening it. Your latest code doesn't.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-12 14:15
    This program seems to exhibiting a strange problem with a cogstart function. In the tail end of this program is a senselog() function which is a cogstart. The function does a simple turn on of one LED and a turn off of another LED, the only problem is that it is not turning off the LED it is supposed to be turning off. Also in my IO section I have an offled command which also not working, it is not turning off the LED. But, when I do not start to senselog() cogstart, the onled/offled works as expected. So, I am wondering what is the problem with the senselog() cogstart function? I just don't see it.

    Ray
    ////////////////////////////////////////////////////////////////////
    /*
      Env_senseP.c
      December 10, 2013
    */
    #include "simpletools.h"
    #include "simpletext.h"
    #include "fdserial.h"
    #include "sRTC.h"
    #include "sht11.h"
    
    
    ////////////////////////////////////////////////////////////////////
    /* Auto sd_mount of SD. */
    extern _Driver _NullDriver;
    extern _Driver _FileDriver;
    
    _Driver *_driverlist[] = {
      &_NullDriver,
      &_FileDriver,
      NULL
    };
    ////////////////////////////////////////////////////////////////////
    serial *xbee;
    FILE *sp;
    ////////////////////////////////////////////////////////////////////
    static volatile float sht11_temp;
    static volatile float sht11_humid;
    static volatile int logstat;
    
    unsigned int sht11stack[40 + 25];
    unsigned int sensestack[40 + 25];
    ////////////////////////////////////////////////////////////////////
    int XB_remote(void);
    void test_SD(void);
    void get_Time(void);
    void get_TD(void);
    void menu(void);
    int prompttime(char *prompt);
    void set_Time(void);
    void set_Clock(void);
    void date_SD(void);
    void time_SD(void);
    
    void sht11(void* par);
    void senselog(void* par);
    
    ////////////////////////////////////////////////////////////////////
    int main()
    {
      // Add startup code here.
    /* Open a file for append. */
      if((sp=fopen("SenseD.txt","a"))==0)
      {
        while(1)
        {
          high(27);    // Red LED, error on open.
          pause(500);
          low(27);
          pause(500);
        }
      }
      else
      {
        high(26);  // Green LED, file was opened.
      }
    /***********************************/
    /* Start the sht11 cog. */
      cogstart(&sht11, NULL, sht11stack, sizeof(sht11stack));
      cogstart(&senselog, NULL, sensestack, sizeof(sensestack));
      pause(100);
    /***********************************/
    /* Init the XBee module. */
    /*                     Rx  Tx mode BAUD */
      xbee = fdserial_open(25, 24, 0, 9600);
      pause(50);
    
    /***********************************/
    /* Start the Sensirion RTC. */
      sRTC_Start();
      sRTC_Update();
      sRTC_Set24hourmode(1);
      sRTC_Update();
    
    /***********************************/
      int xbcmd = -1;
    
    /***********************************/
    /* Start up header. */
      writeStr(xbee,"Environ Sense Program\n");
      menu();
      writeStr(xbee,"> ");
    
      while(1)
      {
        // Add main loop code here.
        xbcmd = XB_remote();  
      }  
    }
    
    ////////////////////////////////////////////////////////////////////
    void menu()
    {
      writeStr(xbee,"Menu - help, time, date, onled, offled, \n");
      writeStr(xbee,"       settime, setclock, temp, humid \n");
    }
    
    ////////////////////////////////////////////////////////////////////
    int XB_remote()
    {
      char inBuff[40];
      int retval = 0;
      
      if(fdserial_rxReady(xbee))
      {
        readStr(xbee, inBuff, 40);
        if(!strcmp(inBuff, "onled")) high(27);  // Red LED
        else if(!strcmp(inBuff, "offled")) low(27);  // Red LED
        else if(!strcmp(inBuff, "write")) test_SD();
        else if(!strcmp(inBuff, "time")) get_Time();
        else if(!strcmp(inBuff, "date")) get_TD();
        else if(!strcmp(inBuff, "help")) menu();
        else if(!strcmp(inBuff, "settime"))
        {
          writeStr(xbee,"Hour,Minute,Second\n");
          set_Time();
        }
        else if(!strcmp(inBuff, "setclock"))
        {
          writeStr(xbee,"Month,Day,Year xx,dow,Hour,Minutes,Seconds\n");
          writeStr(xbee,"dow: 0-Sun,1-Mon,2-Tue,3-Wed,4-Thu,5-Fri,6-Sat\n");
          set_Clock();
        }
        else if(!strcmp(inBuff, "temp"))
        {
          writeFloat(xbee,sht11_temp);
          writeStr(xbee,"\n");
        }
        else if(!strcmp(inBuff, "humid"))
        {
          writeFloat(xbee,sht11_humid);
          writeStr(xbee,"\n");
        }
        else if(!strcmp(inBuff, "testlog"))
        {
          logstat = 1;
        }
        else
        {
          writeLine(xbee,"Invalid Command!");
          retval = -1;
        }
        writeStr(xbee,"> ");
      }
      return retval;
    }
    
    ////////////////////////////////////////////////////////////////////
    void test_SD(void)
    {
      char outBuff[] = {' ',' ',' ',' ',' ',' ',' ',' ','\r','\n'};
      sp = fopen("SenseD.txt", "a");
      fwrite("\r\n",1,2,sp);  // CR
      date_SD();  // Write date
      fwrite("  ",1,2,sp);  // CR
      time_SD();  // Write time
      fwrite("  ",1,2,sp);  // CR
      sprint(outBuff,"%f",sht11_temp);
      fwrite(outBuff,1,8,sp);
      fwrite("  ",1,2,sp);  // CR
      sprint(outBuff,"%f",sht11_humid);
      fwrite(outBuff,1,8,sp);
      fclose(sp); 
    }
    
    void date_SD(void)
    {
      char outBuff[] = {' ',' '};
      int day, month, year;
      sRTC_Update();
      month = sRTC_Getmonth();
      day = sRTC_Getday();
      year = sRTC_Getyear();
      sprint(outBuff,"%d",month);
      fwrite(outBuff,1,2,sp);
      fwrite("/",1,1,sp);
      sprint(outBuff,"%d",day);
      fwrite(outBuff,1,2,sp);
      fwrite("/",1,1,sp);
      sprint(outBuff,"%d",year);
      fwrite(outBuff,1,2,sp);
    }
    
    void time_SD(void)
    {
      char outBuff[] = {' ',' '};
      int hour, minute, second;
      sRTC_Update();
      hour = sRTC_Gethour();
      minute = sRTC_Getminutes();
      second = sRTC_Getseconds();
      sprint(outBuff,"%d",hour);
      fwrite(outBuff,1,2,sp);
      fwrite("/",1,1,sp);
      sprint(outBuff,"%d",minute);
      fwrite(outBuff,1,2,sp);
      fwrite("/",1,1,sp);
      sprint(outBuff,"%d",second);
      fwrite(outBuff,1,2,sp);
    }
    
    ////////////////////////////////////////////////////////////////////
    void get_Time(void)
    {
      int result, result1, result2;
      sRTC_Update();
      result = sRTC_Gethour();
      result1 = sRTC_Getminutes();
      result2 = sRTC_Getseconds();
      writeDecDigits(xbee,result,2);
      writeStr(xbee,":");
      writeDecDigits(xbee,result1,2);
      writeStr(xbee,":");
      writeDecDigits(xbee,result2,2);
      writeStr(xbee,"\n");
    }
    
    ////////////////////////////////////////////////////////////////////
    void get_TD(void)
    {
      int result, result1, result2;
      sRTC_Update();
      result = sRTC_Getmonth();
      result1 = sRTC_Getday();
      result2 = sRTC_Getyear();
      writeDecDigits(xbee,result,2);
      writeStr(xbee,"/");
      writeDecDigits(xbee,result1,2);
      writeStr(xbee,"/");
      writeDecDigits(xbee,result2,2);
      writeStr(xbee,"\n");
    }
    
    ////////////////////////////////////////////////////////////////////
    int prompttime(char *prompt)
    {
      int rc = 0;
      char *endp;
      char buffer[10];
    
      do {
          writeStr(xbee,"Enter ");
          writeStr(xbee,prompt);
          writeStr(xbee," ");
    
          readStr(xbee,buffer,10);
          rc = strtol(buffer, &endp, 10);
          if(endp == buffer)
          {
            if('\n' == *endp)
            {
              rc = 0;
              break;
            }
            writeStr(xbee,"Invalid entry");
            writeChar(xbee,*endp);
            writeStr(xbee,"....");
            writeStr(xbee," Please enter a number.\n");
          }
      } while(endp == 10);
    
      return rc;
    }
    
    ////////////////////////////////////////////////////////////////////
    void set_Time()
    {
      int hour,minute,second;
      hour = prompttime("Hour");
      minute = prompttime("Minute");
      second = prompttime("Second");
      writeDec(xbee,hour);
      writeStr(xbee,":");
      writeDec(xbee,minute);
      writeStr(xbee,":");
      writeDec(xbee,second);
      sRTC_Settime(hour,minute,second);
      sRTC_Update();
      writeStr(xbee,"\n");
    }
    
    ////////////////////////////////////////////////////////////////////
    void set_Clock()
    {
      int month,day,year,dow,hour,minute,second;
      month = prompttime("Month");
      day = prompttime("Day");
      year = prompttime("Year");
      dow = prompttime("DayOfWeek");
      hour = prompttime("Hour");
      minute = prompttime("Minute");
      second = prompttime("Second");
    
      writeStr(xbee,"\n");
      writeDec(xbee,month);
      writeStr(xbee," ");
      writeDec(xbee,day);
      writeStr(xbee," ");
      writeDec(xbee,year);
      writeStr(xbee," ");
      writeDec(xbee,dow);
      writeStr(xbee," ");
      writeDec(xbee,hour);
      writeStr(xbee," ");
      writeDec(xbee,minute);
      writeStr(xbee," ");
      writeDec(xbee,second);
      writeStr(xbee," ");
      writeStr(xbee,"\n");
      sRTC_Setdatetime(month,day,year,dow,hour,minute,second);
      sRTC_Update();  
    }
    
    ////////////////////////////////////////////////////////////////////
    /* Cog function. */
    void sht11(void* par)
    {
    /***********************************/
    /*          data  clk */
      sht11_pins(17,  16);
    
      while(1)
      {
    /* Raw temp */
        int soT = sht11_tempRaw();
        //print("soT=%d", soT);
    /* Raw real humidity */
        int soRH = sht11_rhRaw();
        //print(" soRH=%d", soRH);
    /* Degrees C */
        float sTC = sht11_degC();
        //print(" sTC=%f",sTC);
    /* Degrees F */
        float sTf = sht11_degF();
        sht11_temp = sTf;
        //print(" sTf=%f", sTf);
    //    sprint(outBuff,"%f",sTf);
    //    fwrite(outBuff,1,8,sp);
    //    fwrite("F ",1,2,sp);    
    /* Raw humidity Linear */
        float sRHL = sht11_rhLinear();
       // print(" sRHL=%f", sRHL);
    /* Raw humidity True */
        float sRHT = sht11_rhTrue();
        sht11_humid = sRHT;
        //print(" sRHT=%f\n", sRHT);
    //    sprint(outBuff,"%f",sRHT);
    //    fwrite(outBuff,1,8,sp);
    //    fwrite("H\r\n",1,3,sp); 
    /* Dew point C */
        float sDPC = sht11_dewPointC(); 
        //print(" sDPC=%f\n", sDPC);
        sleep(200);
      }
    }
    
    ////////////////////////////////////////////////////////////////////
    /* Cog function. */
    void senselog(void* par)
    {
    
      high(27);  // Red LED
      pause(50);
      low(26);  // Green LED
      while(1)
      {
        //sostat = logstat;
        //if(logstat == 1)
        //{
        //low(26);
        //}
        pause(250);
      }
    }
    
  • ersmithersmith Posts: 6,054
    edited 2013-12-12 15:48
    I couldn't say for sure, but it's possible that one of your stacks is overflowing -- it would be worth trying with bigger stacks. The symptoms you're describing sound like the stack from one cogstart function may be interfering with the other.

    Eric
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-13 02:14
    Thanks Eric, I went with your suggestion, I kept increasing the stacks, but that did not resolve the problem. I even went to the extreme of increasing the stacks until I hit the hub overflow error then, I backed off until the error went away, we are talking about stacks of 800 for each cog. One of my concerns with the functionality is that in the beginning of the program I have a high(26), which is an LED turned on, and then in the senselog() cogstart I have a low(26), which the LED is not affected, it stays on, although the high(27), an LED does get turned on, but cannot get turned off by my IO commands.

    I think I had a similar problem that I was working on, but it never got resolved, so this is not my first encounter. I tried replicating the problem in a smaller program, but the problem only shows up in the larger program, maybe it is a lack of available memory, but I have no way too confirm that. If that is the case, the subtlety of this, is kind of alarming.

    Ray
  • ersmithersmith Posts: 6,054
    edited 2013-12-13 04:18
    Oh! I see the problem, I think -- you have the LED turned on in the main COG, and then try to turn it off in another COG. That won't work, because the outputs of all the COGs are OR'd together. Your senselog COG sets the pin low, but because the pin is still high on the main COG the LED stays on. You'll have to do a low(26) in the main COG as well to get it turned off.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-13 04:55
    I was testing to see what kind of control I could have of the senselog COG from the main COG. I was trying to set the senselog COG to do some background tasks when instructed from the main cog IO.
      while(1)
      {
        sostat = logstat;
        if(sostat == 1)
        {
          low(26);
        }
        pause(250);
      }
    
    In this scenario, I would change the 'static volatile int logstat' variable, in the main COG IO from 0 to 1, and have the logic work as expected. But, I get the feeling that it can not be accomplished, according to what you just stated. I guess I need some more definition as to what you can really do to another COG from within the main COG. I am really looking for a way to do some controlled tasks in a COG that is controlled by the main COG without having an affect on the main COG IO system. I hope this makes sense?

    Ray
  • ersmithersmith Posts: 6,054
    edited 2013-12-13 05:16
    You can certainly have the senselog COG turn pins on and off according to commands from the main COG. But in order to do that the pin has to be totally controlled by the senselog COG (the main COG cannot turn the pin on). This is a hardware issue, and would happen in any language -- the outputs of all COGs are or'd together to form the output from the chip, so if cog A sets the pin to "on" and a different cog B sets it to "off", the pin will still be on (because 1 (cog A value) | 0 (cog B value) == 1 (pin is still on).
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-13 05:31
    My interpretation of what you just said is that to control some hardware from the main COG commands, ALL of the hardware control has to be from the senselog COG. My intent was to use the senselog to start and shutdown tasks which would essentially be using the SD, sht11, and the RTC to do some specific data logging jobs. So, in essence I would have to have all of the mentioned hardware started and residing in the senselog COG? This is really starting to sound very complicated.

    I was also thinking that I might have a better chance of success of this idea using threads, but I think that would even be more complicated than trying to deal with COGs. But, I am not absolutely sure about this.

    Ray
  • ersmithersmith Posts: 6,054
    edited 2013-12-13 09:58
    Rsadeika wrote: »
    My interpretation of what you just said is that to control some hardware from the main COG commands, ALL of the hardware control has to be from the senselog COG.
    That's not what I was trying to say -- perhaps I didn't phrase it well. Basically what I'm trying to say is that having more than one COG touch any particular pin is a bad idea. It's fine if, for example, cog A controls pin 26 and cog B controls pin 27 -- that will work. But if both cog A and cog B try to change the same pin, the result is not likely to be what you want. (It is *possible* to pull it off, but it requires great care, a thorough knowledge of exactly how the hardware works, and a protocol that's adapted to that.)

    The easy rule is: do not try to use the same pin from 2 different COGs.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-14 04:15
    Now I am bumping into a different problem. In the senselog COG I added some code to get the 'month' from the RTC and write it to the SD, which it does as expected. But this new code now locks up the command IO, in other words after I type in 'testlog', which activates the senslog COG, on the terminal screen I no longer get a key press response. At this point I am not sure if the whole program is locked up, or it is just the command IO. But it does seem to me like the senselog COG might be locking up the program, although I am not sure about this, nor I am sure why the COG would be doing this.

    Ray
    /* COG function. */
    void senselog(void* par)
    {
      int sostat;
      while(1)
      {
        sostat = logstat;
        if(sostat == 1)
        {
          sp = fopen("SenseD.txt", "a");
          //date_SD();
          char outBuff[] = {' ',' '};
          int day, month, year;
          sRTC_Update();
          month = sRTC_Getmonth();
          sprint(outBuff,"%d",month);
          fwrite(outBuff,1,2,sp);
          fwrite("/",1,1,sp);
          fclose(sp);
          logstat = 0;
        }
        pause(250);
      }
    }
    
  • David BetzDavid Betz Posts: 14,516
    edited 2013-12-14 05:10
    Rsadeika wrote: »
    Now I am bumping into a different problem. In the senselog COG I added some code to get the 'month' from the RTC and write it to the SD, which it does as expected. But this new code now locks up the command IO, in other words after I type in 'testlog', which activates the senslog COG, on the terminal screen I no longer get a key press response. At this point I am not sure if the whole program is locked up, or it is just the command IO. But it does seem to me like the senselog COG might be locking up the program, although I am not sure about this, nor I am sure why the COG would be doing this.

    Ray
    /* COG function. */
    void senselog(void* par)
    {
      int sostat;
      while(1)
      {
        sostat = logstat;
        if(sostat == 1)
        {
          sp = fopen("SenseD.txt", "a");
          //date_SD();
          char outBuff[] = {' ',' '};
          int day, month, year;
          sRTC_Update();
          month = sRTC_Getmonth();
          sprint(outBuff,"%d",month);
          fwrite(outBuff,1,2,sp);
          fwrite("/",1,1,sp);
          fclose(sp);
          logstat = 0;
        }
        pause(250);
      }
    }
    
    I'm not sure if this is causing your problem but your outBuff variable will only be allocated two bytes but you need three bytes to represent a two digit month number plus the terminating NUL character.

    Why not just do this?
        char outbuff[3];
    
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-14 05:35
    I added another debug point in my command IO:
    else if(!strcmp(inBuff, "testlog"))
        {
          logstat = 1;
          pause(2000);
          high(27);
        }
    
    I guess this is where it is locking up. When I do the 'testlog' command, the senselog COG does it thing, I get a two second pause before the high(27) red LED turns on, and then terminal screen does not go to the expected '> ' , the terminal screen is no longer responding to a key press. For some reason it is unable too continue with the loop, or something in the main COG has been affected. Since the senselog COG is functioning as expected, is the stack appropriation having an affect on the main COG?

    Ray
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-12-14 08:47
    Since I have not gotten any more suggestions for resolving the problem I will start from scratch and will blame the problem on a bad program design/implementation. I do not know of any other way of resolving this issue, I just hope that in my new design, I do not run into the same problem and find out that maybe it has something to do with program memory shortages that is not apparently showing itself, in whatever manner that may occur. So, back to design status...

    Ray
Sign In or Register to comment.