Another Serial data using Manchester question


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1

    Default

    Thanks SKIMASK, I believe you were referring to the RETURN in this section:
    dout:
    low dgood
    pause 100
    For i=0 TO 7
    IF mydata.0[i]=0 Then
    encoded.0[i*2]=0
    encoded.0[i*2+1]=1
    Else
    encoded.0[i*2]=1
    encoded.0[i*2+1]=0
    EndIF
    Next i
    Return ' I took this out
    serout serpin,N2400,[$55,$55,$55,$55,$55,synch,encoded]
    if keyin = nokey then x2
    goto findkey

    Ive recompiled it, still doesn't work, I check the serial out pin with Oscope and it shows a datastream, Out of curiosity, I have a whole sleeve of the processors so I replaced both but still no luck

  2. #2
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by tazntex View Post
    Thanks SKIMASK, I believe you were referring to the RETURN in this section:
    Yes

    Ive recompiled it, still doesn't work, I check the serial out pin with Oscope and it shows a datastream, Out of curiosity, I have a whole sleeve of the processors so I replaced both but still no luck
    And you HAVE tried this without the RF link? Yes? Without the manchester encoding?

    Code:
    'Serial Transmitter
    @ DEVICE PIC16F628a,XT_OSC
    @ DEVICE pic16F628a, WDT_OFF ' Watchdog Timer
    @ DEVICE pic16F628a, PWRT_ON ' Power-On Timer
    @ DEVICE pic16F628a, MCLR_ON ' Master Clear Options (Internal)
    @ DEVICE pic16F628a, BOD_ON ' Brown-Out Detect
    @ DEVICE pic16F628a, LVP_OFF ' Low-Voltage Programming
    @ DEVICE pic16F628a, CPD_OFF ' Data Memory Code Protect
    @ DEVICE pic16F628a, PROTECT_OFF
    define osc 4  <-Define's won't work unless they're in CAPS (RTFM)
    include "bs2defs.bas"
    CMCON=7 : i var byte : encoded var word : dgood var porta.2 : serpin var porta.3
    nokey con $ff : synch con 254 : keyin var portb : mydata var byte : trisb = $ff : trisa = $17
    ro VAR PORTB.0 : ri VAR PORTB.1 : bkl VAR PORTB.2 : es VAR PORTB.3 : rb VAR PORTB.4
    lb VAR PORTB.5 : bl VAR PORTB.6 : na VAR PORTB.7
    findkey: if rn = 0 then mydata=5 : goto dout
    if lb = 0 then mydata=6 : goto dout
    if ri = 0 then mydata=2 : goto dout
    if ro = 0 then mydata=1 : goto dout
    if es = 0 then mydata=4 : goto dout
    if bl = 0 then mydata=7 : goto dout
    if bkl = 0 then mydata=3 : goto dout
    goto findkey
    dout: dgood=0 : pause 100 : For i=0 TO 7
    IF mydata.0[i] = 0 Then
    encoded.0[i*2]=0 : encoded.0[i*2+1]=1
    Else
    encoded.0[i*2]=1 : encoded.0[i*2+1]=0
    EndIF
    Next i : serout serpin,N2400,[$55,$55,$55,$55,$55,synch,encoded]
    if keyin = nokey then x2
    goto findkey
    x2: dgood=1 : mydata=0 : serout serpin,N2400,[$55,$55,$55,$55,$55,synch,mydata]
    goto findkey
    end
    
    'Serial Receiver
    INCLUDE "bs2defs.bas"
    @ DEVICE PIC16F628a,XT_OSC
    @ DEVICE pic16F628a, WDT_OFF ' Watchdog Timer
    @ DEVICE pic16F628a, PWRT_ON ' Power-On Timer
    @ DEVICE pic16F628a, MCLR_ON ' Master Clear Options (Internal)
    @ DEVICE pic16F628a, BOD_ON ' Brown-Out Detect
    @ DEVICE pic16F628a, LVP_OFF ' Low-Voltage Programming
    @ DEVICE pic16F628a, CPD_OFF ' Data Memory Code Protect
    @ DEVICE pic16F628a, PROTECT_OFF
    DEFINE OSC 4
    mydata var byte : encoded var word : serpin var porta.1 : porta=0 : portb=0 : trisa=2
    trisb=$80 : CMCON=7 : i var byte : PAUSE 50
    loop: gosub loop1
    select case mydata
    case 0
     toggle 0 : pause 250
    case 1
     HIGH 1 : pause 50 : if mydata <> %0101 then low 1
    case 2
     HIGH 2 : pause 50 : if mydata <> %0110 then low 2
    case 3
     HIGH 3 : pause 50 : if mydata <> %0010 then low 3
    case 4
     HIGH 4 : pause 50 : if mydata <> %0001 then low 4
    case 5
     toggle 5 : pause 250
    case 6
     toggle 6 : pause 250
    end select
    goto loop
    loop1: SERIN serpin,N2400,[254],encoded : For i=0 TO 7
    IF encoded.0[i*2]=0 Then
    IF encoded.0[i*2+1]=1 Then mydata.0[i]=0
    Else
    mydata.0[i]=1
    EndIF
    Next i : Return
    End

  3. #3

    Default

    Thanks again for your advice, I had tried it before with direct cable connection when I began tinkering with this and it did work. But sometimes I would get the relays to turn on and off kind of a quick chattering. I have the flyback protection on my relays to help prevent that. Then I notice that after reading other peoples questions about using rf links and having similar problems that Manchester encoding/decoding seemed to resolve this issue. This is why I am trying to experiment with this. Perhaps I may learn from this experience. I am really interested in become proficient with PicBasic Pro, and Bruce has help me alot over the last couple of years. I hope he gets time to publish a book that has clearer examples than the PBP manual has. People like you, Bruce, Melanie and Ioannis are a real asset to this forum. Thanks again for all your help.

  4. #4
    skimask's Avatar
    skimask Guest

    Default

    One other little 'note to self' for this particular program...
    In this case, you're only sending a handful of codes back and forth, not random binary data that has to be coded and decoded 'on-the-fly'.
    So, why not 'hardcode' each of those 'bytes' to their equivalent manchester values?
    0 = 01010101
    1 = 01010110
    and so on.....
    At least that way, you'll take out any chance that the 'manchester routine' is causing the problem.

  5. #5

    Default

    "In this case, you're only sending a handful of codes back and forth, not random binary data that has to be coded and decoded 'on-the-fly'.
    So, why not 'hardcode' each of those 'bytes' to their equivalent manchester values?"

    0 = 01010101
    1 = 01010110

    Would I just send and receive this as a BYTE or Word?

  6. #6
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by tazntex View Post
    0 = 01010101
    1 = 01010110

    Would I just send and receive this as a BYTE or Word?
    Well, since there's only 8 bits, I'd say a BYTE, 'cause there's only 8 bits.
    If there was 16 bits, I'd say a WORD, or maybe 2 bytes...

  7. #7

    Default

    Thanks again Skimask, I have it all working now after using the hardcode you recommended. I never could get the encoder decoder section to work. Everything seem good now, been on it all weekend. I found a couple of errors after rereading the program over and over. Now I have a new question, how would I keep lets say portb.1 high on the receiver as long as I was pressing the button on the transmitter but portb.1 to go low if I release the button?

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Nokia 3310 display text
    By chai98a in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th August 2007, 03:39
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

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