/* * Prints the current encoder values */ cmd_status dsc_get_values(cli_ctx *ctx, const char *args) { char buff[36]; char *value; int32_t ra, dec; ra = ctx->ra->read(); dec = ctx->dec->read(); value = EncoderValue(ra, true); sprintf(buff, "%s\t", value); value = EncoderValue(dec, true); strcat(buff, value); ctx->serial->printf("%s\r\n", buff); return E_CMD_OK; }
void ENC_PROCESSING (WHEEL_ENCODER_STRUCT *S) { S->temp[1] = S->temp[0]; S->temp[0] = EncoderValue(S->timer); S->diff = S->temp[0] - S->temp[1]; if (S->diff> 10000) S->diff=(S->temp[0]-0xFFFF)+(S->temp[1]);//overflow while counting down if (S->diff<-10000) S->diff=(0xFFFF-S->temp[1])+(S->temp[0]);//overflow while counting up S->velo_fb = (float)S->diff*(f_s)*60.0f/28056.0f; // RPM = (pulse/28056/dt)*60 // encoder 334 pulses per round*4*21 (gear21)= 28056 S->posi_fb = S->temp[0]/28056.0f; //round }
bool AnalogEncoder::ProcessIntSelf() { int value = EncoderValue(); EncoderState state = pPinInfo->state; if(state == LOW_STATE && value>highThreshold) { pPinInfo->state = HIGH_STATE; counts++; return true; } if(state== HIGH_STATE && value<lowThreshold) { pPinInfo->state = LOW_STATE; counts++; return true; } return false; }