New Forum Message Sandbox

2009-09-12
2013-05-30
  • Thought I would goof off with the new format.  *Give it a try!*
      
    Huh, noticed by accidentally hitting the **tab** key, was able to get a real time **preview** of the post.

    Thanks Hugh for the xxxx.dat files update, have been able to play with some of the newer devices now!

        'Chip model
        #chip 18f14K50,12
        #CONFIG FOSC = HS, MCLRE = OFF, WDTEN = OFF, PWRTEN = ON
        #Config  BOREN = OFF, LVP = OFF, PLLEN = OFF, HFOFST = OFF
        #Config WRTC = OFF, IESO = ON
        #CONFIG XINST = OFF, USBDIV = OFF, CPUDIV = NoClkDiv
        #CONFIG PCLKEN = ON
       
        #define PWM_Out1 PortC.0
        #define decrDuty PortA.3
        dir PWM_Out1 out
        dir decrDuty in 'RA3 is always set as input no matter the dir stmt
        #define numcycles 10
        redPWM = 255
       
        Main:
        Do while decrDuty Off
        redPWM -= 1
        If redPWM = 0 then redPWM = 255
        PWMOut(1, redPWM, numcycles)  'channel 1, duty cycle, number of cycles
        loop
        PWMOut(1, redPWM, numcycles)
        Goto Main
    Try block quotes

    >Simon says ………….. 
    >>Do this…….
    >Hmmmmm

    ## Heading ##

    1. A
         - B
         - C
         - List item

     
  • kent_twt4
    kent_twt4
    2009-09-12

    Well that was me who just posted, my connection timed out, oh well.

    Code tags work…..**Yeaaaa**!

    No file attachments yet?????…….**Boooo**!

    Give it a go, and see.

    !; (C:/Forum_Pics/PicDem_Z.jpg)

    !; (http://i89.photobucket.com/albums/k214/nickelflipper/IM000121.jpg)

     
  • kent_twt4
    kent_twt4
    2010-05-06

    Maybe if I try the quote tags instead of the @#$*!!! code tags it will look OK?

    'Updated Alternate Soft RS232 routine example with new bin2ascii
    'overloaded subs.  kent_twt4

    #chip 12F683, 8 'mhz
    #config INTRC_OSC_NOCLKOUT, MCLRE=off, WDT=off

    dim num as word
    Ser_Init

    start:
    ;Pic waits for signal from terminal/computer
    RCV_RS232 ;Waits for terminal input, and return value is RxByte
    Xmit_RS232 RxByte ;echo back received ascii value
    If RxByte = 49 Then ;ascii 49 (Decimal 1 from terminal)
    XMIT_PRINT (" hello")
    For num = 0 to 500
    Bin2ascii num  ;send out binary value as ascii
    XMIT_Print (" ")
    next
    end if
    Xmit_RS232 10:Xmit_RS232 13  ;line feed, carriage return
    goto start

    Sub Ser_Init
    ;slight adjustment was required for 9600bps delay value
    #define baud 103
    #define halfbaud 52 ;place Read of SerRx in middle of bit
    #define SerTxHigh Set GPIO.0 On
    #define SerTxLow Set GPIO.0 Off
    #define SerRx GPIO.1
    dir GPIO.0 out ;Tx
    dir GPIO.1 in ;Rx
    SerTxHigh ;Initial RS232 idle state
    end sub

    Sub RCV_RS232
    RxWait:
    IF SerRx On Then goto RCV_RS232 ;wait for start bit
    wait halfbaud us ;do half bit time delay
    If SerRx On Then goto RxWait
    RxByte = 0
    For RxBit = 1 to 8 ;set up to read 8 bits
    wait baud us
    Rotate RxByte Right
    If SerRx On then Set RxByte.7 1
    If SerRx Off Then Set RxByte.7 0
    Next
    wait baud us
    End sub

    sub XMIT_PRINT (PrintData$)
    PrintLen = PrintData(0)
    if PrintLen = 0 then exit sub
    'Write Data
    for SysPrintTemp = 1 to PrintLen
    XMIT_RS232(PrintData(SysPrintTemp))
    next
    end sub

    Sub XMIT_RS232(Xmit_Byte)#NR
    SerTxLow
    wait baud us
    For cntr = 1 to 8
    Rotate Xmit_Byte Right
    If Status.C ON Then SerTxHigh
    If Status.C Off Then SerTxLow
    wait baud us
    Next
    SerTxHigh
    wait baud us
    end sub

    sub bin2ascii (LCDValue) #NR
    LCDValueTemp = 0
    LCDShowChar = 0
    SERCEN = 0
    SERDEC = 0
    SERUN = 0

    If LCDValue >= 100 then
    LCDValueTemp = LCDValue / 100
    LCDValue = SysCalcTempX
    SERCEN = LCDValueTemp + 48
    Xmit_RS232 (SERCEN)
    LCDShowChar = TRUE
    End If

    If LCDShowChar > 0 or LCDValue >= 10 then
    LCDValueTemp = LCDValue / 10
    LCDValue = SysCalcTempX
    SERDEC = LCDValueTemp + 48
    Xmit_RS232 (SERDEC)
    End If

    SERUN = LCDValue + 48
    Xmit_RS232 (SERUN)
    End Sub

    sub bin2ascii (LCDValue as word ) #NR
    Dim SysCalcTempX As Word
    LCDValueTemp = 0
    LCDShowChar = 0
    SERDECMIL = 0
    SERMIL = 0
    SERCEN = 0
    SERDEC = 0
    SERUN = 0

    If LCDValue >= 10000 then
    LCDValueTemp = LCDValue / 10000
    LCDValue = SysCalcTempX
    SERDECMIL = LCDValueTemp + 48
    Xmit_RS232 (SERDECMIL)
    LCDShowChar = TRUE
    End If

    If LCDShowChar > 0 or LCDValue >= 1000 then
    LCDValueTemp = LCDValue / 1000
    LCDValue = SysCalcTempX
    SERMIL = LCDValueTemp + 48
    Xmit_RS232 (SERMIL)
    LCDShowChar = TRUE
    End If

    If LCDShowChar > 0 or LCDValue >= 100 then
    LCDValueTemp = LCDValue / 100
    LCDValue = SysCalcTempX
    SERCEN = LCDValueTemp + 48
    Xmit_RS232 (SERCEN)
    LCDShowChar = TRUE
    End If

    If LCDShowChar > 0 or LCDValue >= 10 then
    LCDValueTemp = LCDValue / 10
    LCDValue = SysCalcTempX
    SERDEC = LCDValueTemp + 48
    Xmit_RS232 (SERDEC)
    End If

    SERUN = LCDValue + 48
    Xmit_RS232 (SERUN)
    End Sub