***[ Octopod Control Code ]******************** * This code is used on the Motorola * * 68332 microcontroller * * * * - for control of 8 legs and 32 muscles * * * * WRITTEN BY: MARIUSZ ZACZEK (11/8/1998) * *********************************************** opt nolist org $9000 * Start of memory location include EQU332.ASM start move.w #$2700,sr * Disable interrupts jsr portEinit * Initialize port E jsr portFinit * Initialize port F jsr threeSEC ***[ VALVE MEANINGS ]**************************************************** * * * ---LEGS 1--- [ bits 7,6,5,4,3,2,1,0 ] PORTE * * 0 = 2-way valve to FILL muscle (T) [normally closed] * * 1 = 3-way valve to EXHAUST muscle (T) [normally open] * * 2 = 2-way valve to FILL muscle (F) [normally closed] * * 3 = 3-way valve to EXHAUST muscle (F) [normally open] * * 4 = 2-way valve to FILL muscle (B) [normally closed] * * 5 = 3-way valve to EXHAUST muscle (B) [normllay open] * * 6 = 2-way valve to FILL muscle (R) [normally closed] * * 7 = 3-way valve to EXHAUST muscle (R) [normally open] * * * * ---LEGS 2--- [ bits 7,6,5,4,3,2,1,0 ] PORTF * * 0 = 2-way valve to FILL muscle (T) [normally closed] * * 1 = 3-way valve to EXHAUST muscle (T) [normally open] * * 2 = 2-way valve to FILL muscle (F) [normally closed] * * 3 = 3-way valve to EXHAUST muscle (F) [normally open] * * 4 = 2-way valve to FILL muscle (B) [normally closed] * * 5 = 3-way valve to EXHAUST muscle (B) [normllay open] * * 6 = 2-way valve to FILL muscle (R) [normally closed] * * 7 = 3-way valve to EXHAUST muscle (R) [normally open] * * * ************************************************************************* bodygo * Initialize ports E and F and pause for 3 seconds clr D0 * Clear D0 register move.b #%00000000,PORTE0 * Set all pins to low on E move.b #%00000000,PORTF0 * Set all pins to low on F jsr fourSEC * Pause for about 12 seconds jsr fourSEC * - jsr fourSEC * - ************************************************************************* * STARTUP section * ************************************************************************* startup * Close the 2-way valves for all muscles and exhaust all expect (B) Bottom. move.b #%10100101,PORTE0 * Move LEGS 1 up and back move.b #%01011010,PORTF0 * Move LEGS 2 down and forward * Pause for 2 seconds - STARTUP is complete. jsr threeSEC * Pause 2 seconds ************************************************************************* * WALK section * ************************************************************************* walk * Move LEGS 1 forward while moving LEGS 2 backward. move.b #%10000100,PORTE0 * Exhaust (R) and fill (F) - 1 move.b #%01001000,PORTF0 * Exhaust (F) and fill (R) - 2 jsr threeSEC * Pause 3 second * Lower LEGS 1 & raise LEGS 2 move.b #%00010010,PORTE0 * Exhaust (T) and fill (B) - 1 jsr threeSEC * Pause 3 second move.b #%00100001,PORTF0 * Exhaust (B) and fill (T) - 2 jsr threeSEC * Pause 3 second * Move LEGS 2 forward while moving LEGS 1 backward. move.b #%01001000,PORTE0 * Exhaust (F) and fill (R) - 1 move.b #%10000100,PORTF0 * Exhaust (R) and fill (F) - 2 jsr threeSEC * Pause 3 second * Lower LEGS 2 & raise LEGS 1 move.b #%00010010,PORTF0 * Exhaust (T) and fill (B) - 2 jsr threeSEC * Pause 3 second move.b #%00100001,PORTE0 * Exhaust (B) and fill (T) - 1 jsr threeSEC * Pause 3 second jmp walk * Continue looping end ***************************************************************** * Subroutine to initialize port E * ***************************************************************** portEinit move.b #$00,PORTE0 * Clear all pins on port E move.b #$00,PEPAR * Configure port E as I/O move.b #$ff,DDRE * Configure port E as output rts * end of subroutine ***************************************************************** * Subroutine to initialize port F * ***************************************************************** portFinit move.b #$00,PORTF0 * Clear all pins on port F move.b #$00,PFPAR * Configure port F as I/O move.b #$ff,DDRF * Configure port F as output rts * end of subroutine ***************************************************************** * Subroutine to pause for 1/5 of a second * ***************************************************************** shortSEC clr.l D0 shortSEC1 cmp.l #100000,D0 * Compare if counter is at 1s beq shortSECend * if yes, leave subroutine nop * Pause for 1 clock cycle add.l #1,D0 * Add 1 to D0 register jmp shortSEC1 * Loop back shortSECend rts ***************************************************************** * Subroutine to pause for 1/2 (half) of a second * ***************************************************************** halfSEC clr.l D0 halfSEC1 cmp.l #250000,D0 * Compare if counter is at 1s beq halfSECend * if yes, leave subroutine nop * Pause for 1 clock cycle add.l #1,D0 * Add 1 to D0 register jmp halfSEC1 * Loop back halfSECend rts ***************************************************************** * Subroutine to pause for 1 second * ***************************************************************** oneSEC clr.l D0 oneSEC1 cmp.l #500000,D0 * Compare if counter is at 1s beq oneSECend * if yes, leave subroutine nop * Pause for 1 clock cycle add.l #1,D0 * Add 1 to D0 register jmp oneSEC1 * Loop back oneSECend rts * end of subroutine ***************************************************************** * Subroutine to pause for 2 seconds * ***************************************************************** twoSEC clr.l D0 twoSEC1 cmp.l #1000000,D0 * Compare if counter is at 1s beq twoSECend * if yes, leave subroutine nop * Pause for 1 clock cycle add.l #1,D0 * Add 1 to D0 register jmp twoSEC1 * Loop back twoSECend rts * end of subroutine ***************************************************************** * Subroutine to pause for 3 seconds * ***************************************************************** threeSEC clr.l D0 threeSEC1 cmp.l #1500000,D0 * Compare if counter is at 1s beq threeSECend * if yes, leave subroutine nop * Pause for 1 clock cycle add.l #1,D0 * Add 1 to D0 register jmp threeSEC1 * Loop back threeSECend rts * end of subroutine ***************************************************************** * Subroutine to pause for 4 seconds * ***************************************************************** fourSEC clr.l D0 fourSEC1 cmp.l #2000000,D0 * Compare if counter is at 1s beq threeSECend * if yes, leave subroutine nop * Pause for 1 clock cycle add.l #1,D0 * Add 1 to D0 register jmp fourSEC1 * Loop back fourSECend rts * end of subroutine