Skip to content

Commit

Permalink
Changed pin config for cnc shield (issue #27)
Browse files Browse the repository at this point in the history
  • Loading branch information
fehlfarbe committed Jan 23, 2024
1 parent 9892717 commit 56c67de
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 6 deletions.
22 changes: 20 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,23 @@ extends = env:promicro16, debug
[env:uno_cnc_shield]
board = uno
extends = env:A4988driver
build_flags = -DPIN_DRIVER_SLEEP=8 -DPIN_DRIVER_DIR=5 -DPIN_DRIVER_STEP=2 -DONE_WIRE_BUS=3 -DBTN_OUT=4
upload_port = /dev/ttyACM0
build_flags =
-DUSE_DRIVER
# using x-header
-DPIN_DRIVER_SLEEP=8
-DPIN_DRIVER_DIR=5
-DPIN_DRIVER_STEP=2
-DPIN_DRIVER_SLEEP_INVERTED=true
# Connect temp sensor to CodeEn
-DONE_WIRE_BUS=A3
# Connect buttons to Z/Y limit switch
-DBTN_IN=10
-DBTN_OUT=11
# Connect speed poti to Abort
-D BTN_POTI_SPEED=A0
# enable debug, RX/TX on Hold/Resume
-DDEBUG
-DDEBUG_RX=A1
-DDEBUG_TX=A2
upload_port = /dev/ttyACM0
monitor_port = /dev/ttyUSB0
44 changes: 40 additions & 4 deletions src/arduino-motorfocus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,66 @@
#include <TimerOne.h>
#include "DummySerial.h"

// button and button speed config
#ifndef BTN_IN
#define BTN_IN 7
#endif
#ifndef BTN_OUT
#define BTN_OUT 8
#endif
#ifndef BTN_POTI_SPEED
#define BTN_POTI_SPEED A0
#endif

#define BTN_MIN_SPEED 8
#define BTN_MAX_SPEED 512
#define BTN_ACCEL_FACTOR 1.05f

// driver config
#ifndef PIN_DRIVER_SLEEP
#define PIN_DRIVER_SLEEP 4
#endif

#ifndef PIN_DRIVER_DIR
#define PIN_DRIVER_DIR 3
#endif
#ifndef PIN_DRIVER_STEP
#define PIN_DRIVER_STEP 5
#endif

#ifndef PIN_DRIVER_SLEEP_INVERTED
#define PIN_DRIVER_SLEEP_INVERTED false
#endif

#ifndef PIN_DRIVER_DIR_INVERTED
#define PIN_DRIVER_DIR_INVERTED false
#endif

#ifndef PIN_DRIVER_STEP_INVERTED
#define PIN_DRIVER_STEP_INVERTED false
#endif

// one wire bus / temperature sensor config
#ifndef ONE_WIRE_BUS
#define ONE_WIRE_BUS 2
#endif

#define PERIOD_US 2000


// Maximum motor speed multiplicator in steps per second
#define SPEED_MULTIPLICATOR 30
// Motor acceleration in steps per second per second
#define ACCELERATION 100

// #define USE_DRIVER

// #define DEBUG
#ifndef DEBUG_RX
#define DEBUG_RX A1
#endif
#ifndef DEBUG_TX
#define DEBUG_TX A2
#endif
#ifdef DEBUG
SoftwareSerial debugSerial(9, 10);
SoftwareSerial debugSerial(DEBUG_RX, DEBUG_TX);
#else
DummySerial debugSerial;
#endif
Expand Down Expand Up @@ -90,6 +125,7 @@ void setup()
#ifdef USE_DRIVER
debugSerial.println("Using A4988 driver");
stepper.setEnablePin(PIN_DRIVER_SLEEP);
stepper.setPinsInverted(PIN_DRIVER_DIR_INVERTED, PIN_DRIVER_STEP_INVERTED, PIN_DRIVER_SLEEP_INVERTED);
stepper.disableOutputs();
isEnabled = false;
#endif
Expand Down

0 comments on commit 56c67de

Please sign in to comment.