Commit eb56baf3 authored by Jake Read's avatar Jake Read
Browse files

ucbus onPacketARx delivers ptr to buffer

parent c488d533
......@@ -9,17 +9,17 @@ AutoSaveProject=1
UsedLibrary="C:/Dropbox/CBA/circuits/eagle/parts/SparkFun-Eagle-Libraries/SparkFun-Connectors.lbr"
[Win_1]
Type="Schematic Editor"
Number=1
File="2020-06_ucbus-stepper-melted.sch"
View="9.34921 -34.902 472.865 217.161"
WireWidths=" 0.0762 0.1016 0.127 0.15 0.2 0.2032 0.254 0.3048 0.4064 0.508 0.6096 0.8128 1.016 1.27 2.54 0.1524"
Type="Board Editor"
Number=2
File="2020-06_ucbus-stepper-melted.brd"
View="5.49378 14.1697 12.3852 21.4832"
WireWidths=" 0.8 0.9 0.1 0.05 0.5 0 0.3 0.2032 0.1524"
PadDiameters=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
PadDrills=" 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.65 0.7 0.75 0.8 0.85 0.9 1 0.6"
ViaDiameters=" 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1 1.05 1.1 1.15 1.2 1.3 0"
ViaDrills=" 0.2 0.25 0.3 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35"
ViaDrills=" 0.2 0.25 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35 0.4 0.3"
HoleDrills=" 0.2 0.25 0.3 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35"
TextSizes=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.778"
TextSizes=" 0.254 0.3048 0.4064 0.6096 0.8128 1.27 1.4224 1.6764 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.778 1.016"
PolygonSpacings=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.27"
PolygonIsolates=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
MiterRadiuss=" 0.254 0.3175 0.635 1.27 2.54 1 2 2.5 5 7.5 10 0"
......@@ -28,14 +28,14 @@ DimensionExtWidths=" 0.127 0.254 0.1 0.13 0.26 0"
DimensionExtLengths=" 1.27 2.54 1 2 3 0"
DimensionExtOffsets=" 1.27 2.54 1 2 3 0"
SmdSizes=" 0.3048 0.1524 0.4064 0.2032 0.6096 0.3048 0.8128 0.4064 1.016 0.508 1.27 0.6604 1.4224 0.7112 1.6764 0.8128 1.778 0.9144 1.9304 0.9652 2.1844 1.0668 2.54 1.27 3.81 1.9304 5.08 2.54 6.4516 3.2512 1.27 0.635"
WireBend=0
WireBendSet=31
WireBend=3
WireBendSet=0
WireCap=1
MiterStyle=1
PadShape=0
ViaShape=1
PolygonPour=0
PolygonRank=0
PolygonRank=4
PolygonThermals=1
PolygonOrphans=0
TextRatio=8
......@@ -50,22 +50,20 @@ SwapLevel=0
ArcDirection=0
AddLevel=2
PadsSameType=0
Layer=91
Views=" 1: 9.34921 -34.902 472.865 217.161"
Sheet="1"
Layer=15
[Win_2]
Type="Board Editor"
Number=2
File="2020-06_ucbus-stepper-melted.brd"
View="15.3304 3.43831 50.8884 41.1746"
WireWidths=" 0.8 0.9 0.1 0.05 0.5 0 0.3 0.2032 0.1524"
Type="Schematic Editor"
Number=1
File="2020-06_ucbus-stepper-melted.sch"
View="148.076 60.2009 334.352 161.499"
WireWidths=" 0.0762 0.1016 0.127 0.15 0.2 0.2032 0.254 0.3048 0.4064 0.508 0.6096 0.8128 1.016 1.27 2.54 0.1524"
PadDiameters=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
PadDrills=" 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.65 0.7 0.75 0.8 0.85 0.9 1 0.6"
ViaDiameters=" 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1 1.05 1.1 1.15 1.2 1.3 0"
ViaDrills=" 0.2 0.25 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35 0.4 0.3"
ViaDrills=" 0.2 0.25 0.3 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35"
HoleDrills=" 0.2 0.25 0.3 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35"
TextSizes=" 0.254 0.3048 0.4064 0.6096 0.8128 1.27 1.4224 1.6764 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.778 1.016"
TextSizes=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.778"
PolygonSpacings=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.27"
PolygonIsolates=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
MiterRadiuss=" 0.254 0.3175 0.635 1.27 2.54 1 2 2.5 5 7.5 10 0"
......@@ -74,14 +72,14 @@ DimensionExtWidths=" 0.127 0.254 0.1 0.13 0.26 0"
DimensionExtLengths=" 1.27 2.54 1 2 3 0"
DimensionExtOffsets=" 1.27 2.54 1 2 3 0"
SmdSizes=" 0.3048 0.1524 0.4064 0.2032 0.6096 0.3048 0.8128 0.4064 1.016 0.508 1.27 0.6604 1.4224 0.7112 1.6764 0.8128 1.778 0.9144 1.9304 0.9652 2.1844 1.0668 2.54 1.27 3.81 1.9304 5.08 2.54 6.4516 3.2512 1.27 0.635"
WireBend=3
WireBendSet=0
WireBend=0
WireBendSet=31
WireCap=1
MiterStyle=1
PadShape=0
ViaShape=1
PolygonPour=0
PolygonRank=4
PolygonRank=0
PolygonThermals=1
PolygonOrphans=0
TextRatio=8
......@@ -96,7 +94,9 @@ SwapLevel=0
ArcDirection=0
AddLevel=2
PadsSameType=0
Layer=15
Layer=91
Views=" 1: 148.076 60.2009 334.352 161.499"
Sheet="1"
[Win_3]
Type="Control Panel"
......
......@@ -3,10 +3,9 @@
#include "drivers/indicators.h"
#include "drivers/step_a4950.h"
#include "osape/osap/osap.h"
#include "osape/osap/vport_ucbus_drop.h"
OSAP* osap = new OSAP("stepper motor drop");
VPort_UCBus_Drop* vPortUcBusDrop = new VPort_UCBus_Drop();
#include "osape/osap/vt_usbSerial.h"
#include "osape/osap/vt_ucBusDrop.h"
#include "osape/ucbus/ucBusDrop.h"
// bare defaults: use vm / bus id to set on startup
uint8_t axis_pick = 0;
......@@ -16,8 +15,9 @@ volatile boolean spu_was_set = false;
float c_scale = 0.2F;
#define TICKS_PER_PACKET 25.0F
// ENDPOINT 0
boolean onAxisPickSet(uint8_t* data, uint16_t len){
// -------------------------------------------------------- AXIS PICK EP
boolean onAxisPickData(uint8_t* data, uint16_t len){
if(data[0] > 3){
axis_pick = 0;
} else {
......@@ -25,10 +25,12 @@ boolean onAxisPickSet(uint8_t* data, uint16_t len){
}
return true;
}
Endpoint* axisPickEP = osap->endpoint(onAxisPickSet);
// ENDPOINT 1
boolean onAxisInvertSet(uint8_t* data, uint16_t len){
vertex_t* axisPickEp = osapBuildEndpoint("axisPick", onAxisPickData, nullptr);
// -------------------------------------------------------- AXIS INVERSION EP
boolean onAxisInvertData(uint8_t* data, uint16_t len){
if(data[0] > 0){
stepper_hw->setInversion(true);
} else {
......@@ -36,20 +38,24 @@ boolean onAxisInvertSet(uint8_t* data, uint16_t len){
}
return true;
}
Endpoint* axisInvertEP = osap->endpoint(onAxisInvertSet);
// ENDPOINT 2
boolean onSPUSet(uint8_t* data, uint16_t len){
vertex_t* axisInvertEp = osapBuildEndpoint("axisInvert", onAxisInvertData, nullptr);
// -------------------------------------------------------- SPU EP
boolean onSPUData(uint8_t* data, uint16_t len){
chunk_float32 spuc = { .bytes = { data[0], data[1], data[2], data[3] } };
old_spu = spu;
spu = fabsf(spuc.f);
spu_was_set = true;
return true;
}
Endpoint* spuEP = osap->endpoint(onSPUSet);
// ENDPOINT 3
boolean onCScaleSet(uint8_t* data, uint16_t len){
vertex_t* spuEp = osapBuildEndpoint("SPU", onSPUData, nullptr);
// -------------------------------------------------------- CSCALE DATA
boolean onCScaleData(uint8_t* data, uint16_t len){
chunk_float32 cscalec = { .bytes = { data[0], data[1], data[2], data[3] } };
if(cscalec.f > 1.0F){
cscalec.f = 1.0F;
......@@ -59,19 +65,28 @@ boolean onCScaleSet(uint8_t* data, uint16_t len){
stepper_hw->setCurrent(cscalec.f);
return true;
}
Endpoint* cscaleEP = osap->endpoint(onCScaleSet);
vertex_t* cScaleEp = osapBuildEndpoint("CScale", onCScaleData, nullptr);
void setup() {
ERRLIGHT_SETUP;
CLKLIGHT_SETUP;
DEBUG1PIN_SETUP;
DEBUG2PIN_SETUP;
DEBUG3PIN_SETUP;
DEBUG4PIN_SETUP;
// osap
osap->description = "remote stepper drop";
osap->addVPort(vPortUcBusDrop);
// stepper
osapSetup();
// ports
vt_usbSerial_setup();
osapAddVertex(vt_usbSerial); // 0
vt_ucBusDrop_setup();
osapAddVertex(vt_ucBusDrop); // 1
// axis pick
osapAddVertex(axisPickEp); // 2
// axis invert
osapAddVertex(axisInvertEp); // 3
// SPU
osapAddVertex(spuEp); // 4
// cscale
osapAddVertex(cScaleEp); // 5
// stepper init
stepper_hw->init(false, c_scale);
}
......@@ -79,7 +94,7 @@ void setup() {
// stepper_hw->setCurrent(currentChunks[AXIS_PICK].f);
void loop() {
osap->loop();
osapLoop();
stepper_hw->dacRefresh();
} // end loop
......@@ -94,7 +109,7 @@ volatile float move_counter = 0.0F;
volatile boolean setBlock = false;
void UCBus_Drop::onPacketARx(void){
void ucBusDrop_onPacketARx(uint8_t* inBufferA, volatile uint16_t len){
if(setBlock) return;
//DEBUG2PIN_TOGGLE;
// last move is done, convert back steps -> float,
......@@ -166,7 +181,7 @@ void UCBus_Drop::onPacketARx(void){
//DEBUG2PIN_OFF;
}
void UCBus_Drop::onRxISR(void){
void ucBusDrop_onRxISR(void){
if(setBlock) return;
//DEBUG2PIN_TOGGLE;
move_counter += vel;
......@@ -189,6 +204,3 @@ void UCBus_Drop::onRxISR(void){
}
}
void OSAP::handleAppPacket(uint8_t *pck, uint16_t ptr, pckm_t* pckm){
pckm->vpa->clear(pckm->location);
}
Subproject commit c940ac7425b5d544590caeeca4b49ce95b16ec76
Subproject commit 6b4dde4c750b1ce3a974e95937ddd20e016f2073
......@@ -18,23 +18,9 @@ With 2x A4950s on the DAC, AS5047P on the encoder, etc.
- bring phase advance back
- even better, run an [alpha beta filter](https://en.wikipedia.org/wiki/Alpha_beta_filter) underneath the control loop, as fast as possible, always.
## Writing the Paper
- holding torque open loop vs closed loop: given disturbance, the open loop motor probably shows more real measured error than a well tuned closed loop controller
- total integral of motor output along the torque curve from 0->10kRPM,
- probably finding resonant dips in open loop,
- maybe extending operating range in the closed loop (more RPM)
Paper List
- microsteps are not real, and we can measure this i.e. with zach's setup:
- closed loop would eliminate microsteps
- wider torque band: potentially higher RPM
- low end torque / torque density: should robotics industry be using BLDCs 3-phase or BLDCs bipolar stepper?
- saturation: we can drive higher peak torque into i.e. N17 when we do closed loop control, offering potentially higher performance overall than open loop fixed-current control
- efficiency: open loop wastes energy, always dissipating
- just gathering motor data:
- torque curve, that includes efficiency - for both approaches
- closed loop can actually hold position better: open loop will only apply best torque when the rotor has deviated from stator's static field by 90degs phase, cl can react
## Paper
Have started a writing doc for this, in cba/papers/2021-03_stepper-paper
## Evaluation
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment