[{"data":1,"prerenderedAt":698},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fmodules\u002Fstepper":3},{"id":4,"title":5,"body":6,"description":691,"extension":692,"meta":693,"navigation":70,"path":694,"seo":695,"stem":696,"__hash__":697},"content\u002Fdocs\u002Fmodules\u002Fstepper.md","Stepper Module",{"type":7,"value":8,"toc":680},"minimark",[9,13,26,31,54,141,145,153,164,168,173,432,436,490,494,594,598,637,641,676],[10,11,5],"h1",{"id":12},"stepper-module",[14,15,16,17,21,22,25],"p",{},"Drive a stepper motor through a step\u002Fdir\u002Fenable driver chip (A4988, DRV8825, TMC2208, etc.). The firmware generates step pulses non-blocking inside ",[18,19,20],"code",{},"device.poll()",", so other modules keep running while the motor moves. When a move completes, an unsolicited ",[18,23,24],{},"done"," event fires with the final position.",[27,28,30],"h2",{"id":29},"firmware-setup","Firmware setup",[32,33,38],"pre",{"className":34,"code":35,"language":36,"meta":37,"style":37},"language-ini shiki shiki-themes github-light github-dark","; platformio.ini\nbuild_flags = -DCONDUYT_MODULE_STEPPER\n","ini","",[18,39,40,48],{"__ignoreMap":37},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,47],{},"; platformio.ini\n",[41,49,51],{"class":43,"line":50},2,[41,52,53],{},"build_flags = -DCONDUYT_MODULE_STEPPER\n",[32,55,59],{"className":56,"code":57,"language":58,"meta":37,"style":37},"language-cpp shiki shiki-themes github-light github-dark","#include \u003CConduyt.h>\n\nConduytSerial transport(Serial, 115200);\nConduytDevice device(\"StepperBot\", \"1.0.0\", transport);\n\nvoid setup() {\n  Serial.begin(115200);\n  device.addModule(new ConduytModuleStepper());\n  device.begin();\n}\n\nvoid loop() {\n  device.poll();\n}\n","cpp",[18,60,61,66,72,78,84,89,95,101,107,113,119,124,130,136],{"__ignoreMap":37},[41,62,63],{"class":43,"line":44},[41,64,65],{},"#include \u003CConduyt.h>\n",[41,67,68],{"class":43,"line":50},[41,69,71],{"emptyLinePlaceholder":70},true,"\n",[41,73,75],{"class":43,"line":74},3,[41,76,77],{},"ConduytSerial transport(Serial, 115200);\n",[41,79,81],{"class":43,"line":80},4,[41,82,83],{},"ConduytDevice device(\"StepperBot\", \"1.0.0\", transport);\n",[41,85,87],{"class":43,"line":86},5,[41,88,71],{"emptyLinePlaceholder":70},[41,90,92],{"class":43,"line":91},6,[41,93,94],{},"void setup() {\n",[41,96,98],{"class":43,"line":97},7,[41,99,100],{},"  Serial.begin(115200);\n",[41,102,104],{"class":43,"line":103},8,[41,105,106],{},"  device.addModule(new ConduytModuleStepper());\n",[41,108,110],{"class":43,"line":109},9,[41,111,112],{},"  device.begin();\n",[41,114,116],{"class":43,"line":115},10,[41,117,118],{},"}\n",[41,120,122],{"class":43,"line":121},11,[41,123,71],{"emptyLinePlaceholder":70},[41,125,127],{"class":43,"line":126},12,[41,128,129],{},"void loop() {\n",[41,131,133],{"class":43,"line":132},13,[41,134,135],{},"  device.poll();\n",[41,137,139],{"class":43,"line":138},14,[41,140,118],{},[27,142,144],{"id":143},"wiring","Wiring",[32,146,151],{"className":147,"code":149,"language":150},[148],"language-text","A4988\u002FDRV8825\u002FTMC2208      Board\n──────                     ─────\nSTEP                    ──► any digital out (e.g. 2)\nDIR                     ──► any digital out (e.g. 3)\nENABLE  (active LOW)    ──► any digital out (e.g. 4) — pass 0xFF to skip\nGND                     ──► GND\nVDD (logic)             ──► 3V3 \u002F 5V depending on board\nVMOT                    ──► motor PSU + (8–35V typical)\nGND_motor               ──► motor PSU −\n1A\u002F1B\u002F2A\u002F2B             ──► motor coils\n","text",[18,152,149],{"__ignoreMap":37},[14,154,155,156,159,160,163],{},"If your driver doesn't expose ENABLE, pass ",[18,157,158],{},"0xFF"," for ",[18,161,162],{},"enPin"," — the firmware will skip touching it. Always set the driver's current limit before powering up the motor or you'll cook either the driver or the coils.",[27,165,167],{"id":166},"host-usage","Host usage",[169,170,172],"h3",{"id":171},"javascript","JavaScript",[32,174,177],{"className":175,"code":176,"language":171,"meta":37,"style":37},"language-javascript shiki shiki-themes github-light github-dark","import { ConduytDevice } from 'conduyt-js'\nimport { SerialTransport } from 'conduyt-js\u002Ftransports\u002Fserial'\nimport { ConduytStepper } from 'conduyt-js\u002Fmodules\u002Fstepper'\n\nconst device = await ConduytDevice.connect(new SerialTransport({ path: '\u003CYOUR_PORT>' }))\nconst stepper = new ConduytStepper(device)\n\nawait stepper.config(2, 3, 4, 200)       \u002F\u002F step, dir, en, stepsPerRev\n\nstepper.onDone((position) => {\n  console.log(`done at position ${position}`)\n})\n\nawait stepper.move(800, 400)             \u002F\u002F 800 steps at 400 Hz\nawait stepper.moveTo(0, 200)             \u002F\u002F home at 200 Hz\n",[18,178,179,196,208,220,224,264,282,286,325,329,353,374,379,383,408],{"__ignoreMap":37},[41,180,181,185,189,192],{"class":43,"line":44},[41,182,184],{"class":183},"szBVR","import",[41,186,188],{"class":187},"sVt8B"," { ConduytDevice } ",[41,190,191],{"class":183},"from",[41,193,195],{"class":194},"sZZnC"," 'conduyt-js'\n",[41,197,198,200,203,205],{"class":43,"line":50},[41,199,184],{"class":183},[41,201,202],{"class":187}," { SerialTransport } ",[41,204,191],{"class":183},[41,206,207],{"class":194}," 'conduyt-js\u002Ftransports\u002Fserial'\n",[41,209,210,212,215,217],{"class":43,"line":74},[41,211,184],{"class":183},[41,213,214],{"class":187}," { ConduytStepper } ",[41,216,191],{"class":183},[41,218,219],{"class":194}," 'conduyt-js\u002Fmodules\u002Fstepper'\n",[41,221,222],{"class":43,"line":80},[41,223,71],{"emptyLinePlaceholder":70},[41,225,226,229,233,236,239,242,246,249,252,255,258,261],{"class":43,"line":86},[41,227,228],{"class":183},"const",[41,230,232],{"class":231},"sj4cs"," device",[41,234,235],{"class":183}," =",[41,237,238],{"class":183}," await",[41,240,241],{"class":187}," ConduytDevice.",[41,243,245],{"class":244},"sScJk","connect",[41,247,248],{"class":187},"(",[41,250,251],{"class":183},"new",[41,253,254],{"class":244}," SerialTransport",[41,256,257],{"class":187},"({ path: ",[41,259,260],{"class":194},"'\u003CYOUR_PORT>'",[41,262,263],{"class":187}," }))\n",[41,265,266,268,271,273,276,279],{"class":43,"line":91},[41,267,228],{"class":183},[41,269,270],{"class":231}," stepper",[41,272,235],{"class":183},[41,274,275],{"class":183}," new",[41,277,278],{"class":244}," ConduytStepper",[41,280,281],{"class":187},"(device)\n",[41,283,284],{"class":43,"line":97},[41,285,71],{"emptyLinePlaceholder":70},[41,287,288,291,294,297,299,302,305,308,310,313,315,318,321],{"class":43,"line":103},[41,289,290],{"class":183},"await",[41,292,293],{"class":187}," stepper.",[41,295,296],{"class":244},"config",[41,298,248],{"class":187},[41,300,301],{"class":231},"2",[41,303,304],{"class":187},", ",[41,306,307],{"class":231},"3",[41,309,304],{"class":187},[41,311,312],{"class":231},"4",[41,314,304],{"class":187},[41,316,317],{"class":231},"200",[41,319,320],{"class":187},")       ",[41,322,324],{"class":323},"sJ8bj","\u002F\u002F step, dir, en, stepsPerRev\n",[41,326,327],{"class":43,"line":109},[41,328,71],{"emptyLinePlaceholder":70},[41,330,331,334,337,340,344,347,350],{"class":43,"line":115},[41,332,333],{"class":187},"stepper.",[41,335,336],{"class":244},"onDone",[41,338,339],{"class":187},"((",[41,341,343],{"class":342},"s4XuR","position",[41,345,346],{"class":187},") ",[41,348,349],{"class":183},"=>",[41,351,352],{"class":187}," {\n",[41,354,355,358,361,363,366,368,371],{"class":43,"line":121},[41,356,357],{"class":187},"  console.",[41,359,360],{"class":244},"log",[41,362,248],{"class":187},[41,364,365],{"class":194},"`done at position ${",[41,367,343],{"class":187},[41,369,370],{"class":194},"}`",[41,372,373],{"class":187},")\n",[41,375,376],{"class":43,"line":126},[41,377,378],{"class":187},"})\n",[41,380,381],{"class":43,"line":132},[41,382,71],{"emptyLinePlaceholder":70},[41,384,385,387,389,392,394,397,399,402,405],{"class":43,"line":138},[41,386,290],{"class":183},[41,388,293],{"class":187},[41,390,391],{"class":244},"move",[41,393,248],{"class":187},[41,395,396],{"class":231},"800",[41,398,304],{"class":187},[41,400,401],{"class":231},"400",[41,403,404],{"class":187},")             ",[41,406,407],{"class":323},"\u002F\u002F 800 steps at 400 Hz\n",[41,409,411,413,415,418,420,423,425,427,429],{"class":43,"line":410},15,[41,412,290],{"class":183},[41,414,293],{"class":187},[41,416,417],{"class":244},"moveTo",[41,419,248],{"class":187},[41,421,422],{"class":231},"0",[41,424,304],{"class":187},[41,426,317],{"class":231},[41,428,404],{"class":187},[41,430,431],{"class":323},"\u002F\u002F home at 200 Hz\n",[169,433,435],{"id":434},"python","Python",[32,437,440],{"className":438,"code":439,"language":434,"meta":37,"style":37},"language-python shiki shiki-themes github-light github-dark","from conduyt import ConduytDevice\nfrom conduyt.transports.serial import SerialTransport\nfrom conduyt.modules import ConduytStepper\n\ndevice = ConduytDevice(SerialTransport('\u003CYOUR_PORT>'))\nawait device.connect()\n\nstepper = ConduytStepper(device, module_id=0)\nawait stepper.config(step_pin=2, dir_pin=3, en_pin=4, steps_per_rev=200)\nawait stepper.move(steps=800, speed_hz=400)\n",[18,441,442,447,452,457,461,466,471,475,480,485],{"__ignoreMap":37},[41,443,444],{"class":43,"line":44},[41,445,446],{},"from conduyt import ConduytDevice\n",[41,448,449],{"class":43,"line":50},[41,450,451],{},"from conduyt.transports.serial import SerialTransport\n",[41,453,454],{"class":43,"line":74},[41,455,456],{},"from conduyt.modules import ConduytStepper\n",[41,458,459],{"class":43,"line":80},[41,460,71],{"emptyLinePlaceholder":70},[41,462,463],{"class":43,"line":86},[41,464,465],{},"device = ConduytDevice(SerialTransport('\u003CYOUR_PORT>'))\n",[41,467,468],{"class":43,"line":91},[41,469,470],{},"await device.connect()\n",[41,472,473],{"class":43,"line":97},[41,474,71],{"emptyLinePlaceholder":70},[41,476,477],{"class":43,"line":103},[41,478,479],{},"stepper = ConduytStepper(device, module_id=0)\n",[41,481,482],{"class":43,"line":109},[41,483,484],{},"await stepper.config(step_pin=2, dir_pin=3, en_pin=4, steps_per_rev=200)\n",[41,486,487],{"class":43,"line":115},[41,488,489],{},"await stepper.move(steps=800, speed_hz=400)\n",[27,491,493],{"id":492},"command-reference","Command reference",[495,496,497,516],"table",{},[498,499,500],"thead",{},[501,502,503,507,510,513],"tr",{},[504,505,506],"th",{},"Command",[504,508,509],{},"ID",[504,511,512],{},"Payload",[504,514,515],{},"Description",[517,518,519,542,560,578],"tbody",{},[501,520,521,525,530,535],{},[522,523,524],"td",{},"Config",[522,526,527],{},[18,528,529],{},"0x01",[522,531,532],{},[18,533,534],{},"step(1) + dir(1) + en(1) + stepsPerRev(2)",[522,536,537,538,541],{},"Configure pins. ",[18,539,540],{},"en=0xFF"," to skip enable line",[501,543,544,547,552,557],{},[522,545,546],{},"Move",[522,548,549],{},[18,550,551],{},"0x02",[522,553,554],{},[18,555,556],{},"steps(4 i32) + speedHz(2)",[522,558,559],{},"Relative move (negative = reverse)",[501,561,562,565,570,575],{},[522,563,564],{},"MoveTo",[522,566,567],{},[18,568,569],{},"0x03",[522,571,572],{},[18,573,574],{},"position(4 i32) + speedHz(2)",[522,576,577],{},"Absolute move to target position",[501,579,580,583,588,591],{},[522,581,582],{},"Stop",[522,584,585],{},[18,586,587],{},"0x04",[522,589,590],{},"(none)",[522,592,593],{},"Halt immediately, position is preserved",[27,595,597],{"id":596},"events","Events",[495,599,600,614],{},[498,601,602],{},[501,603,604,607,609,611],{},[504,605,606],{},"Event",[504,608,509],{},[504,610,512],{},[504,612,613],{},"When",[517,615,616],{},[501,617,618,621,625,630],{},[522,619,620],{},"Done",[522,622,623],{},[18,624,529],{},[522,626,627],{},[18,628,629],{},"position(4 i32)",[522,631,632,633,636],{},"Emitted when a move completes (not on ",[18,634,635],{},"stop()",")",[27,638,640],{"id":639},"notes","Notes",[642,643,644,652,658,661],"ul",{},[645,646,647,648,651],"li",{},"Position is absolute — tracked across moves until you reset it (no command exists for this; power-cycle to zero, or call ",[18,649,650],{},"moveTo(0)"," to home).",[645,653,654,657],{},[18,655,656],{},"speedHz"," is steps-per-second. With 1\u002F16 microstepping and a 200-step\u002Frev motor, 3200 Hz = 1 RPS. Drivers have a maximum step rate per microstep mode — typically 50–200 kHz, well above what most loops achieve.",[645,659,660],{},"The pulse width is fixed at 2 µs HIGH per step. That's safe for every common driver chip.",[645,662,663,664,667,668,671,672,675],{},"Multiple steppers: instantiate ",[18,665,666],{},"ConduytModuleStepper"," once per motor and ",[18,669,670],{},"addModule"," each one. Each appears as its own module ID in ",[18,673,674],{},"HELLO_RESP",".",[677,678,679],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}",{"title":37,"searchDepth":50,"depth":50,"links":681},[682,683,684,688,689,690],{"id":29,"depth":50,"text":30},{"id":143,"depth":50,"text":144},{"id":166,"depth":50,"text":167,"children":685},[686,687],{"id":171,"depth":74,"text":172},{"id":434,"depth":74,"text":435},{"id":492,"depth":50,"text":493},{"id":596,"depth":50,"text":597},{"id":639,"depth":50,"text":640},"Drive a step\u002Fdir\u002Fenable stepper-motor driver — relative or absolute moves, with done-events.","md",{},"\u002Fdocs\u002Fmodules\u002Fstepper",{"title":5,"description":691},"docs\u002Fmodules\u002Fstepper","SyaIVxBr08TXHZq2SqDR95oAu2GEmpjwJOVU6zCokz0",1777412314786]