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


Closed Thread
Results 1 to 40 of 61

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

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

    Code:
     TRISA = %11111111       ' Set PORTA to all input
       TRISC = %00000000	    ' Sets all PortB pins to output
       ADCON1 = %10000101      ' Set PORTA analog and right justify result
       ADCON0=%00000000
       low portc.4
       low portc.5
    Is there something strange here?
    Last edited by pedja089; - 8th July 2016 at 22:42.

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

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

    Easy! It’s giving you a wider pulse duration at the start to qualify the incoming data.
    From there you only need to sample 32 times at the correct interval.
    So look for that, then read it in with a 32 step loop.

    Code:
    bitcode var byte[32]
    count var byte
    pulseduration var byte
    
    pulseduration = time from peak to peak
    
    for count = 0 to 31
    bitcode[count] = inputpin
    pause pulseduration
    next count
    Of course, better ways than reading into a 32 byte array, but quickest.

  3. #3
    Join Date
    Feb 2013
    Posts
    1,154


    Did you find this post helpful? Yes | No

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

    You're omitting an important thing - MCU has own clock, wastes different time on program execution, but incoming data is sent async, so it can't wait for MCU to become ready, so my guess, how it all should work, is as follows:

    As pulse arrives, we start recording it as fast as possible, after pulse sequence finished, we just count numbers of 1's and 0's recorded, and based on that, decide what to do with decoded data. Considering total sequence duration and speed, I guess, external sram or eeprom might be needed?

  4. #4
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

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

    That depends. You didn’t display the duration.
    If it’s several uS duration pulses, the falling edge of the first longer pulse is the place to mark time,
    then waste half a pulse duration before the for-next loop. If you can roughly synchronise from the first pulse (which is what it’s for),
    it takes time for the two clocks to drift apart.

    If you were to sample bits as fast as you can, you’d still want to do that from the falling edge of the first pulse.

  5. #5
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

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

    Does your hardware have the LCD that is in your code?

  6. #6
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

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

    That should get the 32 bits straight into a four byte array.

    Code:
    '
    main:
    @ clrwdt
    '
    if portc.4 = 1 then	‘ count initial pulse duration
    leadcnt = leadcnt + 1
    else
    leadcnt = 0
    endif
    '
    '
    if leadcnt > expectedduration then' qualify initial pulse duration
    burst:			' sync to initial pulse falling edge
    if portc.4 = 1 then
    @ clrwdt
    goto burst
    endif
    '
    for rotcnta = 0 to 3	' shift data into 32 bit buffer
    databuffer = 0
    for rotcntb = 0 to 7	‘ shift data to each byte
    databuffer.bit0 = portc.4
    databuffer = databuffer << 1
    dataarray[rotcnta] = databuffer
    pauseus peaktopeakduration
    next rotcntb
    next rotcnta
    ‘
    leadcnt = 0
    endif
    '
    goto main
    ‘
    Last edited by Art; - 9th July 2016 at 16:34.

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,689


    Did you find this post helpful? Yes | No

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

    surely a candidate for timer1 and gate control
    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