Ejemplo n.º 1
0
int camera_on(){
    if(!w_init())error("bcm2835 missing");
    sphere_init(stepper_init(RHO_SLEEP,RHO_STEP,RHO_DIR,RHO_M0,RHO_M1,RHO_MODE,RHO_STEPS,"ρ"),
                stepper_init(THETA_SLEEP,THETA_STEP,THETA_DIR,THETA_M0,THETA_M1,THETA_MODE,THETA_STEPS,"θ"),
                stepper_init(PHI_SLEEP,PHI_STEP,PHI_DIR,PHI_M0,PHI_M1,PHI_MODE,PHI_STEPS,"φ"),
                "ο");
    trigger_init("μ");
    camera_init("δ");
}
Ejemplo n.º 2
0
int main()
{
	lcd_init();
	init_push_buttons();
	shaft_encoder_init();
	stepper_init();
	
	while (1) {
		char prog;
		
		lcd_clear();
		prog = wait_button("Choose program:");
		switch (prog) {
			case 1:
				part1();
				break;
			case 2:
				part2();
				break;
			case 3:
				part3(); 
				break;
			default:
				;  // do nothing
		}
	}
}
Ejemplo n.º 3
0
int main() {
  // start up the LCD
  lcd_init();
  fdev_setup_stream(&lcd_stream, lcd_putchar, 0, _FDEV_SETUP_WRITE);
  lcd_home();

  // start up the Analog to Digital Converter
  adc_init();  
  
  // configure the stepper controller
  stepper_init();
  syringe_off();
  
  // start up the serial port
  uart_init();
  fdev_setup_stream(&uart_stream, uart_putchar, uart_getchar, _FDEV_SETUP_RW);
  stdin = stdout = &uart_stream;

  // Initialize state machine
  current_state = STATE_IDLE;
  current_command = COMMAND_NONE;
  current_command_state = CMD_STATE_COMMAND;
  value_str_i = 0;
  target_pressure = 512;

  while(1) {    
    poll();
  } 

  return 0;
}
Ejemplo n.º 4
0
int main()
{
	stepper_init();
	stepper_turn_cw(STEPPER_STEPS_PER_TURN * 2);
	stepper_turn_ccw(STEPPER_STEPS_PER_TURN * 2);
	return 0;
}
Ejemplo n.º 5
0
int main(void)
{
  motor_init();
  //while(1)
  //  rotazione1();
    
  // Initialize system upon power-up.
  serial_init();   // Setup serial baud rate and interrupts

  /*while(true) {
    serial_write('A');
    serial_write('B');
    serial_write('C');
  }*/
  
  //settings_init(); // Load grbl settings from EEPROM
  stepper_init();  // Configure stepper pins and interrupt timers
  system_init();   // Configure pinout pins and pin-change interrupt
  
  memset(&sys, 0, sizeof(sys));  // Clear all system variables
  sys.abort = true;   // Set abort to complete initialization
  //sei(); // Enable interrupts

  // Check for power-up and set system alarm if homing is enabled to force homing cycle
  // by setting Grbl's alarm state. Alarm locks out all g-code commands, including the
  // startup scripts, but allows access to settings and internal commands. Only a homing
  // cycle '$H' or kill alarm locks '$X' will disable the alarm.
  // NOTE: The startup script will run after successful completion of the homing cycle, but
  // not after disabling the alarm locks. Prevents motion startup blocks from crashing into
  // things uncontrollably. Very bad.
  #ifdef HOMING_INIT_LOCK
    if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }
  #endif

  // Grbl initialization loop upon power-up or a system abort. For the latter, all processes
  // will return to this loop to be cleanly re-initialized.
  for(;;) {

    // TODO: Separate configure task that require interrupts to be disabled, especially upon
    // a system abort and ensuring any active interrupts are cleanly reset.
  
    // Reset Grbl primary systems.
    serial_reset_read_buffer(); // Clear serial read buffer
    //spindle_init();
    //coolant_init();
    //limits_init(); 
    //probe_init();
    st_reset(); // Clear stepper subsystem variables.

    // Reset system variables.
    sys.abort = false;
    sys.execute = 0;
          
    // Start Grbl main loop. Processes program inputs and executes them.
    protocol_main_loop();
    
  }
  return 0;   /* Never reached */
}
Ejemplo n.º 6
0
int main(void){
pin_config_out(r_led);

Stepper *stepper_x = stepper_init(x_step,x_dir,motor_enb);
Stepper *stepper_y = stepper_init(y_step,y_dir,motor_enb);
Stepper *stepper_z = stepper_init(z_step,z_dir,motor_enb);
//Stepper *stepper_e = stepper_init(e_step,e_dir,motor_enb);

stepper_dir(stepper_x,1);
stepper_dir(stepper_y,1);
stepper_dir(stepper_z,1);


a1_step = 180;
a2_step = 180;
a3_step = 180;
//distance = 18000*20;
stepper_start_frame();

	while(1);
}
Ejemplo n.º 7
0
static void
robot_stepper_init()
{
  init_seq_heap();
  stepper_init(AT91C_BASE_TC0, AT91C_ID_TC0);
  *AT91C_PIOA_OER = STEPPER_INHIBIT;
  *AT91C_PIOA_MDER = STEPPER_INHIBIT; /*  | STEPPER0_IOMASK; */
  *AT91C_PIOA_CODR = STEPPER_INHIBIT;
  stepper_init_io(1, STEPPER_IOMASK(0), stepper0_steps_acc,
		  stepper0_steps_run, stepper0_steps_hold,
		  (sizeof(stepper0_steps_run) / sizeof(stepper0_steps_run[0])));
  stepper_init_io(0, STEPPER_IOMASK(1), stepper1_steps_acc,
		  stepper1_steps_run, stepper1_steps_hold,
		  (sizeof(stepper1_steps_run) / sizeof(stepper1_steps_run[0])));}
Ejemplo n.º 8
0
void init_all()
{
	sensor_init();
	stepper_init();
	dc_mot_init();
	servo_init();
	pinMode(13,OUTPUT);
	Serial.begin(115200);

	pinMode(12,OUTPUT);
	digitalWrite(12,HIGH);
	pinMode(13,OUTPUT);
	digitalWrite(13,LOW);

}
Ejemplo n.º 9
0
void main (void)
{
	USART_init();	
	USART_enable_rx_interrrupt();
	stepper_init();

	sei();

	char *ptr=0;
	while(true)
	{
		_delay_ms(1000);	
		
		stepx(300);
		stepy(200);
		stepz(STEPS_PER_SEC/4);

		ptr=USART_get_rx_buffer();

		if(ptr)
		{
			USART_transmit_string(ptr);
		}else USART_enable_rx_interrrupt();

//		USART_transmit(USART_receive());	
	/*	
		char * ptr=rxBuffer;
		uint8_t flags=0;
		uint16_t number=0;
		for(;ptr<=rxPtr;ptr++)
		{
			if(!isdigit(*ptr))
			{
				if(flags==1)break;
				continue;
			}
			flags=1;
			number=number*10+(ptr-'0');
			
			//TODO wait for new data
*/
	}
	
//		step(atoi(USART_receive())); // XXX make anything like that
}
Ejemplo n.º 10
0
int main( void ){

	// initialize usart
	usart_init();
	usart_psend(PSTR("usart initialized, initializing stepper motor... "));

	// initialize stepper motor
	stepper_init();
	usart_psend(PSTR("done\n"));
	
	// enable interrupts
	sei();
	
	// loop forever
	while (1){	
		sleep_mode();
	}	
}
Ejemplo n.º 11
0
int main(void)
{
    sys_init();
    leds_init();
    stepper_init();
//    inputs_init();
    usb_init();
    gcode_init();
    temp_init();

    while (1)
    {
        // should go idle...
        Delay(10);

        char buffer[255];
        gets(buffer);

        if (buffer[0] != '\0')
        {
            gcode_parse(buffer);
        }
    }
}
Ejemplo n.º 12
0
int unicorn_init(void)
{
    channel_tag fan = NULL;
    int ret = 0;
    board_info_t board_info; 

	printf("unicorn_init...\n");
    ret = eeprom_read_board_info(EEPROM_DEV, &board_info);
    if (ret < 0) {
        printf("Read eeprom board info failed\n");
        return -1;
    }

    if (!strncasecmp("bbp1s", board_info.name, 5)) {
            bbp_board_type = BOARD_BBP1S;
    } else if(!strncasecmp("bbp1", board_info.name, 4)){
            bbp_board_type = BOARD_BBP1;
    }

	printf("board name:%s, version:%s, get board type:%d \n", board_info.name, board_info.version, bbp_board_type);
    
    /* 
     * Create fifo 
     * fifo_plan2st, fifo_st2plan
     * fifo_plan2gc, fifo_gc2plan
     */
    Fifo_Attrs fAttrs = Fifo_Attrs_DEFAULT;
    hFifo_plan2st = Fifo_create(&fAttrs);
    hFifo_st2plan = Fifo_create(&fAttrs);
    if ((hFifo_st2plan == NULL) ||
        (hFifo_plan2st == NULL)) {
        printf("Create Fifo failed\n");
        return -1;
    }
    
    Pause_Attrs pAttrs = Pause_Attrs_DEFAULT;
    hPause_printing = Pause_create(&pAttrs);
    if (hPause_printing == NULL) { 
        printf("Create pause err\n");
        return -1;
    } else {
        Pause_on(hPause_printing);
    }

    /* set up unicorn system */
    ret = unicorn_setup();
    if (ret < 0) {
        return ret;
    }

    /* init sub systems of unicorn */
    ret = parameter_init(EEPROM_DEV);
    if (ret < 0) {
        printf("parameter_init failed\n");
        return ret;
    }

    ret = analog_init();
    if (ret < 0) {
        printf("analog_init failed\n");
        return ret;
    }

    ret = temp_init();
    if (ret < 0) {
        printf("temp_init failed\n");
        return ret;
    }

    ret = pwm_init();
    if (ret < 0) {
        printf("pwm_init failed\n");
        return ret;
    }

    ret = fan_init();
    if (ret < 0) {
        printf("fan_init failed\n");
        return ret;
    }

    ret = heater_init();
    if (ret < 0) {
        printf("heater_init failed\n");
        return ret;
    }

#ifdef SERVO
    if (bbp_board_type == BOARD_BBP1S) {
		ret = servo_init();
		if (ret < 0) {
			printf("servo_init failed\n");
			return ret;
		}
	}
#endif

    ret = lmsw_init();
    if (ret < 0) {
        printf("lmsw_init failed\n");
        return ret;
    }

    ret = plan_init();
    if (ret < 0) {
        printf("plan_init failed\n");
        return ret;
    }

    ret = stepper_init();
    if (ret < 0) {
        printf("stepper_init failed\n");
        return ret;
    }
    
    ret = gcode_init();
    if (ret < 0) {
        printf("gcode_init failed\n");
        return ret;
    }

    fan = fan_lookup_by_name("fan_3");
    if (fan) {
        fan_set_level(fan, DEFAULT_FAN_MAX_LEVEL);
        fan_enable(fan);
    }

    fan = fan_lookup_by_name("fan_4");
    if (fan) {
        fan_enable(fan);
        fan_set_level(fan, DEFAULT_FAN_MAX_LEVEL);
    }

    fan = fan_lookup_by_name("fan_5");
    if (fan) {
        fan_enable(fan);
        fan_set_level(fan, DEFAULT_FAN_MAX_LEVEL);
    }

    fan = fan_lookup_by_name("fan_6");
    if (fan) {
        fan_enable(fan);
        fan_set_level(fan, DEFAULT_FAN_MAX_LEVEL);
    }
  
	printf("unicorn_init ok!!!\n");
    return ret;
}
Ejemplo n.º 13
0
Archivo: main.c Proyecto: MrSurly/grbl
int main(void)
{
  // Initialize system upon power-up.
  serial_init();   // Setup serial baud rate and interrupts
  settings_init(); // Load Grbl settings from EEPROM
  stepper_init();  // Configure stepper pins and interrupt timers
  system_init();   // Configure pinout pins and pin-change interrupt

  memset(sys_position,0,sizeof(sys_position)); // Clear machine position.
  sei(); // Enable interrupts

  // Initialize system state.
  #ifdef FORCE_INITIALIZATION_ALARM
    // Force Grbl into an ALARM state upon a power-cycle or hard reset.
    sys.state = STATE_ALARM;
  #else
    sys.state = STATE_IDLE;
  #endif
  
  // Check for power-up and set system alarm if homing is enabled to force homing cycle
  // by setting Grbl's alarm state. Alarm locks out all g-code commands, including the
  // startup scripts, but allows access to settings and internal commands. Only a homing
  // cycle '$H' or kill alarm locks '$X' will disable the alarm.
  // NOTE: The startup script will run after successful completion of the homing cycle, but
  // not after disabling the alarm locks. Prevents motion startup blocks from crashing into
  // things uncontrollably. Very bad.
  #ifdef HOMING_INIT_LOCK
    if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }
  #endif

  // Grbl initialization loop upon power-up or a system abort. For the latter, all processes
  // will return to this loop to be cleanly re-initialized.
  for(;;) {

    // Reset system variables.
    uint8_t prior_state = sys.state;
    memset(&sys, 0, sizeof(system_t)); // Clear system struct variable.
    sys.state = prior_state;
    sys.f_override = DEFAULT_FEED_OVERRIDE;  // Set to 100%
    sys.r_override = DEFAULT_RAPID_OVERRIDE; // Set to 100%
    sys.spindle_speed_ovr = DEFAULT_SPINDLE_SPEED_OVERRIDE; // Set to 100%
		memset(sys_probe_position,0,sizeof(sys_probe_position)); // Clear probe position.
    sys_probe_state = 0;
    sys_rt_exec_state = 0;
    sys_rt_exec_alarm = 0;
    sys_rt_exec_motion_override = 0;
    sys_rt_exec_accessory_override = 0;

    // Reset Grbl primary systems.
    serial_reset_read_buffer(); // Clear serial read buffer
    gc_init(); // Set g-code parser to default state
    spindle_init();
    coolant_init();
    limits_init();
    probe_init();
    plan_reset(); // Clear block buffer and planner variables
    st_reset(); // Clear stepper subsystem variables.

    // Sync cleared gcode and planner positions to current system position.
    plan_sync_position();
    gc_sync_position();

    // Print welcome message. Indicates an initialization has occured at power-up or with a reset.
    report_init_message();

    // Start Grbl main loop. Processes program inputs and executes them.
    protocol_main_loop();

  }
  return 0;   /* Never reached */
}
Ejemplo n.º 14
0
int main(void) {

    pin_config_out(g_led);
    pin_config_out(r_led);
    pin_config_out(e_heat);
    pin_config_out(b_heat);
    pin_config_out(buzzer);
    pin_low(buzzer);


    Stepper *stepper_x = stepper_init(x_step,x_dir,motor_enb);
    Stepper *stepper_y = stepper_init(y_step,y_dir,motor_enb);
    Stepper *stepper_z = stepper_init(z_step,z_dir,motor_enb);
//	stepper_start_frame();

    Uart *uart = uart_init();
    console_init();
    thermistor_init();
//	console_prompt();

    pin_config_in(x_stop);

    pin_high(r_led);

    char dir = 1;
    int count = 0;
    unsigned int hit = 0;

    while(1) {

//		dir = pin_get(EXP2);
        stepper_dir(stepper_x,dir);
        stepper_dir(stepper_y,dir);
        stepper_dir(stepper_z,dir);

        if(dir == 1) {
            if(pin_get(x_stop)==0 ) {
                if(hit < 2) {
                    stepper_step(stepper_x);
                    stepper_step(stepper_y);
                    stepper_step(stepper_z);
                    count++;
                }
            } else {
                hit++;
                if(hit < 2) {
                    printf("%i\n",count);
                    printf("HIT!\n");
                    dir = 0;
                    hit = 0;
                }
            }

        }


        if(dir == 0) {
            stepper_step(stepper_x);
            stepper_step(stepper_y);
            stepper_step(stepper_z);
            count--;
            if(count == 0) {
                dir = 1;
            }
        }








        _delay_us(50);

        /*
        			count++;
        			if(count == 1000){
        				pin_toggle(g_led);
        				count = 0;
        			//	pin_toggle(stepper_x->direction);
        			//	pin_toggle(stepper_y->direction);
        			//	pin_toggle(stepper_z->direction);
        			}
        */

    }


}
Ejemplo n.º 15
0
Archivo: main.c Proyecto: sebbra/grbl
int main(void)
{
  // Initialize system upon power-up.
  serial_init();   // Setup serial baud rate and interrupts
  settings_init(); // Load Grbl settings from EEPROM
  stepper_init();  // Configure stepper pins and interrupt timers
  system_init();   // Configure pinout pins and pin-change interrupt

  #ifdef CPU_MAP_CUSTOM_1284p
  	spi_init();
    L6474_init(4);
    L6474_CmdEnableAll();
  #endif
  
  memset(&sys, 0, sizeof(sys));  // Clear all system variables
  sys.abort = true;   // Set abort to complete initialization
  sei(); // Enable interrupts

  
  // Check for power-up and set system alarm if homing is enabled to force homing cycle
  // by setting Grbl's alarm state. Alarm locks out all g-code commands, including the
  // startup scripts, but allows access to settings and internal commands. Only a homing
  // cycle '$H' or kill alarm locks '$X' will disable the alarm.
  // NOTE: The startup script will run after successful completion of the homing cycle, but
  // not after disabling the alarm locks. Prevents motion startup blocks from crashing into
  // things uncontrollably. Very bad.
  #ifdef HOMING_INIT_LOCK
    if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }
  #endif
  
  // Force Grbl into an ALARM state upon a power-cycle or hard reset.
  #ifdef FORCE_INITIALIZATION_ALARM
    sys.state = STATE_ALARM;
  #endif
  
  // Grbl initialization loop upon power-up or a system abort. For the latter, all processes
  // will return to this loop to be cleanly re-initialized.
  for(;;) {

    // TODO: Separate configure task that require interrupts to be disabled, especially upon
    // a system abort and ensuring any active interrupts are cleanly reset.
  
    // Reset Grbl primary systems.
    serial_reset_read_buffer(); // Clear serial read buffer
    gc_init(); // Set g-code parser to default state
    spindle_init();
    coolant_init();
    limits_init(); 
    probe_init();
    plan_reset(); // Clear block buffer and planner variables
    st_reset(); // Clear stepper subsystem variables.

    // Sync cleared gcode and planner positions to current system position.
    plan_sync_position();
    gc_sync_position();

    // Reset system variables.
    sys.abort = false;
    sys_rt_exec_state = 0;
    sys_rt_exec_alarm = 0;
    sys.suspend = false;
          
    // Start Grbl main loop. Processes program inputs and executes them.
    protocol_main_loop();
    
  }
  return 0;   /* Never reached */
}