Skip to content

Commit

Permalink
Updated PWM for negative numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
scottalford75 committed Oct 17, 2021
1 parent 2478087 commit 4ebecaf
Show file tree
Hide file tree
Showing 4 changed files with 301 additions and 1 deletion.
125 changes: 125 additions & 0 deletions Firmware/ConfigSamples/SKRv2/config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"Board": "BIGTREETECH SKR v2",
"Modules":[
{
"Thread": "Servo",
"Type": "Reset Pin",
"Comment": "Reset pin",
"Pin": "PC_4"
},
{
"Thread": "Base",
"Type": "Stepgen",
"Comment": "X - Joint 0 step generator",
"Joint Number": 0,
"Step Pin": "PE_2",
"Direction Pin": "PE_1",
"Enable Pin": "PE_3"
},
{
"Thread": "Base",
"Type": "Stepgen",
"Comment": "Y - Joint 1 step generator",
"Joint Number": 1,
"Step Pin": "PD_5",
"Direction Pin": "PD_4",
"Enable Pin": "PD_6"
},
{
"Thread": "Base",
"Type": "Stepgen",
"Comment": "Z - Joint 2 step generator",
"Joint Number": 2,
"Step Pin": "PA_15",
"Direction Pin": "PA_8",
"Enable Pin": "PD_1"
},
{
"Thread": "Base",
"Type": "Stepgen",
"Comment": "E0 - Joint 3 step generator",
"Joint Number": 3,
"Step Pin": "PD_15",
"Direction Pin": "PD_14",
"Enable Pin": "PC_7"
},
{
"Thread": "Servo",
"Type": "Temperature",
"Comment": "Extruder tenperature sensor",
"PV[i]": 0,
"Sensor": "Thermistor",
"Thermistor":
{
"Pin": "0.23",
"beta": 3990,
"r0": 100000,
"t0": 25
}
},
{
"Thread": "Base",
"Type": "RCServo",
"Comment": "RC servo for probe",
"SP[i]": 3,
"Servo Pin": "2.0"
},
{
"Thread": "Servo",
"Type": "Digital Pin",
"Comment": "X min",
"Pin": "PC_1",
"Mode": "Input",
"Data Bit": 0
},
{
"Thread": "Servo",
"Type": "Digital Pin",
"Comment": "X max",
"Pin": "PC_2",
"Mode": "Input",
"Data Bit": 1
},
{
"Thread": "Servo",
"Type": "Digital Pin",
"Comment": "Y min",
"Pin": "PC_3",
"Mode": "Input",
"Data Bit": 2
},
{
"Thread": "Servo",
"Type": "Digital Pin",
"Comment": "Y max",
"Pin": "PA_0",
"Mode": "Input",
"Data Bit": 3
},
{
"Thread": "Servo",
"Type": "Digital Pin",
"Comment": "Z min",
"Pin": "PC_0",
"Mode": "Input",
"Data Bit": 4
},
{
"Thread": "Servo",
"Type": "Digital Pin",
"Comment": "Z max",
"Pin": "PC_15",
"Mode": "Input",
"Data Bit": 5
},
{
"Thread": "Servo",
"Type": "Switch",
"Comment": "Extruder fan switch",
"Pin": "PB_7",
"Mode": "On",
"PV[i]": 0,
"SP": 25.5
}
]
}
173 changes: 173 additions & 0 deletions Firmware/ConfigSamples/SKRv2_TMC2209/config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
{
"Board": "BIGTREETECH SKR v2",
"Modules":[
{
"Thread": "Servo",
"Type": "Reset Pin",
"Comment": "Reset pin",
"Pin": "PC_4"
},
{
"Thread": "Base",
"Type": "Stepgen",
"Comment": "X - Joint 0 step generator",
"Joint Number": 0,
"Step Pin": "PE_2",
"Direction Pin": "PE_1",
"Enable Pin": "PE_3"
},
{
"Thread": "On load",
"Type": "TMC stepper",
"Comment": "X - Joint 0 TMC driver",
"Driver": "2209",
"RX pin": "PE_0",
"RSense": 0.11,
"Current": 800,
"Microsteps": 16,
"Stealth chop": "on",
"Stall sensitivity":0
},
{
"Thread": "Base",
"Type": "Stepgen",
"Comment": "Y - Joint 1 step generator",
"Joint Number": 1,
"Step Pin": "PD_5",
"Direction Pin": "PD_4",
"Enable Pin": "PD_6"
},
{
"Thread": "On load",
"Type": "TMC stepper",
"Comment": "Y - Joint 1 TMC driver",
"Driver": "2209",
"RX pin": "PD_3",
"RSense": 0.11,
"Current": 800,
"Microsteps": 16,
"Stealth chop": "on",
"Stall sensitivity":0
},
{
"Thread": "Base",
"Type": "Stepgen",
"Comment": "Z - Joint 2 step generator",
"Joint Number": 2,
"Step Pin": "PA_15",
"Direction Pin": "PA_8",
"Enable Pin": "PD_1"
},
{
"Thread": "On load",
"Type": "TMC stepper",
"Comment": "Z - Joint 2 TMC driver",
"Driver": "2209",
"RX pin": "PD_0",
"RSense": 0.11,
"Current": 800,
"Microsteps": 16,
"Stealth chop": "on",
"Stall sensitivity":0
},
{
"Thread": "Base",
"Type": "Stepgen",
"Comment": "E0 - Joint 3 step generator",
"Joint Number": 3,
"Step Pin": "PD_15",
"Direction Pin": "PD_14",
"Enable Pin": "PC_7"
},
{
"Thread": "On load",
"Type": "TMC stepper",
"Comment": "E0 - Joint 3 TMC driver",
"Driver": "2209",
"RX pin": "PC_6",
"RSense": 0.11,
"Current": 800,
"Microsteps": 16,
"Stealth chop": "on",
"Stall sensitivity":0
},
{
"Thread": "Base",
"Type": "Stepgen",
"Comment": "E1 - Joint 4 step generator",
"Joint Number": 4,
"Step Pin": "PD_11",
"Direction Pin": "PD_10",
"Enable Pin": "PD_13"
},
{
"Thread": "On load",
"Type": "TMC stepper",
"Comment": "E1 - Joint 4 TMC driver",
"Driver": "2209",
"RX pin": "PD_12",
"RSense": 0.11,
"Current": 800,
"Microsteps": 16,
"Stealth chop": "on",
"Stall sensitivity":0
},
{
"Thread": "Servo",
"Type": "Digital Pin",
"Comment": "X min",
"Pin": "PC_1",
"Mode": "Input",
"Data Bit": 0
},
{
"Thread": "Servo",
"Type": "Digital Pin",
"Comment": "X max",
"Pin": "PC_2",
"Mode": "Input",
"Data Bit": 1
},
{
"Thread": "Servo",
"Type": "Digital Pin",
"Comment": "Y min",
"Pin": "PC_3",
"Mode": "Input",
"Data Bit": 2
},
{
"Thread": "Servo",
"Type": "Digital Pin",
"Comment": "Y max",
"Pin": "PA_0",
"Mode": "Input",
"Data Bit": 3
},
{
"Thread": "Servo",
"Type": "Digital Pin",
"Comment": "Z min",
"Pin": "PC_0",
"Mode": "Input",
"Data Bit": 4
},
{
"Thread": "Servo",
"Type": "Digital Pin",
"Comment": "Z max",
"Pin": "PC_15",
"Mode": "Input",
"Data Bit": 5
},
{
"Thread": "Servo",
"Type": "Switch",
"Comment": "Extruder fan switch",
"Pin": "PB_7",
"Mode": "On",
"PV[i]": 0,
"SP": 25.5
}
]
}
2 changes: 1 addition & 1 deletion Firmware/FirmwareSource/Remora-OS5/.mbed
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ROOT=.
TARGET=LPC1769
TARGET=LPC1768
TARGET_CODE=1010
2 changes: 2 additions & 0 deletions Firmware/FirmwareSource/Remora-OS5/modules/pwm/pwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ void PWM::update()
// update the speed SP
this->SP = *(this->ptrSP);

// ensure SP is within range. LinuxCNC PID can have -ve command value
if (this->SP > 100) this->SP = 100;
if (this->SP < 0) this->SP = 0;

// the SP is as a percentage (%)
// scale the pwm output range (0 - pwmMax) = (0 - 100%)
Expand Down

0 comments on commit 4ebecaf

Please sign in to comment.