Exemple #1
0
int16_t main(void) {
    init();
    REV = 0;
    REQUESTED_DIRECTION = 0;
    SENSED_DIRECTION = 0;
    DUTY = 0;
    led_on(&led2);
    timer_setPeriod(HB_TIMER, 0.5);
    timer_start(HB_TIMER);
    printf("Good morning!\n");

    oc_pwm(&oc3,D2n,PWM_TIMER,FREQ,DUTY);
    
    while (USB_USWSTAT!=CONFIG_STATE) {     // while the peripheral is not configured...
        ServiceUSB();                       // ...service USB requests
    }
    while (1) {
        ServiceUSB();
        SetMotorVelocity(DUTY,REQUESTED_DIRECTION); 
        get_direction();
        get_feedback();
         if (timer_flag(HB_TIMER)) {
            timer_lower(HB_TIMER);
            led_toggle(&led1);
        }      
    }
}
int main(int argc, char *argv[]) {
	int i;

	log_open("WAMtest.log");

	//Register the ctrl-c interrupt handler 
	signal(SIGINT, sigint_handler);
	
	//create and initialize the WamInterface struct
	wamif = wamif_create(0);
	wamif_hand_connect(wamif);

	//start realtime mode, open and close the hand
	printf("starting realtime mode\n");
	wamif_hand_start_realtime(wamif, 0, 0);

	int closevels[3] = {20, 20, 20};
	int openvels[3] = {-50, -50, -50};
	int gains[3] = {100, 100, 100};

	printf("closing hand\n");
	for(i=0; i<50; i++){
		printf("i = %d\n", i);
		wamif_realtime_bend(wamif, closevels, gains);
		get_feedback();
	}

	printf("opening hand\n");
	for(i=0; i<30; i++){
		printf("i = %d\n", i);
		wamif_realtime_bend(wamif, openvels, gains);
		get_feedback();
	}
	
	wamif_terminate_realtime(wamif);

	wamif_destroy(wamif);
	log_close();
	return 1;
}