in the picture I had just finish trying all the B ports., It was in RB6, which was the last of the port I tried
the sending IS on RB2
and Receiving is on RB3
go back to the web site i posted a new picture
in the picture I had just finish trying all the B ports., It was in RB6, which was the last of the port I tried
the sending IS on RB2
and Receiving is on RB3
go back to the web site i posted a new picture
Last edited by lerameur; - 24th December 2006 at 05:00.
Ok so now both receiver and transmitter are on portb.2
the picture is up
would the problem be in the software, is the pic16f88 special and need extra attention ?
Last edited by lerameur; - 24th December 2006 at 05:21.
It does...but I think I'm onto something....
On the receiver PIC, it shows:
Waiting...127,22
The 127 is the number of times it's tried to receive data but timed out, the 22 is the number of times it's actually received 4 bytes of data and dropped thru to the display section.
Post your receiver code as it stands again.
Something is amiss. If the serial port wasn't receiving anything (i.e. the serin statement always timed out and went back to loop, the 22 should remain a 0).
for the receiving code, as soon as I open the power supply I get a different number
trial1: Waiting... 111,22
trial2: Waiting... 111,21
trial3: Waiting... 127,22
trial4: Waiting... 107,21
.....
when I leave the power off for a while, it seems to come back to Waiting... 111,22 when the power is turned on
once the number is there , it stays, it do not move, NO increment.
'RECEIVE
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
'try1 = count of times waiting for bytes, try2 = count of bytes received
try1 var byte : try2 var byte : temp var word : tempf var word : input portb.3 : pause 2500
loop:
lcdout $fe , $c0 , "Waiting..." , DEC3 try1 , "," , DEC3 try2
try1 = try1 + 1
serin portB.2 , n2400 , 1000 , loop , [ temp.highbyte , temp.lowbyte , tempf.highbyte , tempf.lowbyte ]
try2 = try2 + 2
lcdout $fe , $c0 , "Received.." , DEC3 try1 , "," , DEC3 try2
lcdout $fe , $c0 , "Displaying" , DEC3 try1 , "," , DEC3 try2
lcdout $fe , $80 , "Tc=" , DEC temp , "C,Tf=" , DEC tempf , ".."
lcdout $fe , $c0 , "Displayed." , DEC3 try1 , "," , DEC3 try2
goto loop
End
'TRANSMIT
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
try1 var byte : output portb.2 : input portb.3 : dq var portb.4 : temp var word : tempf var word
pause 2500
try2 var byte
loop:
try1 = try1 + 1
lcdout $fe , $c0 , "Getting..." , DEC3 try1 , "," , DEC3 try2
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $44 ] : Pause 500
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $be ]
owin DQ , 0 , [ temp.LOWBYTE , temp.HIGHBYTE , skip 6 ]
tempf = temp * 9 : tempf = tempf / 5 : tempf = tempf + 32
lcdout $fe , $c0 , "Displaying" , DEC3 try1 , "," , DEC3 try2
lcdout $fe , $80 , "Tc=" , DEC temp , "C,Tf=" , DEC tempf , "F.."
lcdout $fe , $c0 , "Sending..." , DEC3 try1 , "," , DEC3 try2
serout portb.2 , n2400 , [ temp.highbyte , temp.lowbyte ]
serout portb.2 , n2400 , [ tempf.highbyte , tempf.lowbyte ]
lcdout $fe , $c0 , "Data Sent." , DEC3 try1 , "," , DEC3 try2
goto loop
End
Last edited by lerameur; - 24th December 2006 at 05:33.
'RECEIVE
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
'try1 = count of times waiting for data, try2 = count of bytes received
try1 var byte : try2 var byte : temp var word : tempf var word : input portb.2 : pause 2500
try1 = 0 : try2 = 0
loop:
lcdout $fe , $c0 , "Waiting.." , DEC3 try1 , "," , DEC3 try2
try1 = try1 + 1
serin portB.2 , n2400 , 1000 , loop , [ temp.highbyte , temp.lowbyte , tempf.highbyte , tempf.lowbyte ]
try2 = try2 + 4
lcdout $fe , $c0 , "Received." , DEC3 try1 , "," , DEC3 try2 : pause 100
lcdout $fe , $c0 , "Display.." , DEC3 try1 , "," , DEC3 try2 : pause 100
lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , ".." : pause 100
lcdout $fe , $c0 , "Shown...." , DEC3 try1 , "," , DEC3 try2 : pause 100
goto loop
End
'TRANSMIT
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
try1 var byte : try2 var byte : output portb.2 : input portb.3
dq var portb.4 : temp var word : tempf var word
pause 2500
try1 = 0 : try2 = 0
loop:
try1 = try1 + 1
lcdout $fe , $c0 , "Getting.." , DEC3 try1 , "," , DEC3 try2
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $44 ] : Pause 500
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $be ]
owin DQ , 0 , [ temp.LOWBYTE , temp.HIGHBYTE , skip 6 ]
tempf = temp * 9 : tempf = tempf / 5 : tempf = tempf + 32
lcdout $fe , $c0 , "Display.." , DEC3 try1 , "," , DEC3 try2
lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC tempf , "F."
lcdout $fe , $c0 , "Sending.." , DEC3 try1 , "," , DEC3 try2
serout portb.2 , n2400 , [ temp.highbyte , temp.lowbyte ]
serout portb.2 , n2400 , [ tempf.highbyte , tempf.lowbyte ]
try2 = try2 + 4 : lcdout $fe , $c0 , "Sent....." , DEC3 try1 , "," , DEC3 try2
goto loop
Try those code chunks. I get the feeling that the lcd at the receiver end might have been overwriting itself, thereby blanking out the data or something. I also added a couple of pauses in there so you could see what was going on. Also, you didn't set the receiver port to an input (I know serin says it does this for you, but I never trust stuff like that).
I tried setting Trisb.2 before and it did ot hnage anythimg so I put it rightback.
Ok now , the sending side, there is an incrementation, and for the first time try2 is incrementing, and it does so by 4.
On the receiver side, first line; empty, second line: 'Waiting... 000,000'
I also added these twoline:
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
but no luck either
Last edited by lerameur; - 24th December 2006 at 06:00.
It's not incrementing at all on the receiving side? Try1 should be going up about once a second.
Add:
DEFINE CHAR_PACING 16667
to the transmit program's defines at the beginning. Maybe the receiver is missing characters 'cause they're coming too fast with the software based serin command. If that fixes it, it'll probably work with a value much less than 16667, but it's a start.
Last edited by skimask; - 24th December 2006 at 06:11. Reason: added info
NO incrementation on the receiver. The same with all zeros all the time
what about using the serin2 command ??
with the new define, I can see glitches of 'Sending...' on the second line of the sending side. But most often it is on like before, 'Getting...'
Last edited by lerameur; - 24th December 2006 at 06:18.
Transmit side - sounds like it's doing like it should.
Receive side - try this one:
'RECEIVE
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
'try1 = count of times waiting for data, try2 = count of bytes received
try1 var byte : try2 var byte : temp var word : tempf var word : input portb.2 : pause 2500
try1 = 0 : try2 = 0
loop:
lcdout $fe , $c0 , "Waiting.." , DEC3 try1 , "," , DEC3 try2
try1 = try1 + 1 : temp = 0 : tempf = 0
serin portB.2 , n2400 , [ temp.highbyte , temp.lowbyte , tempf.highbyte , tempf.lowbyte ]
if temp + tempf > 0 then try2 = try2 + 1 'if temp+tempf are not 0 then data received
lcdout $fe , $c0 , "Received." , DEC3 try1 , "," , DEC3 try2 : pause 100
lcdout $fe , $c0 , "Display.." , DEC3 try1 , "," , DEC3 try2 : pause 100
lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , ".." : pause 100
lcdout $fe , $c0 , "Shown...." , DEC3 try1 , "," , DEC3 try2 : pause 100
goto loop
End
O my I changed to this
serin portB.2 , t2400 , [ temp.highbyte , temp.lowbyte , tempf.highbyte , tempf.lowbyte ]
now the temp is showing up on first line, BUT is it showing zeros,
incrementation on try, try2 fixed at 0
check the web page also, for output on lcd
also:
On the receiver side...
Change the word 'Waiting..' to
'Wait 4 it'
and see what happens ----------- Only the display changed
Last edited by lerameur; - 24th December 2006 at 06:42.
receiver side change - That's what I was wondering. I had a case a couple days ago where I thought it was programming, but the PGD wire had come loose from my board, so it wasn't actually programming, even though it didn't report any errors (and I had my verify turned off!).
Changing to t2400 is going to do exactly what you saw. But it doesn't fix anything. Leave it at n2400, or try changing both sides to t2400.
And try putting a small resistor inline with the big yellow wire, about 100 ohms or so. Without it, it's almost like a direct short from power to ground from one PIC to another. I should've caught this earlier.
Last edited by skimask; - 24th December 2006 at 06:47.
I will leave is at n2400 then
also, are you saying my pgd wire is messed up ??
I am not sure what it is ? it is programming the sending side.., I am not sure what you meant
The 100 ohm resistor did not do anything .
Last edited by lerameur; - 24th December 2006 at 06:53.
Yes, try changing both sides to t2400 instead of n2400.
You must be pulling the chips out and programming them. Changing the 'Waiting...' was just a quick way to make sure the PIC was actually being reprogrammed.
I didn't expect the 100 ohm resistor to change anything, it's just a good idea from a 'safety' standpoint, saves PICs from blowing themselves up.
And this is going to sound a bit wierd, but I'm wondering if SERIN and SEROUT don't like to deal with temp.highbyte and would rather deal with a byte value instead. Give me a couple of minutes to rewrite the programs and I'll post them in a couple of minutes.
Last edited by skimask; - 24th December 2006 at 06:58.
I didn't expect the 100 ohm resistor to change anything, it's just a good idea from a 'safety' standpoint, saves PICs from blowing themselves up.[/QUOTE]
ok too much current, I get it
no changes with t2400 on both chips
Ok I changed the speed to 9600.
I get the temperature showing on the receiving ship, but its showing zeros.
also the increment try do not increment , But when i disconnect the wire, it increments every 0.5 sec
Last edited by lerameur; - 24th December 2006 at 07:05.
'RECEIVE
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
'try1 = count of times waiting for data, try2 = count of bytes received
try1 var byte : try2 var byte : temp var word : tempf var word
temp1 var byte : temp2 var byte : temp3 var byte : temp4 var byte
input portb.2 : pause 2500
try1 = 0 : try2 = 0
loop:
lcdout $fe , $c0 , "Waiting.." , DEC3 try1 , "," , DEC3 try2
try1 = try1 + 1 : temp = 0 : tempf = 0
serin portB.2 , t2400 , [ temp1 , temp2 , temp3 , temp4 ]
temp.highbyte = temp1 : temp.lowbyte = temp2 : tempf.highbyte = temp3 : tempf.lowbyte = temp4
if temp + tempf > 0 then try2 = try2 + 1 'if temp+tempf are not 0 then data received
lcdout $fe , $c0 , "Received." , DEC3 try1 , "," , DEC3 try2 : pause 100
lcdout $fe , $c0 , "Display.." , DEC3 try1 , "," , DEC3 try2 : pause 100
lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , ".." : pause 100
lcdout $fe , $c0 , "Shown...." , DEC3 try1 , "," , DEC3 try2 : pause 100
goto loop
End
'TRANSMIT
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
DEFINE CHAR_PACING 16667
try1 var byte : try2 var byte : output portb.2 : input portb.3
dq var portb.4 : temp var word : tempf var word
temp1 var byte : temp2 var byte : temp3 var byte : temp4 var byte
pause 2500
try1 = 0 : try2 = 0
loop:
try1 = try1 + 1
lcdout $fe , $c0 , "Getting.." , DEC3 try1 , "," , DEC3 try2
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $44 ] : Pause 500
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $be ]
owin DQ , 0 , [ temp.LOWBYTE , temp.HIGHBYTE , skip 6 ]
tempf = temp * 9 : tempf = tempf / 5 : tempf = tempf + 32
lcdout $fe , $c0 , "Display.." , DEC3 try1 , "," , DEC3 try2
lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC tempf , "F."
lcdout $fe , $c0 , "Sending.." , DEC3 try1 , "," , DEC3 try2
temp1 = temp.highbyte : temp2 = temp.lowbyte
serout portb.2 , t2400 , [ temp1 , temp2 ]
temp3 = tempf.highbyte : temp4 = tempf.lowbyte
serout portb.2 , t2400 , [ temp3 , temp4 ]
try2 = try2 + 4 : lcdout $fe , $c0 , "Sent....." , DEC3 try1 , "," , DEC3 try2
goto loop
If that works, then great. I don't know why it works. The PBP manual says the other way should work, but I seem to remember running into this problem before and had to do the same thing, I can't remember what I was doing though.
sorry, still showing zeros at the receiving end, with nothing on the first line
Then try this code for both TX and RX sides:
'RECEIVE
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
'try1 = count of times waiting for data, try2 = count of bytes received
try1 var byte : try2 var byte : temp var word : tempf var word
temp1 var byte : temp2 var byte : temp3 var byte : temp4 var byte
input portb.2 : pause 2500
try1 = 0 : try2 = 0
loop:
lcdout $fe , $c0 , "Waiting.." , DEC3 try1 , "," , DEC3 try2
try1 = try1 + 1 : temp = 0 : tempf = 0
serin portB.2 , t2400 , [ temp1 , temp2 , temp3 , temp4 ]
temp1 = 3 : temp2 = 120 'hardcode receiver to display 888 in tempc space
temp.highbyte = temp1 : temp.lowbyte = temp2 : tempf.highbyte = temp3 : tempf.lowbyte = temp4
if temp + tempf > 0 then try2 = try2 + 1 'if temp+tempf are not 0 then data received
lcdout $fe , $c0 , "Received." , DEC3 try1 , "," , DEC3 try2 : pause 100
lcdout $fe , $c0 , "Display.." , DEC3 try1 , "," , DEC3 try2 : pause 100
lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , ".." : pause 100
lcdout $fe , $c0 , "Shown...." , DEC3 try1 , "," , DEC3 try2 : pause 100
goto loop
End
'TRANSMIT
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
DEFINE CHAR_PACING 16667
try1 var byte : try2 var byte : output portb.2 : input portb.3
dq var portb.4 : temp var word : tempf var word
temp1 var byte : temp2 var byte : temp3 var byte : temp4 var byte
pause 2500
try1 = 0 : try2 = 0
loop:
try1 = try1 + 1
lcdout $fe , $c0 , "Getting.." , DEC3 try1 , "," , DEC3 try2
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $44 ] : Pause 500
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $be ]
owin DQ , 0 , [ temp.LOWBYTE , temp.HIGHBYTE , skip 6 ]
tempf = temp * 9 : tempf = tempf / 5 : tempf = tempf + 32
tempf = 444 'hardcode transmitter to have 444 in tempf space
lcdout $fe , $c0 , "Display.." , DEC3 try1 , "," , DEC3 try2
lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC tempf , "F."
lcdout $fe , $c0 , "Sending.." , DEC3 try1 , "," , DEC3 try2
temp1 = temp.highbyte : temp2 = temp.lowbyte
serout portb.2 , t2400 , [ temp1 , temp2 ]
temp3 = tempf.highbyte : temp4 = tempf.lowbyte
serout portb.2 , t2400 , [ temp3 , temp4 ]
try2 = try2 + 4 : lcdout $fe , $c0 , "Sent....." , DEC3 try1 , "," , DEC3 try2
goto loop
still no changes from previous. I just check the hardware, and seems to be ok, Cystal is oscillating at 20Mhz on both sides.
actually I did, th e pic is back , i will do another one with the last circuit
I just tried sending a constant over, and displaying it on the receiving end and it still gives me zero, maybe breaking the program into even more basic ?
new PIC online
with this last program, both counters are working on both chips.
Last edited by lerameur; - 24th December 2006 at 07:43.
Last edited by skimask; - 24th December 2006 at 07:45.
3 more things to try to get this narrowed down...bear with me....
Try this out now:
'RECEIVE PIC
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
'try1 = count of times waiting for data, try2 = count of bytes received
try1 var byte : try2 var byte : temp var word : tempf var word
temp1 var byte : temp2 var byte : temp3 var byte : temp4 var byte
input portb.2 : pause 2500
try1 = 0 : try2 = 0
loop:
lcdout $fe , $c0 , "Waiting.." , DEC3 try1 , "," , DEC3 try2
try1 = try1 + 1 : temp = 0 : tempf = 0
serin portB.2 , t2400 , [ temp1 , temp2 , temp3 , temp4 ]
temp.highbyte = temp1 : temp.lowbyte = temp2 : tempf.highbyte = temp3 : tempf.lowbyte = temp4
if temp + tempf > 0 then try2 = try2 + 1 'if temp+tempf are not 0 then data received
lcdout $fe , $c0 , "Received." , DEC3 try1 , "," , DEC3 try2 : pause 100
lcdout $fe , $c0 , "Display.." , DEC3 try1 , "," , DEC3 try2 : pause 100
lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , "FR" : pause 100
lcdout $fe , $c0 , "Shown...." , DEC3 try1 , "," , DEC3 try2 : pause 100
goto loop
End
'TRANSMIT PIC
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
DEFINE CHAR_PACING 16667
try1 var byte : try2 var byte : output portb.2 : input portb.3
dq var portb.4 : temp var word : tempf var word
temp1 var byte : temp2 var byte : temp3 var byte : temp4 var byte
pause 2500
try1 = 0 : try2 = 0
loop:
try1 = try1 + 1
lcdout $fe , $c0 , "Getting.." , DEC3 try1 , "," , DEC3 try2
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $44 ] : Pause 500
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $be ]
owin DQ , 0 , [ temp.LOWBYTE , temp.HIGHBYTE , skip 6 ]
tempf = temp * 9 : tempf = tempf / 5 : tempf = tempf + 32
tempf = 444 'hardcode transmitter to have 444 in tempf space
temp = 888 'hardcode transmitter to have 888 in temp space
lcdout $fe , $c0 , "Display.." , DEC3 try1 , "," , DEC3 try2
lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , "FT"
lcdout $fe , $c0 , "Sending.." , DEC3 try1 , "," , DEC3 try2
temp1 = temp.highbyte : temp2 = temp.lowbyte
serout portb.2 , t2400 , [ temp1 , temp2 ]
temp3 = tempf.highbyte : temp4 = tempf.lowbyte
serout portb.2 , t2400 , [ temp3 , temp4 ]
try2 = try2 + 4 : lcdout $fe , $c0 , "Sent....." , DEC3 try1 , "," , DEC3 try2
goto loop
o, I wil wait a bit,
the receing LCD shows only on the second line, with zerosss.
like on the picture, its 2 pics
i tried this thing but it do not work
loop:
lcdout $fe , $c0 , "Waiting.." , DEC3 try1 , "," , DEC3 try2
try1 = try1 + 1 : temp = 0 : tempf = 0
serin portB.2 , t2400 , [ temp1 , temp2 , temp3 , temp4 ]
if temp1 > temp2 then
Portb.4 =1 ------------putting a led here, maybe lcdout is confusing with serin
pause 500
portb.4=0
else
Portb.3 =1 -----------putting a led here
pause 500
portb.3=0
endif
goto loop
End
I meant are you putting the transmit code into the transmit PIC and the receive code into the receive PIC, not the whole thing into both PICs...
'TRANSMIT PIC = one pic
'RECEIVE PIC = another pic
dont worry, only the part that belongs there
Ok, just checking because in that one picture it looked like both PICs had the same writing on them.
Now try this code:
'RECEIVE PIC
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
'try1 = count of times waiting for data, try2 = count of bytes received
try1 var byte : try2 var byte : temp var word : tempf var word
temp1 var byte : temp2 var byte : temp3 var byte : temp4 var byte
input portb.2 : pause 2500
try1 = 0 : try2 = 0
loop:
lcdout $fe , $c0 , "Waiting.." , DEC3 try1 , "," , DEC3 try2
try1 = try1 + 1 : temp = 0 : tempf = 0
serin portB.2 , t2400 , [ temp1 , temp2 , temp3 , temp4 ]
temp.highbyte = temp1 : temp.lowbyte = temp2 : tempf.highbyte = temp3 : tempf.lowbyte = temp4
if temp + tempf > 0 then try2 = try2 + 1 'if temp+tempf are not 0 then data received
lcdout $fe , $c0 , "Received." , DEC3 try1 , "," , DEC3 try2 : pause 100
lcdout $fe , $c0 , "Display.." , DEC3 try1 , "," , DEC3 try2 : pause 100
lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , "FR" : pause 100
lcdout $fe , $c0 , "Shown...." , DEC3 try1 , "," , DEC3 try2 : pause 100
goto loop
End
'TRANSMIT PIC
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
DEFINE CHAR_PACING 16667
try1 var byte : try2 var byte : output portb.2 : input portb.3
dq var portb.4 : temp var word : tempf var word
temp1 var byte : temp2 var byte : temp3 var byte : temp4 var byte
pause 2500
try1 = 0 : try2 = 0
loop:
try1 = try1 + 1
lcdout $fe , $c0 , "Getting.." , DEC3 try1 , "," , DEC3 try2
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $44 ] : Pause 500
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $be ]
owin DQ , 0 , [ temp.LOWBYTE , temp.HIGHBYTE , skip 6 ]
tempf = temp * 9 : tempf = tempf / 5 : tempf = tempf + 32
tempf = 444 'hardcode transmitter to have 444 in tempf space
temp = 888 'hardcode transmitter to have 888 in temp space
lcdout $fe , $c0 , "Display.." , DEC3 try1 , "," , DEC3 try2
lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , "FT"
lcdout $fe , $c0 , "Sending.." , DEC3 try1 , "," , DEC3 try2
temp1 = temp.highbyte : temp2 = temp.lowbyte
serout portb.2 , t2400 , [ temp1 , temp2 ]
temp3 = tempf.highbyte : temp4 = tempf.lowbyte
serout portb.2 , t2400 , [ temp3 , temp4 ]
try2 = try2 + 4 : lcdout $fe , $c0 , "Sent....." , DEC3 try1 , "," , DEC3 try2
goto loop
And post a fresh picture if you can
Last edited by skimask; - 24th December 2006 at 08:36.
ok , I'm back, still no changes,
picture up
The two leds there are from a previous program which instead of using lcdout, I was trying to make led blink.
but the picture was takien while your last program was working
Last edited by lerameur; - 24th December 2006 at 13:28.
i tried this program for the reciver. The led blinks, If I added the serin , led would sit on high. There is definately a problem with serin command, It does not work with lcdout or simple led blinking
'RECEIVE PIC
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
'try1 = count of times waiting for data, try2 = count of bytes received
try1 var byte : try2 var byte : temp var word : tempf var word
temp1 var byte : temp2 var byte : temp3 var byte : temp4 var byte
input portb.2 : pause 2500
try1 = 0 : try2 = 0
trisb=%00000000
loop:
lcdout $fe , $c0 , "Waiting.." , DEC3 try1 , "," , DEC3 try2
try1 = try1 + 1 : temp = 0 : tempf = 0
'serin portB.2 , t2400 , [ temp1 , temp2 , temp3 , temp4 ]
Portb.4 =1 : pause 500 : portb.4=0
Portb.3 =1 : pause 500 : portb.3=0
goto loop
End
I also wanted to see if the chip was able to see the data coming in, so i tried this loop, and nothing is happening to the led:
loop:
serin portB.2 , t2400 , [ temp1 , temp2 , temp3 , temp4 ]
if temp1 > 0 then
Portb.4 =1 : pause 500 : portb.4=0
Portb.3 =1 : pause 500 : portb.3=0
endif
goto loop
End
Last edited by lerameur; - 24th December 2006 at 14:08.
Ok now I used your pogram and changed the serin line :
serin portB.2 , t2400 , temp1 -----works
It takes in the value,IT is NOW working. BUT For some odd reason it do not take multiple input..
serin portB.2 , t2400 , [ temp1 , temp2 , temp3 , temp4 ] ------------- do not work
Hi leramuer.
I think you need to store and retrieve those values in an array. I am not experienced enough to have confidence with this statement, but methinks it is so.
Anyone, ring in here with an opinion!
JS
edit:
try this
Temp var byte[4]
Temp[0] = n ' your first temp value
Temp[1] = n1 ' your second value
Temp[2] = n2 ' your third value
Temp[3] = n3 ' your fourth value
serout portB.2 , t2400,[# temp[0],# temp[1], # Temp[2], # Temp[3]]
it displays on my backpack display.
JS
Last edited by Archangel; - 25th December 2006 at 07:56. Reason: add possible solution
Merry Christmas to all
I just tried that , the information is not sending. Maybe I got the code wrong, but it till skipping over the lcdout
k
Bookmarks