From: Stephen W. P. <swp...@us...> - 2005-11-28 20:21:28
|
Update of /cvsroot/emc/emc2/src/hal/drivers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9562 Modified Files: hal_ppmc.c Log Message: added index sense pins, also fixed some comments Index: hal_ppmc.c =================================================================== RCS file: /cvsroot/emc/emc2/src/hal/drivers/hal_ppmc.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** hal_ppmc.c 28 Nov 2005 06:46:05 -0000 1.6 --- hal_ppmc.c 28 Nov 2005 20:21:19 -0000 1.7 *************** *** 181,185 **** hal_s32_t *count; /* output: unscaled encoder counts */ hal_float_t scale; /* parameter: scale factor */ ! // hal_bit_t *index; /* output: index flag */ signed long oldreading; /* used to detect overflow / underflow of the counter */ } encoder_t; --- 181,185 ---- hal_s32_t *count; /* output: unscaled encoder counts */ hal_float_t scale; /* parameter: scale factor */ ! hal_bit_t *index; /* output: index flag */ signed long oldreading; /* used to detect overflow / underflow of the counter */ } encoder_t; *************** *** 703,706 **** --- 703,708 ---- { int i, byteindex; + hal_u8_t mask = 0x01, indextemp; + union pos_tag { signed long l; *************** *** 713,716 **** --- 715,719 ---- } pos, oldpos; + indextemp = (hal_u8_t)(slot->rd_buf[ENCISR]); byteindex = ENCCNT0; /* first encoder count register */ for (i = 0; i < 4; i++) { *************** *** 729,732 **** --- 732,737 ---- *(slot->encoder[i].count) = pos.l; *(slot->encoder[i].position) = pos.l * slot->encoder[i].scale; + *(slot->encoder[i].index) = (((indextemp & mask) == mask) ? 1 : 0); + mask <<= 1; } } *************** *** 1042,1046 **** ppmc.n.encoder.m.position float ppmc.n.encoder.m.counts s32 ! TODO: ppmc.n.encoder.m.indexflag bit the output value is position=counts * scale --- 1047,1051 ---- ppmc.n.encoder.m.position float ppmc.n.encoder.m.counts s32 ! ppmc.n.encoder.m.index bit the output value is position=counts * scale *************** *** 1085,1089 **** return retval; } ! /* velocity scaling parameter */ rtapi_snprintf(buf, HAL_NAME_LEN, "ppmc.%d.encoder.%02d.position", bus->busnum, bus->last_encoder); --- 1090,1094 ---- return retval; } ! /* scaled encoder position */ rtapi_snprintf(buf, HAL_NAME_LEN, "ppmc.%d.encoder.%02d.position", bus->busnum, bus->last_encoder); *************** *** 1092,1104 **** return retval; } ! /* velocity scaling parameter */ ! rtapi_snprintf(buf, HAL_NAME_LEN, "ppmc.%d.encoder.%02d.count", ! bus->busnum, bus->last_encoder); ! retval = hal_pin_s32_new(buf, HAL_WR, &(slot->encoder[n].count), comp_id); ! if (retval != 0) { ! return retval; ! } ! /* increment number to prepare for next output */ ! bus->last_encoder++; } add_rd_funct(read_encoders, slot, ENCCNT0, ENCCNT3+2); --- 1097,1116 ---- return retval; } ! /* raw encoder position */ ! rtapi_snprintf(buf, HAL_NAME_LEN, "ppmc.%d.encoder.%02d.count", ! bus->busnum, bus->last_encoder); ! retval = hal_pin_s32_new(buf, HAL_WR, &(slot->encoder[n].count), comp_id); ! if (retval != 0) { ! return retval; ! } ! /* encoder index bit */ ! rtapi_snprintf(buf, HAL_NAME_LEN, "ppmc.%d.encoder.%02d.index", ! bus->busnum, bus->last_encoder); ! retval = hal_pin_u8_new(buf, HAL_WR, &(slot->encoder[n].index), comp_id); ! if (retval != 0) { ! return retval; ! } ! /* increment number to prepare for next output */ ! bus->last_encoder++; } add_rd_funct(read_encoders, slot, ENCCNT0, ENCCNT3+2); |