Skip to content

Commit

Permalink
Merge branch 'master' of github.com:artek/emc2
Browse files Browse the repository at this point in the history
Conflicts:
	src/emc/kinematics/tc.c
  • Loading branch information
yishinli committed Dec 7, 2010
2 parents 2f9ef11 + 6f3507f commit 23c5158
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 32 deletions.
10 changes: 7 additions & 3 deletions src/emc/rs274ngc/gcodemodule.cc
Expand Up @@ -178,7 +178,7 @@ void NURBS_FEED_3D (
// OUTPUT:
// p - Evaluated points, matrix of size (dim,nu)

int d = order-1;
int d = order /* this order is degree not order.*/;//order-1;
int nu = c.size() * 10 + 1; // u.length();
int nc = c.size(), knot_size;
double *N ,*knot,R, X, Y, Z, A , B, C, U, V, W;
Expand All @@ -191,7 +191,7 @@ void NURBS_FEED_3D (
memcpy(cp,&c[0],sizeof(CONTROL_POINT)*c.size());
knot_size = k.size();

if (nc + d == (int)(knot_size - 1)) {
if (nc + d == (int)(knot_size + 1)) {
int s, tmp1;

for (int col(0); col<nu; col++) {
Expand Down Expand Up @@ -290,9 +290,13 @@ void NURBS_FEED_3D (

}
} else {
fprintf(stderr, "inconsistent bspline data, d + columns(c) != length(k) - 1.\n");
/*fprintf(stderr, "inconsistent bspline data, d(%d) + columns(c(%d)) != length(k(%d)) - 1.\n",
d, nc, k);*/
fprintf(stderr, "inconsistent bspline data, d + columns(c) != length(k).\n");
}

fprintf(stderr, "TODO: confirm this case inconsistent bspline data, d(%d) + columns(c(%d)) != length(k(%d)) - 1.\n",
d, nc, knot_size);
free(N);
free(cp);
free(knot);
Expand Down
3 changes: 2 additions & 1 deletion src/emc/rs274ngc/interp_convert.cc
Expand Up @@ -203,7 +203,8 @@ int Interp::convert_nurbs(int mode, block_pointer block, //!< pointer to a block
("Cannot make a NURBS with 0 feedrate"));
}

CHKS((!(block->k_flag)/*&&!(block->d_flag)*/), ("You must specify Knots(K)"));
CHKS(!(((block->k_flag)||(block->d_flag))), ("You must specify Knots(K) or (D)"));

// Find NURBS control point dimention mask
if (axis_mask == 0) {
if (block->x_flag == ON) {
Expand Down
85 changes: 57 additions & 28 deletions src/hal/components/wou_stepgen.c
Expand Up @@ -137,7 +137,7 @@
#include <mailtag.h>
#define MAX_CHAN 8
#define MAX_STEP_CUR 255

#define PLASMA_ON_BIT 0x02
// to disable DP(): #define TRACE 0
#define TRACE 0
#include "dptrace.h"
Expand All @@ -147,7 +147,7 @@ static FILE *dptrace;
#endif

// to disable MAILBOX dump: #define MBOX_LOG 0
#define MBOX_LOG 0
#define MBOX_LOG 1
#if (MBOX_LOG)
static FILE *mbox_fp;
#endif
Expand Down Expand Up @@ -287,6 +287,9 @@ typedef struct {
} gpio_t;

typedef struct {
/* plasma control */
hal_bit_t *thc_enbable;
hal_bit_t *plasma_enable;
/* sync input pins (input to motmod) */
hal_bit_t *sync_in_trigger;
hal_u32_t *sync_in; //
Expand Down Expand Up @@ -443,7 +446,7 @@ static void fetchmail(const uint8_t *buf_head)
);
stepgen += 1; // point to next joint
}
fprintf (mbox_fp, "%10d %10d %10d %10d %10d %10d %10d %10d \n",
fprintf (mbox_fp, "%10d %10d %10d 0x%04X %10d %10d %10d %10d \n",
*(gpio->a_in[0]), original_adc_data, pid_output, din[0],accum, error, cur_vel, req_vel/*,
req_vel >> 20, cur_vel >> 20*/);

Expand Down Expand Up @@ -529,6 +532,9 @@ int rtapi_app_main(void)
#endif
// set mailbox callback function
wou_set_mbox_cb (&w_param, fetchmail);
data[0] = 1; // RISC ON
wou_cmd(&w_param, WB_WR_CMD, (JCMD_BASE | OR32_CTRL), 1, data);

}

if(pulse_type != -1) {
Expand Down Expand Up @@ -865,11 +871,20 @@ static void update_freq(void *arg, long period)
if (data[0] != gpio->prev_out) {
gpio->prev_out = data[0];
// issue a WOU_WRITE while got new GPIO.OUT value
wou_cmd(&w_param, WB_WR_CMD, GPIO_BASE | GPIO_OUT, 1, data);
wou_flush(&w_param);
// check if plasma enabled

/* M63 M62 not actually control this block , add just for in-case*/
if((data[0] & PLASMA_ON_BIT) /* plasma on bit */) {
if(*(machine_control->plasma_enable)) {

wou_cmd(&w_param, WB_WR_CMD, GPIO_BASE | GPIO_OUT, 1, data);
wou_flush(&w_param);
}
} else {

wou_cmd(&w_param, WB_WR_CMD, GPIO_BASE | GPIO_OUT, 1, data);
wou_flush(&w_param);
}
}

/* begin: process position compensation enable */
Expand All @@ -881,22 +896,24 @@ static void update_freq(void *arg, long period)
fprintf(stderr, "position_compensation_en == 2\n");
remove_thc_effect = THC_REMOVE_EFFECT;
} else {
immediate_data = (uint32_t)(*(machine_control->position_compensation_ref));
fprintf(stderr,"position compensation triggered(%d) ref(%d)\n",
*(machine_control->position_compensation_en),immediate_data);

for(j=0; j<sizeof(uint32_t); j++) {
sync_cmd = SYNC_DATA | ((uint8_t *)&immediate_data)[j];
if(*(machine_control->thc_enbable)) {
immediate_data = (uint32_t)(*(machine_control->position_compensation_ref));
fprintf(stderr,"position compensation triggered(%d) ref(%d)\n",
*(machine_control->position_compensation_en),immediate_data);

for(j=0; j<sizeof(uint32_t); j++) {
sync_cmd = SYNC_DATA | ((uint8_t *)&immediate_data)[j];
memcpy(data, &sync_cmd, sizeof(uint16_t));
wou_cmd(&w_param, WB_WR_CMD, (uint16_t) (JCMD_BASE | JCMD_SYNC_CMD),
sizeof(uint16_t), data);
}
sync_cmd = SYNC_PC | SYNC_COMP_EN(*(machine_control->position_compensation_en));
memcpy(data, &sync_cmd, sizeof(uint16_t));
wou_cmd(&w_param, WB_WR_CMD, (uint16_t) (JCMD_BASE | JCMD_SYNC_CMD),
sizeof(uint16_t), data);
}
sync_cmd = SYNC_PC | SYNC_COMP_EN(*(machine_control->position_compensation_en));
memcpy(data, &sync_cmd, sizeof(uint16_t));
wou_cmd(&w_param, WB_WR_CMD, (uint16_t) (JCMD_BASE | JCMD_SYNC_CMD),
sizeof(uint16_t), data);

machine_control->position_compensation_en_flag = *machine_control->position_compensation_en;
machine_control->position_compensation_en_flag = *machine_control->position_compensation_en;
}

}
*(machine_control->position_compensation_en_trigger) = 0;
Expand Down Expand Up @@ -945,10 +962,13 @@ static void update_freq(void *arg, long period)
for (i = 0; i < machine_control->num_sync_out; i++) {
if(((machine_control->prev_out >> i) & 0x01) !=
((*(machine_control->sync_out[i]) & 1))) {

sync_cmd = SYNC_DOUT | SYNC_IO_ID(i) | SYNC_DO_VAL(*(machine_control->sync_out[i]));
memcpy(data, &sync_cmd, sizeof(uint16_t));
wou_cmd(&w_param, WB_WR_CMD, (JCMD_BASE | JCMD_SYNC_CMD),sizeof(uint16_t), data);
if(i==1 /* plasma on bit */ && *(machine_control->plasma_enable)) {
fprintf(stderr,"plasma enabled disable command (%d) send\n",
*(machine_control->sync_out[i]));
sync_cmd = SYNC_DOUT | SYNC_IO_ID(i) | SYNC_DO_VAL(*(machine_control->sync_out[i]));
memcpy(data, &sync_cmd, sizeof(uint16_t));
wou_cmd(&w_param, WB_WR_CMD, (JCMD_BASE | JCMD_SYNC_CMD),sizeof(uint16_t), data);
}
j ++;
}

Expand Down Expand Up @@ -1128,8 +1148,8 @@ static void update_freq(void *arg, long period)
// [bit-1]: SSIF_EN, servo/stepper interface enable
// [bit-2]: RST, reset JCMD_FIFO and JCMD_FSMs
if (*stepgen->enable) {
data[0] = 1; // RISC ON
wou_cmd(&w_param, WB_WR_CMD, (JCMD_BASE | OR32_CTRL), 1, data);
// obsolete: data[0] = 1; // RISC ON
// obsolete: wou_cmd(&w_param, WB_WR_CMD, (JCMD_BASE | OR32_CTRL), 1, data);
data[0] = 2/*3*/; // SVO-ON, WATCHDOG-ON
wou_cmd(&w_param, WB_WR_CMD, (JCMD_BASE | JCMD_CTRL), 1, data);
wou_flush(&w_param);
Expand Down Expand Up @@ -1351,8 +1371,6 @@ static void update_freq(void *arg, long period)
assert(wou_pos_cmd < 8192);
assert(wou_pos_cmd > -8192);
{


// SYNC_JNT: opcode for SYNC_JNT command
// DIR_P: Direction, (positive(1), negative(0))
// POS_MASK: relative position mask
Expand Down Expand Up @@ -1407,7 +1425,6 @@ static void update_freq(void *arg, long period)
wou_cmd(&w_param, WB_WR_CMD, (uint16_t) (JCMD_BASE | JCMD_SYNC_CMD),
sizeof(uint16_t), data);
}

if (fp_cur_vel != machine_control->fp_current_vel) {
// forward current velocity
machine_control->fp_current_vel = fp_cur_vel;
Expand All @@ -1422,8 +1439,6 @@ static void update_freq(void *arg, long period)
memcpy(data, &sync_cmd, sizeof(uint16_t));
wou_cmd(&w_param, WB_WR_CMD, (uint16_t) (JCMD_BASE | JCMD_SYNC_CMD),
sizeof(uint16_t), data);


}
}
#if (TRACE!=0)
Expand Down Expand Up @@ -1822,6 +1837,20 @@ static int export_machine_control(machine_control_t * machine_control)
return retval;
}

/* for plasma control */

retval =
hal_pin_bit_newf(HAL_IN, &(machine_control->thc_enbable), comp_id,
"wou.thc_enable");
if (retval != 0) {
return retval;
}retval =
hal_pin_bit_newf(HAL_IN, &(machine_control->plasma_enable), comp_id,
"wou.plasma_enable");
if (retval != 0) {
return retval;
}


machine_control->num_sync_in = num_sync_in;
machine_control->num_sync_out = num_sync_out;
Expand Down

0 comments on commit 23c5158

Please sign in to comment.