Esempio n. 1
0
void setup(void) {	
//----------- Setup ----------------
	fruitInit();
			
	pinModeDigitalOut(LED); 	// set the LED pin mode to digital out
	digitalClear(LED);		// clear the LED
	delayStart(mainDelay, 5000); 	// init the mainDelay to 5 ms
	delayStart(secondesDelay, 1000000); 	// init the secondesDelay to 1 s

//----------- Analog setup ----------------
	analogInit();		// init analog module
	analogSelect(0,MOTA_CURRENT);	// assign MotorA current sense to analog channel 0
	analogSelect(1,MOTB_CURRENT);	// assign MotorA current sense to analog channel 0

//----------- dcmotor setup ----------------

    //DCMOTOR_INIT(A);
    //DCMOTOR_INIT(B);
    dcmotorInit(A);
    dcmotorInit(B);

    rampInit(&rampeVitesseA);
    rampInit(&rampeVitesseB);
    
//--- on/off switch
    pinModeDigitalIn(ONOFF); 	// set the ONOFF pin mode to digital input
    
    EEreadMain();
}
Esempio n. 2
0
int main (void)
{
	//void wdt_disable(void);

		/* Initialise the Due board */
		sysclk_init();
		board_init();
		analogInit();
		/* Initialise console UART */
		configureConsole();

		/* Print demo information on the terminal*/
		printf("-- Terminal by William & Elvin--\n\r");
		
		

		/* Create the first task for running the code lock */
		if (xTaskCreate(TaskJoystickX, (const signed char * const) "TaskJoystickX", 1024, NULL, 2, NULL) != pdPASS){
			printf("Failed to create TaskJoystick\n");
		}
		if (xTaskCreate(TaskJoystickY, (const signed char * const) "TaskJoystickY", 1024, NULL, 2, NULL) != pdPASS){
			printf("Failed to create TaskJoystick\n");
		}
		
		
		vTaskStartScheduler();
		
	}
Esempio n. 3
0
void test_ADConverterInitialisesProperly(void){
	
	analogInit();
	TEST_ASSERT_BIT_HIGH_MESSAGE(5, *p_PMC_PCSR1, "PMC has not enabled the peripheral ADC clock");	/* Asserting the PMC manager has activated the ADC clock */
	TEST_ASSERT_BIT_HIGH_MESSAGE(7, *p_ADC_CHSR, "ADC channel 7 is not enabled");	/* Asserting that ADC channel 7 is enabled */
	TEST_ASSERT_BIT_HIGH_MESSAGE(6, *p_ADC_CHSR, "ADC channel 6 is not enabled");	/* Asserting that ADC channel 6 is enabled */
	TEST_ASSERT_BIT_HIGH_MESSAGE(5, *p_ADC_CHSR, "ADC channel 5 is not enabled");	/* Asserting that ADC channel 5 is enabled */
}
Esempio n. 4
0
void init()
{
	disableWatchDog();

	initClocks();

	//Copy RAM functions
	memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);

	//Setup flash waitstates
	initFlash();

	initPie();

	analogInit();

	EINT;
}
Esempio n. 5
0
int main(void)
{
	/* Initialise the Due board */
	sysclk_init();
	board_init();
	delayInit();
	daccInit();
	analogInit(1);
	

	if (xTaskCreate(task_PID, (const signed char * const) "Task_PID", TASK_STACK_PID_SIZE, NULL, TASK_PID_STACK_PRIORITY, NULL) != pdPASS) 
	{
		printf("Failed to create PID task\r\n");
	}
	/*
	if (xTaskCreate(task_Matlab, (const signed char * const) "Task_Matlab", TASK_STACK_MATLAB_SIZE, NULL, TASK_MATLAB_STACK_PRIORITY, NULL) != pdPASS) 
	{
		printf("Failed to create Matlab task\r\n");
	}*/
	vTaskStartScheduler();
}
Esempio n. 6
0
//
// Function: analogHmsInit
//
// Initialize the LCD display of a very simple analog clock with
// Hour and Minutes arrow and Seconds needle
//
void analogHmsInit(u08 mode)
{
  anaSecShow = GLCD_TRUE;
  analogInit(mode);
}
Esempio n. 7
0
//
// Function: analogHmInit
//
// Initialize the LCD display of a very simple analog clock with
// Hour and Minutes arrow
//
void analogHmInit(u08 mode)
{
  anaSecShow = GLCD_FALSE;
  analogInit(mode);
}
Esempio n. 8
0
void setup(void)
{
	//unsigned long t3,servoSOF;
		
	fruitInit();
	switchInit();
	
	//i2cm_init(I2C_MASTER, I2C_SLEW_ON, FOSC/400000/4-1) ;		//400kHz : clock = FOSC/(4 * (SSPADD + 1)) : SSPADD=FOSC/clock/4-1
	//HMC5883_init();
	
// --------- init motors PWM on TMR2 ----------- // now done by core & dcmotor
	// PWM on Timer2 : fPWM = fOSC / (TMR2prescale * 4 * (PR2+1))
	//						= 64000000Hz/(4 * 4 * 256) = 15625Hz
	/*CCP2CON=CCP3CON=0b00001100 ; // single PWM active high
	T2CONbits.T2CKPS0=1; //prescaler 4
	PR2=255;
	T2CONbits.TMR2ON=1;*/

// ------- init PWM1 to pulse MOTC_IN1
	//PSTR1CON=0;
	//PSTR1CONbits.STR1D=1;

// ------- init PWM2 to pulse MOTD_EN

	//PSTR2CON=0;
	//PSTR2CONbits.STR2B=1;

#if 1
// ---------- capture timer : TMR1 ------------
	T1CON=0b00110011;//src=fosc/4,ps=8,16bit r/w,on.
	PIE1bits.TMR1IE=1;  //1;
	IPR1bits.TMR1IP=1;


// ---------- Servos ------------
	//Servo_Init();
	
	//SERVO_SET_PORT(0,K3);
	
	dcmotorInit(X);
	DCMOTOR(X).Setting.PosWindow = 1;
	DCMOTOR(X).Setting.PwmMin = 50;
	DCMOTOR(X).Setting.PosErrorGain = 6;
	DCMOTOR(X).Setting.onlyPositive = 0;
	
	DCMOTOR(X).PosRamp.maxSpeed = 40;
	DCMOTOR(X).PosRamp.maxAccel = 50;
	DCMOTOR(X).PosRamp.maxDecel = 50;
	rampSetPos(&DCMOTOR(X).PosRamp, 0);

	DCMOTOR(X).PosPID.GainP = 120; //90
	DCMOTOR(X).PosPID.GainI = 10;
	DCMOTOR(X).PosPID.GainD = 0;
	DCMOTOR(X).PosPID.MaxOut = 1023;

	DCMOTOR(X).VolVars.homed = 1;
	pinModeDigitalOut(MXEN2);
	digitalSet(MXEN2);

	dcmotorInit(Y);
	DCMOTOR(Y).Setting.PosWindow = 100;
	DCMOTOR(Y).Setting.PwmMin = 50;
	DCMOTOR(Y).Setting.PosErrorGain = 1;
	
	DCMOTOR(Y).PosRamp.maxSpeed = 2000;
	DCMOTOR(Y).PosRamp.maxAccel = 5000;
	DCMOTOR(Y).PosRamp.maxDecel = 5000;
	rampSetPos(&DCMOTOR(Y).PosRamp, 16384);

	DCMOTOR(Y).PosPID.GainP = 200; //90
	DCMOTOR(Y).PosPID.GainI = 1;
	DCMOTOR(Y).PosPID.GainD = 0;
	DCMOTOR(Y).PosPID.MaxOut = 1023;

	DCMOTOR(Y).VolVars.homed = 1;
	pinModeDigitalOut(MYEN2);
	digitalSet(MYEN2);
#endif
	analogInit();
	//ANALOG_SELECT(MOTX_POSCHAN, MOTX_POS);
	analogSelect(MOTX_CSCHAN, MXCS);
	//ANALOG_SELECT(MOTY_POSCHAN, MOTY_POS);
	analogSelect(MOTY_CSCHAN, MYCS);

	analogSelect(ACCX_CHAN, ACCX);
	analogSelect(ACCZ_CHAN, ACCZ);
	
    switchSelect(0,K7); 
	//EEreadMain();
	delayStart(mainDelay, 5000); 	// init the mainDelay to 5 ms
}