julian on February 25th, 2009

The PIC microcontroller has a 10-bit A/D converter on board, so accurately measuring battery voltage should be straightforward enough. However, there are a few issues that need to be considered. Firstly, the A/D converter’s voltage range is 0 volts to 5 volts, whereas the battery can go as high as 15 volts, so a simple [...]

Continue reading about Measuring Battery Voltage

julian on February 19th, 2009

This program flashes LED D6 on the PICkit1 programmer board using the PWM hardware. The microcontroller’s clock is set to 125kHz to make the pulse frequency low enough to see the LED turning on and off. 
;12F683 Flashing LED using PWM

list p=12F683
#include “p12f683.inc”

__CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF

org 0×00

init
clrf GPIO ;initialise all outputs
movlw 0×0c
movwf CCP1CON ;select PWM mode (active high)
movlw 0×80
movwf CCPR1L ;set PWM duty cycle to [...]

Continue reading about 12F683 Flashing LED using PWM

julian on February 18th, 2009

This program flashes LED D0 on the PICkit1 programmer board using software delays. Two general purpose registers, del_lo and del_hi form a 16 bit counter (65,536 counts). The delay subroutine is called between each change of state of the LED.
;12F683 Flashing LED using software delay

list p=12F683
#include “p12f683.inc”

__CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF

del_lo equ 0×20
del_hi equ 0×21

org 0×00

init
clrf GPIO ;initialise all outputs
banksel 0×80 ;select upper register bank
movlw 0×0f
movwf TRISIO ;make [...]

Continue reading about 12F683 Flashing LED using software delays

julian on February 17th, 2009

Microchip PICkit1 Programmer

 I’ll be using the Microchip PIC12F683 for this design as it has both an A/D converter and a PWM module. Since I have a couple of PICkit1 programmers available, that’ll be used to prototype the firmware.
The starting point for anyone new to programming microcontrollers is to get an LED to flash on and [...]

Continue reading about Playing with Microcontrollers