serin2?


Closed Thread
Results 1 to 12 of 12

Thread: serin2?

  1. #1
    Join Date
    May 2006
    Posts
    19

    Default serin2?

    i'm trying to receive some serial data on my pic 16f688 but it doesn't receive anything (sending data works perfectly). i'm want to blink a led on the pic on command.

    I use this code to send the data from my basic stamp 2:

    SEROUT S_out, 396, ["blink"]

    and i use this code to receive on my pic:

    SerIn2 S_in,396,[WAIT("k")]
    gosub blink

    what can it be?

  2. #2
    Join Date
    May 2006
    Posts
    19

    Default

    it seems to be receiving something after al.
    if i use this code:
    main:
    SerIn2 S_in,396,[dat]
    pause 100
    SEROUT s_out, N2400,["1234t", dat]
    goto main

    and i read it out on my BS2 it says dat = 0
    so it is constantly receiving "nothing" but if i use wait("k") then it wil never see the k i send...
    what can it be (it's quite urgent becouse i need this code to be working tomorow)

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    Post the whole code here!

    Be sure you disable ALL analog stuff on this 'unknown' S_Pin

    Internal osc or external?

    Did you try to connect your BS2 to your PC?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    May 2006
    Posts
    19

    Default

    ok here is the whole code:

    on the stamp:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' {$PORT COM1}

    dat VAR Byte
    DO
    SEROUT 10, 396, ["blink"]
    SERIN 10, 396, [WAIT("t"), dat]
    DEBUG "data: ", DEC dat, CR

    PAUSE 1000
    LOOP


    on the pic:


    define OSC 20
    INCLUDE "modedefs.bas"

    S_in var PORTC.0
    S_Out var PORTC.0
    Led var PORTC.3
    dat var byte

    Main:
    SerIn2 S_in,396,[dat]
    gosub blink
    SEROUT s_out, T2400,["1234t", dat]
    pause 50
    goto main

    Blink:
    high led
    pause 10
    low led
    return


    this code only returns me "data: 0" in my debugwindow, if i use the code
    SerIn2 S_in,396,[wait("k")]
    on my pic and remove the SERIN 10, 396, [WAIT("t"), dat] on my stamp it never blinks and it keeps waiting for that "k" the osc is an external 20 mhz crystal
    Last edited by chriroz; - 30th October 2006 at 08:55.

  5. #5
    Join Date
    May 2006
    Posts
    19

    Default

    does anyone know how to fix this? the transmitting does work from stamp to pic but it doesn't from pic to stamp. please help me.

  6. #6
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166

    Default

    chriroz, What is the value of "dat"? I don't ever see it getting set...

    Dave Purola,
    N8NTA

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    Quote Originally Posted by chriroz
    this code only returns me "data: 0" in my debugwindow, if i use the code
    SerIn2 S_in,396,[wait("k")]
    on my pic and remove the SERIN 10, 396, [WAIT("t"), dat] on my stamp it never blinks and it keeps waiting for that "k" the osc is an external 20 mhz crystal
    So you didn't post the whole thing?

    Are you sure you properly set the config fuses for your PIC? HS_OSC?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    May 2006
    Posts
    19

    Unhappy

    OK, THIS IS THE WHOLE CODE:


    on the stamp:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' {$PORT COM1}

    dat VAR Byte
    DO
    SEROUT 10, 396, ["blink"]
    SERIN 10, 396, [WAIT("t"), dat]
    DEBUG "data: ", DEC dat, CR

    PAUSE 1000
    LOOP


    on the pic:


    define OSC 20
    INCLUDE "modedefs.bas"

    S_in var PORTC.0
    S_Out var PORTC.0
    Led var PORTC.3
    dat var byte

    Main:
    SerIn2 S_in,396,[dat]
    gosub blink
    SEROUT s_out, T2400,["1234t", dat]
    pause 50
    goto main

    Blink:
    high led
    pause 10
    low led
    return


    THAT code only returns me "data: 0" in my debug window (witch is already strange.)

    and if i use THIS code (the one i actually need):


    on the stamp:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' {$PORT COM1}

    dat VAR Byte
    DO
    SEROUT 10, 396, ["blink"]
    DEBUG "data: ", DEC dat, CR

    PAUSE 1000
    LOOP


    on the pic:


    define OSC 20
    INCLUDE "modedefs.bas"

    S_in var PORTC.0
    S_Out var PORTC.0
    Led var PORTC.3
    dat var byte

    Main:
    SerIn2 S_in,396,[wait("k")]
    gosub blink
    pause 50
    goto main

    Blink:
    high led
    pause 10
    low led
    return


    than it never blinks and never sees a "k". I really need this problem solved. please post ANYTHING that might help me (i live in european time so i usely have to wait a whole night before i can read your answers and an other day before you read my posts, so post anything you got, i don't have much time left) and my config is HS (in winpic) and define OSC = 20. "dat" is the byte in witch it saves the data received from serin2, isn't it?

    thanks in advance,

    Chris
    Last edited by chriroz; - 1st November 2006 at 07:38.

  9. #9
    Join Date
    May 2006
    Posts
    19

    Default

    I also tried to use an FlowPin and it didn't work. but i found out something strange. after i send my data from my stamp the pin stays high. is that normal? if i give an "low 10" command after it it will get low again

  10. #10
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA.
    Posts
    130

    Lightbulb Maybe?

    It looks to me like you're waiting for the letter "K" to come in from the word "blink". Picbasic will wait until it sees the letter "K", and then the next character is placed into your variable. What is the next character after the "K"? Nothing. Hence you will return the value zero. Try it without the wait, or try something like
    hserin 100,,[str Variable\5\$6b]
    This will take in a string of five characters, or fewer if it sees the hex value 6b, which should be the ascii value for a lower case letter "k" if I read it right. (The print is small on my ascii table, and I forgot my glasses!)

    Hope this helps.

    Jerry.

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    Try to connect your PIC to your PC to see what's happen... Use MCS serial communicator to monitor it.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    Join Date
    May 2006
    Posts
    19

    Default

    in the case where i receive the zero's i don't wait for the "k" (SerIn2 S_in,396,[dat]) I just wait for anything to come in and thats a zero (witch i didn't send!). also tried to send some data AFTER the "k" but it still doesn't get to the blink code...

    Can someone just give me a working code and the right winpic settings to send data from one pic16f688 @ 20MHz to an other through portc.0 on both pics? it should blink a led (@ portc.3) on both pic's one after sending and one after receiving data. so they blink synchrome.

    example:
    pic1: sending data (portc.0)--> blink (portc.3)--> pause --> loop

    pic2: waiting for right data (portc.0)--> receiving data --> blink (portc.3) --> loop

    ok, I've been patient enough but time is running out so:
    [whine]
    I REALY need this code working. I use this code in a huge high-school project (i'm building a local positioning system) and i'm nominated for the "best project of the year" and i have to present my project for 1600 students. even without this code working they say my team will win this competition by far BUT I just want the whole thing working so PLEASE HELP ME. (I have no teachers or anyone i know that have any knowledge about this subject to help me, so that's why i came here)
    [/whine]
    sorry for my Engrish but i'm not a native (i'm dutch)

Similar Threads

  1. GPS $GPRMC to PIC16F684. Need help with SERIN2
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th November 2009, 09:47
  2. Getting SERIN2 to work?
    By BobPigford in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 22nd July 2009, 20:10
  3. SLOW Serin2 and Serout2
    By dragons_fire in forum General
    Replies: 3
    Last Post: - 26th June 2009, 02:38
  4. SERIN2 digit parsing
    By skimask in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th January 2007, 23:15
  5. SEROUT2 and SERIN2 commands
    By bangunprayogi in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th August 2005, 09:03

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