pin 12f683


Closed Thread
Results 1 to 23 of 23

Thread: pin 12f683

Hybrid View

  1. #1

    Cool pin 12f683

    trying to program this 8 pin pic
    trouble defining pins in pbp
    microchip manual listpins as gp0 to gp4 this does not work
    tried just pin 1 ect this compiles but does not function on pic

    whats the correct syntax for the baby chips

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Comparators...

    Hi,
    Try this:
    Code:
    ANSEL = %00000000	'Make sure Analog functions are turned OFF (should not be needed)
    CMCON = 7		'Turn OFF comparators, datasheet section 8.3
    TRISIO = 0		'All pins except GPIO3(MCLR) as output.
    
    Start:
      GPIO.0 = 1
      Pause 100
      GPIO.1 = 0
      Pause 100
    Goto Start
    /Henrik Olsson.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    GPIO.0, GPIO.1, etc, for I/O-pins, and TRISIO for TRIS regs. Here's a sample
    I/O-pin setup header from an old 683 test program..

    Code:
    @ DEVICE PIC12F683,MCLR_OFF,INTRC_OSC_NOCLKOUT,WDT_OFF,BOD_ON, PWRT_ON
    
    OSCCON  = %01100000     ' Internal 4MHz osc
    ADCON0 = 0              ' A/D off
    CMCON0 = 7              ' Comparators off
    ANSEL = 0	        ' Set all digital
    WPU = 0                 ' Internal pull-ups = off
    OPTION_REG = %10000000  ' Pull-ups = off, GPIO.2 = I/O, prescaler to Timer1
    GPIO = %00000000        ' All outputs = 0 on boot
    TRISIO = %00111101      ' GPIO,0=data in, GPIO,1=IRLED out, GPIO,2,3,4,5 unused
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4


    Did you find this post helpful? Yes | No

    Smile update

    this looks great
    only my program will require mostly inputs and at least 1 output
    can you tell what changes i need

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    TRISIO = %11111110 would setup GPIO.0 as an output leaving the rest setup as inputs.

    What is it you're doing?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6


    Did you find this post helpful? Yes | No

    Default responce

    setting up a alarm for my motorhome to sound if ignition is off and trans is not in park older coach does not have this feature also will sound alarm if turn signals are on too long

  7. #7
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile How many pins?

    How about (slow repetition) beep if head-lights are on and ignition off?
    We should be able to get this up to a 40 pin PIC
    -Adam-
    Ohm it's not just a good idea... it's the LAW !

  8. #8
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Sounds like a cool project. The 12F683 is a really nifty part.

    My wife thinks I'm a complete nerd, so she buys me all this odd stuff like RoboSapien robots and such. I got kind of bored with it after the first few minutes, and decided to have a go at controlling the thing from my PC with an 8-pin PIC.

    I used the 12F683 since I hadn't played with this one yet 'note the date of the code'. Here's what I came up with. It's pretty simple stuff, but still fun. I have a VB interface if anyone's interested. You can connect the PIC to your PC serial port, and control your RoboSapien robot with it by clicking buttons on-screen.
    Code:
    '****************************************************************
    '*  Name    : RoboSapien_IR.bas                                 *
    '*  Author  : Bruce Reynolds  11/11/2005                        *
    '*  Notes   : Serial IR controller for RoboSapien robot         *
    '*          : Replace RoboSapien hand-held IR transmitter with  *
    '*          : an 8-pin PIC & IR LED. Just goofin off one day.   *
    '****************************************************************
    ' Connections for a 12F683
    ' Pin #8 = gnd
    ' Pin #1 = Vcc
    ' GPIO.0 serial input from other controller or PC
    ' GPIO.1 IR LED drive ----/\/\/\---|>|----gnd  (note: use a 940nm IRLED)
    '                          330    IR LED
    ' Need more range use a simple NPN or mosfet driver.
    ' Rest of I/O-pins available for whatever.
    
    @ DEVICE PIC12F683, MCLR_OFF, INTRC_OSC_NOCLKOUT, WDT_OFF, BOD_ON, PWRT_ON
    DEFINE OSC 4
    DEFINE DEBUG_BAUD 2400 
    DEFINE DEBUGIN_REG GPIO 
    DEFINE DEBUGIN_BIT 0  
    DEFINE DEBUGIN_MODE 0   ' 0 = true mode (with a PC use a MAX232)
    
    @ #DEFINE IRTX GPIO  ; Define port to use for IR LED drive
    @ #DEFINE PIN 1      ; Define port pin to use for IR LED    
    
    BotHdr   CON 255     ' Pulse timing stuff
    BotHdr2  CON 25     
    Bot1     CON 3400   
    Bot0     CON 800     
    BotInter CON 38     
    Bot      CON "B"     ' Used for synch byte
    X        VAR BYTE    ' Bit index pointer
    Cycles   var BYTE    ' Holds number of 40KHz carrier cycles
    Device   VAR BYTE    ' Holds device select byte
    KeyNum   VAR BYTE    ' Key pressed
    
    OSCCON  = %01100000     ' Internal 4MHz osc
    ADCON0 = 0              ' A/D off
    CMCON0 = 7              ' Comparators off
    ANSEL = 0	            ' Set all digital
    WPU = 0                 ' Internal pull-ups = off
    OPTION_REG = %10000000  ' Pull-ups = off, GPIO.2 = I/O, prescaler to Timer1
    GPIO = %00000000        ' All outputs = 0 on boot
    TRISIO = %00111101      ' GPIO,0=data in, GPIO,1=IRLED out, GPIO,2,3,4,5 unused
    
    Main:
        DEBUGIN [Device,KeyNum] ' With MCS+ serial terminal program, sending B#135
        IF Device = Bot THEN    ' will move bot backwards. Full list of commands
           GOTO SendCmd         ' can be found in lower section.
        ENDIF
        GOTO Main
        
    SendCmd:
        Cycles = BotHdr  ' 1st part of synch pulse
        CALL Pulse
        Cycles = BotHdr2 ' 2nd part of synch pulse
        CALL Pulse
        
        FOR X = 7 to 0 STEP - 1 ' 8-bits per button command
            IF KeyNum.0[X] = 1 THEN
               PAUSEUS Bot1     ' high for logic 1 bit period
            ELSE
               PAUSEUS Bot0     ' or low for logic 0 bit period
            ENDIF
            Cycles = BotInter   ' Inter-bit period between data bits
            Call Pulse          ' During these periods the carier is on
        NEXT X
        GOTO Main
        
    Pulse:              ' Generate "Cycles" number of 40kHz pulses
    ASM
       bsf IRTX,PIN     ; 1uS, LED=on
       goto $+1         ; + 2uS = 3uS
       goto $+1         ; + 2uS = 5uS
       goto $+1         ; + 2uS = 7uS
       goto $+1         ; + 2uS = 9uS
       goto $+1         ; + 2uS = 11uS
       goto $+1         ; + 2uS = 13uS   
       bcf IRTX,PIN     ; 1uS, LED=off
       goto $+1         ; + 2uS = 3uS
       goto $+1         ; + 2uS = 5uS
       goto $+1         ; + 2uS = 7uS
       goto $+1         ; + 2uS = 9uS
       decfsz _Cycles,f ; + 1uS = 10S    
       goto _Pulse      ; + 2uS = 12uS
       return           ; Add 2uS for return to caller    
    ENDASM
     
        END
    
    ' Send ASCII character B followed by key commands below to
    ' control your RoboSapien from a PC or another PIC.
    
    ' A simple VB example to move RoboSapien forward would be;
    ' Private Sub Cmd_Forward_Click()
    ' MSComm1.Output = "B" & Chr$(134)
    ' End Sub
    
    ' Upper red commands
    ' Right arm up      = 129
    ' Right arm down    = 132
    ' Right arm in      = 133
    ' Right arm out     = 130
    ' Left arm up       = 137
    ' Left arm down     = 140
    ' Left arm in       = 141
    ' Left arm out      = 138
    ' Tilt body right   = 131
    ' Tilt body left    = 139
    
    ' Red commands - middle & lower controller
    ' Walk forward      = 134 
    ' Walk backward     = 135
    ' Turn left         = 136
    ' Turn right        = 128
    ' Stop              = 142
    ' Rht sensor pgm    = 146
    ' Master command program = 144
    ' Program / play    = 145
    ' Left sensor program = 147
    ' Sonic sens pgm    = 148
    
    ' Green commands - upper controller
    ' Right hand thump  = 161
    ' Right hand pickup = 164
    ' Lean backward     = 165
    ' Rht hand throw    = 162
    ' Sleep             = 163
    ' Listen            = 171
    ' Left hand throw   = 170
    ' Lean forward      = 173
    ' Left hand pickup  = 172
    
    ' Green commands - middle & lower controller
    ' Right turn step   = 160
    ' Backward step     = 167
    ' Forward step      = 166
    ' Reset             = 174
    ' Left turn step    = 178
    ' Right sensor program execute = 178
    ' Master command program execute = 176
    ' Wake up           = 177
    ' Sonic sensor program execute = 180
    ' Left sensor program execute  = 179
    
    ' Orange commands - upper controller
    ' Right hand sweep  = 193
    ' High 5            = 196
    ' Right hand strike = 197
    ' Burp              = 194
    ' Right hand strike 2 = 195
    ' Left hand strike 2  = 203
    ' Whistle           = 202
    ' Left hand strike  = 205
    ' Talk back         = 204
    ' Left hand sweep   = 201
    
    ' Orange commands - middle & lower controller
    ' Right hand strike 3 = 192
    ' Oops              = 199
    ' Left hand strike 3 = 200
    ' Roar              = 206
    ' Demo 1            = 210
    ' All demo          = 208
    ' Power off         = 209
    ' Dance demo        = 212
    ' Demo 2            = 211
    Here's a pic of the VB app;


    I ended up with an 8-pin PIC controlling my RCA TV, Motorolla cable box, DVD, stereo, RoboSapien 'when I could afford batteries every few minutes', etc. from my PC. Maybe my wife was right...;o}
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Is this a K Type sensor?
    By jessey in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st November 2009, 13:55
  2. What's the best way to output 30 to 40 kHz from a 12F683 pin?
    By fizyxman in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 1st June 2009, 00:08
  3. DS1820 with 16f688
    By jessey in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 23rd May 2009, 05:07
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07

Members who have read this thread : 1

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