|
Tài trợ cho PIC Vietnam |
English forum on PICs Forum for foreigners -only English in this forum - Do not need to register or login |
|
Ðiều Chỉnh | Xếp Bài |
|
08-07-2007, 07:00 PM | #1 |
Guest
Bài gửi: n/a
|
PIC 16F877 with 3 serial ports
Hell All,
I want to control two equipement with pic 16f877, so 2 ports, and the intructions are sent from my PC, so anouther port. Does anybody know how to do that? Thanks in advance for any help you might provid. |
09-07-2007, 02:05 AM | #2 | |
Trưởng lão PIC bang
|
Trích:
Is it necessary to use RS-232 serial ports? Could you use other serial protocols such as I2C, SPI? What is the requirement of the communication speed, data rate? Cheers,
__________________
Biển học mênh mông, sức người có hạn. Đang gặp vấn đề cần được giúp đỡ? Hãy dành ra vài phút đọc luồng sau: http://www.picvietnam.com/forum/showthread.php?t=1263 |
|
09-07-2007, 05:51 AM | #3 | |
Guest
Bài gửi: n/a
|
Trích:
the equipements are: Multimeter with serial port rs232, it can be adjusted on the following coniguration:Baud rates:9600, 4800, 2400, 1200, 300 Format: 8 bits no parỉty, or 7 bits even parity Stop bit: Always 1 |
|
09-07-2007, 05:57 AM | #4 | |
Guest
Bài gửi: n/a
|
Trích:
the equipements are: a Barometer and a Multimeter with serial port rs232, it can be adjusted on the following configurations: Baud rates:9600, 4800, 2400, 1200, 300 Format: 8 bits no parỉty, or 7 bits even parity Stop bit: Always 1 Can I use I2C or SPI? Thanks in advance for any help you can provide. |
|
09-07-2007, 07:17 PM | #5 |
Trưởng lão PIC bang
|
If the equipments use RS-232, then the only way to talk to them is via RS-232. That's fine. Your problem can be solved in different ways, depending on the data rate you need.
The baud rate is your communication speed, not the data rate. The data rate is how frequent you want your data. If your data rate is low, like 10 samples/second, then you probably can use some multiplexer to connect the equipments and the host PC to the PIC one-by-one. If the data rate is high and/or control action is fast, then you probably need a couple of PICs connected together. They can talk to each other via different protocols. Cheers,
__________________
Biển học mênh mông, sức người có hạn. Đang gặp vấn đề cần được giúp đỡ? Hãy dành ra vài phút đọc luồng sau: http://www.picvietnam.com/forum/showthread.php?t=1263 thay đổi nội dung bởi: namqn, 09-07-2007 lúc 11:28 PM. |
09-07-2007, 11:11 PM | #6 | |
Guest
Bài gửi: n/a
|
Trích:
Do you have a schematic for that? thanks in advance. |
|
09-07-2007, 11:18 PM | #7 | |
Guest
Bài gửi: n/a
|
PIC 16F877 with 3 serial ports
Trích:
Thanks in advance |
|
10-07-2007, 12:09 AM | #8 |
Trưởng lão PIC bang
|
For RX signal of PIC, you will need a 3-to-1 multiplexer. For TX signal of PIC, you will need a 1-to-3 demultiplexer.
Have a look at the following links: http://www.play-hookey.com/digital/m...our_input.html http://www.play-hookey.com/digital/d...emux_four.html Remember that you would need 3 separate level shifters (MAX232, for example) in total, when you use commercial multiplexer/demultiplexer chips (because they are logic chips). Sorry I don't have time to create a schematic for you! Cheers,
__________________
Biển học mênh mông, sức người có hạn. Đang gặp vấn đề cần được giúp đỡ? Hãy dành ra vài phút đọc luồng sau: http://www.picvietnam.com/forum/showthread.php?t=1263 |
06-10-2007, 03:32 PM | #9 | |
Đệ tử 5 túi
Tham gia ngày: Oct 2005
Bài gửi: 117
: |
Trích:
Syntax: #use rs232 (options) Elements: Options are separated by commas and may be: STREAM=id Associates a stream identifier with this RS232 port. The identifier may then be used in functions like fputc. BAUD=x >> Set baud rate to x XMIT=pin >> Set transmit pin RCV=pin >> Set receive pin FORCE_SW >> Will generate software serial I/O routines even when the UART pins are specified. Example: #use rs232(Stream = HWRS232,9600,xmit = PIN_C6,rcv = PIN_C7) // #1 HW #use rs232(Stream = SWRS232_1,9600,xmit = PIN_B0,rcv = PIN_B1) // #2 #use rs232(Stream = SWRS232_2,9600,xmit = PIN_B2,rcv = PIN_B3) // #3 #use rs232(Stream = SWRS232_3,9600,xmit = PIN_B4,rcv = PIN_B5) // #4 /* In your program, when you want to send some data to your specification rs232 port, use function fputc(), fgetc(), fprintf() */ fprintf(HWRS232,"This is 1st 232 Port"); fprintf(SWRS232_1,"This is 2st 232 Port"); fprintf(SWRS232_2,"This is 3st 232 Port"); fprintf(SWRS232_3,"This is 4st 232 Port"); I used this method for my project, expand from 1 RS232 port to 4 RS232 port using PIC16F876A. For the successfull with this, please refer to HELP of CCS to get more informations. Good luck.
__________________
CallerID, Ethernet-RS232, PICWEB, Cảnh báo BTS Giải pháp toàn diện giám sát - điều khiển từ xa qua GSM/Internet 0988006696 http://linhnc308.blogspot.com linhnc308@gmail.com |
|
13-12-2007, 10:14 PM | #10 |
Nhập môn đệ tử
Tham gia ngày: May 2006
Bài gửi: 7
: |
hi! when we use software RS232, can we use interrupt for receive data? i have used it, but not sussecc.
thanks for help. |
14-12-2007, 11:11 PM | #11 |
Nhập môn đệ tử
Tham gia ngày: Nov 2007
Bài gửi: 3
: |
chuong trinh dieu khien 8 led don dung ngon ngu ccsc don gian de hieu
Chương trình điều khiển 8 led chớp tắt dùng PIC16F877A viết bằng C: Code:
//================================================= ======= // Ten chuong trinh : Mach test den chop tat tren PORTB // Nguoi thuc hien : abc // Ngay thuc hien : dd/mm/yyyy // Mo ta phan cung : Dung PIC16F877A - thach anh 20MHz // : LED giao tiep voi PORTB // : Cuc duong cua LED noi voi Vcc // : RB0 - RB7 la cac chan output //================================================= ======= #include <16f877a.h> #include <def_16f877a.h> #device *=16 ADC=8 #FUSES NOWDT, HS, PUT, NOPROTECT, NOLVP #use delay(clock=20000000) void main() { // Thiet lap che do cho PORTB TRISB = 0x00; // Tat ca PORTB deu la cong xuat du lieu PORTB = 0xFF; // Tat het cac LED While(1) { PORTB = 0; // Cho các LED sáng delay_ms(500); // Tạo thời gian trễ 500ms PORTB = 0xFF; // Cho các LED tắt delay_ms(500); // Tạo thời gian trễ 500ms } } thay đổi nội dung bởi: namqn, 15-12-2007 lúc 01:23 AM. |
14-12-2007, 11:15 PM | #12 |
Nhập môn đệ tử
Tham gia ngày: Nov 2007
Bài gửi: 3
: |
DONG HO SO gui moi nguoi tham khao
Code:
THIEÁT KEÁ ÑOÀNG HOÀ SOÁ DUØNG PIC 16F877A //*Write : //*Hardware :PIC16f877A //*Compiler :CCS C //*========================================= #include<16F877A.h> #include<def_16F877a.h> #fuses NOWDT,PUT,HS,NOPROTECT,NOLVP #use delay(clock=20000000) #use fast_io(b) #use fast_io(d) int8 i,dvis,chucs,dvim,chucm,dvih,chuch; int32 a,b; int32 h,k; int32 bien; const unsigned char dig[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; void hienthi() { i=0; while(i<24) { portd=0xfe; portb=dig[dvis]; delay_us(6900); portd=0xfd; portb=dig[chucs]; delay_us(6900); portd=0xfb; portb=dig[dvim]; delay_us(6900); portd=0xf7; portb=dig[chucm]; delay_us(6900); portd=0xef; portb=dig[dvih]; delay_us(6900); portd=0xdf; portb=dig[chuch]; delay_us(6900); i++; } } void chuyendoi() { b=a/3600; a=a%3600; h=a/60; a=a%60; k=a; chucs=k/10; dvis=k%10; chucm=h/10; dvim=h%10; chuch=b/10; dvih=b%10; } void main() { trisb=0x0; trisd=0x0; bien=0; while(1) { bien=bien+1; if(bien==86400) { bien=0; } a=bien; chuyendoi(); hienthi(); } thay đổi nội dung bởi: namqn, 15-12-2007 lúc 01:24 AM. |
10-08-2008, 03:32 AM | #13 | |
Guest
Bài gửi: n/a
|
Androisa
Trích:
The #USE RS232 (and I2C for that matter) is in effect for GETC, PUTC, PRINTF and KBHIT functions encountered until another #USE RS232 is found. The #USE RS232 is not an executable line. It works much like a #DEFINE. The following is an example program to read from one RS-232 port (A) and echo the data to both the first RS-232 port (A) and a second RS-232 port (B). #USE RS232(BAUD=9600, XMIT=PIN_B0, RCV=PIN_B1) void put_to_a( char c ) { put(c); } char get_from_a( ) { return(getc()); } #USE RS232(BAUD=9600, XMIT=PIN_B2,RCV=PIN_B3) void put_to_b( char b ) { putc(c); } main() { char c; put_to_a("Online\n\r"); put_to_b("Online\n\r"); while(TRUE) { c=get_from_a(); put_to_b(c); put_to_a(c); } } The following will do the same thing but is more readable and is the recommended method: #USE RS232(BAUD=9600, XMIT=PIN_B0, RCV=PIN_B1, STREAM=COM_A) #USE RS232(BAUD=9600, XMIT=PIN_B2, RCV=PIN_B3, STREAM=COM_B) main() { char c; fprintf(COM_A,"Online\n\r"); fprintf(COM_B,"Online\n\r"); while(TRUE) { c = fgetc(COM_A); fputc(c, COM_A); fputc(c, COM_B); } } this code came into the help of the compiler, searching as tag 'stream' |
|
23-03-2010, 07:14 PM | #14 |
Nhập môn đệ tử
Tham gia ngày: Mar 2010
Bài gửi: 2
: |
hi!!! mình có tài liệu về PIC 16F87x các bạn có thể download về tham khảo:
http://www.ziddu.com/download/912306...gviet.pdf.html |
27-03-2010, 08:14 PM | #15 |
Đệ tử 5 túi
Tham gia ngày: May 2007
Bài gửi: 102
: |
I can write 3 seria port for pic6f877a. I use software
__________________
Thật bó tay! |
|
|