Serin serout problem


Closed Thread
Results 1 to 40 of 337

Hybrid View

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

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

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

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

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

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

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

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

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