Esempio n. 1
0
void print_Duty() {
    dbprintf("Left Motor Duty: %d\nRight Motor Duty: %d\n\n",
            PWM_GetDutyCycle(LEFT_MOTOR_ENABLE) / 10,
            PWM_GetDutyCycle(RIGHT_MOTOR_ENABLE) / 10);


}
static int writePWMChannels(SampleRecord *sampleRecord, size_t currentTicks, LoggerConfig *loggerConfig){
	int rate = SAMPLE_DISABLED;
	for (int i = 0; i < CONFIG_PWM_CHANNELS; i++){
		PWMConfig *c = &(loggerConfig->PWMConfigs[i]);
		size_t sr = c->cfg.sampleRate;
		if (sr != SAMPLE_DISABLED){
			if ((currentTicks % sr) == 0){
				rate = HIGHER_SAMPLE_RATE(sr, rate);
				float value = 0;
				switch (c->loggingMode){
					case MODE_LOGGING_PWM_PERIOD:
						value = PWM_GetPeriod(i);
						break;
					case MODE_LOGGING_PWM_DUTY:
						value = PWM_GetDutyCycle(i);
						break;
					case MODE_LOGGING_PWM_VOLTS:
						value =  PWM_GetDutyCycle(i) * c->voltageScaling;
						break;
					default:
						break;
				}
				if (c->loggingPrecision == 0){
					sampleRecord->PWMSamples[i].intValue = value;
				}
				else{
					sampleRecord->PWMSamples[i].floatValue = value;
				}
			}
		}
	}
	return rate;
}
Esempio n. 3
0
void __ISR(_TIMER_3_VECTOR, ipl3) Timer3Handler(void) {
    mT3ClearIntFlag();
    printf("timeout\n");
    //printf("mspeed %d\n",motor_command(500));
    //waitabit(1000);
    //printf("angle %f\n",get_AHRS_angle());
    //waitabit(1000);
   // printf("speed %f\n", get_AHRS_rate());
    //waitabit(500000); //works with 1000000 and 500000
    //printf("mspeed %d\n\n", motor_command(500));
    printf("duty cycle %d\n", PWM_GetDutyCycle(PWM_PORTY04));
    motor_command(300);
    //MDBSS ^= 1;
}