PIC with PC interface (in asm)

Thread Starter

Robben

Joined Jul 11, 2010
5
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:

t06afre

Joined May 11, 2009
5,934
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
 

Thread Starter

Robben

Joined Jul 11, 2010
5
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 ?
 

t06afre

Joined May 11, 2009
5,934
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?
 

tom66

Joined May 9, 2009
2,595
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.
 

Thread Starter

Robben

Joined Jul 11, 2010
5
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.
 

Flow

Joined May 30, 2010
37
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.
 

tom66

Joined May 9, 2009
2,595
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.
 

Thread Starter

Robben

Joined Jul 11, 2010
5
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 ? *
 

t06afre

Joined May 11, 2009
5,934
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.
 

Flow

Joined May 30, 2010
37
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.
 

t06afre

Joined May 11, 2009
5,934
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.
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
 

tom66

Joined May 9, 2009
2,595
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.
 

Markd77

Joined Sep 7, 2009
2,806
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.
 

Thread Starter

Robben

Joined Jul 11, 2010
5
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.
 
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
 
Top