Saturday, 14 January 2012

Microcontroller Ahoy

And here we are. No more talking about 3D printer or parts I have designed and/or made (*), now it's time for some microcontroller projects.

Couple days ago I ordered basic programming tool and ten Pic 16F616 controllers. Pictured here is the first test circuit running short program I made earlier today. Here Pickit2 is used as programming device and also it provided the power for running the test circuit. LED with current limiting resistor is connected from RC0 (Pin10) to  ground, and the one small capacitor is located between 16F616:s ground (Pin 14) and operating voltage (Pin1) for filtering the power fluctuations at the circuit.

Prototype board with Pic 16F616 connected to Pickit2 programmer
This is not the first time I have been using Microchip Pic chips, since my first Pic based projects were made with classic 16C84:s like fifteen years ago. This 16F616 has a lot improvements compared to that older chip. Having multiple timers and option to use Timer1 with 32Khz quarts to build real time clock will be handy. Also the build in 10-bit A/D converter will have it's uses as will the extended PWM -modes available. 

Making assembler code for these cheap-class  (about one Euro, in small numbers) controllers is a bit like driving a bike, you have learned it once and you'll have the skill rest of your life. Of course it can take few hours to get all necessary manuals and data sheets, and some time will be spend on software and tools playing nicely together.



My bit kludgish  asm-source follows, in case anyone is interested. :-)

; Not so nice example.
; PortC pins:
; RC:0 = digital out, led active high

  #include p16f616.inc 
  __config _INTOSCIO & _WDT_OFF  ;   8 Mhz int-osc with IO:s
                      
  ; Start from reset vector 
  org 0x00 ; obvious, but just in case.
  goto Main ; Skip over interrupt vector

  org 0x20  ; main program
Main
  BCF STATUS,RP0 ;Bank 0
  CLRF PORTC ;Init PORTC
  BSF STATUS,RP0 ;Bank 1
  CLRF ANSEL ;digital I/O  (disable Analog Inputs)
  MOVLW 0xFE ;Set RC<5:1> as input
  MOVWF TRISC ;and set RC<0> as outputs
  BCF STATUS,RP0 ;Bank 0

Loop
  incf  PORTC,F   ;Read PORTC, add 1 and save back
  goto  Loop      ;Like forever


  end             ;All things must end someday



(*) PS: As a footnote I'll want to show you one thingy I designed couple days ago. It's a kitchen towel hook, made to fit at two centimeter thick cabinet doors. Drawings and prints are available at request.




1 comment:

  1. The HUMANOID robotic ARM using pic microcontroller The purpose of the HUMANOID robotic ARM project is to implement the position control and vision control on the robotic arm. Which in my opinion is one of the best things happening and even KLDS and http://microcontrollerslab.com/ talked about this.

    ReplyDelete