好,看了一大段代碼后小結(jié)一下。對(duì)于普通結(jié)構(gòu)來說,G1 每次將新讀取gcode代碼參數(shù)傳遞給prepare_move()函數(shù)中destination數(shù)組以后,prepare_move()就會(huì)將其傳遞到plan_buffer_line()進(jìn)行電機(jī)的運(yùn)動(dòng)。而delta結(jié)構(gòu)呢,就相對(duì)復(fù)雜一點(diǎn),G1命令讀取了gcode代碼參數(shù)后也是傳遞到prepare_move()函數(shù)中destination,然后marlin要計(jì)算目標(biāo)坐標(biāo)與當(dāng)前坐標(biāo)的笛卡爾距離,然后通過固定時(shí)間間隔的方式來將笛卡爾距離分成若干個(gè)小直線,通過這樣的方式來就減少cpu的浮點(diǎn)預(yù)算量,然后再通過calculate_delta函數(shù)來將簡(jiǎn)化后的destination換算成三個(gè)電機(jī)的運(yùn)動(dòng)坐標(biāo),并傳遞到delta中,接下來就是plan_buffer_line()了。
最后!到了最后了!來看看calculate_delta()函數(shù),這個(gè)函數(shù)的主要用途是將打印件的世界坐標(biāo)轉(zhuǎn)換為三個(gè)垂直的電機(jī)軸的運(yùn)動(dòng)坐標(biāo)哦。注意:新的marlin支持SCARA結(jié)構(gòu)的delta,那里也有個(gè)calculate_delta()的函數(shù),不過那個(gè)跟rostock有點(diǎn)差異。所以我們還是看rostock的吧。
void calculate_delta(float cartesian[3])
{
delta[X_AXIS] = sqrt(delta_diagonal_rod_2
- sq(delta_tower1_x-cartesian[X_AXIS])
- sq(delta_tower1_y-cartesian[Y_AXIS])
) + cartesian[Z_AXIS];
delta[Y_AXIS] = sqrt(delta_diagonal_rod_2
- sq(delta_tower2_x-cartesian[X_AXIS])
- sq(delta_tower2_y-cartesian[Y_AXIS])
) + cartesian[Z_AXIS];
delta[Z_AXIS] = sqrt(delta_diagonal_rod_2
- sq(delta_tower3_x-cartesian[X_AXIS])
- sq(delta_tower3_y-cartesian[Y_AXIS])
) + cartesian[Z_AXIS];
/*
SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]);
SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]);
SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]);
SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]);
SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]);
SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]);
*/
}
代碼很簡(jiǎn)單delta是指電機(jī)軸的運(yùn)動(dòng)坐標(biāo),cartesian是指打印件的世界坐標(biāo),從上面的程序來看就是從prepare_move()中經(jīng)過插值簡(jiǎn)化的destination。大伙隨便看一個(gè)軸的換算
delta[X_AXIS] = sqrt(delta_diagonal_rod_2
- sq(delta_tower1_x-cartesian[X_AXIS])
- sq(delta_tower1_y-cartesian[Y_AXIS])
) + cartesian[Z_AXIS];
delta_diagonal_rod_2 是推桿長(zhǎng)的平方
delta_tower1_x 是左前柱的x坐標(biāo)值,是由radius這個(gè)參數(shù)算出來的
delta_tower1_y 是左前柱的y坐標(biāo)值,是由radius這個(gè)參數(shù)算出來的
具體怎么算就看下面這個(gè)函數(shù)
void recalc_delta_settings(float radius, float diagonal_rod)
{
delta_tower1_x= -SIN_60*radius; // front left tower
delta_tower1_y= -COS_60*radius;
delta_tower2_x= SIN_60*radius; // front right tower
delta_tower2_y= -COS_60*radius;
delta_tower3_x= 0.0; // back middle tower
delta_tower3_y= radius;
delta_diagonal_rod_2= sq(diagonal_rod);
}
好了回顧一下marlin的delta機(jī)型參數(shù)是需要什么?
推桿的長(zhǎng)度、電機(jī)軸上滑塊的寬度、噴頭支架的寬度,還有三個(gè)電機(jī)的圓半徑。對(duì)不對(duì)?忘了?!不要緊,給你看看代碼
//=================================================================
//========================Delta Settings =============================
//=================================================================
// Enable DELTA kinematics and most of the default configuration for Deltas
#define DELTA
// Make delta curves from many straight lines (linear interpolation).
// This is a trade-off between visible corners (not enough segments)
// and processor overload (too many expensive sqrt calls).
#define DELTA_SEGMENTS_PER_SECOND 200
// NOTE NB all values for DELTA_* values MUST be floating point, so always have a decimal point in them
// Center-to-center distance of the holes in the diagonal push rods.
#define DELTA_DIAGONAL_ROD 250.0 // mm //桿長(zhǎng)
// Horizontal offset from middle of printer to smooth rod center.
#define DELTA_SMOOTH_ROD_OFFSET 175.0 // mm //電機(jī)軸的圓半徑
// Horizontal offset of the universal joints on the end effector.
#define DELTA_EFFECTOR_OFFSET 33.0 // mm // 裝噴嘴的平臺(tái)的中心到桿連接處的距離
// Horizontal offset of the universal joints on the carriages.
#define DELTA_CARRIAGE_OFFSET 18.0 // mm //電機(jī)軸滑塊的距離
// Effective horizontal distance bridged by diagonal push rods.
#define DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET-DELTA_EFFECTOR_OFFSET-DELTA_CARRIAGE_OFFSET)
通過上述的參數(shù)可以算出一個(gè)DELTA_RADIUS ,這個(gè)delta_radius就是上面“delta_tower1_x 是左前柱的x坐標(biāo)值,是由radius這個(gè)參數(shù)算出來的 ”里面的radius了。
至此所有有關(guān)與delta的運(yùn)動(dòng)的代碼已經(jīng)通讀了一遍。下面就開始分析分析代碼和運(yùn)動(dòng)的關(guān)系了。
Delta3D打印機(jī)代碼解讀及調(diào)機(jī)心得(一)
Delta3D打印機(jī)代碼解讀及調(diào)機(jī)心得(二)
Delta3D打印機(jī)代碼解讀及調(diào)機(jī)心得(四) |
|
你可能喜歡
最新《Nature》:動(dòng)態(tài)界面3D打印
石墨烯增強(qiáng)混凝土能否推動(dòng)可持續(xù)建筑? UVA
杜克大學(xué):新型無溶劑3D打印材料,可用于醫(yī)
超強(qiáng)金屬3D打印合金問世:為太空探索打造極
推薦課程
神奇的3D打印
SLA3D打印工藝全套培訓(xùn)課程 - 軟件篇
3D打印月球燈視頻教程 包括完整貼圖建模流
【原創(chuàng)發(fā)布】Cura軟件修改二次開發(fā)定制視頻