Serin serout problem


Closed Thread
Page 1 of 9 12345 ... LastLast
Results 1 to 40 of 337
  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default Serin serout problem

    Hello,
    nice to see the site back up.

    I am almost finish my little project now. I have diffculty sending mutliple item on serout and receiving them on another chip using serin. I think its the way i type the command, the program does compile , but do not work.;
    here is the two codes of line:
    Sending Pic:
    serout2 portb.2, n2400, [encoded22.HighBYTE, encoded22.LowBYTE, encoded11.HighBYTE, encoded11.LowBYTE ]

    Receiving Pic:
    serin portB.3, n2400,[ encoded22.HighBYTE, encoded22.LowBYTE, encoded11.HighBYTE, encoded11.LowBYTE]

    after that i want to make the thing wireless. I have been trying to make the qualifier work in the serin command with no luck. I think this is needed because I will need to send some premamble to the receiving chip before the data right ??

    Ken

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    ---------------------------------------------------------------
    serout2 portb.2, n2400, [encoded22.HighBYTE, encoded22.LowBYTE, encoded11.HighBYTE, encoded11.LowBYTE ]
    ---------------------------------------------------------------


    SEROUT, not SEROUT2. Check your PBP manual for the explanation.

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    yes in fact I tried both and it do not work.
    I think my problem might be in the receiving end. when I do an lcd out without the serin command, the LCDout works, as soon I add the serin command, I only see black squares on the LCDout. So I think the serin command is not good.
    BUT if I just put

    serin portB.3, n2400,[ encoded22.HighBYTE, encoded22.LowBYTE, encoded11.HighBYTE, encoded11.LowBYTE]

    lcdout $FE,1
    LCDOUT "datain: ", BIN 5
    lcdout $FE,$C0, "datain2: ", bin encoded22.HighBYTE
    Pause 500

    is there something else I should be putting in for serin ?

    k

  4. #4
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    You might have to provide some more of your code to troubleshoot and maybe a schematic. I believe what Skimask is referring to is SEROUT2 requires mode number instead of a mnemonic such as "n2400".
    Quote Originally Posted by TFM
    Mode is used to specify the baud rate and operating parameters of the
    serial transfer. The low order 13 bits select the baud rate. Bit 13 selects
    parity or no parity. Bit 14 selects inverted or true level. Bit 15 selects
    whether it is driven or open.
    The baud rate bits specify the bit time in microseconds - 20. To find the
    value for a given baud rate, use the equation:
    (1000000 / baud) - 20
    t2400 = 396
    n2400 = 16780
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    By the way , the LCD is there basically to tell me what is goign on .
    anyway , here is the complete program :
    sending:

    ' Picbasic Pro program to read DS1820 1-wire temperature sensor
    ' and display temperature on LCD
    ' FOR SENDING SERIAL
    INCLUDE "modedefs.bas"
    DEFINE OSC 20 'use external 20mhz crystal

    CMCON = 7 : ANSEL = 0 : ADCON1 = 7
    ' Define LCD pins
    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

    TRISB.2 =0
    TRISB.3 =1
    DQ var PortB.4
    temp var word
    '27
    temperature var word
    count_remain var byte
    count_per_c var byte
    counter var byte
    tempc var word
    dataout var word
    dataout2 var word
    datain var word
    array var word
    encoded1 var word
    encoded2 var word
    encoded22 var word
    encoded11 var word


    loop:
    owout DQ,1,[$cc]
    owout DQ,0,[$44]
    Pause 500
    owout DQ,1,[$cc]
    owout DQ,0,[$be]
    owin DQ, 0, [temperature.LOwBYTE, temperature.Highbyte, Skip 4, count_remain, count_per_c]
    '50
    temperature = ((( temperature >> 1) *100)- 25) + (((count_per_c - count_remain) * 100) / count_per_c)
    tempc = (((temperature *9) / 5)+3200)
    dataout = temperature / 100
    dataout2 = temperature

    encoded1 =temperature.LowBYTE
    encoded2 =temperature.HighBYTE

    For counter=0 TO 7
    IF encoded1.0[counter]=0 Then
    encoded11.0[counter*2]=0
    encoded11.0[counter*2+1]=1
    Else
    encoded11.0[counter*2]=1
    encoded11.0[counter*2+1]=0
    EndIF
    Next counter

    For counter=0 TO 7
    IF encoded2.0[counter]=0 Then
    encoded22.0[counter*2]=0
    encoded22.0[counter*2+1]=1
    Else
    encoded22.0[counter*2]=1
    encoded22.0[counter*2+1]=0
    EndIF
    Next counter
    lcdout $FE,1
    LCDOUT BIN temperature , ".", dec (temperature / 10)," ",$DF,"C"
    lcdout $FE,$C0, bin encoded22.HighBYTE , ".", bin encoded2," ",$DF,"F"
    serout portb.2, n2400, [encoded22.HighBYTE, encoded22.LowBYTE, encoded11.HighBYTE, encoded11.LowBYTE ]
    goto loop

    End


    AND RECEIVING:
    ' Picbasic Pro program to read DS1820 1-wire temperature sensor
    ' and display temperature on LCD
    ' FOR Receiving SERIAL
    INCLUDE "modedefs.bas"
    DEFINE OSC 20 'use external 20mhz crystal

    CMCON = 7 : ANSEL = 0 : ADCON1 = 7
    ' Define LCD pins
    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
    '22
    datain2 var word
    datain var word
    dataout var word
    counter var byte
    temperature var word
    encoded1 var word
    encoded2 var word
    encoded11 var word
    encoded22 var word

    pause 500

    loop:
    '36
    serin portB.3, n2400,[ encoded22.HighBYTE, encoded22.LowBYTE, encoded11.HighBYTE, encoded11.LowBYTE]

    lcdout $FE,1
    LCDOUT "datain: ", BIN 5
    lcdout $FE,$C0, "datain2: ", bin encoded22.HighBYTE , ".", dec datain2," ",$DF,"C"
    Pause 500

    For counter=0 TO 7 'decoding
    encoded1.0[counter]=encoded11.0[counter*2]
    encoded2.0[counter]=encoded22.0[counter*2]
    Next counter

    temperature= encoded1 ' putting back together as the original temperature
    For counter=0 TO 7
    temperature.0[counter+8]=encoded2.0[counter+8]
    Next counter

    goto loop

    End

  6. #6
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    If you're not using a Qualifier, I think you need to use Serin2. Maybe you can use it without the qualifier... I don't know.
    Quote Originally Posted by Manual
    SERIN Pin,Mode,{Timeout,Label,}{[Qual...],}{Item...}
    ‘ Wait until the character
    serially on Pin1 and put
    SERIN 1,N2400,[“A”],B0

    ....The list of data items to be received may be preceded by one or more
    qualifiers enclosed within brackets. SERIN must receive these bytes in
    exact order before receiving the data items.
    Quote Originally Posted by Manual
    SERIN2 DataPin{\FlowPin},Mode,{ParityLabel,}{Timeout,Labe l,}[Item...]
    ‘ Wait until the character “A” is received
    serially on Pin1 and put next character into B0
    SERIN2 1,16780,[WAIT(“A”),B0]
    Either way, I'd try to send a qualifier down. Either the Serin format or as noted in the manual with Serin2.
    Last edited by rhino; - 22nd December 2006 at 18:40.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post

    AND RECEIVING:
    .......................................
    pause 500

    lcdout $FE,1 - put this above your main loop, you don't need to 'home' the LCD, you already do that with $FE,$C0.

    loop:
    '36
    serin portB.3, n2400,[ encoded22.HighBYTE, encoded22.LowBYTE, encoded11.HighBYTE, encoded11.LowBYTE]

    LCDOUT "datain: ", BIN 5 ------------- ???? what's this for?

    lcdout $FE,$C0, "datain2: ", bin encoded22.HighBYTE , ".", dec datain2," ",$DF,"C" ---------- where is datain2 getting set at?

    Pause 500

    For counter=0 TO 7 'decoding
    encoded1.0[counter]=encoded11.0[counter*2]
    encoded2.0[counter]=encoded22.0[counter*2]
    Next counter

    temperature= encoded1 ' putting back together as the original temperature
    For counter=0 TO 7
    temperature.0[counter+8]=encoded2.0[counter+8]
    Next counter

    goto loop

    End



    No LCD_RWREG or LCD_RWBIT defines in either transmit or receive sections.

    Add:
    DEFINE LCD_COMMANDUS 2500
    DEFINE LCD_DATAUS 250
    to both sections.

    Increase initial pause to 1000 or higher as needed.

    Where is datain2 getting it's value from?

    You don't do your decoding/etc until after you've displayed it. Change that around.

    Check the listing above for other notes.

  8. #8
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    LCDOUT "datain: ", BIN 5 ------------- ???? what's this for?
    I was just testing my LCDout

    lcdout $FE,$C0, "datain2: ", bin encoded22.HighBYTE , ".", dec datain2," ",$DF,"C" ---------- where is datain2 getting set at?
    Past program , forgot to remove it, was just using the first line for LCDout


    In the receiving chip, nothing is happening, its going in but not recognizing it.
    This is the code I have, nothing is going to the lcd screen. If I remove the SERIN line, then the LCDOUT work, but gives me all 1. (thats normal its not seeing anything)
    How do i output this on the lcd ?
    It seems that i cannot use the command SERIN and LCDOUT in the same program...


    serin portB.2, n2400,[ encoded22.HighBYTE, encoded22.LowBYTE, encoded11.HighBYTE, encoded11.LowBYTE]

    LCDOUT "d: ", BIN encoded22.HighBYTE ,".",bin encoded22.LowBYTE ---------------------not outputting what i want
    lcdout $FE,$C0, "datain2: ", bin encoded22.HighBYTE , ".", bin encoded22.HighBYTE," ",$DF,"C"
    Pause 500
    Last edited by lerameur; - 23rd December 2006 at 06:50.

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    '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_RWREG ----------------DEFINE YOUR RW REGISTER
    DEFINE LCD_RWBIT ----------------DEFINE YOUR RW REGISTER

    trisb.2 = 0 : trisb.3 = 1 : dq var portb.4 : temp var word : tempf var word
    pause 2500

    loop:
    lcdout $fe , $c0 , "Getting..."
    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"
    lcdout $fe , $80 , "Tc=" , DEC temp , "C,Tf=" , DEC tempf , "F.."
    lcdout $fe , $c0 , "Sending..." : serout portb.2 , n2400 , [ temp, tempf ]
    lcdout $fe , $c0 , "Data Sent."
    goto loop
    End


    '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_RWREG ----------------DEFINE YOUR RW REGISTER
    DEFINE LCD_RWBIT ----------------DEFINE YOUR RW REGISTER

    temp var word : tempf var word : pause 2500
    loop:
    lcdout $fe , $c0 , "Waiting..."
    serin portB.3 , n2400 , 1000 , loop , [ temp , tempf ]
    lcdout $fe , $c0 , "Received.." : lcdout $fe , $c0 , "Displaying"
    lcdout $fe , $80 , "Tc=" , DEC temp , "C,Tf=" , DEC tempf , ".."
    lcdout $fe , $c0 , "Displayed."
    goto loop
    End



    Little steps like I told you before...
    Get the basics working. Add in the temperature correction code after you get the basic temperature displayed. Blow on the element, make it change, get it 'in the ballpark'. Forget about the encoding/decoding. If you can't get temp to be displayed as it is without the wireless, how are you going to get it to work with the wireless? Magic? Me thinks not...
    Make your LCD work for you. Notice I added a bunch of lines telling me what the PIC is doing. Use them often!
    And you had your C to F conversion backwards, and there was no way your original program was going to work. You had your decoding happening after you displayed the results. If you're going to send the whole code, send the whole code.
    Post back when this works. If it doesn't work, you've got other problems, hardware.

  10. #10
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    about the LCD_RWREG, I stuck my lcd pin to ground, so it should always be write function.

    I still get the same problem , The lcdout do not display the inpuT from serin. tHE LCD shows on the second line : 'Waiting...'
    It seems to me that the as soon as it sees the serin command it skips all the lcdout afterward, and loops again.

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    about the LCD_RWREG, I stuck my lcd pin to ground, so it should always be write function.

    I still get the same problem , The lcdout do not display the inpuT from serin. tHE LCD shows on the second line : 'Waiting...'
    It seems to me that the as soon as it sees the serin command it skips all the lcdout afterward, and loops again.
    LCD_RWBIT....ok, understood. I'd define it anyways to an unused pin just to keep PBP from thinking otherwise.

    Screwed up a bit overall. You can't send words thru a bytewide serial port!

    Try this instead:


    '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

    trisb.2 = 0 : trisb.3 = 1 : dq var portb.4 : temp var word : tempf var word
    pause 2500

    loop:
    lcdout $fe , $c0 , "Getting..."
    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"
    lcdout $fe , $80 , "Tc=" , DEC temp , "C,Tf=" , DEC tempf , "F.."
    lcdout $fe , $c0 , "Sending..."
    serout portb.2 , n2400 , [ temp.highbyte , temp.lowbyte ]
    serout portb.2 , n2400 , [ tempf.highbyte , tempf.lowbyte ]
    lcdout $fe , $c0 , "Data Sent."
    goto loop
    End


    '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

    temp var word : tempf var word : pause 2500
    loop:
    lcdout $fe , $c0 , "Waiting..."
    serin portB.3 , n2400 , 1000 , loop , [ temp.highbyte , temp.lowbyte , tempf.highbyte , tempf.lowbyte ]
    lcdout $fe , $c0 , "Received.." : lcdout $fe , $c0 , "Displaying"
    lcdout $fe , $80 , "Tc=" , DEC temp , "C,Tf=" , DEC tempf , ".."
    lcdout $fe , $c0 , "Displayed."
    goto loop
    End

  12. #12
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    The same thing is happeneing as before,
    the LCD is just showing 'Waiting ... ' on the receiving unit
    And I can see on the scope a signal coming in on portB3

    ken
    Last edited by lerameur; - 23rd December 2006 at 22:46.

  13. #13
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    The same thing is happeneing as before,
    the LCD is just showing 'Waiting ... ' on the receiving unit

    ken
    Anything showing up on the first line? Something like:
    Tc=100C,Tf=212 or anything similar?

  14. #14
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    the first line of the receiving unit is blank
    the second: waiting ....

    k

  15. #15
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    the first line of the receiving unit is blank
    the second: waiting ....

    k

    What does the transmitter lcd display?

  16. #16
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    TC=46c, Tf=114f
    getting...

  17. #17
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    TC=46c, Tf=114f
    getting...
    Ok, obviously the temp sensor code is working fine, and the receiver code is 'working'.

    Check your wiring again. This should be working just fine. I just built up the same thing (during the last 10 minutes), 2 PIC16F628A's, exact code, simulated the one-wire temp sensor in the transmit section with some dummy values, added a button to change the number when pressed.
    Both transmit and receive sections worked fine.
    Are both sections on the same power and ground lines?

    Use this code. Again, make the LCD work for you....

    '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

    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




    '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.3 , 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
    Last edited by skimask; - 23rd December 2006 at 23:24. Reason: Added code

  18. #18
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    yes they are on the same vdd and ground,
    I just tried seperating them by putting the sedning end on a battery but no diferent.
    Also the receiving, here is only one wire that is going in , the other wires are used for the LCD, obviously, the lcd works. I am putting the scope on the incoming port adn there is a signal in . The signal is sent every 500ms, Maybe that is too slow ?? and the receiving cant see it ..

    ken

  19. #19
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    yes they are on the same vdd and ground,
    I just tried seperating them by putting the sedning end on a battery but no diferent.
    Also the receiving, here is only one wire that is going in , the other wires are used for the LCD, obviously, the lcd works. I am putting the scope on the incoming port adn there is a signal in . The signal is sent every 500ms, Maybe that is too slow ?? and the receiving cant see it ..

    ken



    Which is why:
    serin portB.3 , n2400 , 1000 , loop , [ temp.highbyte , temp.lowbyte , tempf.highbyte , tempf.lowbyte ]

    It sits in a tight loop for 1000 ms waiting for anything to come across the serial lines. If nothing happens for 1000 ms, it jumps back to 'loop', which almost immediately goes back into the waiting loop. It's not going to miss anything.

    Is the try1 counter going up by one about once a second on both ends?

  20. #20
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    try counter , what is that ?
    I just moved the circuit to somewhere else on the breadboard, no changes

    k

  21. #21
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    try counter , what is that ?
    I just moved the circuit to somewhere else on the breadboard, no changes

    k
    3 or 4 posts ago, I changed the code, added a couple of counters...
    making the lcd work for you!

  22. #22
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    aa ok , i see that, my compiler does not recognize the 'dec3' command
    picbasic pro 2.46

  23. #23
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    aa ok , i see that, my compiler does not recognize the 'dec3' command
    picbasic pro 2.46
    I'm running 2.46, using it just fine, no space between dec and 3. Just replace it with DEC and see what happens.

  24. #24
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    ok, working now, Try2 was not initialized

    the sending counter works, but is about incrementing once every .5 seconds
    With temperature showing on the first line
    The second lcd (receiving) nothing on the first line , and the counter is not counting, The counter starts when the wire (input) is disconnected
    but NO Tc anf Tf
    k
    Last edited by lerameur; - 24th December 2006 at 00:51.

  25. #25
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    ok, working now, Try2 was not initialized

    the sending counter works, but is about incrementing once every .5 seconds
    With temperature showing on the first line
    The second lcd (receiving) nothing on the first line , and the counter is not counting, The counter starts when the wire (input) is disconnected
    but NO Tc anf Tf
    k



    Which PIC are you using?
    And while we're at it, try changing the receiving PIC receiving line over to portb.2 and change the references. Who knows...maybe you blew out a pin.

  26. #26
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I have not changed Pic16f88

    I also tried f84a, same thing
    I dont have much in the 6 series, more in the 18,

  27. #27
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    I have not changed Pic16f88

    I also tried f84a, same thing
    I dont have much in the 6 series, more in the 18,



    Have you got PGM pulled low for your programmer?

  28. #28
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    dont know, I am using this programmer:

    http://www.olimex.com/dev/pic-mcp-usb.html

  29. #29
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    dont know, I am using this programmer:

    http://www.olimex.com/dev/pic-mcp-usb.html
    Move the serial input port on the receiver from RB3 to RB2 and change the program as required.

  30. #30
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    nothing, i tried that before, acually I tried all the ports (B), same thing.

    k

  31. #31
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    nothing, i tried that before, acually I tried all the ports (B), same thing.

    k


    Post your receiver code again (since I think we can assume that the transmitter side is working fine)

    and try switching to t2400 on the receiving side for the heck of it. If it doesn't work, change it back.
    Last edited by skimask; - 24th December 2006 at 02:02.

  32. #32
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I took a picture of both circuit
    receiving on the left
    http://www3.sympatico.ca/lerameur/

    its the exacte code you gave me :

    '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.3 , 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
    Last edited by lerameur; - 24th December 2006 at 02:14.

  33. #33
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    I took a picture of both circuit
    receiving on the left
    http://www3.sympatico.ca/lerameur/

    its the exacte code you gave me :

    '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.3 , 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
    The picture at the site is messed up. Scale it down or something.
    Have you tried switching the pins/code over to RB2?
    Have you tried changing the receiver to t2400?

    Change
    serin portB.3 , n2400 , 1000 , loop , [ temp.highbyte , temp.lowbyte , tempf.highbyte , tempf.lowbyte ]

    to
    serin portB.2 , n2400 , 100 , loop , [ temp.highbyte , temp.lowbyte , tempf.highbyte , tempf.lowbyte ]

    Now you should see try1 increment fast, like 10 times per second.
    Wait on it for a couple of minutes. If it only increases about once a minute or so, something is wrong with your oscillator, it's running on the internal backup failsafe oscillator.

    I thought you said DEC3 doesn't work?
    Last edited by skimask; - 24th December 2006 at 02:33.

  34. #34
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    the site is ok now,

    the counter goes up ten times as fast

    I change to t2400 and n 2400 , no change,

    bth crytals are clocking 20 Mhz,

    also I have been swaping pic, i am using 2 pic16f88, so they can be both ****ed up, and I have a third one, with no change,
    I just tried a brand new pic88, no changes, i swapped the crytals between the two circuits too!

    I thought you said DEC3 doesn't work? yes I thought, it was because try2 was not initialized, and it happend only where dec3 was, . The other program was compiling
    Last edited by lerameur; - 24th December 2006 at 02:41.

  35. #35
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    the site is ok now,

    the counter goes up ten times as fast

    I change to t2400 and n 2400 , no change,

    bth crytals are clocking 20 Mhz,

    also I have been swaping pic, i am using 2 pic16f88, so they can be both ****ed up, and I have a third one, with no change,
    I just tried a brand new pic88, no changes, i swapped the crytals between the two circuits too!

    I thought you said DEC3 doesn't work? yes I thought, it was because try2 was not initialized, and it happend only where dec3 was, . The other program was compiling
    What is that big yellow wire for? The one that looks like it's going over the top of the picture? Either that or zoom back out just a little bit more for your picture....

  36. #36
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    that is the data, serout going to the input pin of the other circuit

    i also tried an f648a, nothing on the lcd
    k
    Last edited by lerameur; - 24th December 2006 at 03:11.

  37. #37
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I just flip the circuit around, I mean take the receiving chip put it in the sending circuit and flip the other chip around, Then I just plug in the input wire to the new receiving chip.
    Same output as before. The receiving LCD just sits there

  38. #38
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    that is the data, serout going to the input pin of the other circuit


    i also tried an f648a, nothing on the lcd
    k
    Ok, I'm back...the relatives showed up for a bit...had to deal with them...

    Your programs:
    Transmit side - output is on RB2, correct?
    Receive side - input on RB3, correct?

    And the big yellow wire is the data wire right?
    Last edited by skimask; - 24th December 2006 at 04:15.

  39. #39
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    yes that sit,
    Its hard to belive it works on your end.

    thats ok , i was watching mad tv...

  40. #40
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    yes that sit,
    Its hard to belive it works on your end.
    Well, do me a favor....
    Take that big yellow wire, follow it to the PIC on the right.
    Consult your datasheet, and tell me what pin it goes to.

    Then take that same big fat yellow wire, follow it to the PIC on the left, consult your datasheet, tell me what pin that goes to....and fix it!

Closed Thread
Page 1 of 9 12345 ... LastLast

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. PIC16f877 code crosses boundary @800h
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th April 2009, 22:03
  3. serout and serin problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th April 2006, 19:44
  4. Replies: 11
    Last Post: - 13th July 2005, 19:26
  5. SerIn and SerOut
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 21st July 2004, 15:54

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts