PDA

View Full Version : Serial Communication



morris
- 14th December 2006, 17:05
I am trying to build a robot through a college experiment. We are using two Pic16F628A microcontrollers. The problem that we are having is that the first pic is using a serial function to communicate through an infrared led. This led sends the modulated signal to a ir reciever. In turn, this circuit sends the signal to another Pic. This is where our problem is... this pic isn't sending the serial message to the LCD like we want it to. Does anyone have any suggestions on the commands that we could use in attempt to get this working?

This is the current program that we have and are trying to use to get this working...

TRISB=%00010000

Include "modedefs.bas"
B0 var byte

PAUSE 500

LCDLoop:
Serin2 PORTB.4, T2400, [B0]
lcdout $FE, 1
LCDOUT $FE, 2
LCDOUT B0
GOTO LCDLoop

END

Please.. if anyone can help please do so

skimask
- 14th December 2006, 17:39
In your original code, you displayed the character, then reset the LCD, then displayed the character. Sounds to me like the LCD is clearing itself before you actually get to see it.

Small steps, get the individual core PICs working first, LCDs, buttons, motor control, etc. Then start adding the extra stuff.

If you're asking this type of question here on a forum AND you're doing this for a 'college level experiment', it sounds to me like your instructor sucks and you'd better get your money back.
JDG

morris
- 15th December 2006, 04:35
appreciate man... i agree 100% with the last part... ill try your suggestions... thank you

Archangel
- 15th December 2006, 22:09
I am trying to build a robot through a college experiment. We are using two Pic16F628A microcontrollers. The problem that we are having is that the first pic is using a serial function to communicate through an infrared led. This led sends the modulated signal to a ir reciever. In turn, this circuit sends the signal to another Pic. This is where our problem is... this pic isn't sending the serial message to the LCD like we want it to. Does anyone have any suggestions on the commands that we could use in attempt to get this working?

This is the current program that we have and are trying to use to get this working...




TRISB=%00010000

Include "modedefs.bas"
B0 var byte

PAUSE 500

LCDLoop:
Serin2 PORTB.4, T2400, [B0]
lcdout $FE, 1 ' clears display
LCDOUT $FE, 2 ' returns curser home
LCDOUT B0 ' displays variable's contents
<font color=red> PAUSE 1000 </font color> ' makes time to read lcd
GOTO LCDLoop ' returns to beginning of loop

END

mister_e
- 16th December 2006, 13:35
The PAUSE 1000 above is handy if you want to loose incoming data ;)

So do you have any information how the data is modulated and sent? Do you have any access to the it's source code or not? If the baudrate and mode are good, use a scope an look if you see anything going out of your IR receiver. If at least you have some signal, it could be the accuracy of it.

Let's say you're using internal OSC on both side (transmitter and receiver) and both are a little bit out of range.. there's no chance to have something good at the end.

If you're using the default LCD pin assignement, you need to disable the analog comparator on PORTA or your LCD will probably never work
Try this one bellow and post your results



'
' PIC Configuration
' =================
@ __CONFIG _INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON

'
' Hardware configuration
' ======================
PORTA=0
PORTB=0
TRISA=0
CMCON=7 ' Disable analog comparator
TRISB=%00010000 ' RB4 as input (Serial comm)

'
' Variables definition
' ===================
B0 var byte

'
' Constants definition
' ====================
Include "modedefs.bas"

'
' ////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
' Program Start Here
' ////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
PAUSE 500

LCDLoop:
Serin2 PORTB.4, T2400, [B0]
lcdout $FE, 1,"N:",B0," D:",DEC b0
GOTO LCDLoop ' returns to beginning of loop