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


Results 1 to 40 of 61

Threaded View

  1. #28
    Join Date
    May 2013
    Location
    australia
    Posts
    2,691


    Did you find this post helpful? Yes | No

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

    for comparison I came up with this , oddly it uses mode code space

    Code:
    '****************************************************************
    '*  Name    : deMODULATOR.BAS                                   *
    '*  Author  : richard                                           *
    '*  Notice  : Copyright (c) 2016                                *
    '*          : All Rights Reserved                               *
    '*  Date    : 5/29/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
    
    main:
        select case dm_state
            case 0
                PULSIN demod, 0, counter
                if counter > 7800  then
                    dm_state=1
                    x=0
                endif
            case 1
                pir1.1=0 
                tmr2=0
                t2con=7
                while demod : wend
                if   pir1.1 | (tmr2 < 220)   then
                   dm_state=0
                else
                    dm_state=2
                    tmr2=0
                endif
            case 2
                while !demod : wend
                t2con=0
                if   pir1.1 then 
                 dm_state=0
                 led=1 
                endif 
                if tmr2 < 150    then 
                    darta.0[x]=0
                else
                    darta.0[x]=1
                endif
                tmr2=0
                x=x+1
                if x >31 then 
                    dm_state=3
                else
                    while demod : wend
                    t2con=7    
                endif
            case 3
                led2=1     ;DEBUG
            '    Debug 13 ,10 ,hex2 darta[3] ,hex2 darta[2],hex2 darta[1],hex2 darta[0]    ;DEBUG
                Debug 13 ,10 ,bin8 darta[3],bin8 darta[2],bin8 darta[1],bin8 darta[0]    ;DEBUG
                pause 200
                led2=0             ;DEBUG
                dm_state=0
        end select
    
    goto main
    Last edited by richard; - 10th October 2016 at 11:38. Reason: left a line out
    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, 13:29
  2. Interpret to Picbasic Code ¿?!!
    By Denner in forum PBP3
    Replies: 3
    Last Post: - 9th June 2015, 19:00
  3. sample code for AT45DB642D in Picbasic Pro
    By itsssyam in forum General
    Replies: 0
    Last Post: - 10th March 2010, 07:01
  4. Max/232 Bootloader problems - Schematic attached...
    By rossfree in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 4th May 2007, 16:54
  5. Replies: 0
    Last Post: - 30th November 2004, 03: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