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
    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

  2. #2
    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

    Currently I have LCD connected, for debugging purposes, but in final device, I will have no LCD.

  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

    So this is how initial things should work, as I see it:

    1. We sent interrupt on rising edge of PORTC.4
    2. As PORTC.4 gets high, timer is started, and counts to predefined value (width of 1st pulse)
    3. While timer is running, PORTC.4 is still being continuously checked, to determine, whenever it is still high. It should be high while timer is counting, if it gets low, while timer is on, this means, this is not proper pulse, so we should reset and start everything over.
    4. If timer counting ended, and PORTC.4 was high all that time, this means that sync pulse was captured correctly, and we're ready for the next step.

    This appears quite simple in words, but all Greek for me, in code , so far, my practical experience with timers and pwm is light dimming, and playing polyphonic tunes via it

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

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

    Or Timer1 and Interrupt on Change or even better Interrupt on PortB.0 and use of Option_reg.6 to select which edge is expected to arrive and trigger the interrupt.

    Needs a bit of work in the interrupt routine...

    Ioannis

  5. #5
    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

    Indeed, but lack of knowledge....

  6. #6
    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

    Code that works - It differentiates "0" from any other command:

    Code:
    UIDEDA:
    
    if pulsi=0 then
    FOR N=0 TO 300     'main loop duration
    IF PULSI=0 THEN
    A=A+c                                 'count positive edges
    c=0   'stop increasing  1 after first loop
    d=1    'set increase for 0
    ELSE
    B=B+d         'count 0 volt
    d=0     'stop increasing 0 after first loop
    c=1      'set increase for 1
    ENDIF
    NEXT
    IF A<>0 AND B<>0 THEN
    lcdout $FE,2, "A=",#A, "    "
    lcdout $FE,$C0,"B=",#B, "    "
    ENDIF
    if a=7 and b=8 then high natura    'on
    if a=6 and b=7 then low natura   'off
    A=0
    B=0
    endif
    GOTO UIDEDA

  7. #7
    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

    Now I want to ad an array, where, when "1" occurs, value of N variable will be stored, which later can be counted, and position of "1" s and "0" -s detected.

  8. #8
    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

    Going totally crazy, can't figure out what to do and how

  9. #9
    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

    Logically, code should look like this:

    WAIT FOR LOW LEVEL AND MEASURE IT'S DURATION
    IF LOW LEVEL LENGTH=10MS THEN MEASURE HIGH LEVEL DURATION AFTER IT
    IF HIGH LEVEL DURATION WAS 2MS, THEN GO TO NEXT STEP, ELSE, LOOP THIS CYCLE AGAIN
    NEXT LEVEL:
    CONSIDER 600US LOW LEVEL AS 1, AND 2MS LOW LEVEL AS 0, WRITE THEM SEQUENTALY TO 32 BIT ARRAY, UNTIL 32 BITS WRITTEN
    EXTRACT MSB AND LSB FROM ARRAY
    CONVERT TO WORD

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