Counting led blinks..


Closed Thread
Results 1 to 40 of 93

Hybrid View

  1. #1
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Hi, I would like to incorporate an sdcard to the project and record the number of coins, only when pressing a button (e.g RB7) , but first I want to make a seperate test program using Pic18F4550. As I understood the connection should be simple enough but just to make sure I attached an image of my connections(Please correct me if it's wrong). I found a source code but it's in C.
    Code:
     // example writing to SD card, sford 
     #include "mbed.h"
     #include "SDFileSystem.h"
     SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool  Components workshop board
     
     int main() {
         printf("Hello World!\n");   
     
         mkdir("/sd/mydir", 0777);
         
         FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
         if(fp == NULL) {
             error("Could not open file for write\n");
        }
        fprintf(fp, "Hello fun SD Card World!");
        fclose(fp); 
    
    
       printf("Goodbye World!\n");
     }
    The code creates a folder and writes "Hello fun SD Card World" to file name "sdtest.txt".
    Hope anyone can help...

    thanks in advance,
    tacbanon
    Attached Images Attached Images  

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Hi,
    That C-example does nothing for or with PBP, the C-compiler used in the example (which ever it is) has a built in library function to support a SD-card. There is no such function built into PBP. HOWEVER there is a SD-card example on (who would've thought) the examples page at MELABS (SDFS3.pbp).

    With that said do you really need a SD-card? How much info do you need to store? The 4550 has 256bytes of EEPROM, can't you use that? Not that having a SD-card is "impossible" but using the EEPROM is going to be MUCH (I mean MUCH) easier than - which I think you'll see once you look at the example code.

    /Henrik.

  3. #3
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Hi Henrik, thanks for the responce. To be honest I already saw the link, but I'm skeptical because I dont really understand how it works(not simple for me). But I'm willing to try it out. I need to incorporate the sdcard because I'm trying to create a "coin operated computer rental app" I want later to save the number of coins and date/time per transaction. I also want to learn the EEPROM stuff but I was thinking about the capacity and since SDCARD can be quite cool (if I manage to incorporate it). I will try the link and post the results.

    regards,
    tacbanon

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Maybe you can get some use from this?
    http://www.picbasic.co.uk/forum/cont...USB-SD-LOGGING
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    @mackrackit
    very nice thanks for the link.

  6. #6
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    @mackrackit
    Hi, I was able to run the example from melabs...but I'm interested how you made it as usb cdc and incorporating DT's interrupt, I tried to copy and paste your codes to see if it will compile, but unfortunately compiler errors occured on my setup. I have some questions that will help me understand using your code.
    1. I use pic18F4550 instead of pic18F2550.
    2. I dont have "SDFS.BAS" only "SDFS.PBP"
    I dont have an rtc and temp sensor right now, only the sdcard. I commented out the functions that regards to the rtc and temp sensor. My goal at the meantime is to read/write to an sdcard and display its content to the hyperterminal.

    thanks in advance,
    tacbanon
    Last edited by tacbanon; - 10th October 2011 at 16:43.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    The 4550 and 2550 are pretty much the same, just more or less I/Os.

    SDFS.bas is the same as SDFS.pbp. Just different extensions. Way back when it was .bas.

    What are the errors?

    What version of PBP are you using?

    Do you have DTs instant interrupt routines downloaded?
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts