Skip to content

Modular-Things CoreXY

  • Andri Sæmundsson (Fab Lab Reykjavík, Iceland)

  • Yuichi Tamiya (Fab Lab Kannai, Japan)

Board

This board is based on Quentin’s WS in Bhutan and modified for fabable.

Alt text
Alt text Alt text
Alt text Alt text
Alt text Alt text
ATTENTION! The orientation of the H-bridge is 180 degrees different.
Download Fusion360 Electronics file Download Library
XiaoRP2040_SMD_vertical_pinsocket
TB67H45FNG-FAB
S4B-XH-SM4_FAB

BOM

Part Count Info
Xiao RP2040 1
H-Bridge TB67H451FNG 2
0.1uF 1206 2
1uF 1206 2
10uF 1206 2
0.25R 1206 2
120R 1206 2
1x7 SMD Vertical Pinsocket 2
S4B-XH-SM4-TB
or
1x4 SMD Pinheader
1
1x2 SMD Pinheader 1

Firmware(Arduino)

Install OSAP library

  • https://github.com/jakeread/osap-arduino -> Code -> Download ZIP
  • Include Library -> Add .ZIP Library

Set up Board Manager

  • Ref. Earle F. Philhower, the Third's PICO build

  • Additional Boards Manager URLs: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

  • Tools->Boards->Board Manager
    Type "pico" in the search box and select "Add": Rp2040

Arduino Code

Download from Quentin’s WS

Change pin assign

Note

This is original modular-things repo

Alt text

.  
├── firmware  
│   └── simple-stepper  
│       ├── motionStateMachine.cpp  
│       ├── motionStateMachine.h  
│       ├── simple-stepper.ino  
│       ├── stepperDriver.cpp  
│       └── stepperDriver.h  
stepperDriver.cpp
#define AIN1_PIN 7//6
#define AIN2_PIN 0//7
#define BIN1_PIN 2//28
#define BIN2_PIN 4//4
#define APWM_PIN 6//27
#define BPWM_PIN 3//29

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
Alt text

Press rename to name your "Things"(board)
This name will be used as javascript object name
Alt text

Open browser’s DevTools console with

  • cmd + shift + j (Linux)
  • ctrl + shift + j (win)
  • command + option + j (mac)

Alt text

Javascript code

Alt text

// 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
Alt text
Alt text

Other parts

WIP