source code

H-bridge controller firmware: i2c-pwm.asm

ian – Tue, 2006 – 07 – 04 21:36

This is the main source file for the PIC device in the I2C-based H-bridge controller with PWM.


; PIC16F84A H-Bridge controller
;
; Release 1.0, 27 June 2006
; Copyright (C) 2006 Ian Howson (ian@mouldy.org)
;
; Uses an I2C interface and PWM to provide variable speed and direction 
; control to two H-bridges. These are intended for Eugene Blanchard's H-bridge
; design (http://www.geocities.com/fet_h_bridge/index.html), but should work 
; with any H-bridge that can accept 5V logic-level inputs.
;
; This design includes braking functionality. If this is not needed, only the 
  

AVR pulsing LED: avrledtest.c

ian – Tue, 2006 – 05 – 16 15:03

Based heavily off the sample code on http://www.captain.at/electronics/atmel-programmer/

This has been tested on an ATmega32 with a 4MHz crystal oscillator.

#include < avr/io.h>

void delay_ms(unsigned char ms)
/* badly mangled delay_ms */
{
	unsigned short outer1, outer2;
     	outer1 = 1; 

    	while (outer1) {
		outer2 = 1000;
		while (outer2) {
			while ( ms ) ms--;
			outer2--;
		}
		outer1--;
	}
}

int main(void)
{
	/* enable  PD5 as output */
	DDRD |= 1 << PD5;

	unsigned char bright = 0;

Syndicate content