Is it possible to interpret non-standard serial data with PicBasic (sample attached)


Results 1 to 40 of 61

Threaded View

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


    Did you find this post helpful? Yes | No

    Default Re: Is it possible to interpret non-standard serial data with PicBasic (sample attach

    I modified henriks code an tested it with my simulation , works fine
    Code:
    '****************************************************************
    '*  Name    : deMODULATOR.BAS                                   *
    '*  Author  : richard's modified version of henriks             *
    '*  Notice  :  2016                                             *
    '*          : All Rights Reserved                               *
    '*  Date    : 10/10/2016                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : decodes missing pulse encoded data stream A.5     *
    '*          : 16F1825                                           *
    '****************************************************************
      #CONFIG
                 __config        _CONFIG1,    _FOSC_INTOSC & _CP_OFF & _WDTE_ON  &  _PWRTE_ON  &  _MCLRE_ON  & _CLKOUTEN_OFF
                  __config      _CONFIG2, _PLLEN_ON & _LVP_OFF            
    #ENDCONFIG
     
    OSCCON=$70 
    DEFINE OSC 32
    
    
    
    '                       PIC 16F1825
    
    
    
        TRISA     = %111110	 ' Make somepins Input 
        trisc     = %111100  ;Make some pins Input   
        ANSELA=0     
        ANSELC=0
        led var latc.0      ;DEBUG
        led2 var latc.1      ;DEBUG
        demod var porta.5     ;demod in
        X VAR byte
        darta   VAR byte[4] 
        counter var word
        dm_state   VAR byte
        lata.0=1             ;DEBUG
        clear
        led=0
        DEFINE DEBUG_REG PORTA
        DEFINE DEBUG_BIT 0       
        DEFINE DEBUG_BAUD 9600
        DEFINE DEBUG_MODE 0     
        pause 2000
        Debug "Start",13 ,10  
        DEFINE PULSIN_MAX 9000
    
    Code:
    HighTime  VAR WORD
    LowTime   VAR WORD
    
    
    
    WaitForStartBit:
        GOSUB MeasureLow
        
        IF (LowTime < 9500) OR (LowTime > 11000) THEN WaitForStartBit    ' 9.5-10.5ms qualifies
        led2=1
        GOSUB MeasureHigh
        IF (HighTime < 1500) OR (HighTime > 2500) THEN WaitForStartBit    ' 1.5-2.5ms qualifies
        led2=0
        NextLevel:
        For x = 0 to 31
            GOSUB MeasureLow
            IF     LowTime < 1000   then
                darta .0[x] = 0 
            else
                darta .0[x] = 1  
            endif
        NEXT
        led=1
        Debug 13 ,10 ,bin8 darta[3],bin8 darta[2],bin8 darta[1],bin8 darta[0]    ;DEBUG
        Pause 1000
        led=0
        Goto WaitForStartBit
    
    MeasureLow:
      LowTime = 0
      While demod = 1 : WEND         ' Wait for low level
      While demod = 0                ' Measure low level
        LowTime = LowTime + 100       ' Resolution is 100us, change if needed
        PauseUS 92                    ' Tweak to calibrate, depends on actual loop time
      WEND
    RETURN
    
    MeasureHigh:
      HighTime = 0
      While demod = 0 : WEND	  ' Wait for low  
        While demod = 1              ' Measure high level
        HighTime = HighTime + 100       ' Resolution is 100us, change if needed
        PauseUS 92                    ' Tweal to calibrate, depends on actual loop time
      WEND
    RETURN
    Last edited by richard; - 10th October 2016 at 10:27. Reason: d key dodgy
    Warning I'm not a teacher

Similar Threads

  1. Is there an ICSP pinout standard???
    By OldMarty in forum General
    Replies: 12
    Last Post: - 21st September 2016, 12:29
  2. Interpret to Picbasic Code ¿?!!
    By Denner in forum PBP3
    Replies: 3
    Last Post: - 9th June 2015, 18:00
  3. sample code for AT45DB642D in Picbasic Pro
    By itsssyam in forum General
    Replies: 0
    Last Post: - 10th March 2010, 06:01
  4. Max/232 Bootloader problems - Schematic attached...
    By rossfree in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 4th May 2007, 15:54
  5. Replies: 0
    Last Post: - 30th November 2004, 02:18

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