![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
Hello
i'm working on a project at school and i need to program 2 serial interfaces on a PIC to communicate between a computer another device. This is a summary of my project: i want to create a Power line communication interface to enable 2 computers communicate via the seria port and over the 220V AC power line. So i need an RS232 interface with the PIC (using a MAX232) to enable the PIC receive 8N1 (8 data bits and 1 stop bit) from the PC and transmit it over the power line to the receiving PC. A the PIC sends the serial data over the power line through a Power line Modem chip. But the problem is i have to add some preamble to my data (as adviced a technical personal from the company i got the power line chip from) before i send it over the Power line through the Power line modem to prevent me loosing some of my data during reception. So i need to send/receive 8bit data from/to the PC and send/receive about 24bit data to/from the power line modem i know i'll implement my two serial interfaces using a hardware UART of the PIC16F877 and a software UART using any other pin. But how best do i implement this. My major area of challenge is this 1. if i have to receive more than 8bits of data say from the PC, how do implement this? Or must i restrict the maximum amount of input bytes i can get at a time or can i send out each byte as i receive it 2. secondly what kind of pramble can i use? because due to the nature of entire system, i will loose some of my input data before actual reception begins so how can i ignore the preambel and collect just my data? 3. which interface would be better to implement the software and Hardware UARTs, the PIC to PC interface or the PIC to modem interface? I'll appreciate all the help i can get. Thank you. |
|
|
|
|
|
|
(permalink) |
|
Use the hardware USART to the PC, and the software one for the power line (as it's much more versatile). I would suggest you use some kind of packet system, Manchester coding might be a good idea as well, check my tutorials for an example.
|
|
|
|
|
|
|
(permalink) |
|
thanks i'll work on that
|
|
|
|
|
|
|
(permalink) | |
|
Quote:
More digested, you need to use interrupts to process the data has it comes. I sugest you send the data from the PC and count the Bytes on the PIC, 24bits give you 3 Bytes, so, count 3 interrupts of Byte received and on the 3rd Byte read the 24bits at once. This is the easyest way. OR Send 8bits of data then just confirm the 8bits, sending another 8bits will allow you to avoid errors by comparing all the 3bytes and searching for common bits on the 3 of them and building 1 byte from those 3 bytes. Did i wrote too much ?... :P
__________________
Best Regards, Tiago Silva. |
||
|
|
|
|
|
(permalink) |
|
thanks alot im greatful. i'll read up on all these, try my hand on some code and let you all know how far. thanks
|
|
|
|
|
|
|
(permalink) |
|
I don't know how this works, but feel free to add me some reputation :P
Keep us updated so that we may know what you have done and still need to do. Have fun!
__________________
Best Regards, Tiago Silva. |
|
|
|
|
|
|
(permalink) |
|
please i'm having a bit of a problem in understanding delay routines. how do i calculate the time per cycle for each instruction when i'm using a 20MHz clock?
|
|
|
|
|
|
|
(permalink) |
|
please i'm having a bit of a problem in understanding delay routines. how do i calculate the time per cycle for each instruction when i'm using a 20MHz clock? or any other clock speed
|
|
|
|
|
|
|
(permalink) | |
|
Quote:
A nanosecond (nS) is a billionth of a second. 1000nS = 1 microsecond (uS) or millionth of a second. 1000uS = 1 millisecond (mS) or thousandth of a second. Did I miss one there?
__________________
========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 12th June 2008 at 02:41 PM. |
||
|
|
|
|
|
(permalink) |
|
Okeedokee, welllll...I suggest using a timer (possibly the 16-bit one, TMR1 I think it was?) to make the software USART more accurate. To receive more than 8 bits at a time to use in the PIC, it might be a good idea to set the Receive Buffer Full interrupt and some subroutines to make a buffer in the general purpose registers.
__________________
<-- Feel free to IM me for random chit-chat and PIC assembly talk Adobe After Effects lets you save your work before it crashes, now THAT'S user-friendly. Last edited by ArtemisGoldfish; 12th June 2008 at 02:41 PM. |
|
|
|
|
|
|
(permalink) |
|
[quote=ulot;319105]Hello
My major area of challenge is this 1. if i have to receive more than 8bits of data say from the PC, how do implement this? Or must i restrict the maximum amount of input bytes i can get at a time or can i send out each byte as i receive it Stop thinking in terms of bits, think in bytes. Use the PIC hardware UART and an interrupt service subroutine to handle the data coming from the PC. On each interrupt read the byte in the receive buffer and save it, until you detect the crlf code, if you are using ASCII data transmission. 2. secondly what kind of pramble can i use? because due to the nature of entire system, i will loose some of my input data before actual reception begins so how can i ignore the preambel and collect just my data? What data are you transferring to and from the PIC to PC.? 3. which interface would be better to implement the software and Hardware UARTs, the PIC to PC interface or the PIC to modem interface? Hardware interface. QUOTE] Hi, Give more information regarding the data.. To calculate the execution time of one instruction divide the crystal freq/4 One or two types of instructions, take two execution cycles. What delays are you wanting.? Look here: Delay Code Generator , which PIC type.?
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 12th June 2008 at 02:56 PM. |
|
|
|
|
|
|
(permalink) |
|
The PIC24FJ16GA002 etc have two USARTs if you can use a 16 bit processor. You can even chose which pins the USARTS connect to.
There are some 8 bit PICs with two USARTs, but only in surface mount packages. The PIC18F24J11 is not yet available but it will have two USARTs. |
|
|
|
|
|
|
(permalink) |
|
Thanks alot for all the advice.
I can't easily lay my hands on any PIC i want, i had to order the 16F from abroad, they're not available in my country so i'm stuck with the 16F877. I get the gist about the cycle time now. I guess i'll be transfering ASCII characters from PC to PC basically, just to see how the serial communication works although i might also need to send binary data in some cases because the chip i'm using with my PIC has a 24bit (8bytes) programmable register which controls the operation of the chip. I read about the use of the TMR0 timer in RB4/TMR0 pin for software UART implementation, using the timer overflow interrupt and the two operation modes of the pin. i saw an application note on it at microchip. when i'm done with all these i'll post my code for "debugging" . thanks for all your help an advice i'll appreciate a whole lot more. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
24 bits make 3 Bytes Have fun!
__________________
Best Regards, Tiago Silva. |
||
|
|
|
|
|
(permalink) | |
|
Quote:
If you are using ASCII and Binary transmission via the RS232 you should program prefix and sufix codes to identify the start and end of a string. If the data integrity is critical, you should use Parity and a CRC check code. Tell us what the data is going to be.
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 13th June 2008 at 12:01 PM. |
||
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| project ideas for final year project! | AceOfHearts | Electronic Projects Design/Ideas/Reviews | 3 | 24th April 2007 05:42 PM |
| need suggestions on uni project. (mechatronics project) | konzen | General Electronics Chat | 16 | 13th March 2006 11:56 AM |
| electronics project for btech mini project | sujith123 | Electronic Projects Design/Ideas/Reviews | 4 | 23rd September 2005 11:28 PM |
| i need a project idea\concept for a 10 month project..... | mackoy | General Electronics Chat | 3 | 21st February 2005 11:27 PM |
| biomedical project(electronic project) | naguru | Electronic Projects Design/Ideas/Reviews | 1 | 2nd November 2004 11:07 AM |