Serout problem


Closed Thread
Results 1 to 40 of 95

Thread: Serout problem

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur
    I have two Pic16F88 ( did try a PIC16F628A once to see what would happen, how did you know, I dont think I mentioned that)

    both circuits are running independently, Just the power supply is hooked up in parallel. Two circuits, two breadboards. two are doing the same thing


    k
    Ok, I'm back. I don't think you did specifically mention you had a 16F628A except that it was in one of the headers of one of your files somewhere.

    So, you've got 2 16F88's, one will eventually be a transmitter (TXPIC), one will eventually be a receiver (RXPIC).

    Right now, both PICs right now have 4 LEDS and a push button. When you fire it up, the leds do their little power up check, then when you push the button, the leds light up in sequence about once per second.

    Release the button, the sequence stops until you hit the button again right?

    If that's correct, now we'll connect the 2 PICs, define one as TXPIC and and as RXPIC.
    On the TXPIC side:
    Select a pin for serial output. I suggest RB2.

    -------------------------------------
    Add:
    txout var portb.2
    output txout
    dataout var byte

    near the beginning of your TXPIC program, next to the rest of the variable declarations
    --------------------------------------

    -------------------------------------
    And add:
    dataout = ledcount
    serout txout, n2400, [ dataout ]
    pause 100

    on the line after 'ledcount = ledcount + 1', but before the 1st endif
    ---------------------------------------




    On the RXPIC side:
    Select a pin for serial input. I suggest RB5.

    -------------------------------------
    Add:
    rxin var portb.5
    input rxin
    datain var byte

    near the beginning of your RXPIC program, next to the rest of the variable declarations
    --------------------------------------


    ------------------------------------
    Change your RXPIC code to this (starting at mainloop):

    mainloop:
    serin rxin, n2400, 5000, nodatarx, datain
    'if no data received in 5 seconds, jump to nodatarx

    if datain = 0 then 'all leds off
    led1 = 0 : led2 = 0 : led3 = 0 : led4 = 0
    endif

    if datain = 1 then '1st led on
    led1 = 1 : led2 = 0 : led3 = 0 : led4 = 0
    endif

    if datain = 2 then '2nd led on and so on and so on down the line....
    led1 = 0 : led2 = 1 : led3 = 0 : led4 = 0
    endif

    if datain = 3 then
    led1 = 0 : led2 = 0 : led3 = 1 : led4 = 0
    endif

    if datain = 4 then
    led1 = 0 : led2 = 0 : led3 = 0 : led4 = 1
    endif

    goto mainloop

    nodatarx: 'flash the leds 3 times
    led1 = 0 : led2 = 0 : led3 = 0 : led4 = 0
    led1 = 1 : led2 = 1 : led3 = 1 : led4 = 1
    pause 400
    led1 = 0 : led2 = 0 : led3 = 0 : led4 = 0
    pause 400
    led1 = 1 : led2 = 1 : led3 = 1 : led4 = 1
    pause 400
    led1 = 0 : led2 = 0 : led3 = 0 : led4 = 0
    pause 400
    led1 = 1 : led2 = 1 : led3 = 1 : led4 = 1
    pause 400
    led1 = 0 : led2 = 0 : led3 = 0 : led4 = 0
    goto mainloop

    END
    ----------------------------------------



    Connect the PortB.2 pin on the TXPIC to the PortB.5 pin on the RXPIC, and write/burn the programs.
    This should make the TXPIC and RXPIC act in their respective roles. You push a button on the TXPIC, it sends a code to the RXPIC. Both sets of LEDs on both PICs should match. If you don't send a code for 5 seconds the RXPIC will flash the LEDs 3 times, then turn them all off. The next time you press the button on the TXPIC, the same leds should be on for both the TXPIC and RXPIC.

    Try it out, see what happens....
    JDG

  2. #2
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Ok, I tried it, everything is fine, its working, The four leds flashes if no data from sending chip after 5 seconds, everything like you said.

    ken

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur
    Ok, I tried it, everything is fine, its working, The four leds flashes if no data from sending chip after 5 seconds, everything like you said.

    ken


    GREAT!!! That's great news. I'm at work at the moment. I'll post a bit more in a few hours when I get some spare time.
    JDG

  4. #4
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    thanks alot, I wont be home till late again today so no hurry.
    I just tried putting it through the RF module just to see what would happen, but it was not going through nicely.
    Waiting for your next instruction.

    k

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur
    thanks alot, I wont be home till late again today so no hurry.
    I just tried putting it through the RF module just to see what would happen, but it was not going through nicely.
    Waiting for your next instruction.

    k
    Now go back and read thru this whole thread and see if you can tell me why that data did not go thru the RF modules correctly. The correct answer is in the thread, young grasshopper.

    Same thing. I probably won't get back to this for a few hours yet. But if you're around, we should be able to get it all working within about 4-5 thread posts.
    JDG

  6. #6
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Well a big rule I learn not long ago is to use encoding techniques. and perhaps keep on sending the data a little while longer with serout command.

    k

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur
    Well a big rule I learn not long ago is to use encoding techniques. and perhaps keep on sending the data a little while longer with serout command.

    k

    Ok, so as it stands, you have:
    TXPIC: one button, 4 leds, serial out on PortB.2
    RXPIC: 4 leds, serial in on PortB.5

    All works well, data appears to transfer from TXPIC to RXPIC, LEDs match on both, then go out on RXPIC after 5 seconds without button push on TXPIC....

    If that's all good....Read on...I'll be typing up the next post while you read this one....
    JDG

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. Serout to serial servo
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 12th August 2009, 16:46
  3. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  4. Strange SerOut Problem
    By masosi in forum mel PIC BASIC Pro
    Replies: 39
    Last Post: - 23rd April 2007, 06:06
  5. Replies: 11
    Last Post: - 13th July 2005, 19:26

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