Serin serout problem - Page 3


Closed Thread
Page 3 of 9 FirstFirst 1234567 ... LastLast
Results 81 to 120 of 337
  1. #81
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    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


    Ok, I'm back. In the last program I posted, I had the values hardcoded in the transmitter side, so since they displayed correctly, now try a couple of dummy values hardcoded in the receiver side. Try out these programs and let me know what happens....

    Things I changed since the last programs posted a couple of days ago:

    Removed the hardcoded '444' and '888' on the transmitter side

    Added a hardcoded '444' and '888' on the receiver side.

    On both the transmit and receive side, I split the serout and serin into 4 seperate lines, each sending (or receiving) one byte. I don't know if this will fix the problem or not.

    I also added a couple of lines in there to 'sync' up the transmit and receive sides in the case that the receive side starts receiving in the middle of a transmission (which could happen). Very simple setup - 6 bytes are sent, 1st byte - $aa , 2nd-3rd-tempC, 4th-5th-tempF, 6th byte-$55. 1st and 6th byte should add up to $FF. If it doesn't, it was received in the wrong order is values are thrown out. (actually, the 2 numbers from the transmit side could be any pair, as long as they add up to $ff, the receiver will take it, which could mess up the values at the receiver if the right temperature combination comes along, but we'll stay with this for now)

    If the receive side shows '444' and '888', remove the lines and comments, and try it again. It just might work...

    Of course then again, over the past couple of days, you might've gotten it fixed, which would be a sweet deal overall...

    Added a line to idle the transmit line high between characters. This might fix the whole problem...?(see next post)

    '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
    leader var byte : trailer 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 : leader = 0 : trailer = 0 'clear out old values
    temp1 = 0 : temp2 = 0 : temp3 = 0 : temp4 = 0 'clear out old values
    serin portb.2 , t2400 , [ leader ] 'get leader byte
    serin portb.2 , t2400 , [ temp1 ]:serin portb.2 , t2400 , [ temp2 ] 'get data
    serin portb.2 , t2400 , [ temp3 ]:serin portb.2 , t2400 , [ temp4 ] 'get data
    serin portb.2 , t2400 , [ trailer ] 'get trailer byte

    'remove the line below if 444 and 888 show up on the LCD
    temp1 = 1 : temp2 = 188 : temp3 = 3 : temp4 = 120
    'remove the line above if 444 and 888 show up on the LCD

    if ( leader + trailer ) <> $ff then 'if leader + trailer doesn't add up right...
    lcdout $fe , $c0 , "No Sync..", DEC3 try1 , "," , DEC3 try2
    pause 200 : goto loop 'try again
    endif

    temp.highbyte = temp1 : temp.lowbyte = temp2 'put the received values
    tempf.highbyte = temp3 : tempf.lowbyte = temp4 'where they need to be
    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 33333

    try1 var byte : try2 var byte : output portb.2 : high 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:
    lcdout $fe , $c0 , "Getting.." , DEC3 try1 , "," , DEC3 try2 : try1 = try1 + 1
    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=" , DEC3 tempf , "FT"
    lcdout $fe , $c0 , "Sending.." , DEC3 try1 , "," , DEC3 try2
    high portb.2 : serout portb.2, t2400 , [ $aa ] 'send a leader byte
    temp1 = temp.highbyte : temp2 = temp.lowbyte
    high portb.2 : serout portb.2 , t2400 , [ temp1 ]
    high portb.2 : serout portb.2 , t2400 , [ temp2 ] 'send data
    temp3 = tempf.highbyte : temp4 = tempf.lowbyte
    high portb.2 : serout portb.2 , t2400 , [ temp3 ]
    high portb.2 : serout portb.2 , t2400 , [ temp4 ] 'send data
    high portb.2 : serout portb.2 , t2400 , [ $ff ] 'send a trailer byte
    high portb.2 : try2 = try2 + 4 : lcdout $fe , $c0 , "Sent....." , DEC3 try1 , "," , DEC3 try2
    goto loop
    Last edited by skimask; - 26th December 2006 at 14:17. Reason: increase char_pacing value in transmit section and added lines to idle portb.2 high

  2. #82
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default Serin problems

    Something else I just found...
    http://www.picbasic.co.uk/forum/show...ght=idle+state

    You might have to add a bit of code to manually toggle the pin before/after transmitting...not sure... I'll look into it more tomorrow. This may have been the problem I was having before (long time ago) when I switched over to using the actual PIC hardware serial modules.

  3. #83
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    HI, NO I have not found the problem . I was about to order some pic16f648a, you told it worked with these chips.

    I tried your program , the No sync appears at every increment,
    so guess there is a problem with the trailer or leader bit.

    k

  4. #84
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    HI, NO I have not found the problem . I was about to order some pic16f648a, you told it worked with these chips.

    I tried your program , the No sync appears at every increment,
    so guess there is a problem with the trailer or leader bit.

    k
    I wouldn't order any '648's or '628's, the 'F88 should be just fine.

    What does the display read? Does it show the hardcoded 444 and 888? Did you try removing that? Also, get rid of the pauses in the receiver code, or at least drop them down a bit, cut them in half or so.

    JUST SAW THIS: In the transmit code, the trailer byte should be a $55, not $ff. That'll probably fix it now. The fact that you said it shows 'No Sync' at 'EVERY INCREMENT' is the key thing, it shows that the loop is going thru the SERIN commands now.
    Last edited by skimask; - 26th December 2006 at 19:18. Reason: fixing mistake in the transmitter side

  5. #85
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    The display never showed the 444 or 888.
    I posted a new picture.
    I tried removing the pauses, putting them at half the pause you had them, also changed the trailer byte to $55 ..same effect.
    Last edited by lerameur; - 26th December 2006 at 20:44.

  6. #86
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    The display never showed the 444 or 888.
    I posted a new picture.
    I tried removing the pauses, putting them at half the pause you had them, also changed the trailer byte to $55 ..same effect.
    Ok, let's try the silly simple and build back up... I guess we gotta figure out where this whole thing is failing at. If this don't work......I dunno....


    '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

    temp var word : temp1 var word : input portb.2

    loop:
    serin portb.2 , t2400 , [ temp ]
    lcdout $fe , $80 , DEC3 temp
    temp1 = temp1 + 1
    lcdout $fe , $c0 , DEC5 temp1
    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 33333

    temp var byte : temp1 var word : output portb.2

    loop:
    temp = temp + 1
    serout portb.2 , t2400 , [ temp ]
    lcdout $fe , $80 , DEC3 temp
    temp1 = temp1 + 1
    lcdout $fe , $c0 , DEC5 temp1
    goto loop

  7. #87
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    ok, the sending pic increment both on line 1 and two
    the receiving end displays a constant 535 on the 1st line and 49102 on the second line


    problem still persist
    Last edited by lerameur; - 26th December 2006 at 22:23.

  8. #88
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    ok here it is :

    THIS DO NOT WORK;
    loop:
    serin portb.2 , n2400 , [ temp]
    lcdout $fe , $80 , DEC temp
    pause 200
    goto loop
    End



    THIS WORKS;;
    loop:
    serin portb.2 , n2400 , temp
    lcdout $fe , $80 , DEC temp
    pause 200
    goto loop
    End

    AS soon as I put the square brackt , the display is messed up

  9. #89
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    ok here it is :

    THIS DO NOT WORK;
    loop:
    serin portb.2 , n2400 , [ temp]
    lcdout $fe , $80 , DEC temp
    pause 200
    goto loop
    End



    THIS WORKS;;
    loop:
    serin portb.2 , n2400 , temp
    lcdout $fe , $80 , DEC temp
    pause 200
    goto loop
    End

    AS soon as I put the square brackt , the display is messed up



    You are abso-freekin-lutely right!!!!!!!!!! My fonts have been messed up this whole time on my pdf viewer!!!!!!!! In the PBP manual, it shows what looks like brackets around the 'item', when there really isn't any brackets!!!!!!! AND...when I looked at the project I was saying that worked just fine, it doesn't have brackets either!!!!!!! Freekin''''amazing....I should've caught this days ago!!!!!

    Let's go back, but not as far...
    Working on another post/program that should work 100% all the way this time.

    (damn, I could seriously kick my own ass right now)....
    I'll have it posted here in a few minutes...

  10. #90
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default A program that WILL work (or else I will kick myself square in the arse, twice!)

    SERIN doesn't use brackets!!!!!!
    SEROUT DOES use brackets!!!!!!
    (My installation of Acrobat reader's fonts got screwed up at my end sometime in the past, that's what been messing it up. With the brackets in place, serin has been waiting for qualifiers this whole time, not actual data!)

    '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

    temp var word : tempf var word
    leader var byte : trailer var byte : count var byte
    temp1 var byte : temp2 var byte : temp3 var byte : temp4 var byte
    input portb.2 : pause 1000

    loop:
    lcdout $fe , $c0 , "Waiting......" , DEC3 count
    temp = 0 : tempf = 0
    leader = 0 : trailer = 0 : count = 0
    temp1 = 0 : temp2 = 0 : temp3 = 0 : temp4 = 0
    serin portb.2 , t2400 , leader 'get leader byte
    serin portb.2 , t2400 , temp1
    serin portb.2 , t2400 , temp2
    serin portb.2 , t2400 , temp3
    serin portb.2 , t2400 , temp4
    serin portb.2 , t2400 , count
    serin portb.2 , t2400 , trailer

    if ( leader + trailer ) <> $ff then 'if leader + trailer doesn't add up right...
    lcdout $fe , $c0 , "Out of Sync..", DEC3 count : goto loop
    endif

    temp.highbyte = temp1
    temp.lowbyte = temp2
    tempf.highbyte = temp3
    tempf.lowbyte = temp4
    lcdout $fe , $c0 , "Received....." , DEC3 count
    lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , "F."
    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 33333

    count var byte
    output portb.2 : high 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 1500

    loop:
    lcdout $fe , $c0 , "Getting......" , DEC3 count
    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 count
    lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , "F."
    lcdout $fe , $c0 , "Sending......" , DEC3 count
    serout portb.2, t2400 , [ $aa ] 'send a leader byte
    temp1 = temp.highbyte : temp2 = temp.lowbyte
    serout portb.2 , t2400 , [ temp1 ]
    serout portb.2 , t2400 , [ temp2 ] 'send data
    temp3 = tempf.highbyte : temp4 = tempf.lowbyte
    serout portb.2 , t2400 , [ temp3 ]
    serout portb.2 , t2400 , [ temp4 ] 'send data
    serout portb.2 , t2400 , [ count ] 'send count
    serout portb.2 , t2400 , [ $ff ] 'send a trailer byte
    lcdout $fe , $c0 , "Sent....." , DEC3 try1 , "," , DEC3 try2
    count = count + 1
    goto loop


    And that should do it!!!

  11. #91
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    in the transmit code you have this line:
    lcdout $fe , $c0 , "Sent....." , DEC3 try1 , "," , DEC3 try2

    what is try1 and try2 from ???

    I just tried it,

    even with that line out, it still dont show me the temperature on the receiving end

    I think the word count is a reserved word.
    changed to counter

    The receiver is just showing waiting... and the counter
    Last edited by lerameur; - 27th December 2006 at 11:16.

  12. #92
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    in the transmit code you have this line:
    lcdout $fe , $c0 , "Sent....." , DEC3 try1 , "," , DEC3 try2

    what is try1 and try2 from ???

    I just tried it,

    even with that line out, it still dont show me the temperature on the receiving end

    I think the word count is a reserved word.
    changed to counter

    The receiver is just showing waiting... and the counter
    Yep, forgot to take out the try1 and try2.
    And I thought I had the problem fixed all the way around...
    Got a new picture up?

  13. #93
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Going to try something different. Since you are reading the temperature at the transmit end and it's in C, there's practically no chance it'll go above 255 C, so how about simplifying the problem greatly, and just sending one byte across the serial link. Do the C -> F conversion at the receiver end. One byte sent, no header/leader/trailer/counter bytes needed, no nothing....
    I'll get the new program up in a minute or two...

  14. #94
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default Try this...much easier to deal with...

    'RECEIVE PIC

    'same includes and defines as the other versions

    temp var word : tempf var word : count var byte
    input portb.2 : pause 1000

    loop:
    count = count + 1 : lcdout $fe , $c0 , "Waiting......" , DEC3 count
    serin portb.2 , t2400 , temp
    tempf = temp * 9 : tempf = tempf / 5 : tempf = tempf + 32
    lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , "F."
    lcdout $fe , $c0 , "Received....." , DEC3 count
    goto loop
    End






    'TRANSMIT PIC

    'same includes and defines as the other versions

    count var byte : temp var word : output portb.2 : high portb.2
    input portb.3 : dq var portb.4 : pause 1000

    loop:
    lcdout $fe , $c0 , "Getting......" , DEC3 count
    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 ]
    lcdout $fe , $80 , "Tc=" , DEC3 temp
    lcdout $fe , $c0 , "Sending......" , DEC3 count
    serout portb.2 , t2400 , [ temp.lowbyte ]
    count = count + 1
    goto loop

    If it doesn't work, try putting a 'high portb.2' in front of the serout statement.

  15. #95
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    that works
    Then again it is only one 8 bit sending/receiving, I need four in the serout, but it is a good step.

  16. #96
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    that works
    Then again it is only one 8 bit sending/receiving, I need four in the serout, but it is a good step.
    So it does work, completely, as intended? Temperature is sent over and all that?

    Why do you need 4 bytes to go over the link? You can keep doing the math at the receiving end and like I said, temp probably wouldn't ever get above 255C?


    Oh...I forgot about the wireless link that was supposed to be there in the first place....
    Re-post what you have for code....
    Last edited by skimask; - 27th December 2006 at 14:34. Reason: Forgot...

  17. #97
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    the code I have is the code you have on top a couple of posts ago, I am trying to add multiple items to it though

    'receiving:
    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


    temp var word : temp1 var word : tempf var word : counter var byte
    input portb.2 : pause 1000

    loop:
    counter = counter + 1 : lcdout $fe , $c0 , "Waiting......" , DEC3 counter
    serin portb.2 , t2400 , temp
    serin portb.2 , t2400 , temp1
    tempf = temp * 9 : tempf = tempf / 5 : tempf = tempf + 32
    lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 temp1 , "F."
    lcdout $fe , $c0 , "Received....." , DEC3 counter
    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 33333

    counter var byte : temp var word : output portb.2 : high portb.2
    input portb.3 : dq var portb.4 : pause 1000

    loop:
    lcdout $fe , $c0 , "Getting......" , DEC3 counter
    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 ]
    lcdout $fe , $80 , "Tc=" , DEC3 temp
    lcdout $fe , $c0 , "Sending......" , DEC3 counter
    serout portb.2 , t2400 , [ temp.lowbyte, temp.highbyte ]
    counter = counter + 1
    goto loop

  18. #98
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    [QUOTE=lerameur;30072]the code I have is the code you have on top a couple of posts ago, I am trying to add multiple items to it though

    I'm modifying it a bit (adding the manchester encoding stuff) so you can hook up the wireless modules and try it with one byte. Should be easier to add more data after the wireless it working with byte, then to make sure multiple bytes work without the wireless....that's my thought anyways...

  19. #99
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    you can look at the first post I have manchester encoding there and it works

  20. #100
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    you can look at the first post I have manchester encoding there and it works
    It probably does work, but I threw this together....unless I made some silly mistakes, this should work with (and without) the wireless modules, in fact it should work just fine with the wire still attached. Maybe it wouldn't be a bad idea to test it out that way also...



    'RECEIVE PIC

    'same includes and defines as the other versions

    temp var word : tempf var word : counter var byte
    templo var byte : temphi var byte : input portb.2
    converts var byte[15] : convtemp var byte
    converts[0]=$55 : converts[1]=$56 : converts[2]=$59 : converts[3]=$5a
    converts[4]=$65 : converts[5]=$66 : converts[6]=$69 : converts[7]=$6a
    converts[8]=$95 : converts[9]=$96 : converts[10]=$99 : converts[11]=$9a
    converts[12]=$a5 : converts[13]=$a6 : converts[14]=$a9 : converts[15]=$aa

    pause 1000

    loop:
    counter = counter + 1 : lcdout $fe , $c0 , "Waiting......" , DEC3 counter

    waitfor55:
    serin portb.2 , t2400 , temp : if temp <> $55 then goto waitfor55

    waitforaa:
    serin portb.2 , t2400 , temp : if temp <> $aa then goto waitforaa

    serin portb.2 , t2400 , templo : serin portb.2 , t2400 , temphi

    for convtemp = 0 to 15
    if templo = converts[temp] then temp1 = convtemp
    if temphi = converts[temp] then temp2 = convtemp
    next convtemp

    temp = ( temp2 * 16 ) + temp1
    tempf = temp * 9 : tempf = tempf / 5 : tempf = tempf + 32
    lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , "F."
    lcdout $fe , $c0 , "Received....." , DEC3 count
    goto loop


    'TRANSMIT PIC

    'same includes and defines as the other versions
    'can probably reduce the char_pacing value quite a bit now that it's working

    counter var byte : temp var word : output portb.2 : high portb.2
    input portb.3 : dq var portb.4 : templo var byte : temphi var byte
    converts var byte[15] : convtemp var byte
    converts[0]=$55 : converts[1]=$56 : converts[2]=$59 : converts[3]=$5a
    converts[4]=$65 : converts[5]=$66 : converts[6]=$69 : converts[7]=$6a
    converts[8]=$95 : converts[9]=$96 : converts[10]=$99 : converts[11]=$9a
    converts[12]=$a5 : converts[13]=$a6 : converts[14]=$a9 : converts[15]=$aa
    pause 1000

    loop:
    lcdout $fe , $c0 , "Getting......" , DEC3 count
    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 ]
    lcdout $fe , $80 , "Tc=" , DEC3 temp
    lcdout $fe , $c0 , "Sending......" , DEC3 count

    templo = temp.lowbyte & $f : temphi = temp.lowbyte >> 4
    templo = converts[templo] : temphi = converts[temphi]

    serout portb.2 , t2400 , [ $55 , $55 , $55 , $55 , $aa ]
    serout portb.2 , t2400 , [ templo ] : serout portb.2 , t2400 , [ temphi ]

    counter = counter + 1
    goto loop

  21. #101
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    what are temp1 and temp2 used for in the receiving code ?
    because it is used at the end of the program , but the value is not initialized to anything, , no input,
    Last edited by lerameur; - 27th December 2006 at 16:03.

  22. #102
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    what are temp1 and temp2 used for in the receiving code ?
    Whoops....should be hi and lo instead of 1 and 2

    temp = ( temphi * 16 ) + templo

  23. #103
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    This is one way of encoding I have not seen before,
    you did not like the loop I was doing in the first post ?
    It displays 578C and 872F on the receiver side,
    I will look at the decodin technique, because I do not know if it is encoding error or calculation error.

  24. #104
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    This is one way of encoding I have not seen before,
    you did not like the loop I was doing in the first post ?
    It displays 578C and 872F on the receiver side,
    I will look at the decodin technique, because I do not know if it is encoding error or calculation error.
    Is this with the wireless or with the wires like before? Could be either type of error.... I'll look at it a bit more....

  25. #105
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    still using the wire.

    WHY do you do this :

    templo = temp.lowbyte & $f
    Last edited by lerameur; - 27th December 2006 at 16:33.

  26. #106
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    still using the wire.

    WHY do you do this :

    templo = temp.lowbyte & $f
    That masks off the upper 4 bits ( logical AND, temp.lowbyte AND %00001111 ) and use only the lower 4 bits to convert the nibble value to a byte-wide manchester encoded value....(and with the temphi variable, I shift the upper 4 into the lower 4 and do the same thing with it to get manchester encoded values)...
    And do the same thing in reverse at the other end. Your method that you had when you started might work just fine.

  27. #107
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Ya, I screwed it up again. This gets a bit difficult when you don't run the program immediately to see your errors (which is what you're doing at that end!).

    Another version of the program coming in a couple of minutes (or less)...

  28. #108
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default And yet again...

    'RECEIVE PIC

    'same includes and defines as the other versions

    temp var word : tempf var word : counter var byte : templo var byte : temphi var byte : input portb.2 : converts var byte[15]
    convtemp var byte : converts[0] = $55 : converts[1] = $56 : converts[2] = $59 : converts[3] = $5a : converts[4] = $65
    converts[5] = $66 : converts[6] = $69 : converts[7] = $6a : converts[8] = $95 : converts[9] = $96 : converts[10] = $99
    converts[11] = $9a : converts[12] = $a5 : converts[13] = $a6 : converts[14] = $a9 : converts[15] = $aa
    pause 1000

    loop:
    counter = counter + 1 : lcdout $fe , $c0 , "Waiting......" , DEC3 counter

    waitfor55:
    serin portb.2 , t2400 , temp : if temp <> $55 then goto waitfor55

    waitforaa:
    serin portb.2 , t2400 , temp : if temp <> $aa then goto waitforaa

    serin portb.2 , t2400 , templo : serin portb.2 , t2400 , temphi

    for convtemp = 0 to 15
    if templo = converts[temp] then templo = convtemp
    if temphi = converts[temp] then temphi = convtemp
    next convtemp

    temp = ( temphi << 4 ) + templo : tempf = temp * 9 : tempf = tempf / 5 : tempf = tempf + 32
    lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , "F." : lcdout $fe , $c0 , "Received....." , DEC3 count
    goto loop





    'TRANSMIT PIC

    'same includes and defines as the other versions, EXCEPT --------------
    ----------------------------------------------------------------------------------------
    'change the char_pacing value to 500. If it's a large value (above 1000 or so), the receiver loses it's "training"
    ----------------------------------------------------------------------------------------

    counter var byte : temp var word : output portb.2 : high portb.2 : input portb.3 : dq var portb.4 : templo var byte
    temphi var byte :converts var byte[15] : converts[0]=$55 : converts[1]=$56 : converts[2]=$59 : converts[3]=$5a
    converts[4]=$65 : converts[5]=$66 : converts[6]=$69 : converts[7]=$6a : converts[8]=$95 : converts[9]=$96 : converts[10]=$99
    converts[11]=$9a : converts[12]=$a5 : converts[13]=$a6 : converts[14]=$a9 : converts[15]=$aa : pause 1000

    loop:
    lcdout $fe , $c0 , "Getting......" , DEC3 count : 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 ]
    lcdout $fe , $80 , "Tc=" , DEC3 temp : lcdout $fe , $c0 , "Sending......" , DEC3 count
    templo = temp.lowbyte & $f : temphi = temp.lowbyte >> 4 : templo = converts[templo] : temphi = converts[temphi]
    serout portb.2 , t2400 , [ $55 , $55 , $55 , $55 , $aa , templo , temphi ]
    counter = counter + 1
    goto loop

  29. #109
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    still getting extremely high values at the receiving end:
    578C 872F

  30. #110
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    still getting extremely high values at the receiving end:
    578C 872F
    Good numbers at the transmitter side?

  31. #111
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    yes , the transmitter is good

  32. #112
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    yes , the transmitter is good
    Well, what are the numbers at the TX and RX side?

  33. #113
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    transmitter:
    043

    receiver:
    578 C 892 F

    plus the counters

  34. #114
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    transmitter:
    043

    receiver:
    578 C 892 F

    plus the counters


    Try n2400 instead of t2400.

  35. #115
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Try n2400 instead of t2400.
    Skip that...I forgot we're still on the wired, not the wireless modules. But, worth I try I suppose.

  36. #116
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    no changes,

    ok i will try the wireless

  37. #117
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    no changes,

    ok i will try the wireless
    I meant changing the t2400 to n2400, not switching over to wireless yet. Still have to get the comm's working without the wireless.

  38. #118
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    I meant changing the t2400 to n2400, not switching over to wireless yet. Still have to get the comm's working without the wireless.
    How about this... (getting annoying isn't it? )
    I commented out the encoding/decoding parts. Just sending a split up raw value now....see what happens...


    'RECEIVE PIC

    'same includes and defines as the other versions

    temp var word : tempf var word : counter var byte : templo var byte
    temphi var byte : input portb.2 : converts var byte[15] : convtemp var byte
    converts[0] = $55 : converts[1] = $56 : converts[2] = $59
    converts[3] = $5a : converts[4] = $65 : converts[5] = $66
    converts[6] = $69 : converts[7] = $6a : converts[8] = $95
    converts[9] = $96 : converts[10] = $99 : converts[11] = $9a
    converts[12] = $a5 : converts[13] = $a6 : converts[14] = $a9
    converts[15] = $aa : pause 1000

    loop:
    counter = counter + 1 : lcdout $fe , $c0 , "Waiting......" , DEC3 counter

    waitfor55:
    serin portb.2 , n2400 , temp : if temp <> $55 then goto waitfor55

    waitforaa:
    serin portb.2 , n2400 , temp : if temp <> $aa then goto waitforaa

    serin portb.2 , n2400 , templo : serin portb.2 , n2400 , temphi

    'for convtemp = 0 to 15
    'if templo = converts[temp] then templo = convtemp
    'if temphi = converts[temp] then temphi = convtemp
    'next convtemp

    temp = ( temphi << 4 ) + templo : tempf = temp * 9 : tempf = tempf / 5
    tempf = tempf + 32
    lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , "F."
    lcdout $fe , $c0 , "Received....." , DEC3 count
    goto loop


    'TRANSMIT PIC

    'same includes and defines as the other versions
    '--------------------------------------------------------------------------
    'remove the char_pacing value, with it in there, the RX will lose it's "training"
    '-------------------------------------------------------------------------

    counter var byte : temp var word : output portb.2 : high portb.2
    input portb.3 : dq var portb.4 : templo var byte : temphi var byte
    converts var byte[15] : converts[0] = $55 : converts[1] = $56
    converts[2] = $59 : converts[3] = $5a : converts[4] = $65
    converts[5] = $66 : converts[6] = $69 : converts[7] = $6a
    converts[8] = $95 : converts[9] = $96 : converts[10] = $99
    converts[11] = $9a : converts[12] = $a5 : converts[13] = $a6
    converts[14] = $a9 : converts[15] = $aa : pause 1000

    loop:
    lcdout $fe , $c0 , "Getting......" , DEC3 count : 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 ]
    lcdout $fe , $80 , "Tc=" , DEC3 temp
    lcdout $fe , $c0 , "Sending......" , DEC3 count
    templo = temp.lowbyte & $f : temphi = temp.lowbyte >> 4
    'templo = converts[templo] : temphi = converts[temphi]
    serout portb.2 , n2400 , [ $55 , $55 , $55 , $55 , $aa ]
    serout portb.2 , n2400 , [ templo , temphi ]
    counter = counter + 1
    goto loop

  39. #119
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    well same results with n2400 and t2400

  40. #120
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    well same results with n2400 and t2400
    And you're using the program as listed in post #118?

    Probably going to end up backing up again, so we can move forward again!

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