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


+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 40 of 61
  1. #1
    Join Date
    Feb 2013
    Posts
    838

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

    I have some remotely managed studio strobe, it has keyboard, and when pressing numerical keys, the following sequences being transmitted on single wire, as shown on the picture. What protocol is this, and can I somehow interpret it, using picbasic pro?



    Width of wide pulse is 1.9msec, and width of narrow pulse is 642usec.

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

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

    It looks like some kind of binary coding judging by the number entered and the output stream. Why not ask the manufacture for the protocol?
    Dave Purola,
    N8NTA
    EN82fn

  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

    hi dave,

    it reminds me of a sort of binary encoding...
    0= no missing pulse 0000
    1= 1 missing pulse in the "ones" position 0001
    2= 1 missing pulse in the "twos" position 0010
    3= ones missing and twos missing 0011
    4= 1 missing pulse in the fours position 0100
    5= ones and fours missing 1001

    it would help to see all the way up to 9
    do you also need to decode other letter/function key/enter/backspace etc. etc. characters??

    I don't recognize the protocol off hand but then I am no protocol expert.

    perhaps some sort of digital logic analyzer that has a good interpreter behind it would help.
    something like this... https://www.saleae.com
    I have never used the saleae but I know it comes highly regarded for it's price.

    good luck
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  4. #4
    Join Date
    Feb 2013
    Posts
    838


    Did you find this post helpful? Yes | No

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

    Yes is goes up that way, I can record it up to 9, but you are correct, it looks like plain BCD code, but the rendering of "0" and "1" with pulses, looks weird for me. I have saelae logic analyzer, but it can't detect these pulses at all, I've used scope to record them.

    In fact, I want very simple thing - say, set variable ENABLE=0, when "zero" is transmitted, and ENABLE=1, when any other digit is being sent. I'm not looking for character decoding or whatsoever.

  5. #5
    Join Date
    Feb 2013
    Posts
    838


    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 suggested, that this is PPM (Pulse Position Modulation), used in some IR/RF remotes and telemetric control equipment. Datasheet of Holtek HT6222 shows quite similar, but not exact diagram of signal.

  6. #6
    Join Date
    Sep 2009
    Posts
    721


    Did you find this post helpful? Yes | No

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

    If you need only ENABLE use count to count pulses.
    Try something like this:

    Code:
    COUNT Pin, Period, Var
    If Var<xxx then
        enable=1
    else 
        enable=0
    endif

  7. #7
    Join Date
    Feb 2013
    Posts
    838


    Did you find this post helpful? Yes | No

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

    But pulses are of different width in series, will it work?

  8. #8
    Join Date
    Feb 2013
    Posts
    838


    Did you find this post helpful? Yes | No

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

    Just checked, it works, but not as it should - even on same sequence, it always reads different values.

    Code:
    taki:
    COUNT PORTC.4, 70, LABEL
    if label=0 then
    goto taki
    endif
    LCDOUT $FE,$c0, DEC(LABEL), "          "
    PAUSE 5
    GOTO TAKI

  9. #9
    Join Date
    Sep 2009
    Posts
    721


    Did you find this post helpful? Yes | No

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

    try this:
    taki:
    While PORTC.4=0
    WEND
    COUNT PORTC.4, 70, LABEL
    LCDOUT $FE,$c0, DEC5 LABEL
    PAUSE 5
    GOTO TAKI

  10. #10
    Join Date
    Feb 2013
    Posts
    838


    Did you find this post helpful? Yes | No

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

    The actual issue is different I guess.

    The system used is IDPPM - Differential Pulse Position Modulation.
    Now I changed algorithm, and it detects pulses, there are 34 pulses, and it does it properly. But quantity of pulses is always 34, only pauses between them change, so COUNT is not proper implementation I guess.

    P.S. above code displays only 00000

  11. #11
    Join Date
    Sep 2009
    Posts
    721


    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

  12. #12
    Join Date
    Feb 2013
    Posts
    838


    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.

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

  14. #14
    Join Date
    Sep 2009
    Posts
    721


    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.

  15. #15
    Join Date
    Feb 2013
    Posts
    838


    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?

  16. #16


    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.

  17. #17
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,410


    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.

  18. #18
    Join Date
    Feb 2013
    Posts
    838


    Did you find this post helpful? Yes | No

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

    Here is the complete code:

    Code:
    Include "modedefs.bas"  ' Include serial modes
       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
       
    X   VAR PORTC.4 
    
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 1
    DEFINE LCD_BITS 4 
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 1500
    DEFINE LCD_DATAUS 44
    DEFINE OSC 4
    
    lcdout "test 2"
    PAUSE 500
    
    LABEL VAR WORD
    DROEBITI VAR WORD
    
    
    taki:
    if portc.4=0 then
    COUNT PORTC.4, 60, LABEL
    endif
    if label=0 then
    goto taki
    endif
    LCDOUT $FE,$c0, DEC(LABEL), "          "
    GOTO TAKI
    I have source of signal (chip with name grinded off, but holtek logo is recognizable), which is connected directly to PORTC.4. Also, scope is connected to same pin.

    As long as I introduce the statement "if portc.4=0 then"
    If it is "=0" then pin is sunk to ground, so no pulses can be detected, and nothing can be seen on scope. If it is "=1", then pin gets driven high, and no pulses can be seen with scope or read too.

    Chip is 16F870.

  19. #19
    Join Date
    Sep 2009
    Posts
    721


    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 21:42.

  20. #20
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    983


    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.

  21. #21
    Join Date
    Feb 2013
    Posts
    838


    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?

  22. #22
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    983


    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.

  23. #23
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    983


    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?

  24. #24
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    983


    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 15:34.

  25. #25
    Join Date
    May 2013
    Location
    australia
    Posts
    2,085


    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 , prose like a gushing embroilment is not my style

  26. #26
    Join Date
    Feb 2013
    Posts
    838


    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.

  27. #27
    Join Date
    Feb 2013
    Posts
    838


    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

  28. #28
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,230


    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

  29. #29
    Join Date
    Feb 2013
    Posts
    838


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

  30. #30
    Join Date
    Feb 2013
    Posts
    838


    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

  31. #31
    Join Date
    Feb 2013
    Posts
    838


    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.

  32. #32
    Join Date
    Feb 2013
    Posts
    838


    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

  33. #33
    Join Date
    Feb 2013
    Posts
    838


    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

  34. #34
    Join Date
    Feb 2013
    Posts
    838


    Did you find this post helpful? Yes | No

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

    Or, more "programmer" approach. Assuming "A" is the input pin:

    START COUNTING
    A=0, B=0
    WHILE A=1, B=B+1
    WHILE A=0, C=C+1
    IF B=500 AND C=100 THEN CONTINUE, ELSE, START OVER
    B=0 C=0
    FOR N=1 TO 32
    WHILE A=1, B=B+1
    WHILE A=0, C=C+1
    IF B=50 AND C=50 THEN CONTENTS[N]=1
    IF B=50 AND C=150 THEN CONTENTS[N]=0
    A=0, B=0
    NEXT N


    Name:  HUMANBASIC.jpg
Views: 446
Size:  31.0 KB

  35. #35
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,410


    Did you find this post helpful? Yes | No

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

    Here's one idea:
    Code:
    HighTime  VAR WORD
    LowTime   VAR WORD
    BitArray  VAR WORD [2]
    LSB       VAR BitArray.LowWord
    MSB       VAR BitArrat.HighWord
    
    WaitForStartBit:
      GOSUB MeasureLow
      IF (LowTime < 9500) OR (LowTime > 10500) THEN WaitForStartBit    ' 9.5-10.5ms qualifies
      GOSUB MeasureHigh
      IF (HighTime < 1500) OR (HighTime > 2500) THEN WaitForStartBit    ' 1.5-2.5ms qualifies
     
    NextLevel:
    For i = 0 to 31
      GOSUB MeasureLow
      IF (LowTime > 400) AND (LowTime < 800) THEN BitArray.0[i] = 1     ' 500-700us qualifies as 1
      IF (LowTime > 1700) AND (LowTime < 2320) THEN BitArray.0[i] = 0   ' 1800-2200us qualifies as 0
    NEXT
    LCDOUT $FE,$01, "HighWord", DEC MSB
    LCDOUT $FE,$C0, "LowWord", DEC LCB
    
    Pause 1000
    Goto WaitForStartBit
    
    MeasureLow:
      LowTime = 0
      While Signal = 1 : WEND         ' Wait for low level
      While Signal = 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
      WhileSignal = 0 : WEND	  ' Wait for low  
        While Signal = 1              ' Measure high level
        HighTime = HighTime + 1       ' Resolution is 100us, change if needed
        PauseUS 92                    ' Tweal to calibrate, depends on actual loop time
      WEND
    RETURN
    I can't compile this let alone test it but it serves to show the genereal idea of a software only solution.

  36. #36
    Join Date
    Feb 2013
    Posts
    838


    Did you find this post helpful? Yes | No

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

    Thanks, will give it a try tomorrow.

    My oscilloscope can record in .csv format, is it possible in some emulator to "play back" this recording, and feed it to virtual chip? So I can test and debug without using original hardware, which generates these pulses.

  37. #37
    Join Date
    May 2013
    Location
    australia
    Posts
    2,085


    Did you find this post helpful? Yes | No

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

    the waveform is simple to simulate like this is you have a chip with a dsp module.
    note the timings are estimated since the curious one's info is lacking most of the meaningful detail

    Code:
    '****************************************************************
    '*  Name    : MODULATOR.BAS                                     *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2016 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 5/29/2016                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                        *
    '*          : 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     = %111111    ' Make all pins Input 
    trisc     = %101111  ;Make all pins Input   
    ANSELA=0     
    ANSELC=0
    MDSRC=    %00000000
    MDCARH   =%11000100
    MDCARL   =%00000000
    X VAR byte
    darta   VAR byte[4] 
    TIMER1     VAR WORD EXT
    clear
    modout var latc.4
    darta.0[15]=1 
    hpwm 1,128,1600
    MDCON.0 = 0
    modout =0
    Main_Loop:
    modout=1
    pauseus 8000
    modout =0
    while tmr2 :wend
    MDCON=    %11000000
    for x = 0 to 31
    while tmr2 :wend
    MDCON.0 = !  darta.0[x]
    next  
    modout=1
    MDCON=    0
    pauseus 600
    modout = 0
    PAUSE 200 
    goto Main_Loop
    end
    Last edited by richard; - 7th October 2016 at 04:50.
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  38. #38
    Join Date
    May 2013
    Location
    australia
    Posts
    2,085


    Did you find this post helpful? Yes | No

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

    this works better the first one did no work for sequential 1's

    Code:
    '****************************************************************
    '*  Name    : MODULATOR.BAS                                     *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2016 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 5/29/2016                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                        *
    '*          : 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     = %111111    ' Make all pins Input 
    trisc     = %101111  ;Make all pins Input   
    ANSELA=0     
    ANSELC=0
    MDSRC=    %00000000
    MDCARH   =%11000100
    MDCARL   =%00000000
    X VAR byte
    darta   VAR byte[4] 
    TIMER1     VAR WORD EXT
    clear
    modout var latc.4
    darta.0[14]=1 
    darta.0[15]=1  
    hpwm 1,128,1600
    MDCON.0 = 0
    modout =0
    Main_Loop:
    modout=1
    pauseus 8000
    modout =0
    while tmr2 :wend
    MDCON=    %11010001
    for x = 0 to 31
    while tmr2 :wend
      
    if  darta.0[x]  then
    MDCON.0 = 0
    while tmr2 :wend
    pauseus 6
    while tmr2 :wend
    pauseus 6
    MDCON.0 = 1
    while tmr2 :wend
    pauseus 6
    else
    MDCON.0 = 1
    endif
    next  
    modout=1
    MDCON=    0
    pauseus 600
    modout = 0
    PAUSE 200 
    goto Main_Loop
    end
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  39. #39
    Join Date
    May 2013
    Location
    australia
    Posts
    2,085


    Did you find this post helpful? Yes | No

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

    the output
    Attached Images Attached Images  
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  40. #40
    Join Date
    Feb 2013
    Posts
    838


    Did you find this post helpful? Yes | No

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

    Wow! Such an input.

    Here are signal details. Actual signal is high and goes low, on my last picture, I've inverted it just for ease of viewing and analyzing.

    On the picture below, I've specified all timings as required.
    Name:  logi-cal.jpg
Views: 440
Size:  33.6 KB

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts