PDA

View Full Version : datalogging from pic16f877a to usb-stick



arie
- 4th April 2007, 17:38
I've got a tricky project involving a gps receiver sensors and a pic16f877a.
I would like to receive gpscoordinates and store it on a usb stick with data from different sensors attached to a motorcycle. Its a datarecording system. The tricky part is the datastorage cause pic hasn't enough memory.

Does anyone kno how to connect a usb stick to a pic16f877a and how to send data to a memorystick?

skimask
- 4th April 2007, 17:50
I've got a tricky project involving a gps receiver sensors and a pic16f877a.
I would like to receive gpscoordinates and store it on a usb stick with data from different sensors attached to a motorcycle. Its a datarecording system. The tricky part is the datastorage cause pic hasn't enough memory.

Does anyone kno how to connect a usb stick to a pic16f877a and how to send data to a memorystick?

Not to a memory stick. But how about to an SD card?
Take your PIC, get the datalogging working, hook it up to a "DOS-On-Chip" chip (www.sparkfun.com, search for Dos-On-Chip), add an SD card slot, start datalogging. Take the card out of the slot, put card into card reader at your PC.

Probably a hundred ways to do this...You can have it 2 of 3 ways...
Cheap and simple, but it won't be good...
Cheap and good, but it won't be simple...
Simple and good, but it won't be cheap...
:)

Pic_User
- 4th April 2007, 18:05
Hi arie,

Welcome to the forum.

Some of the beginner’s answers can be found using the site’s search function.

For instance this previously posted answer. It refers to a “Bluetooth device” but applies to PICs hosting USB in general.


As far as I know PICs can only be used as a USB Device not a USB Host as you would require to connect the USB Bluetooth device. To do this you would need to get a USB Host controller and connect it to the PIC. Unfortunatly I havn't seen anyone do this yet but if I do I will post more info.
http://www.picbasic.co.uk/forum/showthread.php?t=3119

skimask is correct not a simple task.

-Adam-

arie
- 5th April 2007, 16:11
Thank you very much for the help.
Can you write data from pic to dos on chip module just using hserin or is it much more complicated?

thanks a lot

skimask
- 5th April 2007, 16:11
Thank you very much for the help.
Can you write data from pic to dos on chip module just using hserin or is it much more complicated?

thanks a lot

The datasheet is right there at www.sparkfun.com

arie
- 9th April 2007, 19:18
I read the datasheet for the dosonchip, but how do you read and write data from the sd chip\?

Do you need to tell which memory adress you want to write or read or is this done automatically with hserin hserout?

i use pic basic pro

skimask
- 9th April 2007, 19:26
I read the datasheet for the dosonchip, but how do you read and write data from the sd chip\?

Do you need to tell which memory adress you want to write or read or is this done automatically with hserin hserout?

i use pic basic pro

I use PicBasicPro too...imagine that...
No, you don't tell which memory address to read/write from.
This chip is a DOS on CHIP. Disk Operating System On A Chip.
It's an interface chip, a 'relatively' seamless interface chip.
With it, you can treat the SD card just like you would treat a floppy disk (or maybe a small hard drive) from a DOS command prompt. Ok, it's a bit more complicated than that, but not by much.

If this is your first project...whew...don't get me started...
If it actually is your first project...I'd back up, WAY up, and make an LED blink first.
If it isn't your first time around the block, then it really shouldn't be that hard, unless you haven't really read the datasheet (which explains everything you really need to know as long as you really READ it), or maybe you haven't messed with the serial port before, in which case, I say again, You'd better back WAY up, and make something simple first, like PC to PIC communications.

arie
- 10th April 2007, 06:46
I did make some pic projects by myself, but this is the first time I use serial communications. Hserin and hserout works perfectly with pic to pc. But i can't get serin and serin2 etc to work properly. Could it be that I use a bootloader so there must be an extra code inserted in pic basic pro just like lcd and bootloader

skimask
- 10th April 2007, 13:28
I did make some pic projects by myself, but this is the first time I use serial communications. Hserin and hserout works perfectly with pic to pc. But i can't get serin and serin2 etc to work properly. Could it be that I use a bootloader so there must be an extra code inserted in pic basic pro just like lcd and bootloader

Well then, let's see some code. That's what we're here for...

arie
- 10th April 2007, 19:22
I tried it without an bootloader and programmed th pic16F877A with an usb programmer this works ok! Does anybody know how to get the stuff working with a bootloader I use the bloader from sparkfun

this is the code that works only if you not program it with a bootloader
FLAGS=0
DEFINE LOADER_USED 1
DEFINE OSC 4
Define __16F877A 1
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTD
DEFINE LCD_RSBIT 2
DEFINE LCD_EREG PORTD
DEFINE LCD_EBIT 3
DEFINE LCD_BITS 4
define CHAR_PACING 1000

Include "modedefs.bas"

pause 500
LCDOUT $FE, 1

TRISA = %00000000 'porta = output'
TRISB = %00000000 'portb = output'
TRISC = %10000000 'portc.7 = input'
rx var PORTC.7
tx var PORTC.6



but0 var portc.0
but1 var portc.1
but2 var portc.2
but3 var portc.3
led0 var portb.0
led1 var portb.1
led2 var portb.2
led3 var portb.3
led4 var portb.4
led5 var portb.5
led6 var portb.6
led7 var portb.7
backl var porte.0

high backl

main:
serout2 portc.6, 813, ["hello world", 10, 13]
goto main



goto main



I really appreciate it that everybody is so helpfull cause the simple things are sometimes though to crack! When I'll receive my dosonchip and gps receiver I'm going to test it a lot. Now I'm just doing research to everything I need to use in my project.