Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

connect Microcontroller PIC PIC16F877 to PC via rs232

Status
Not open for further replies.

mado-wardany

Newbie level 5
Joined
Mar 24, 2010
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,353
I'm working on a senior project, consists of temperture sensor and pulse sensor , these sensors are connected to PIC 16f877 (ADC; convert the signals received from sensors to digital, 8 bit to each sensor ) then transmit these 16 bits by serial port RS232 to computer,
I know that these 16 bits (8bits for temp sensor and 8 bits for pulse sensor) transmit via RS232 bit then bit,

i want to ask a question,,,,May I face any problem when i worked on this project specially in serial connection between PIC and computer (synchronization)?

plz help me as soon as
 

i also work on similar thing. for rs232, it is quite straight forward.
 

may the synchronization issue you will face but don't worry about it cause all problems from this kind you will find solutions for it on the web, check www.beyondlogic.org
very nice website about computer interfacing stuff.
good luck
 

what do you mean by Synchronization ??
 

what i understand is when u send a char, u get replied exactly the same char also.

also to take note, baud rate.
 

You need a level translator circuit. You can do it with discrete componets, but probaly lest trouble to use a level translator chip, Maxim etc. Then it is just a matter of using the same baud rate settings as your Pic. You can of course only send 1 byte at a time, so for 16bits you would need to send 2 bytes and the reassemble them when received. If you are using something like hyperterminal, dont forget that anything you send will be interpreted as characters. If you are sending data you will probably have to write your own PC program, Basic,C etc.

Added after 4 minutes:

BTW you can buy adaptors that plug into the PC serial port and give 5v TTL levels. Also USB to serial are available, but make sure they are TTL output and not RS232 levels.
 

Yes, GrandAlf is correct.
U need to do some conversion on the signal level. one it, u may use MAX232 to interface from ur RS232 port to your PIC. Can check on the hardware connection, you may need around 4 capacitors. Then Tx and Rx line to the uC.

Inside the programming, try UART to test the com port and can check using USART terminal.
 

how do you determine the sending rate bit by bit or byte ?
and also what is the connection ciecuit between pic and max 232 and serial port
as it didnt work with me
 

It mainly depends on the capability of your compiler. For instance, if you are using the Picbasic Pro (as also some others, I'm sure), you can select the 'inverted' mode of serial comms, in which case you DO NOT need any extra hardware to connect the pic with the PC (besides a resistor). Also, you can use any port pin for the communications, not necessarily the UART pins.

Second, you would also be able to define the comm parameters in your program (baud rate, stop bits, parity); just set the same parameters on the terminal program you use (eg.: Terraterm, Hyperterminal etc) and you're all set.

Thirdly, treat each digitized sensor reading as a separate byte; NOT 16 bits. Thus, you'll be sending 2 characters, one for the temperature, and the second for the pulse.

Regards,

Anand Dhuru
 

SORRY I CANT UNDERSTAND WHAT YOU MEAN i use microbasic program
and i st baud rate at 9600 in the program
but how many bytes will i send and ididnt detect it in the program
after convert word to string

program ADC_10
dim temp_res as word
dim output as string[5]
DIM AD_RES AS WORD


USART_INIT(9600)
main:
TRISA = %11111111 ' Port A is input


trisb=0
TRISD = %00000000
ADCON1 =%10000010 ' Port A is in analog mode,
' 0 and 5V are reference voltage values,
' and the result is aligned right
' (higher 6 bits of ADRESH are zero).
ADCON0 = %00000001
Delay_ms (1) ' 1 ms pause
eloop:
ADCON0.2 = 1 ' Conversion starts
wait:
' wait for ADC to finish
Delay_ms(1)
if ADCON0.2 = 1 then
goto wait
end if
temp_RES=ADC_READ(0)
PORTD=LO(temp_RES) ' Set LOWER 8 bits on port D
Delay_ms(1) ' 1 ms pause

while true
if Usart_Data_Ready = 1 then ' Check if there is data received
' if Usart_Read = "g" then ' is it "g" ?
Usart_Write(13) ' Write CR
Usart_Write(10) ' ... and LF
temp_res = ADC_read(0) ' Read ADC
WordToStrWithZeros(temp_res, output) ' Convert result to string
Usart_Write_Text(output) ' Send string to Usart
Usart_Write(13) ' CR
Usart_Write(10) ' LF
'end if
end if
wend
end.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top