Skip to content

Commit

Permalink
Merge branch 'feature/mecha-e1' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
laurb9 committed Sep 27, 2020
2 parents b64c372 + 5759788 commit 2d02707
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
5 changes: 3 additions & 2 deletions examples/PanoController/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
#define VCC 3300
// R1/R2 is the voltage divisor in Ω (GND-R1-A0-R2-Vin)
// measure resistors and enter actual values for a more accurate voltage
#define BATT_R1 9980
#define BATT_R2 46500
#define BATT_R1 7060
#define BATT_R2 42600

// MPU (accel/gyro)
#define MPU_I2C_ADDRESS 0x68

#include "platform_gigapan.h"
#include "platform_panocontroller_v4.h"
#include "platform_mecha_e1.h"
#ifndef MOTOR_STEPS
#warning "Missing PLATFORM_ setting, default to PLATFORM_GIGAPAN"
#define PLATFORM_GIGAPAN
Expand Down
18 changes: 18 additions & 0 deletions examples/PanoController/platform_mecha_e1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#if defined PLATFORM_MECHA_E1
/*
* Nodal Ninja Mecha E1
* Motors ??, 9-28V
* Identical lower and upper units, integrated driver with preset 32 microstep
*/
#define MOTOR_STEPS 200
#define MICROSTEPS 32
// max RPM
#define MOTOR_RPM 480
// max acceleration/deceleration in steps/sec^2
#define MOTOR_ACCEL 10000
#define MOTOR_DECEL 10000

#define HORIZ_GEAR_RATIO 37.7f
#define VERT_GEAR_RATIO 37.7f

#endif // PLATFORM_MECHA_E1
4 changes: 3 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ lib_deps =
adafruit/Adafruit GFX Library@^1.10.1
adafruit/Adafruit BusIO@^1.4.2
build_flags =
-D PLATFORM_PANOCONTROLLER_V4
-D PLATFORM_MECHA_E1
; -D PLATFORM_PANOCONTROLLER_V4
; -D PLATFORM_GIGAPAN

[env:adafruit_feather_m0]
platform = atmelsam
Expand Down
15 changes: 8 additions & 7 deletions src/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,13 @@ void GCode::execute(char buffer[]){

void GCode::move(Motion motion, Coords coords, Position& current, Position& target){
if (coords == Coords::RELATIVE){
motors.rotate(target.a * horiz_gear_ratio, target.c * vert_gear_ratio);
motors.rotate(target.a * horiz_gear_ratio, 0.0);
motors.rotate(0.0, target.c * vert_gear_ratio);
current.a += target.a;
current.c += target.c;
} else {
motors.rotate((target.a - current.a) * horiz_gear_ratio,
(target.c - current.c) * vert_gear_ratio);
motors.rotate((target.a - current.a) * horiz_gear_ratio, 0.0);
motors.rotate(0.0, (target.c - current.c) * vert_gear_ratio);
current.a = target.a;
current.c = target.c;
};
Expand All @@ -283,8 +284,8 @@ void GCode::move(Motion motion, Coords coords, Position& current, Position& targ
* Set acceleration
*/
void GCode::setAccel(float horiz_plat_accel, float vert_plat_accel){
horiz_accel = min(max_accel, motorAccel(horiz_plat_accel, horiz_motor.getSteps(), horiz_gear_ratio));
vert_accel = min(max_accel, motorAccel(vert_plat_accel, vert_motor.getSteps(), vert_gear_ratio));
horiz_accel = min(max_accel, (short) motorAccel(horiz_plat_accel, horiz_motor.getSteps(), horiz_gear_ratio));
vert_accel = min(max_accel, (short) motorAccel(vert_plat_accel, vert_motor.getSteps(), vert_gear_ratio));
horiz_decel = horiz_accel;
vert_decel = vert_accel;
}
Expand All @@ -305,8 +306,8 @@ void GCode::setSpeed(Speed speed, short horiz_speed, short vert_speed){
case Speed::CONSTANT:
horiz_motor.setSpeedProfile(Motor::CONSTANT_SPEED);
vert_motor.setSpeedProfile(Motor::CONSTANT_SPEED);
horiz_motor.setRPM(min(horiz_rpm, max_horiz_rpm/10));
vert_motor.setRPM(min(vert_rpm, max_vert_rpm/10));
horiz_motor.setRPM(min(horiz_rpm, (short) (max_horiz_rpm/10)));
vert_motor.setRPM(min(vert_rpm, (short) (max_vert_rpm/10)));
break;
}
}

0 comments on commit 2d02707

Please sign in to comment.