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
    737


    Did you find this post helpful? Yes | No

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

    I was thinking that 1 is represented with missing pulse.
    You can try something like this
    Code:
    DEFINE PULSIN_MAX 65535 ' Limit wait-for-pulse and maximum-pulse count
    While PORTC.4=0 'wait for rising edge of start pulse
    WEND
    FOR I=0 TO 33
    PULSIN PORTC.4,0,W3
    IF W3>XXX THEN GOTO GotData
    NEXT I

  2. #2
    Join Date
    Feb 2013
    Posts
    1,079


    Did you find this post helpful? Yes | No

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

    A side note, a statement like

    IF PORTC.4=1 THEN

    actually sets PORTC.4 high.

    Is this bug or feature?

    I've added 1 transistor signal inverter, but no help. Also, your code does not work.

    OK, I will give up with this idea.

  3. #3
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

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

    This, to me, is the classic problem of how to tell (program) your micro controller to recognize and interpret the pattern.
    The human brain combined with an eyeball can recognize it... now you just need to figure out how to translate that into code.

    I would start by watching for the start pulse, which is longer than the other pulses. Then keep track of the width of the following pulses (or the width of the "low" part. Then watch for one or more extended "low" pulses.

    Since you only need to differentiate between 0 and any other number/key press, then just watch for an extended "low" in a given time period after the extended "high" start pulse. If in the given time period you do not get any extended "low" pulses then the digit is "0" other wise if you get an extended "low" pulse then the keypress was non-zero.

    Since the quantity of pulses in each character is always 34 then you should be able to just set up a counter to increment whenever the pulse is low and stop incrementing when the pulse goes back high. Then if the counter has incremented above a certain threshold then that particular "low" pulse was a "wide" one and indicates a non zero digit. (I hope that makes sense)

    I believe it is easily do-able. you just need to distill it down to how to detect the extended low pulse that indicates a non-zero digit pressed.

    that is how I would attack the challenge.
    Last edited by Heckler; - 8th July 2016 at 15:13.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  4. #4
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

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

    Code for that is in post #11 except it waits for transition from low to high to start measure 34 low intervals.

  5. #5
    Join Date
    Feb 2013
    Posts
    1,079


    Did you find this post helpful? Yes | No

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

    Yes, I know how to implement detection logically, I have no issues with algorithm, but I can't implement it in hardware, also, I can't understand, why statement
    IF PORTC.4=1

    or

    IF PORTC.4=0

    makes corresponding pin high or low?

  6. #6
    Join Date
    Aug 2011
    Posts
    415


    Did you find this post helpful? Yes | No

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

    IF PORTC.4=1
    or
    IF PORTC.4=0

    makes corresponding pin high or low?
    I highly doubt that. I don't know how you're testing it, but if that's the case things are seriously broken.

    You likely have some other issue.

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,523


    Did you find this post helpful? Yes | No

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

    The IF statement per se should not and I'm pretty sure does not twiddle the pin but if what you you're doing is somehing like...
    Code:
    If PortC.4 = 0 THEN
       PortC.1 = 1
    ENDIF
    ...and there happens to be analog functions on the pins which you haven't disabled then the actual state of PortC.4 isn't read correctly and you're getting into the classic RMW issue where the "invalid" state of PortC.4 is being written back to PortC.4 when the write operation to PortC.1 occurs but without seeing the rest of the code it's hard to say for sure.

    /Henrik.

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