Papabravo said:
It is a silly idea to use an opamp as a comparator. The 741 does not really like single supply operation, it wants bi-polar supplies. You also can't have your inputs or you outputs ge too close to the power supply rails. I'm surprised that people still buy this 40 year old pig of a part.
I'd like to have a little more detail on the meaning of messy. Does it refer to the signal going into the RXD pin on your processor? Where is the signal coming from? How long is the cable?
Or does messy refer to the LCD display in which case your problem might have nothing to do with the serial input.
Actually what I'm doing right now is try to send a counter number and display it on LCD at receiver board. So, I use Tx and Rx module to make the operation success. my Tx and Rx works fine in a short distance.But If I take the receiver board outdoor around 10m from Tx board, the lcd at RX board will display wrong counting numbers and then stop counting.So, I assume there is too much noise in my signal.That's why I want to use a comparator to get a better signal.I connect RxD pin to PortA.0 at PIC16F877A and use pull up 10k resistor at RxD pin.For your information My Rx module is YS-CWC1.Please help me by giving some Ideas on how to reduce the noise and what types of comparator should I use?? Actually I don't know how to use internal comparator Inside my PIC and don't know the instruction to turn on the internal comparator because I'm a new user of PIC.So, please help me on this.Your IDeas and answers will greatly appreciated.
Below is my code
Tx part
@__CONFIG_HS_OSC
DEFINE OSC 20
ADCON1=7
;CMCON = 7 'Alla I/O Digitala
LEDPin VAR PORTB.4
TransmitterPIN VAR PORTA.0
INCLUDE "modedefs.bas"
Counter VAR BYTE
Synk VAR BYTE
Synk = $55
DEFINE CHAR_PACING 500
Counter = 0
HIGH TransmitterPin
pause 200
Main:
HIGH LEDPin
PAUSE 100
LOW LEDPin
PAUSE 100
SEROUT TransmitterPIN,T2400,[Synk,Synk,9,Counter]
HIGH LEDPin
PAUSE 100
LOW LEDPin
PAUSE 100
Counter = Counter + 1
PAUSE 600
GOTO Main
END
Rx part
@__CONFIG_HS_OSC
define OSC 20
DEFINE LCD_DREG PORTC 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTB 'LCD register select port
DEFINE LCD_RSBIT 7 'LCD register select bit
DEFINE LCD_EREG PORTB 'LCD enable port
DEFINE LCD_EBIT 5 'LCD enable bit
DEFINE LCD_RWREG PORTB 'LCD read/write port
DEFINE LCD_RWBIT 6 'LCD read/write bit
DEFINE LCD_BITS 8 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD
DEFINE LCD_COMMANDUS 2000 'Command delay time in us
DEFINE LCD_DATAUS 50 'Data delay time in us
TRISC = %00000000 'Set port B as output
TRISB = %00000000 'Set port D as output
low PORTB.6 'Set the R/W bit to low
pause 1000 'wait until the LCD initializes
INCLUDE "modedefs.bas"
Counter VAR BYTE
ReciverPIN VAR PORTA.0
ADCON1 = 7 ' Alla digitala
PAUSE 500
Main:
SERIN ReciverPIN,T2400,[9],Counter
GOSUB LCD
GOTO Main
LCD:
LCDOUT $FE,1
LCDOUT $FE,$80,#Counter
PAUSE 500
RETURN
END