+ Reply to Thread
Results 1 to 23 of 23
  1. #1
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    80

    Default Newbie Manchester Coding question

    So, I have a temperature sensor that reports in Manchester code. I need to decode it. Looking through the various examples on here leaves me confused about how to tackle this. Most of the code examples do bit conditioning/math to decode with no reliance on timing, but they all appear to rely on the assumption they're also providing the encoding process.

    eg. http://www.picbasic.co.uk/forum/showthread.php?t=198


    There's one example that decodes a 'foreign' device but that notably relies on timing as a central part of the process.

    eg. http://www.picbasic.co.uk/forum/showthread.php?t=10768

    I was under the impression that to successfully decode my device, I also need to rely on timing as there are short and long pulses of data?

    Thanks,

    Troy

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,914

    Default Re: Newbie Manchester Coding question

    Usually there should be a preamble of time p in a known state, say low and then data pulses in the manchester encoding.

    Also the preamble could be a train of specific pulses, most often 50% square and then data pulses in the manchester encoding.

    Manchester encoding, since it is pulses of variable width, is based on timing also.

    So the short answer is yes. You need to measure time, then if within specs, keep the data bits and then try to decode them. Else reject the data as noise or wrong spec pulses and start over.

    Not an easy task especially if the pulses are fast (micro seconds). You may need asm routines to be quick enough and Interrupts might be one way.

    Ioannis

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,196

    Default Re: Newbie Manchester Coding question

    After sending a number of pulses to the transmitter to condition the receiver data slicer you should send a high pulse of a specific length to use as a start of frame. After this pulse has completed (end of start of frame) then send the Manchester data bits and after the correct number of bits are received (2 per data bit), process the data. It is a standard practice to include a CRC of some type to validate the data stream.
    Dave Purola,
    N8NTA
    EN82fn

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,914

    Default Re: Newbie Manchester Coding question

    Dave, he has already the sensor that outputs data in manchester encoding but has not said, yet, how the data are sent. Maybe RF or cable?

    Ioannis

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,196

    Default Re: Newbie Manchester Coding question

    Ioannis, I use the LINX TXM-433-LR transmitter and the LINX TXM-433-LR-S receiver to send digital data (2 ports) and temperature data from my green house to the main house. I also use another transmitter for a MOLE detector in my front yard. The method has been used for ASK tire and remote keyless entry systems for vehicles for years. I have written numerous software for my former employer about 10 years ago to decode and encode ASK and FSK transmissions from the products we built for the automotive industry.
    Last edited by Dave; - 17th July 2019 at 18:43.
    Dave Purola,
    N8NTA
    EN82fn

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,914

    Default Re: Newbie Manchester Coding question

    I am sure you know very well what you are doing (I am doing the same thing also).

    But Troy has not given more details for his project.

    Ioannis

  7. #7
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    80

    Default Re: Newbie Manchester Coding question

    Apologies, I was beginning to think nobody was responding so it's been couple of days since I've checked.

    They're old temperature sensors I picked up cheap and I was hoping to utilise for a specific application that suites them perfectly, but it's starting to look too difficult to interface. In fact, the only meaningful info I can find on them was a report a Russian fellow put together (attached conversion to English). No RF, just a short connection directly to a PIC. Well, that was the intention.

    Thanks for the responses Ioannis & Dave - I 99% expected that timing would be essential and that's probably a showstopper for me.

    Regards,

    Temperature ICe.pdf

    Troy

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Newbie Manchester Coding question

    Looks straight forward, esp if you use a chip with gate control and can set a timer to count in 1uS increments

    what did you have in mind ?
    This is more entertaining than Free to Air TV

  9. #9
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    80

    Default Re: Newbie Manchester Coding question

    Quote Originally Posted by richard View Post
    Looks straight forward, esp if you use a chip with gate control and can set a timer to count in 1uS increments

    what did you have in mind ?
    Richard,
    in terms of processors or algorithms or code? I have about 10 or so different flavours of 8 bit PICs sitting here (preference would be the smaller packaged varieties). Code: I was considering adapting the linked example in the OP (second link) to suit the timing for this?

    Regards,

    Troy

  10. #10
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Newbie Manchester Coding question

    you need something with timer gate control that can run @32 or 64 mhz

    eg 12f1822,12f1840,16f1825,18f25k22 ........

    i put this in the simulator and it seems to work, the data sheet is very vague re transmission , i assume its lsb first
    not sure about space between bytes, wtf is a 1/2 stop bit , parity a mystery

    used this hdl script to simulate the sensor in vsm , my code will tolerate a half or full stop bit with no gap between bytes

    you probably need a logic analyser or a digital cro to verify my assumptions

    Code:
    // SERIAL DATA GENERATOR
    
    // Define data to be output
    DATA 1154
    DATA  1500m
    DATA REPEAT
    
    
    
    
    
    
    FLOAT BITTIME=0.000125
    
    
    // Declare working variables
    
    
    INT i,j,d
    TIME td
    
    
    // Top level
    OUT = 1
    SLEEP FOR 5m
    
    
    LOOP:
    READ d,td
    
    
    GOSUB OUTSTRING
    SLEEP FOR td
    GOTO LOOP
    
    
    // Output an ASCIIZ string in S
    OUTSTRING:
    
    
    
    
    // Start bit
    OUT = 0
    SLEEP FOR BITTIME
    OUT = 1
    SLEEP FOR BITTIME
    // Data bits
    FOR j=0 TO 16
    OUT = 0
     if d & (1 << j)>0  
     SLEEP FOR BITTIME/2
     OUT = 1
     SLEEP FOR BITTIME/2
     SLEEP FOR BITTIME
    ELSE
     SLEEP FOR BITTIME 
     SLEEP FOR BITTIME/2
     OUT = 1
     SLEEP FOR BITTIME/2
    ENDIF
    
    
    if j = 7  
     OUT = 0//parity=0
     SLEEP FOR BITTIME 
     SLEEP FOR BITTIME/2
     OUT = 1
     SLEEP FOR BITTIME/2
    //stop
     OUT = 1
     SLEEP FOR BITTIME
     OUT = 0
     SLEEP FOR BITTIME
    // Start bit
     OUT = 0
     SLEEP FOR BITTIME
     OUT = 1
     SLEEP FOR BITTIME
    ENDIF
    NEXT j
     OUT = 0//parity=0
     SLEEP FOR BITTIME 
     SLEEP FOR BITTIME/2
     OUT = 1
     SLEEP FOR BITTIME/2
    //stop
     OUT = 1
     SLEEP FOR BITTIME
    RETURN
    pic code to retrieve raw data as a word var traw and print it to serial debug,

    Code:
    #CONFIG ; 12LF1840               __config _CONFIG1, _FOSC_INTOSC & _MCLRE_ON & _CP_OFF & _CPD_OFF & _WDTE_ON & _PWRTE_ON    
    
    
        __config _CONFIG2, _PLLEN_OFF & _LVP_OFF   
    #ENDCONFIG
    
    
    
    
    '    ****12LF1840 PIC*****
    '           RA0      debug 9600
    '                RA1     led
    '              RA2     led2
    ' MCLR       RA3     
    '              RA4     zac
    
    
    
    
    
    
    
    
        Clear                       ' Reset all variables.
    
    
      
       
        DEFINE DEBUG_REG PORTA      ' Debug pin port 
        DEFINE DEBUG_BIT 0          ' Debug pin.
        DEFINE DEBUG_BAUD 9600      ' Debug baud rate.
        DEFINE DEBUG_MODE 1         ' Debug mode: 0 = True, 1 = Inverted
    
    
    
    
        DEFINE  OSC 32              ' Adjust to suit design.
    
    
        Ansela = 0                  ' all dig
       
        OSCCON  = 110000         ' Internal 8MHz osc,   x4 PLL.
        
        T1GCON=$80
        WHILE !OSCSTAT.3            ' Wait for stable Osc...
        WEND
        zac var porta.4
        TRISA = 1000            
        
    
    
    
    
    latA = 0                     
     Pause 500                     
     bc var byte
     traw var word
     led var lata.1
     led2 var lata.2
    debug "ready"
    
    
    loopy:   
        tmr1h=0
        tmr1l=0
        traw=0
        while zac :wend
        t1con=$31
        while !zac :wend
        t1con=$30    
        if tmr1l<123 then loopy   ;start bit too short
        if tmr1l>127 then loopy   ;start bit too long
        gosub readbyte
        while zac :wend     'ignore parity and stop
        while !zac :wend     'ignore parity and stop
    '    led2=1 
        while zac :wend     'start
        while !zac :wend     'start
       
        
         gosub readbyte
    '     led2=0
         debug "start " ,#traw
        
        pause 500
         
    
    
        Goto loopy                          
    
    
    readbyte:
        bc=8
        tmr1h=0        
        while bc
            traw=traw>>1 
            bc=bc-1       
            tmr1l=0
            while zac :wend
            t1con=$31
            while !zac :wend
            t1con=$30 
            if tmr1l<100 then traw = traw|32768
        wend 
    return
    Attached Images Attached Images  
    Last edited by richard; - 19th July 2019 at 14:45.
    This is more entertaining than Free to Air TV

  11. #11
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    80

    Default Re: Newbie Manchester Coding question

    Thanks again Richard,
    About to head away for the weekend and intend to have a reasonable crack at this when I get back. I plugged your code into a 12F1840 and received the following output (I've formatted it to the 00 byte as the start??):

    00 46 51 DA 17 BF 23 35 3B 11 8D
    00 46 51 DA 17 BF 13 15 3B 11 8D
    00 46 51 DA 17 BF 23 35 3B 11 8D
    00 46 51 DA 17 BF 33 15 1B 31 8D
    00 46 51 DA 17 BF 23 25 3B 11 8D
    00 46 51 DA 17 BF 23 35 1B 91 8D
    00 46 51 DA 17 BF 13 15 3B 11 8D
    00 46 51 DA 17 BF 33 15 3B 31 8D
    00 46 51 DA 17 BF 33 15 3B 11 8D
    00 46 51 DA 17 BF 13 15 3B 11 8D
    00 46 51 DA 17 BF 23 35 1B 31 8D
    00 46 51 DA 17 BF 23 35 1B 91 8D
    00 46 51 DA 17 BF 23 35 1B 91 8D
    00 46 51 DA 17 BF 23 35 1B 91 8D
    00 46 51 DA 17 BF 33 15 3B 11 8D
    00 46 51 DA 17 BF 13 15 3B 11 8D
    00 46 51 DA 17 BF 23 35 1B 91 8D
    00 46 51 DA 17 BF 33 15 1B 31 8D
    00 46 51 DA 17 BF 33 15 3B 11 8D
    00 46 51 DA 17 BF 33 15 3B 11 8D
    00 46 51 DA 17 BF 13 15 3B 11 8D
    00 46 51 DA 17 BF 23 25 3B 11 8D

    It's currently 14-15 deg C here at the moment and one of the datasheets says I should be getting 0x200 @0degC and 0x2FF @25degC...so dunno. I'm not totally convinced about the correctness of the debug output of the 12F1840s so I'll play around with that too. I do have a digital oscilloscope (70mhz) so I can try and catch some traces to compare.

    Yeah, totally agree on the 1/2 stop bit(s). No idea...

    Thanks again, Troy

  12. #12
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Newbie Manchester Coding question

    found this web https://weekly-geekly.github.io/arti...506/index.html
    that has a pic of the data stream for val 792 [27.3 deg]
    so i was wrong the data is msb first ,high byte first
    hdl script
    Code:
    // SERIAL DATA GENERATOR
    
    // Define data to be output
    DATA 792
    DATA  1500m
    DATA REPEAT
    
    
    
    FLOAT BITTIME=0.000125
    
    // Declare working variables
    
    INT i,j,d
    TIME td
    
    // Top level
    OUT = 1
    SLEEP FOR 5m
    
    LOOP:
    READ d,td
    
    GOSUB OUTSTRING
    SLEEP FOR td
    GOTO LOOP
    
    // Output an ASCIIZ string in S
    OUTSTRING:
    
    
    // Start bit
    OUT = 0
    SLEEP FOR BITTIME
    OUT = 1
    SLEEP FOR BITTIME
    // Data bits
    FOR j=0 TO 16
    
    if j = 8 
    OUT=0 
     SLEEP FOR BITTIME/2
     OUT = 1
     SLEEP FOR BITTIME/2
     SLEEP FOR BITTIME
    //stop
     OUT = 1
     SLEEP FOR BITTIME
     //OUT = 0
     //SLEEP FOR BITTIME
    // Start bit
     OUT = 0
     SLEEP FOR BITTIME
     OUT = 1
     SLEEP FOR BITTIME
    ENDIF
    
    
    
    OUT = 0
     if d & (1 <<(15- j))>0  
     SLEEP FOR BITTIME/2
     OUT = 1
     SLEEP FOR BITTIME/2
     SLEEP FOR BITTIME
    ELSE
     SLEEP FOR BITTIME 
     SLEEP FOR BITTIME/2
     OUT = 1
     SLEEP FOR BITTIME/2
    ENDIF
    
    
    
    
    NEXT j
     SLEEP FOR BITTIME/2
     OUT = 1
     SLEEP FOR BITTIME/2
     SLEEP FOR BITTIME
    //stop
     OUT = 1
     SLEEP FOR BITTIME
    RETURN
    pbp with two methods to decode sampled or timed, both work with Russian sample

    Code:
    '*********************************************************************************
    '*  Name    : 12LF1840 Serin2 Test.pbp                  *** NON Working ***      *
    '*  Author  : WJ Sherwood                                                        *
    '*  Date    : 14Jul19                                                            *
    '*  Device  : 12LF1840                                                           *
    '*          :                                                                    *
    '*  Notes   : This program for testing serial menu system code                   *
    '*          : LatA.x in place of PortA.x no difference, LF & F versions same.    *
    '*          :                                                                    *
    '*********************************************************************************
    '
    '===================================================================================================
    '        CONFIGURE DEVICE
    '===================================================================================================
    #CONFIG ; 12LF1840           
        __config _CONFIG1, _FOSC_INTOSC & _MCLRE_ON & _CP_OFF & _CPD_OFF & _WDTE_OFF & _PWRTE_ON    ; WDT off for test.
    ;    __config _CONFIG2, _PLLEN_ON & _LVP_OFF    ; PLL always on regardless of OSCON.7
        __config _CONFIG2, _PLLEN_OFF & _LVP_OFF    ; PLL determined by OSCON.7 if disabled in config.
    #ENDCONFIG
     ;data stream simulated from what shown here
     ;https://weekly-geekly.github.io/articles/330506/index.html
    '    ****12LF1840 PIC*****
    '           RA0      debug 9600
    '                RA1     led
    '              RA2     led2
    ' MCLR       RA3     
    '              RA4     zac
    
    
    
    
        Clear                       ' Reset all variables.
       
        DEFINE DEBUG_REG PORTA      ' Debug pin port 
        DEFINE DEBUG_BIT 0          ' Debug pin.
        DEFINE DEBUG_BAUD 9600      ' Debug baud rate.
        DEFINE DEBUG_MODE 1         ' Debug mode: 0 = True, 1 = Inverted
    
        DEFINE  OSC 32              ' Adjust to suit design.
       
        OSCCON  = %11110000         ' Internal 8MHz osc,   x4 PLL.
        Ansela = 0                  ' all dig 
        T1GCON=$80
        WHILE !OSCSTAT.3            ' Wait for stable Osc...
        WEND
        zac var porta.4
        TRISA = %111000            
        bc var byte
        traw var word
        t var word
        led var lata.1
        led2 var lata.2
    
        latA = 0                     
        Pause 500                     
        
        debug "ready"
    
    loopy:   
        tmr1h=0
        tmr1l=0
        traw=0
        while zac :wend
        t1con=$31
        while !zac :wend
        t1con=$30    
        if tmr1l<123 then loopy   ;start bit too short
        if tmr1l>127 then loopy   ;start bit too long
        gosub readbyte  ;or readbyte2
        while zac :wend     'ignore parity and stop
        while !zac :wend     'ignore parity and stop
    '    led2=1
        tmr1h=0
        tmr1l=0
        while zac :wend
        t1con=$31
        while !zac :wend
        t1con=$30    
        if tmr1l<123 then loopy   ;start bit too short
        if tmr1l>127 then loopy   ;start bit too long    
        gosub readbyte   ;or readbyte2
    '    led2=0    
        t = (traw*/250)-500
        debug "start " ,#traw,",",#t/10,".",#t//10,13,10
        pause 500
    Goto loopy      
    
                                 
    
    readbyte:     ;TIMING method
        bc=8
        tmr1h=0        
        while bc
            traw=traw<<1 
            bc=bc-1       
            tmr1l=0
            t1con=$31
            while zac :wend
            led=1
            while !zac :wend
            t1con=$30
            led=0 
            if tmr1l<120 then traw = traw+1
        wend 
    return
    
    readbyte2:     ;SAMPLING method
        bc=8
        while bc
            while zac :wend
            pauseus 90 
            led=1 
            traw=traw<<1 
            traw=traw+zac 
            bc=bc-1       
            led=0    
            while !zac :wend 
        wend 
    return
    Attached Images Attached Images    
    Last edited by richard; - 19th July 2019 at 23:14.
    This is more entertaining than Free to Air TV

  13. #13
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Newbie Manchester Coding question

    ps .
    its akin to manchester code like oil is to water, ie not even close. its 25% 75% [or there about] pulse width encoded with 50/50% start bit and some sort of stop bit with parity bit as ? can't find that at all.bit timing specs nah.
    has got to been one of the worst data sheets i have encountered

    ZACwire single-wire protocol is a protocol. bits
    Encoding therein is performed like the Manchester
    code. Since the clock information embedded in the
    transmitted signal, it allows the protocol to be
    insensitive to the rate of exchange between two
    endpoints.

    ....

    In the initial state signal is high.
    When the transfer starts, it generates a start bit,
    followed by 8 data bits (MSB first, younger-last). The
    package ends with a parity bit. TSic provides
    temperature data with 11-bit resolution. These data
    can not be formed into a single package. Therefore,
    the transfer of temperature data from TSic consists
    of two packages (Fig. 2). The first package contains
    3 bits of temperature information, and secondremaining
    eight. There is one bit of the high level
    (stop bits) between the end of the first packet and
    the start of the second packet. coding bits is as
    follows (Fig. 3). The start bit is always greater than
    or equal to 50% of the period duration bits (125
    microseconds at a nominal transmission frequency
    of 8 kHz). Logic level "1" is fixed under the condition
    that the pulse width being in a logic "1" during one
    period is greater than or equal to 75% of the
    duration of this period. Accordingly, logical "0"
    fiksiruetsya
    at a pulse duration of greater than or equal to
    25% of the period duration. The duration of the stop
    bit is always equal to half the duration of the bit
    period. It has a high level and is always in the
    package between bytes.

    Last edited by richard; - 19th July 2019 at 23:46.
    This is more entertaining than Free to Air TV

  14. #14
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,196

    Default Re: Newbie Manchester Coding question

    Here is a bit of code I wrote to test a TSIC506 temperature sensorsome time ago Mfr.'d by ZMD.
    Attached Files Attached Files
    Dave Purola,
    N8NTA
    EN82fn

  15. #15
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Newbie Manchester Coding question

    Since i'm playing around with the simulator i stuck dave's code in for a look. first thing i noticed is that i made the simulated bit time twice as long as it should be

    all three version "agree" with the decoded raw data at the proper bitrate now
    in hdl script FLOAT BITTIME=0.0000625//HALFBIT

    Code:
    #CONFIG ; 12LF1840           
        __config _CONFIG1, _FOSC_INTOSC & _MCLRE_ON & _CP_OFF & _CPD_OFF & _WDTE_OFF & _PWRTE_ON    ; WDT off for test.
    ;    __config _CONFIG2, _PLLEN_ON & _LVP_OFF    ; PLL always on regardless of OSCON.7
        __config _CONFIG2, _PLLEN_OFF & _LVP_OFF    ; PLL determined by OSCON.7 if disabled in config.
    #ENDCONFIG
     ;data stream simulated from what shown here
     ;https://weekly-geekly.github.io/articles/330506/index.html
    '    ****12LF1840 PIC*****
    '           RA0      debug 9600
    '                RA1     led
    '              RA2     led2
    ' MCLR       RA3     
    '              RA4     zac
    
    
    
    
        Clear                       ' Reset all variables.
       
        DEFINE DEBUG_REG PORTA      ' Debug pin port 
        DEFINE DEBUG_BIT 0          ' Debug pin.
        DEFINE DEBUG_BAUD 9600      ' Debug baud rate.
        DEFINE DEBUG_MODE 1         ' Debug mode: 0 = True, 1 = Inverted
    
        DEFINE  OSC 32              ' Adjust to suit design.
       
        OSCCON  = %11110000         ' Internal 8MHz osc,   x4 PLL.
        Ansela = 0                  ' all dig 
        T1GCON=$80   ;@32mhz  timer counts in uS  for ease of use gated by zac pin
        WHILE !OSCSTAT.3            ' Wait for stable Osc...
        WEND
        zac var porta.4
        TRISA = %111000            
        bc var byte
        traw var word
        t var word
        led var lata.1
        led2 var lata.2
    
        latA = 0                     
        Pause 500                     
        
        debug "ready"
    
    loopy:   
        tmr1h=0
        tmr1l=0
        traw=0
        while zac :wend
        t1con=$31   ;@32mhz  timer counts in uS  for ease of use 
        while !zac :wend
        t1con=$30    
        if tmr1l<60 then loopy   ;start bit too short  
        if tmr1l>65 then loopy   ;start bit too long
        gosub readbyte2
        while zac :wend     'ignore parity and stop
        while !zac :wend     'ignore parity and stop
    '    led2=1 
        tmr1h=0
        tmr1l=0
        while zac :wend
        t1con=$31
        while !zac :wend
        t1con=$30    
        if tmr1l<60 then loopy   ;start bit too short
        if tmr1l>65 then loopy   ;start bit too long
        gosub readbyte2
    '    led2=0
        
        t = (traw*/250)-500
        debug "start " ,#traw,",",#t/10,".",#t//10,13,10
        pause 500
    Goto loopy      
    
                                 
    
    readbyte:     ;TIMING
        bc=8
        tmr1h=0        
        while bc
            traw=traw<<1 
            bc=bc-1       
            tmr1l=0
            t1con=$31
            while zac :wend
            led=1
            while !zac :wend
            t1con=$30
            led=0 
            if tmr1l<60 then traw = traw+1
        wend 
    return
    
    readbyte2:     ;SAMPLING
        bc=8
        while bc
            while zac :wend
            pauseus 45 ;     probably should be 1/2 bit time
            led=1 
            traw=traw<<1 
            traw=traw+zac 
            bc=bc-1       
            led=0    
            while !zac :wend 
        wend 
    return
    This is more entertaining than Free to Air TV

  16. #16
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    80

    Default Re: Newbie Manchester Coding question

    Back... [and total exhausted]

    Thanks sooo sooo much Richard and Dave (particularly Richard). I just ran Richard's code and as expected I got complete and utter nonsense - I have no luck in receiving any PBP software serial data from the 12F1840s, but after shifting the output to a hserout, I get:

    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 688,17.1
    start 691,17.4
    start 715,19.8
    start 718,20.1
    start 718,20.1
    start 717,20.0
    start 716,19.9
    start 715,19.8
    start 714,19.7
    start 713,19.6
    start 711,19.4
    start 710,19.3
    start 709,19.2
    start 708,19.1
    start 707,19.0
    start 706,18.9
    start 706,18.9
    start 705,18.8
    start 704,18.7
    start 704,18.7
    start 703,18.6
    start 703,18.6
    start 702,18.5
    start 702,18.5
    start 701,18.4
    start 701,18.4
    start 700,18.3
    start 700,18.3
    start 700,18.3
    start 699,18.2
    start 699,18.2
    start 697,18.0
    start 696,17.9
    start 696,17.9
    start 695,17.8
    start 695,17.8
    start 695,17.8
    start 694,17.7
    start 694,17.7

    The rise towards the end is me blowing onto the PIC in an attempt to warm it up a bit and the response was instant The temperature checks out too!

    BINGO - I think I owe someone some beers

    You guys are freck'n legends! I still don't know how you can do that (write that code) without having the data stream to test. There's no way I could ever get that right!

    Thanks sooo much again!

    Troy

  17. #17
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Newbie Manchester Coding question

    I just ran Richard's code and as expected I got complete and utter nonsense
    the DEBUG output is inverted logic to suit the pickit 2 serial input, your setup might req true logic
    try
    DEFINE DEBUG_MODE 0 ' Debug mode: 0 = True, 1 = Inverted

    I still don't know how you can do that (write that code) without having the data stream to test. There's no way I could ever get that right!
    me too , i was always skeptical about proteus so i am testing a few ideas
    to see if i can get some value from it. your project looked like a good test.
    if you don't have a device its possible to simulate some things with a script
    and it works yeh!
    This is more entertaining than Free to Air TV

  18. #18
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    80

    Default Re: Newbie Manchester Coding question

    the DEBUG output is inverted logic to suit the pickit 2 serial input, your setup might req true logic
    try
    DEFINE DEBUG_MODE 0 ' Debug mode: 0 = True, 1 = Inverted
    Duh, yup, that was it [slapping forehead].

    Cheers,

    Troy

  19. #19
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    80

    Default Re: Newbie Manchester Coding question

    Richard,
    Curiosity question: so I've essentially replaced the 500ms delay in the loop with a hserin complete with waitstr to basically only report the temperature reading on command.
    What I'm finding is that after a short while (few minutes or n received commands) the hserin will stop functioning ie. it will continually loop back to the timeout label (loopy) whether a command is sent or not; your code still functions perfectly post this event.
    I can stop it from happening by clearing the continuous receive enable bit (RCSTA.4) and setting it again within the loop, but I was wondering if you had any idea of what was causing that to occur?

    Regards,

    Troy

  20. #20
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Newbie Manchester Coding question

    I can stop it from happening by clearing the continuous receive enable bit (RCSTA.4) and setting it again within the loop, but I was wondering if you had any idea of what was causing that to occur?
    its one of the limitations of async comms that needs to be managed.
    listening at irregular times for signals that occur at random intervals can lead to all sorts of issues.
    noise or a misstimed start condition will cause timeout or buffer overrun errors


    simple solution
    DEFINE HSER_CLROERR 1

    better way is to listen constantly using isr , use a start message symbol and an end message symbol.
    isr manages reception and errors and sets flag when message complete
    This is more entertaining than Free to Air TV

  21. #21
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    80

    Default Re: Newbie Manchester Coding question

    Thanks again Richard!

  22. #22
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    80

    Default Re: Newbie Manchester Coding question

    Richard - 1 more: your code's configuration disables the WDT with the comment that it's been disabled for testing. Can you see any problem with me reactivating it for use with that code?

    thanks,

    Troy

  23. #23
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Newbie Manchester Coding question

    the wdt was for another project , you can leave it on or off unless u use
    DEFINE NO_CLRWDT 1
    where wdt must be off or else ....
    This is more entertaining than Free to Air TV

Similar Threads

  1. Manchester coding/decoding Code help
    By financecatalyst in forum Code Examples
    Replies: 0
    Last Post: - 25th August 2009, 19:05
  2. Manchester Coding / Decodeing for RF Modules
    By charudatt in forum Code Examples
    Replies: 23
    Last Post: - 31st January 2009, 10:51
  3. Replies: 8
    Last Post: - 22nd July 2008, 20:31
  4. Manchester coding question
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 5th May 2007, 17:35
  5. Manchester coding
    By micro in forum General
    Replies: 1
    Last Post: - 13th January 2006, 03:40

Members who have read this thread : 19

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