Modular-Things CoreXY¶
-
Andri Sæmundsson (Fab Lab Reykjavík, Iceland)
-
Yuichi Tamiya (Fab Lab Kannai, Japan)
simple-stepper.ino
#define PIN_LIMIT 29//26
Web UI¶
Modular-Things site¶
Visit on modular-things site
Note
Only Chrome base browser
Connect modular things board to PC¶
Press pair new thing
-> select Serial port -> XIAO RP2040
The available Javascript properties are displayed on the right. If not, press scan
and it will appear
Press rename
to name your "Things"(board)
This name will be used as javascript object name
Open browser’s DevTools console with
- cmd + shift + j (Linux)
- ctrl + shift + j (win)
- command + option + j (mac)
Javascript code¶
// warning: without a powered usb-hub, currentScale > 0.5 are likely to fail
const el = document.createElement("div");
el.style = `
padding: 10px;
`
el.innerHTML = `
<button id="Home"> Home</button>
<p>
<button id="Draw"> DrawSquare</button>
<p>
<button id="DrawStar"> DrawStar</button>
`;
el
.querySelector("#Home")
.addEventListener("click", () => {
goToHome();
})
el
.querySelector("#Draw")
.addEventListener("click", () => {
delay(100);
draw();
})
el
.querySelector("#DrawStar")
.addEventListener("click", () => {
delay(100);
drawStar();
})
render(el);
motorA.setCurrent(1);
motorA.setStepsPerUnit(5);
motorB.setCurrent(1);
motorB.setStepsPerUnit(5);
const machine = createSynchronizer([motorA, motorB]);
machine.setPosition([0, 0]);
//const isAtEndStopX = false;
//console.log(isAtEndStopX);
async function goToHome(){
while(await motorA.getLimitState()){
motorA.velocity(10);
motorB.velocity(10);
}
while(await motorB.getLimitState()){
motorA.velocity(10);
motorB.velocity(-10);
}
motorA.velocity(0);
motorB.velocity(0);
machine.setPosition([0, 0]);
await delay(1000);
goTo(2,2);
machine.setPosition([0, 0]);
await delay(1000);
}
//goToHome();
async function goTo(x,y){
console.log(`Moving to (${x}, ${y})`);
await machine.absolute([-x-y,-x+y]);
}
//Square
var pts = [[50,0],[50,50],[0,50],[0,0]];
//Star
var ptsStar = [[20,10],[30,50],[40,10],[10,40],[50,40],[20,10]];
async function draw(){
for (let i = 0; i < pts.length; i++){
await goTo(pts[i][0], pts[i][1]);
await delay(200);
}
}
async function drawStar(){
for (let i = 0; i < ptsStar.length; i++){
await goTo(ptsStar[i][0], ptsStar[i][1]);
await delay(200);
}
}
Hard ware¶
Stepper motor¶
42BYGH37 From Inventory
Ref. amazon.com
Other parts¶
WIP