commiunication with PIC and computer

Microcontroller Topics
Post Reply
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

commiunication with PIC and computer

Post by Rksk » Tue Apr 06, 2010 7:54 pm

Can it use PICs to commiunicate with computer?

like control a pic from computer, record data sent from PIC....
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: commiunication with PIC and computer

Post by Rksk » Tue Apr 06, 2010 7:59 pm

Also i want to read data from flash drive using. is it possible with PIC ?
User avatar
Magneto
Major
Major
Posts: 430
Joined: Wed Jul 15, 2009 1:52 pm
Location: London

Re: commiunication with PIC and computer

Post by Magneto » Tue Apr 06, 2010 11:01 pm

Dear Friend ,

It is very easy to establishment communication between a PIC and PC. for this you have to use the UART module
of PIC micro controller and one of serial port in PC. So you have to use a PIC micro controller which have at least one UART module. Lots of PIC micro controllers available in Sri Lanka has at least one UART module.

Once you have establish communication between PIC and PC , you can do any thing like computer controlling of devices which have attached to the PIC , record external device data in a PC .... etc..

And other important thing is you want to have some intermediate circuit , between PC and PIC , for connecting PIC to a PC.
this is called voltage shifter. because PC serial port is working +/- 12 V and PIC UART module is working 0-3 V.
You can easily make this circuit from the voltage shifter IC called MAX 232 , which is available in Sri Lanka. There are
lots of circuits available in Internet for this voltage shifting.


And there are lots of source codes in the Internet which have written to PIC micro controllers for interfacing UART module.

If you come across any question regarding this, just drop a post in robot.lk. Then we can help you to solve your problems.

And regarding your question on Flash Drive , it is possible to communicate with a flash drive with PIC. If your flash drive has plug to the computer , you can speak with flash drive with windows. If you want to directly connect a flash drive to a PIC micro controller , then you have to study the protocol , which a flash drive can communicate with outside world.

I have worked connecting SD cards to a micro controller and reading and saving data on to SD card by using the microcontroller. SD cards including mini and micro are supporting for SPI . I think Flash Drives should have similar
protocol.

All the Best !!!!!!!!!!!
Magneto
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: commiunication with PIC and computer

Post by Neo » Wed Apr 07, 2010 1:54 am

See following posts that contains most of what you need. If you have searched the forum, you would have found most of these. (Almost all these tutorials are put by our Microcontroller genius, Magneto).

Connecting a PIC with PC using UART (Serial port)
Serial Communication Tutorial
C Code for Interfacing UART module in PIC 16F87X
USB Serial port on PIC18F4550
Serial port example for Hi-Tech C and PIC16x core
Serial port example for Hi-Tech C and PIC18x core

Connecting a flash drive to PIC
Interfacing MMC Card with PIC Mircocontroller
C Code for Interfacing SPI module in AVR MCU
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: commiunication with PIC and computer

Post by Rksk » Wed Apr 07, 2010 7:58 pm

Can i connect a PIC and flash drive directly without a computer?
User avatar
Magneto
Major
Major
Posts: 430
Joined: Wed Jul 15, 2009 1:52 pm
Location: London

Re: commiunication with PIC and computer

Post by Magneto » Wed Apr 07, 2010 11:04 pm

yes , you can. There is some protocol for each Flash Drive to communicate with outside world. So first you
have to study this protocol. Then only thing you have to do is , implement that protocol in your micro controller.

That mean then your flash drive and micro controller. can speak same language. If the flash drivers use standard protocols like SPI , you do not want to implement them in micro controller. Because they are built in most of the micro controllers.
In such a situation , micro controller can directly speak with flash drives , and you do not want to do much work.

All SD cards including mini and micro SD , has SPI protocol for communicate with outside world. That is we can read and write data to a SD card with a micro controller , by using SPI module of that micro controller. I think flash drives also
have SPI or similar protocol.
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: commiunication with PIC and computer

Post by Neo » Thu Apr 08, 2010 1:19 am

First of all you need to clarify what's the device you need to connect. When you say Flash Drive, it means like a Flash Pen with USB interface to me? If that is the case you need to have a separate USB control chips in-between the Micro and the Card. I do see this as a bad option to have a data storage in a Microcontroller system.

As Magneto stated, if you can chose SD or MMC cards (that are commonly available nowadays), then Serial Peripheral Interface(SPI) protocol is the most common way of integrating those to a Microcontroller without need of any supportive chips. Most modern Microcontrollers have a SPI port (including Magneto''s favourite PIC16F877 and AtMega128 :D ) which can be used to connect these cards straight away.

See Interfacing MMC Card with PIC Mircocontroller.
Post Reply

Return to “Microcontrollers”