Skip to content
Snippets Groups Projects
Commit 4d34a339 authored by Jake Read's avatar Jake Read
Browse files

microstep

parent 37111b9a
Branches
No related tags found
No related merge requests found
...@@ -16,6 +16,9 @@ is; no warranty is provided, and users accept all liability. ...@@ -16,6 +16,9 @@ is; no warranty is provided, and users accept all liability.
#include "../indicators.h" #include "../indicators.h"
// LUT, 0-1022, 64 entries, sin w/ 511 at midpoint // LUT, 0-1022, 64 entries, sin w/ 511 at midpoint
// full sweep of electrical phase is actually 4 'steps' -
// so making a full step means incrementing 16 times through this LUT,
// half step is 8, quarter step 4, eighth step 2, sixteenth microstepping is one, fin
uint16_t LUT_1022[64] = { uint16_t LUT_1022[64] = {
511,561,611,659,707,752,795,835,872,906,936,962,983,1000,1012,1020, 511,561,611,659,707,752,795,835,872,906,936,962,983,1000,1012,1020,
1022,1020,1012,1000,983,962,936,906,872,835,795,752,707,659,611,561, 1022,1020,1012,1000,983,962,936,906,872,835,795,752,707,659,611,561,
...@@ -104,24 +107,50 @@ void step_a4950_set_cscale(float scale){ ...@@ -104,24 +107,50 @@ void step_a4950_set_cscale(float scale){
step_a4950_publish_currents(); step_a4950_publish_currents();
} }
void step_a4950_set_microstep(uint8_t microstep){
//
}
// step states // step states
boolean _dir = true; // current direction boolean _dir = true; // current direction
boolean _dirInvert = false; // invert directions ? boolean _dirInvert = false; // invert directions ?
uint8_t _microstep_count = MICROSTEP_16_COUNT; // default to 16th microstepping
uint8_t lutptra = 16; // current pt. in microstep phase uint8_t lutptra = 16; // current pt. in microstep phase
uint8_t lutptrb = 0; // A leads B by 1/4 period uint8_t lutptrb = 0; // A leads B by 1/4 period
void step_a4950_set_microstep(uint8_t microstep){
switch(microstep){
case 64:
_microstep_count = MICROSTEP_64_COUNT;
break;
case 32:
_microstep_count = MICROSTEP_32_COUNT;
break;
case 16:
_microstep_count = MICROSTEP_16_COUNT;
break;
case 8:
_microstep_count = MICROSTEP_8_COUNT;
break;
case 4:
_microstep_count = MICROSTEP_4_COUNT;
break;
case 2:
_microstep_count = MICROSTEP_2_COUNT;
break;
case 1:
_microstep_count = MICROSTEP_1_COUNT;
break;
default:
_microstep_count = MICROSTEP_1_COUNT;
break;
}
}
void step_a4950_step(){ void step_a4950_step(){
// step LUT ptrs thru table, // step LUT ptrs thru table, increment and wrap w/ bit logic
if(_dir){ if(_dir){
lutptra ++; if(lutptra >= 64) lutptra = 0; lutptra += _microstep_count; lutptra = lutptra & 0b00111111;
lutptrb ++; if(lutptrb >= 64) lutptrb = 0; lutptrb += _microstep_count; lutptrb = lutptrb & 0b00111111;
} else { } else {
(lutptra == 0) ? lutptra = 63 : lutptra --; lutptra -= _microstep_count; lutptra = lutptra & 0b00111111;
(lutptrb == 0) ? lutptrb = 63 : lutptrb --; lutptrb -= _microstep_count; lutptrb = lutptrb & 0b00111111;
} }
// depending on sign of phase, set up / down on gates // depending on sign of phase, set up / down on gates
if(LUT_1022[lutptra] > 511){ if(LUT_1022[lutptra] > 511){
......
...@@ -17,6 +17,15 @@ is; no warranty is provided, and users accept all liability. ...@@ -17,6 +17,15 @@ is; no warranty is provided, and users accept all liability.
#include <Arduino.h> #include <Arduino.h>
// lol
#define MICROSTEP_64_COUNT 1
#define MICROSTEP_32_COUNT 1
#define MICROSTEP_16_COUNT 1
#define MICROSTEP_8_COUNT 2
#define MICROSTEP_4_COUNT 4
#define MICROSTEP_2_COUNT 8
#define MICROSTEP_1_COUNT 16
// AIN1 PA14 // AIN1 PA14
// AIN2 PA15 // AIN2 PA15
// BIN1 PA05 // BIN1 PA05
......
...@@ -44,15 +44,6 @@ EP_ONDATA_RESPONSES onMicrostepData(uint8_t* data, uint16_t len){ ...@@ -44,15 +44,6 @@ EP_ONDATA_RESPONSES onMicrostepData(uint8_t* data, uint16_t len){
endpoint_t* microstepEp = osapBuildEndpoint("microstep", onMicrostepData); endpoint_t* microstepEp = osapBuildEndpoint("microstep", onMicrostepData);
// -------------------------------------------------------- SPU EP
EP_ONDATA_RESPONSES onSPUData(uint8_t* data, uint16_t len){
// doesn't do anything w/ step-on-tick situation
return EP_ONDATA_ACCEPT;
}
endpoint_t* spuEp = osapBuildEndpoint("SPU", onSPUData, nullptr);
// -------------------------------------------------------- CSCALE DATA // -------------------------------------------------------- CSCALE DATA
EP_ONDATA_RESPONSES onCScaleData(uint8_t* data, uint16_t len){ EP_ONDATA_RESPONSES onCScaleData(uint8_t* data, uint16_t len){
...@@ -117,13 +108,11 @@ void setup() { ...@@ -117,13 +108,11 @@ void setup() {
osapAddEndpoint(axisInvertEp); // 3 osapAddEndpoint(axisInvertEp); // 3
// microstep // microstep
osapAddEndpoint(microstepEp); // 4 osapAddEndpoint(microstepEp); // 4
// SPU
osapAddEndpoint(spuEp); // 5
// cscale // cscale
osapAddEndpoint(cScaleEp); // 6 osapAddEndpoint(cScaleEp); // 5
// homing // homing
osapAddEndpoint(homeEp); // 7 osapAddEndpoint(homeEp); // 6
osapAddEndpoint(homeStateEp); // 8 osapAddEndpoint(homeStateEp); // 7
// step hardware init // step hardware init
step_a4950_init(); step_a4950_init();
} }
......
...@@ -314,15 +314,26 @@ Now I just want to touch up the motor APIs in JS, and add the steps-per-unit adj ...@@ -314,15 +314,26 @@ Now I just want to touch up the motor APIs in JS, and add the steps-per-unit adj
### Power State API ### Power State API
- do need this, and it needs to be part of the 'setup' routine Just a bunch of buttons, turns out to not be so bad. Done.
### New Motor API and JS Config ### New Motor API and JS Config
- check that 'microstep' config does what it claims (?) This should actually be chill... it's working after all, right?
- now ... we need to reconsider how / whomst makes SPU / dir configs, etc
- inversion is per-motor
- so is microstepping
- so is the axis pick
- spu is per-axis in the head
A final treat would be reconfiguring the ucbus-stepper firmware to match this. Another treat would be a tiny demo video for Donny. I'm setting the SPUs in the motion-head now... meaning I could also calculate / guard against max rates there.
\ No newline at end of file
- motion-head things
- steps per unit
- max accels
- max rates
- motor things
- direction inversion
- microstepping
- axis picking
OK I've diffed all that... need to make a microstep update actually do something, then this adventure is over.
11752 / 24584
12520 / 24976
Done, for the time being. Probably needs in-mcu guards against large rates.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment