PIC with PC interface (in asm)

Discussion in 'Embedded Systems and Microcontrollers' started by Robben, Aug 18, 2010.

  1. Robben

    Thread Starter New Member

    Jul 11, 2010
    5
    0
    Hello, I want to develop my program (PIC16F84A receives information from sensor and stores in memory) by adding PC interface (i mean to be able to copy measurements to a pan drive or mmc - common slots). What kind on communication it is better to choose (which one is easier) ? My software is in asembler. Do you have some nice examples (f.ex. write file with measurements on a MMC/pen drive) ?
     
    Last edited by a moderator: Aug 18, 2010
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Robben likes this.
  3. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    The 16f84 do not have an UART. So you would have to make a software uart, or bit bing the the data. I have used the 16f690 a lot. It have more pins than the 16f628. But it is not a 40 pin monster. Anyway dump the 16f84 and use a newer chip that cost less with far more functions
     
    Robben likes this.
  4. Robben

    Thread Starter New Member

    Jul 11, 2010
    5
    0
    hello, thanks for replays, I would like to have it modern and user friendly (without serial port):
    1. plug pendrive/MMC
    2. press button (save measurement to a txt file on pendrive/MMC)
    What USB-serial converter can you recomend ?
     
  5. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    What kind of programmer du you use for uploading your program to the PIC? It is this unit that will limit your choice of PIC. If I understand you correct you want to save your data to say a SD card. Not have your application connected to a PC all the time.
    How much data do you need to store?
     
    Robben likes this.
  6. tom66

    Senior Member

    May 9, 2009
    2,613
    213
    If you're open to upgrading to an 18F series chip, Microchip have an SD card library that supports FAT16 and FAT32 which you can use.
     
  7. Robben

    Thread Starter New Member

    Jul 11, 2010
    5
    0
    I didn't upload, I have program on my HDD (I use PICkit 2 programmer), originally the program (PIC reads from a sensor and displays on LCD) was written for PIC16F84A. Now I would like to update the program - should have interface with a PC ...for example should be able to store measurements in *.txt file on pendrive or SD card (once you press the button, measurement is stored and so on .. up to 10 measurements, if you keep pressing longer you can reset all measurements) - I think this is the simplest solution regarding interface with PC, would like to keep it simply - don't have big experience with programming uC, any advice is valuable.
     
  8. Flow

    Member

    May 30, 2010
    37
    1
    This is not exactly trivial. If you want to store the data in a PC readable format (*.txt), you need a FAT filesystem. I could not imagine implementing one in assembly language to be honest.

    I have used fatfs in the past, a FAT12/16/32 filesystem for embedded systems, written in C.

    I think all MMC/SD card libraries are also written in C. I'm not sure about that though.
     
  9. tom66

    Senior Member

    May 9, 2009
    2,613
    213
    One trick you can do (not advised for production units) would be to create an empty FAT filesystem on the SD with one very large empty file (about 90-95% the size of the disk). Then you could write data to it, by simply locating the file's position, you wouldn't have to worry about FAT fragmentation because it would be the only file. The only thing is, how to locate the file's position and the sectors it occupies? An understanding of FAT will be needed. Also, it's important that this still doesn't solve the problem of interfacing with the SD card.
     
    Robben likes this.
  10. Robben

    Thread Starter New Member

    Jul 11, 2010
    5
    0
    I don't have experience with FAT and see that it is not easy, maybe it is better to use USB-serial converter and transfer measurement from PIC to HyperTerminal over USB port. Can you please recommend a nice description how to do it ? *
     
  11. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    You need a RS232 level converter between your PIC and the serial port. Google max232. Max232 is common chip family used for this purpose. You can get it in many variants. Have you chosen your PIC yet? Since your programmer is a PICKIT 2 programmer it should not be a problem to find one.
     
  12. Flow

    Member

    May 30, 2010
    37
    1
    Hyperterminal + USB...? Eek, overkill!

    Just use the standard serial port of the computer. You could then write a small program that regularly polls the uC for its sensor data and writes it into a file.
     
  13. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Most modern computers do not have a serial port anymore. but the problem is fixed with USB dongle. USB in one end and RS232 in the other end
     
  14. tom66

    Senior Member

    May 9, 2009
    2,613
    213
    Beware that most cheap dongles do not include any RS232 level shifting, they usually put out 0-5V (and they'll usually accept -12V to +12V, they just don't produce a signal like that.) So the MAX232 may be unnecessary.
     
  15. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    I got a USB serial converter for about £3 on Ebay and it has worked fine so far.
    You can also get serial to USB chips, so you could have one on your device and not require the serial converter cable. It's possible that they are only available in surface mount.
    If you are using the USART on a PIC, the input and output is inverted from what the PC requires so it needs inverting anyway. A MAX232 or ST232 does this and is probably as easy as inverting it some other way.
    Does your existing program use PORTB <1 and 2>? They are used on the 16F628 for USART so if you are using them it might make the program slightly harder to adapt for that chip.
     
  16. Robben

    Thread Starter New Member

    Jul 11, 2010
    5
    0
    thanks for answers! Markd77 what USB serial converter do you use (can U give details, link?). I think it will be the easiest to use 16F628, especially that i found nice tutorial (http://www.oz1bxm.dk/PIC/628uart.htm) - always kind of interface :) My old soft uses port B (occupied with LCD interface), need to be adopted. hopefully the tutorial will work with USB serial converter.
     
  17. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Robben likes this.
  18. ssureshtronics

    New Member

    Sep 8, 2006
    8
    0
    Hi TOM66,

    Have you worked with the FAT file system reading, I need a suggestion on how to locate exactly the location of the file and how to read the "*.txt" file content
     
Loading...