Project

General

Profile

Differences mbed.org project, and git project for laser f... ยป differences.diff

markp, 2012-09-27 23:42

View differences:

laser/LaosMotion/LaosMotion.cpp
PwmOut pwm(p22); // O1: PWM (Yellow)
DigitalOut laser_enable(p21); // O2: enable laser
DigitalOut o3(p6); // 03: NC
DigitalOut *laser = NULL; // O4: (p5) LaserON (White)
DigitalOut laser(p5); // O4: (p5) LaserON (White)
// Analog in/out (cover sensor) + NC
DigitalIn cover(p19);
......
#endif
pwm.period(1.0 / cfg->pwmfreq);
pwm = cfg->pwmmin/100.0;
if ( laser == NULL ) laser = new DigitalOut(LASER_PIN);
*laser = LASEROFF;
mark_speed = cfg->speed;
//start.mode(PullUp);
......
{
step = command = xstep = xdir = ystep = ydir = zstep = zdir = 0;
ofsx = ofsy = ofsz = 0;
*laser = LASEROFF;
laser = LASEROFF;
enable = cfg->enable;
cover.mode(PullUp);
}
......
**/
void LaosMotion::write(int i)
{
static int x=0,y=0,z=0,power=10000;
static int x,y,z,power=10000;
//if ( plan_queue_empty() )
//printf("Empty\n");
if ( step == 0 )
......
case 2:
action.target.y = i/1000.0;;
step=0;
action.target.z = 0;
action.param = power;
action.ActionType = (command ? AT_LASER : AT_MOVE);
if ( bitmap_enable && action.ActionType == AT_LASER)
......
switch(step)
{
case 1:
step = 0;
z = action.target.z = i/1000.0;;
action.param = power;
action.ActionType = AT_MOVE;
action.target.feed_rate = 60.0 * cfg->speed;
plan_buffer_line(&action);
z = i;
step = 0;
break;
}
case 4: // set x,y,z (absolute)
......
}
else // copy data
{
if ( step-2 == bitmap_size ) // last dword received
if ( step-2 == bitmap_size )
{
step = 0;
printf("Bitmap: received %d dwords\n\r", bitmap_size);
......
laser/LaosMotion/grbl/stepper.c
{
xdir = ( (direction_bits & (1<<X_DIRECTION_BIT))? 0 : 1 );
ydir = ( (direction_bits & (1<<Y_DIRECTION_BIT))? 0 : 1 );
zdir = ( (direction_bits & (1<<Z_DIRECTION_BIT))? 0 : 1 );
// zdir = ( (direction_bits & (1<<Z_DIRECTION_BIT))?0:1);
// edir = ( (direction_bits & (1<<E_DIRECTION_BIT))?0:1);
}
......
{
xstep = ( (bits & (1<<X_STEP_BIT))?1:0 );
ystep = ( (bits & (1<<Y_STEP_BIT))?1:0 );
zstep = ( (bits & (1<<Z_STEP_BIT))?1:0 );
// zstep = ( (bits & (1<<Z_STEP_BIT))?1:0 );
// estep = ( (bits & (1<<E_STEP_BIT))?1:0 );
}
......
xstep =( (step_inv & (1<<X_STEP_BIT)) ? 1 : 0 );
ystep =( (step_inv & (1<<Y_STEP_BIT)) ? 1 : 0 );
zstep =( (step_inv & (1<<Z_STEP_BIT)) ? 0 : 1 );
// zstep =( (step_inv & (1<<Z_STEP_BIT)) ? 0 : 1 );
// estep =( (step_inv & (1<<E_STEP_BIT)) ? 0 : 1 );
}
......
timer.detach();
running = 0;
clear_all_step_pins();
*laser = LASEROFF;
laser = LASEROFF;
pwm = cfg->pwmmax / 100.0; // set pwm to max;
//printf("idle()..\n");
}
......
{
if ( current_block->options & OPT_BITMAP )
{
*laser = ! (bitmap[pos_l / 32] & (1 << (pos_l % 32)));
laser = ! (bitmap[pos_l / 32] & (1 << (pos_l % 32)));
counter_l += bitmap_width;
// printf("%d %d %d: %d\n\r", bitmap_len, pos_l, counter_l, (bitmap[pos_l / 32] & (pos_l % 32) ? 1 : 0 ) );
if (counter_l > 0)
......
}
else
{
*laser = ( current_block->options & OPT_LASER_ON ? LASERON : LASEROFF);
laser = ( current_block->options & OPT_LASER_ON ? LASERON : LASEROFF);
}
if (current_block->action_type == AT_MOVE)
......
while(plan_get_current_block()) { sleep_mode(); }
}
laser/LaosMotion/pins.h
extern PwmOut pwm; // O1: PWM (Yellow)
extern DigitalOut laser_enable; // O2: enable laser
extern DigitalOut o3; // 03: NC
#define LASER_PIN p5 // note: we define the laser pin here and do not allocate the laser DigitalOut()
extern DigitalOut *laser; // O4: LaserON (White), do not statically allocte: because this will cause the laser to switch on at reboot
extern DigitalOut laser; // O4: LaserON (White)
// Analog in/out (cover sensor) + NC
laser/main.cpp
if ( cfg->autohome )
{
printf("WAIT FOR COVER...\n");
printf("HOME...\n");
wait(1);
mnu->SetScreen("HOME....");
// Start homing
mnu->SetScreen("WAIT FOR COVER....");
//if ( cfg->waitforstart )
while ( !mot->isStart() );
mnu->SetScreen("HOME....");
printf("HOME...\n");
while ( !mot->isStart() );
mot->home(cfg->xhome,cfg->yhome, cfg->zhome);
// if ( !mot->isHome ) exit(1);
printf("HOME DONE. (%d,%d, %d)\n",cfg->xhome,cfg->yhome,cfg->zhome);
    (1-1/1)