コード例 #1
0
ファイル: mainV6.c プロジェクト: NxRLab/gibbot
int main(void) {
    initialize();
    //initialize_ADC_Offset();
    //initialize_UART();
    //TOPMAG=1;
    unsigned char c=0;
    motoron = 1;
    direction = CW;
    kick();
    write_duty(512);
    //write_duty(0);
    //timer1_on();

    printf("hello world!\n");
    while (1) {
        c = read_UART();
        if (c=='o'){
            TOPMAG=1;
        }
        else if (c=='f'){
            TOPMAG=0;
        }
        else if(c == 'g') {
            //Turn on Bottom Magnet
            write_UART2('1');
        } else if(c =='h') {
             //Turn off Bottom Magnet
            write_UART2('2');
        }
        else if (c=='u'){
            // inc duty
            // for now, increase the duty by 10% of max duty
            write_duty(read_duty()+100);
            c = 'x';
        }
        else if (c=='d'){
            // dec duty
            write_duty(read_duty()+100);
            c = 'x';
        }
        else if (c=='m'){
            // motor off
            motoron = 0;
        }
        else if (c=='x'){
            // make sure duty is only updated once per call 
            continue;
        }
    }
    return 0;
}
コード例 #2
0
ファイル: s_events.c プロジェクト: Lopo/Lotos
void check_autosave(void)
{
	set_crash();
	syspp->autosave+=amsys->heartbeat;
	if (syspp->autosave>=(syspp->auto_save*60)) {
		force_save(NULL);
		write_duty(GOD, "Automatic saved user's details\n", NULL, NULL, 0);
		syspp->autosave=0;
		}
}
コード例 #3
0
ファイル: mainV6.c プロジェクト: NxRLab/gibbot
int main(void) {
    initialize();
    initialize_ADC_Offset();
    printf("hello world!\n");

    last_state = -1;
    motoron = 0;

    do {
        if(!motoron) {
            __delay_ms(1000);
            printf("ready when you are...press USER button\n");
            while (!USER);
            printf("running\n");
            __delay_ms(1000);

            motoron = 1;
            write_duty(60);
            kick();
        }
    } while (1);

    while(1);

    while (1){
        /*
        if(USER){
            LED1 = !LED1;
            LED2 = !LED2;
            LED3 = !LED3;
            LED4 = !LED4;
            //TOPMAG = !TOPMAG;
            //commutate(7);
        }
        */

       //test_MayDay();
    }

    return 0;
}
コード例 #4
0
ファイル: mainV6.c プロジェクト: NxRLab/gibbot
int main(void) {
    int duty = 500;
    initialize();
    write_duty(duty); //apply duty cycle change
    motoron = 1;//turn motor on
    kick();//kick start commutation
    while (1){
        commutate(2);
        __delay32(40000000);
        commutate(4);
        __delay32(40000000);
        commutate(3);
        __delay32(40000000);
        if(USER){
            motoron=0;
        }
        LED1 = !S3;
        LED2 = !S2;
        LED3 = !S1;
        //test_MayDay();
    }
    return 0;
}
コード例 #5
0
ファイル: mainV6.c プロジェクト: NxRLab/gibbot
int main(void) {

    initialize();
    unsigned char b = 'x';

    write_duty(0);
    motoron=0;
    direction = CW;

    LED1 = 1;
    LED2 = 1;
    LED3 = 1;
    LED4 = 1;

    printf("%s %s\rHi! Welcome to the current control menu. Please press the number corresponding to your choice.\r1 = Idle\r2 = PWM Select\r3 = Tuning\r4 = Activate PI controller\r\n", __DATE__, __TIME__);


    while(1) { //The actual running menu portion is currently commented out to test the controller output.

        test_output();
        delay_ms(10000);
        LED1=!LED1;



//MENU

        /*if (USER){
            motoron=0;
            LED1=!LED1;
        }

        b = read_UART();    //read command from UART

        if (b=='1'){
            printf("Motor is in Idle mode.\r\n");
            write_duty(0);
            b='x';
        }

        if (b=='2'){
            printf("PWM mode selected. the motor is running at 10 percent duty.\rpress 'u' to increase it by 10, or press 'd' to decrease it by 10.\rpress'q' to quit.\r\n");
            motoron=1;
            write_duty(100);
            kick();
        while (b=='2'){
            int x = read_UART();
            if (x=='u'){
                write_duty(read_duty()+100);
            }
            else if (x=='d'){
                write_duty(read_duty()-100);
            }
            else if (x=='q'){
                write_duty(0);
                motoron=0;
                b='x';
                printf("PWM mode exited.\r\n");
            }
            }
            }

        if (b=='3'){
            printf("Tuning mode selected.");
            tune='1';
            track_wave(refcurrent);
            motoron=1;
            write_duty(10);
            kick();
            timer1_on();
            while(1);
        }

        if (b=='4'){
            printf("PI controller activated.");
        	run='1';
            motoron=1;
            write_duty(10);
            kick();
            timer1_on();
            while(1);
        }

        else if (b=='x'){
            LED4=!LED4;
            continue;
        }*/
    }



}