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. |
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, |
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 |
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. |
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, |
Trích:
Do you have a schematic for that? thanks in advance. |
PIC 16F877 with 3 serial ports
Trích:
Thanks in advance |
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, |
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. |
hi! when we use software RS232, can we use interrupt for receive data? i have used it, but not sussecc.
thanks for help. |
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:
//================================================= ======= |
DONG HO SO gui moi nguoi tham khao
Code:
THIEÁT KEÁ ÑOÀNG HOÀ SOÁ DUØNG PIC 16F877A |
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' |
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 |
I can write 3 seria port for pic6f877a. I use software
|
Múi giờ GMT. Hiện tại là 09:20 PM. |
Tên diễn đàn: vBulletin Version 3.8.11
Được sáng lập bởi Đoàn Hiệp.
Copyright © PIC Vietnam