Menu

Sersend Pulse Length

Help
BEAR
2011-12-19
2013-05-30
  • BEAR

    BEAR - 2011-12-19

    The following code sends out the pulse I want, except I would like to have the high pulse longer than the low pulse.   How can I change the pulse bit length in GCGB.

    ;Chip Settings
    #chip 12F629,4

    ;Defines (Constants)
    #define SendAHigh Set GPIO.0 ON
    #define SendALow Set GPIO.0 OFF

    ;Variables
    Dim Pulse As byte

    Pulse = b'10101101'
    Dir GPIO.0 Out
    InitSer 1, r2400, 1+WaitForStart, 8, 1, None, Normal
    Do Forever
    Wait 1 10us
    SerSend 1, Pulse
    Wait 1 ms
    Loop

    Thanks for any help.

    Bear

     
  • Bert

    Bert - 2011-12-19

    Serial communications commands always send high and low bits with equal time, or else there is a risk of bit errors.  If you want high and low bits with different times, drop the SerSend idea and use "Bit banging".  Since 2400 b/s gives a 417 uS bit time, let's say high should be 480 uS and low should be 350 uS:

    ...
    Set GPIO.0 ON
    Wait 480 uS
    Set GPIO.0 OFF
    Wait 350 uS
    Set GPIO.0 ON
    Wait 480 uS
    Set GPIO.0 OFF
    Wait 350 uS
    Set GPIO.0 ON
    Wait 960 uS            'the double 1
    Set GPIO.0 OFF
    Wait 350 uS
    Set GPIO.0 ON
    Wait 480 uS
    

    Add the start bit (OFF I think) before the first ON, and stop bit (ON I think) at the end if required.

    -Bert

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.