void L6470::goTo_DIR(byte dir, long pos) { // Same as GOTO, but with user constrained rotational direction. Xfer(GOTO_DIR); if (pos > 0x3FFFFF) pos = 0x3FFFFF; Xfer((byte)(pos >> 16)); Xfer((byte)(pos >> 8)); Xfer((byte)(pos)); }
int L6470::getStatus() { // Fetch and return the 16-bit value in the STATUS register. Resets // any warning flags and exits any error states. Using GetParam() // to read STATUS does not clear these values. int temp = 0; Xfer(GET_STATUS); temp = Xfer(0)<<8; temp |= Xfer(0); return temp; }
void L6470::goTo(long pos) { // GOTO operates much like MOVE, except it produces absolute motion instead // of relative motion. The motor will be moved to the indicated position // in the shortest possible fashion. Xfer(GOTO); if (pos > 0x3FFFFF) pos = 0x3FFFFF; Xfer((byte)(pos >> 16)); Xfer((byte)(pos >> 8)); Xfer((byte)(pos)); }
void L6470::setMark(long value) { Xfer(MARK); if (value > 0x3FFFFF) value = 0x3FFFFF; if (value < -0x3FFFFF) value = -0x3FFFFF; Xfer((byte)(value >> 16)); Xfer((byte)(value >> 8)); Xfer((byte)(value)); }
void L6470::goUntil(byte act, byte dir, unsigned long spd) { // GoUntil will set the motor running with direction dir (REV or // FWD) until a falling edge is detected on the SW pin. Depending // on bit SW_MODE in CONFIG, either a hard stop or a soft stop is // performed at the falling edge, and depending on the value of // act (either RESET or COPY) the value in the ABS_POS register is // either RESET to 0 or COPY-ed into the MARK register. Xfer(GO_UNTIL | act | dir); if (spd > 0x3FFFFF) spd = 0x3FFFFF; Xfer((byte)(spd >> 16)); Xfer((byte)(spd >> 8)); Xfer((byte)(spd)); }
void L6470::run(byte dir, float spd) { // RUN sets the motor spinning in a direction (defined by the constants // FWD and REV). Maximum speed and minimum speed are defined // by the MAX_SPEED and MIN_SPEED registers; exceeding the FS_SPD value // will switch the device into full-step mode. // The SpdCalc() function is provided to convert steps/s values into // appropriate integer values for this function. unsigned long speedVal = SpdCalc(spd); Xfer(RUN | dir); if (speedVal > 0xFFFFF) speedVal = 0xFFFFF; Xfer((byte)(speedVal >> 16)); Xfer((byte)(speedVal >> 8)); Xfer((byte)(speedVal)); }
void L6470::Step_Clock(byte dir) { // STEP_CLOCK puts the device in external step clocking mode. When active, // pin 25, STCK, becomes the step clock for the device, and steps it in // the direction (set by the FWD and REV constants) imposed by the call // of this function. Motion commands (RUN, MOVE, etc) will cause the device // to exit step clocking mode. Xfer(STEP_CLOCK | dir); }
void L6470::releaseSW(byte act, byte dir) { // Similar in nature to GoUntil, ReleaseSW produces motion at the // higher of two speeds: the value in MIN_SPEED or 5 steps/s. // The motor continues to run at this speed until a rising edge // is detected on the switch input, then a hard stop is performed // and the ABS_POS register is either COPY-ed into MARK or RESET to // 0, depending on whether RESET or COPY was passed to the function // for act. Xfer(RELEASE_SW | act | dir); }
void L6470::SetLowSpeedOpt(boolean enable) { // Enable or disable the low-speed optimization option. If enabling, // the other 12 bits of the register will be automatically zero. // When disabling, the value will have to be explicitly written by // the user with a SetParam() call. See the datasheet for further // information about low-speed optimization. Xfer(SET_PARAM | MIN_SPEED); if (enable) Param(0x1000, 13); else Param(0, 13); }
void L6470::move(long n_step) { // MOVE will send the motor n_step steps (size based on step mode) in the // direction imposed by dir (FWD or REV constants may be used). The motor // will accelerate according the acceleration and deceleration curves, and // will run at MAX_SPEED. Stepping mode will adhere to FS_SPD value, as well. byte dir; if(n_step >= 0) { dir = FWD; } else { dir = REV; } long n_stepABS = abs(n_step); Xfer(MOVE | dir); //set direction if (n_stepABS > 0x3FFFFF) n_step = 0x3FFFFF; Xfer((byte)(n_stepABS >> 16)); Xfer((byte)(n_stepABS >> 8)); Xfer((byte)(n_stepABS)); }
/*执行"nlist"命令(即把指定路径下的所有文件(不包括目录)的信息返回来) 入参:pOutputfile - 信息返回后保存到这个文件里,如果pOutputfile为NULL,则信息直接打印到屏幕 pPath - 指定的路径 nMode - 以文本或二进制模式返回,缺省是二进制模式(文本:'A' ;二进制:'I') 出参:成功返回1,失败返回0 */ int yCFtp::Nlist (const char *pOutputfile, const char *pPath, int nMode) { return Xfer (pOutputfile, pPath, FTPLIB_DIR, nMode); }
/*执行"ls"命令(即把指定路径下的所有文件、目录的信息返回来) 入参:pOutputfile - 信息返回后保存到这个文件里,如果pOutputfile为NULL,则信息直接打印到屏幕 pPath - 指定的路径 nMode - 以文本或二进制模式返回,缺省是二进制模式 出参:成功返回1,失败返回0 */ int yCFtp::Ls (const char *pOutputfile, const char *pPath, int nMode) { return Xfer (pOutputfile, pPath, FTPLIB_DIR_VERBOSE, nMode); }
void L6470::free() { // disengage the motor immediately with no deceleration. Xfer(HARD_HIZ); }
void L6470::goMark() { // GoMark is equivalent to GoTo(MARK), but requires less time to send. // Note that no direction is provided; motion occurs through shortest // path. If a direction is required, use GoTo_DIR(). Xfer(GO_MARK); }
void L6470::softFree() { // Decelerate the motor and disengage Xfer(SOFT_HIZ); }
void L6470::hardStop() { // Stop the motor right away. No deceleration. Xfer(HARD_STOP); }
void L6470::softStop() { // Bring the motor to a halt using the deceleration curve. Xfer(SOFT_STOP); }
void L6470::resetDev() { // Reset device to power up conditions. Equivalent to toggling the STBY // pin or cycling power. Xfer(RESET_DEVICE); }
/*执行"get"命令(从服务器下载某个文件) 入参:pOutputfile - 下载的文件保存在这个文件中 pPath - 要下载的文件 nMode - 以文本或二进制模式下载,缺省是二进制模式 出参:成功返回1,失败返回0 */ int yCFtp::Get (const char *pOutputfile, const char *pPath, int nMode) { return Xfer (pOutputfile, pPath, FTPLIB_FILE_READ, nMode); }
/*执行"put"命令(往服务器上传某个文件) 入参:pOutputfile - 要上传的文件 pPath - 上传的文件保存到服务器的这个文件中 nMode - 以文本或二进制模式上传,缺省是二进制模式 出参:成功返回1,失败返回0 */ int yCFtp::Put (const char *pInputfile, const char *pPath, int nMode) { return Xfer (pInputfile, pPath, FTPLIB_FILE_WRITE, nMode); }
void L6470::setAsHome() { // Sets the ABS_POS register to 0, effectively declaring the current // position to be "HOME". Xfer(RESET_POS); }