Esempio n. 1
0
//----- Begin Code ------------------------------------------------------------
int main(void)
{
	// initialize our libraries
	// initialize the UART (serial port)
	uartInit();
	uartSetBaudRate(115200);
	// make all rprintf statements use uart for output
	rprintfInit(uartSendByte);
	// initialize the timer system
	timerInit();
	// initialize vt100 terminal
	vt100Init();

	timerPause(100);

	// print welcome message
	vt100ClearScreen();
	vt100SetCursorPos(1,0);
	rprintfProgStrM("\r\nWelcome to the MMC Test Suite!\r\n");

	timerPause(1000);

	mmcTest();

	return 0;
}
Esempio n. 2
0
//----- Begin Code ------------------------------------------------------------
int main(void)
{
	// initialize our libraries
	// initialize the UART (serial port)
	uartInit();
	// set the baud rate of the UART for our debug/reporting output
	uartSetBaudRate(9600);
	// initialize the timer system
	timerInit();

	// initialize rprintf system
	// - use uartSendByte as the output for all rprintf statements
	//   this will cause all rprintf library functions to direct their
	//   output to the uart
	// - rprintf can be made to output to any device which takes characters.
	//   You must write a function which takes an unsigned char as an argument
	//   and then pass this to rprintfInit like this: rprintfInit(YOUR_FUNCTION);
	rprintfInit(uartSendByte);

	// initialize vt100 library
	vt100Init();
	
	// clear the terminal screen
	vt100ClearScreen();
	
	// run the test
	rprintfTest();

	return 0;
}
Esempio n. 3
0
//----- Begin Code ------------------------------------------------------------
int main(void)
{
	// initialize our libraries
	// initialize the UART (serial port)
	uartInit();
	// set the baud rate of UART 0 for our debug/reporting output
	uartSetBaudRate(0,9600);
	// set uart0SendByte as the output for all rprintf statements
	rprintfInit(uart0SendByte);
	// initialize the timer system
	timerInit();
	// initialize vt100 library
	vt100Init();
	
	// print a little intro message so we know things are working
	vt100ClearScreen();
	rprintf("\r\nWelcome to GPS Test!\r\n");
	
	// run example gps processing loop
	// (pick the one appropriate for your GPS packet format)
//	gpsTsipTest();
	gpsNmeaTest();
	
	return 0;
}
Esempio n. 4
0
//----- Begin Code ------------------------------------------------------------
int main(void)
{
	// initialize our libraries
	// initialize the UART (serial port)
	uartInit();
	uartSetBaudRate(9600);
	// make all rprintf statements use uart for output
	rprintfInit(uartSendByte);
	// turn on and initialize A/D converter
	a2dInit();
	// initialize the timer system
	timerInit();
	// initialize vt100 terminal
	vt100Init();

	// configure port B for led output and pushbutton input
	outb(DDRB, 0x0F);
	// all LEDs on
	outb(PORTB, 0x00);
	// wait for hardware to power up
	timerPause(100);
	// all LEDs off
	outb(PORTB, 0x0F);

	// start command line
	goCmdline();

	return 0;
}
Esempio n. 5
0
void setup() {
  uart0Init();
  uartSetBaudRate(0, 9600);
  rprintfInit(uart0SendByte);
  //rprintf("Hello.."); rprintfCRLF();
  rprintf("$Id: psp_joystick.c,v 1.1.1.1 2007/08/21 05:14:23 julian Exp $");
  vt100Init();

  sbi(DDRD, DDD4); // output PD4
  sbi(PORTD, PD4); // set it high
  cbi(DDRD, DDD5); // input PD5
  sbi(PORTD, PD5); // set it low

  cbi(DDRA, DDA0); // input (one axis)
  cbi(DDRA, DDA1); // input (the other axis)
  //cbi(DDRA, DDA2); // input
  //sbi(DDRA, DDA3); // output
  //sbi(PORTA, PA0);
  //sbi(PINA, PINA0); // set high
  //sbi(PINA, PA3);
  a2dInit();

  // set up the power pulse LED
  TCCR0A |= (1<<WGM00) | (1<<COM0A1); // mode 1, phase-correct PWM
  TCCR0B |= (1<<CS02); // clk/256 from prescaler
  //TCCR0B |= (0<<CS02) | (1<<CS01) | (1<<CS00); // clk/64

  // set up and enable the power pulse thing
  TCNT0 = 0x00;
  sbi(TIMSK0, TOIE0);

  sbi(DDRB, DDB3); // output on the LED
  sbi(PORTB, PB3); // turn it on
  u08 i, j;
  for(j=0; j<1; j++) {
  for(i=0; i<10; i++) {
  	_delay_ms(32);
  }
  cbi(PORTB, PB3);
  for(i=0; i<10; i++) {
  	_delay_ms(32);
  }
  sbi(PORTB, PB3);
  for(i=0; i<10; i++) {
	  _delay_ms(32);
  }
  }
  cbi(PORTB, PB3);
  sei();
}
int main(void)
{
	uartInit();
	uartSetBaudRate(115200);
	rprintfInit(uartSendByte);

	a2dInit();
	timerInit();
	vt100Init();




	return 0;
}
Esempio n. 7
0
void init_uart(void) {
    // initialize our libraries
    // initialize the UART (serial port)
    uartInit();
    // set the baud rate of the UART for our debug/reporting output
    uartSetBaudRate(9600);
    // set uartSendByte as the output for all rprintf statements
    rprintfInit(uartSendByte);
    // initialize the timer system
    timerInit();
    // initialize vt100 library
    vt100Init();
    vt100ClearScreen();
    // print a little intro message so we know things are working
    rprintf("\r\nServo tester\r\n");
    rprintf("Sebastien CELLES\r\n");
    rprintf("IUT de Poitiers\r\n");
    rprintf("Genie Thermique et Energie\r\n");
}
Esempio n. 8
0
//----- Begin Code ------------------------------------------------------------
int main(void)
{
	// initialize our libraries
	// initialize the UART (serial port)
	uartInit();
	// set the baud rate of the UART for our debug/reporting output
	uartSetBaudRate(9600);
	// set uartSendByte as the output for all rprintf statements
	rprintfInit(uartSendByte);
	// initialize the timer system
	timerInit();
	// initialize vt100 library
	vt100Init();
	vt100ClearScreen();
	// print a little intro message so we know things are working
	rprintf("\r\nWelcome to Servo Test!\r\n");

	// begin servo test
	servoTest();

	return 0;
}
Esempio n. 9
0
//----- Begin Code ------------------------------------------------------------
int main(void)
{
	// initialize our libraries
	// initialize the UART (serial port)
	uartInit();
	// set the baud rate of the UART for our debug/reporting output
	uartSetBaudRate(9600);
	// initialize the timer system
	timerInit();
	// initialize rprintf system
	rprintfInit(uartSendByte);
	// initialize vt100 library
	vt100Init();

	// clear the terminal screen
	vt100ClearScreen();
	
	// run the test
	encoderTest();

	return 0;
}
Esempio n. 10
0
File: main.c Progetto: sndae/b3r1
/*******************************************************************
*		rprintf_test
*******************************************************************/
void rprintf_test(void)
{
    u16 val;
    u08 mydata;
    u08 mystring[10];
    double b;
    u08 small;
    u16 medium;
    u32 big;

    // initialize the UART (serial port)
    uartInit();

    // set the baud rate of the UART for our debug/reporting output
    uartSetBaudRate(38400);

    // initialize rprintf system
    // - use uartSendByte as the output for all rprintf statements
    //   this will cause all rprintf library functions to direct their
    //   output to the uart
    // - rprintf can be made to output to any device which takes characters.
    //   You must write a function which takes an unsigned char as an argument
    //   and then pass this to rprintfInit like this: rprintfInit(YOUR_FUNCTION);
    rprintfInit(uartSendByte);

    // initialize vt100 library
    vt100Init();

    // clear the terminal screen
    vt100ClearScreen();

    while (!(getkey() == 1))		//do the folling block until enter is pressed
    {

        // print a little intro message so we know things are working
        rprintf("\r\nWelcome to rprintf Test!\r\n");

        // print single characters
        rprintfChar('H');
        rprintfChar('e');
        rprintfChar('l');
        rprintfChar('l');
        rprintfChar('o');
        // print a constant string stored in FLASH
        rprintfProgStrM(" World!");
        // print a carriage return, line feed combination
        rprintfCRLF();
        // note that using rprintfCRLF() is more memory-efficient than
        // using rprintf("\r\n"), especially if you do it repeatedly

        mystring[0] = 'A';
        mystring[1] = ' ';
        mystring[2] = 'S';
        mystring[3] = 't';
        mystring[4] = 'r';
        mystring[5] = 'i';
        mystring[6] = 'n';
        mystring[7] = 'g';
        mystring[8] = '!';
        mystring[9] = 0;	// null termination

        // print a null-terminated string from RAM
        rprintfStr(mystring);
        rprintfCRLF();

        // print a section of a string from RAM
        // - start at index 2
        // - print 6 characters
        rprintfStrLen(mystring, 2, 6);
        rprintfCRLF();


        val = 24060;
        mydata = 'L';

        // print a decimal number
        rprintf("This is a decimal number: %d\r\n", val);

        // print a hex number
        rprintf("This is a hex number: %x\r\n", mydata);

        // print a character
        rprintf("This is a character: %c\r\n", mydata);

        // print hex numbers
        small = 0x12;		// a char
        medium = 0x1234;	// a short
        big = 0x12345678;	// a long

        rprintf("This is a 2-digit hex number (char) : ");
        rprintfu08(small);
        rprintfCRLF();

        rprintf("This is a 4-digit hex number (short): ");
        rprintfu16(medium);
        rprintfCRLF();

        rprintf("This is a 8-digit hex number (long) : ");
        rprintfu32(big);
        rprintfCRLF();

        // print a formatted decimal number
        // - use base 10
        // - use 8 characters
        // - the number is signed [TRUE]
        // - pad with '.' periods
        rprintf("This is a formatted decimal number: ");
        rprintfNum(10, 8, TRUE, '.', val);
        rprintfCRLF();

        b = 1.23456;

        // print a floating point number
        // use 10-digit precision

        // NOTE: TO USE rprintfFloat() YOU MUST ENABLE SUPPORT IN global.h
        // use the following in your global.h: #define RPRINTF_FLOAT

        rprintf("This is a floating point number: ");
        rprintfFloat(8, b);
        rprintfCRLF();
    }
}
Esempio n. 11
0
File: main.c Progetto: sndae/b3r1
/*****************************************************************************
 *	Balance -
 *****************************************************************************/
void balance(void)
{
    unsigned long TimerMsWork;

    long int g_bias = 0;
    double x_offset = 532;		//offset value 2.56V * 1024 / 4.93V = 4254
    double q_m = 0.0;
    double int_angle = 0.0;
    double x = 0.0;
    double tilt = 0.0;

    int pwm;

    InitADC();
    init_pwm();

    // initialize the UART (serial port)
    uartInit();

    // set the baud rate of the UART for our debug/reporting output
    uartSetBaudRate(115200);

    // initialize rprintf system
    rprintfInit(uartSendByte);

    // initialize vt100 library
    vt100Init();

    // clear the terminal screen
    vt100ClearScreen();

    TimerMsWork = TimerMsCur();

    DDRB |= (1 << PB0);	// Make B0 an output for LED


    /* as a 1st step, a reference measurement of the angular rate sensor is
     * done. This value is used as offset compensation */

    for (int i=1 ; i<=200; i++) // determine initial value for bias of gyro
    {
        g_bias = g_bias + GetADC(gyro_sensor);
    }

    g_bias = g_bias / 200;


    while (!(getkey() == 1))
    {
        /* insure loop runs at specified Hz */
        while (!TimerCheck(TimerMsWork, (dt_PARAM * 1000) -1))
            ;
        TimerMsWork = TimerMsCur();

        // toggle pin B0 for oscilloscope timings.
        PORTB = PINB ^ (1 << PB0);

        // get rate gyro reading and convert to deg/sec
//		q_m = (GetADC(gyro_sensor) - g_bias) / -3.072;	// -3.07bits/deg/sec (neg. because forward is CCW)
        q_m = (GetADC(gyro_sensor) - g_bias) * -0.3255;	// each bit = 0.3255 /deg/sec (neg. because forward is CCW)
        state_update(q_m);


        // get Accelerometer reading and convert to units of gravity.
//		x = (GetADC(accel_sensor) - x_offset) / 204.9;	// (205 bits/G)
        x = (GetADC(accel_sensor) - x_offset) * 0.00488;	// each bit = 0.00488/G

        // x is measured in multiples of earth gravitation g
        // therefore x = sin (tilt) or tilt = arcsin(x)
        // for small angles in rad (not deg): arcsin(x)=x
        // Calculation of deg from rad: 1 deg = 180/pi = 57.29577951
        tilt = 57.29577951 * (x);
        kalman_update(tilt);

        int_angle += angle * dt_PARAM;

        rprintf("  x:");
        rprintfFloat(8, x);
        rprintf("  angle:");
        rprintfFloat(8, angle);
        rprintf("  rate:");
        rprintfFloat(8, rate);

        // Balance.  The most important line in the entire program.
        //	balance_torque = Kp * (current_angle - neutral) + Kd * current_rate;
        //	rprintf("bal_torq: ");
        //	rprintfFloat(8, balance_torque);
        //	rprintfCRLF();

        //steer_knob = 0;

        // change from current angle to something proportional to speed
        // should this be the abs val of the cur speed or just curr speed?
        //double steer_cmd = (1.0 / (1.0 + Ksteer2 * fabs(current_angle))) * (Ksteer * steer_knob);
        //double steer_cmd = 0.0;

        // Get current rate of turn
        //double current_turn = left_speed - right_speed; //<-- is this correct
        //double turn_accel = current_turn - prev_turn;
        //prev_turn = current_turn;

        // Closed-loop turn rate PID
        //double steer_cmd = KpTurn * (current_turn - steer_desired)
        //					+ KdTurn * turn_accel;
        //					//+ KiTurn * turn_integrated;

        // Possibly optional
        //turn_integrated += current_turn - steer_cmd;

        //	Differential steering
        //left_motor_torque	= balance_torque + steer_cmd; //+ cur_speed + steer_cmd;
        //right_motor_torque	= balance_torque - steer_cmd; //+ cur_speed - steer_cmd;


        // Limit extents of torque demand
        //left_motor_torque = flim(left_motor_torque, -MAX_TORQUE, MAX_TORQUE);
//		if (left_motor_torque < -MAX_TORQUE) left_motor_torque = -MAX_TORQUE;
//		if (left_motor_torque > MAX_TORQUE)  left_motor_torque =  MAX_TORQUE;

        //right_motor_torque = flim(right_motor_torque, -MAX_TORQUE, MAX_TORQUE);
//		if (right_motor_torque < -MAX_TORQUE) right_motor_torque = -MAX_TORQUE;
//		if (right_motor_torque > MAX_TORQUE)  right_motor_torque =  MAX_TORQUE;

        pwm = (int) ((angle -3.5) * Kp) + (rate * Kd); // + (int_angle * Ki);

        rprintf("  pwm:%d\r\n", pwm);

        // Set PWM values for both motors
        SetLeftMotorPWM(pwm);
        SetRightMotorPWM(pwm);
    }
    SetLeftMotorPWM(0);
    SetRightMotorPWM(0);
}