Serin serout problem


Closed Thread
Results 1 to 40 of 337

Hybrid View

  1. #1
    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.

  2. #2
    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.

  3. #3
    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.

  4. #4
    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.

  5. #5
    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

  6. #6
    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.

  7. #7
    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?

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 : 0

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