- #include <mega8515.h>
- //8MHz CB1 final 29 April without pulse strecher
- #include<stdio.h>
- #include<delay.h>
- // Declare your global variables here
- char a;
- bit dlag,ulag;
- char str[16];
- int dly=0;
- void blink();
- void blink2();
- void main(void)
- {
- DDRB=0xFF;
- DDRC=0x80;
- PORTC=0x00;
- ACSR=0x80;
- while (1)
- {
- a=PINC;
- a^=0x70;
- if(a&0x20) {PORTB=0x02; blink2();
- }
- else if(a&0x40) {PORTB=0x01; blink2();
- }
- else if(a&0x10) {PORTB=0x00; blink2();
- }
- else
- {
- if(a)
- {
- switch(a)
- {
- case 1: //Move Down
- PORTB=0x06;;
- delay_ms(200);
- dly=0;
- break;
- case 3: //Move Down Sort Steps
- PORTB=0x06;
- delay_ms(100);
- dly=0;
- break;
- ////////////////////////////////////
- case 2: //Move Down Long Steps
- if(ulag)
- {
- delay_ms(250); ulag=0;
- }
- else
- { PORTB=0x06;
- delay_ms(35);
- dly=15; dlag=1;
- }
- break;
- /////////////////////////////////
- case 6: //Don't move
- PORTB=0x08; delay_ms(200);
- dly=10; ulag=0; dlag=0;
- break;
- ///////////////////////////////////////////
- case 4: //Move Up in Steps
- if(dlag)
- { delay_ms(250); dlag=0;
- }
- else
- {
- PORTB=0x11; delay_ms(35);
- dly=15; ulag=1;
- }
- break;
- ////////////////////////////////////////////
- case 12: //Move Up in Short steps
- PORTB=0x11; delay_ms(90);
- dly=0;
- break;
- case 8: //Move Up in Long Steps
- PORTB=0x11; delay_ms(190);
- dly=0;
- //Long or Short steps is controlled by the time delay
- }
- }
- else
- {
- //Make all OFF
- PORTB=0;
- delay_ms(dly);
- }
- }
- };
- }
- void blink()
- {
- a&=0x0F;
- switch(a)
- {
- case 1: //Move Down
- PORTB=0x04;;
- delay_ms(200);
- dly=0;
- break;
- case 3: //Move Down Sort Steps
- PORTB=0x04;
- delay_ms(100);
- dly=0;
- break;
- //////////////////////////////////////////
- case 2: //Move Down Long Steps
- PORTB=0x04;
- delay_ms(50);
- dly=15;
- break;
- ///////////////////////////////////
- case 6: //Don't move
- PORTB=0x08; delay_ms(80);
- dly=10;
- break;
- ///////////////////////////////////
- case 4: //Move Up in Steps
- PORTB=0x10; delay_ms(50);
- break;
- //////////////////////////////////
- case 12: //Move Up in Short steps
- PORTB=0x10; delay_ms(90);
- dly=0;
- break;
- case 8: //Move Up in Long Steps
- PORTB=0x10; delay_ms(190);
- dly=0;
- //Long or Short steps is controlled by the time delay
- }
- }
- void blink2()
- {
- a&=0x0F;
- switch(a)
- {
- case 1: //Move Down
- PORTB.2=1;
- delay_ms(200);
- dly=0;
- break;
- case 3: //Move Down Sort Steps
- PORTB.2=1;
- delay_ms(100);
- dly=0;
- break;
- /////////////////////////////////
- case 2: //Move Down Long Steps
- PORTB.2=1;
- delay_ms(50);
- dly=15;
- break;
- ////////////////////////////////
- case 6: //Don't move
- PORTB.3=1; delay_ms(80);
- dly=10;
- break;
- /////////////////////////////////////
- case 4: //Move Up in Steps
- PORTB.4=1; delay_ms(50);
- break;
- ////////////////////////////////////
- case 12: //Move Up in Short steps
- PORTB.4=1; delay_ms(90);
- dly=0;
- break;
- case 8: //Move Up in Long Steps
- PORTB.4=1; delay_ms(190);
- dly=0;
- //Long or Short steps is controlled by the time delay
- }
- }
#include "msp430x21x2.h" #define PWM_OUTPUT 0x03 #define DUTY_CYCLE TA0CCR2 #define MAX_LIMIT 300 /* #define no_of_samples 1 #define duty_cycle_limit 1000 #define temp_sensor 0xA000 #define panel_selection_cutoff 250 */ #define PV_VOLTAGE INCH_0 #define PV_CURRENT INCH_1 #define BATT_VOLTAGE INCH_2 #define BATT_CURRENT INCH_3 #define UPPER_CRG_LVL 0x0105 // 0x00FF // 0x00F5 //0x023A #define LOWER_CRG_LVL ...
Comments
Post a Comment