Working test-program using user LEDs and delays
This commit is contained in:
@@ -1100,7 +1100,7 @@ StepGen3::StepGen3(void)
|
||||
step->pos_scale = JOINT_0_SCALE;
|
||||
step->maxaccel = JOINT_0_STEPGEN_MAXACCEL;
|
||||
|
||||
for (int servo_thread = 0; servo_thread < 00; servo_thread++)
|
||||
for (int servo_thread = 0; servo_thread < 100; servo_thread++)
|
||||
{
|
||||
step->pos_cmd = servo_thread * 1;
|
||||
update_pos(step, SERVO_PERIOD);
|
||||
@@ -1108,10 +1108,13 @@ StepGen3::StepGen3(void)
|
||||
for (int base_thread = 0; base_thread < 20; base_thread++)
|
||||
{
|
||||
make_pulses(stepgen_array, BASE_PERIOD);
|
||||
digitalWrite(PA6, step->phase[DIR_PIN] ? LOW : HIGH);
|
||||
digitalWrite(PA7, step->phase[STEP_PIN] ? LOW : HIGH);
|
||||
delay(50);
|
||||
// printf("pos_cmd=%f\n", step->pos_cmd);
|
||||
// printf("pos_fb=%f\n", step->pos_fb);
|
||||
printf("pickoff=%d accum=%lld addval=%d ", 1 << 28, step->accum, step->addval);
|
||||
printf("dir=%d step=%d\n", step->phase[DIR_PIN], step->phase[STEP_PIN]);
|
||||
// printf("pickoff=%d accum=%lld addval=%d ", 1 << 28, step->accum, step->addval);
|
||||
// printf("dir=%d step=%d\n", step->phase[DIR_PIN], step->phase[STEP_PIN]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ extern "C"
|
||||
_Objects Obj;
|
||||
|
||||
HardwareSerial Serial1(PA10, PA9);
|
||||
|
||||
// STG = StepGenTest
|
||||
#define SGT 0
|
||||
#if SGT
|
||||
volatile uint16_t ALEventIRQ; // ALEvent that caused the interrupt
|
||||
#define DEBUG_TIM8 1
|
||||
#include "MyEncoder.h"
|
||||
@@ -17,8 +21,9 @@ void indexPulseEncoderCB1(void)
|
||||
{
|
||||
Encoder1.indexPulse();
|
||||
}
|
||||
|
||||
#endif
|
||||
#include "StepGen3.h"
|
||||
#if SGT
|
||||
#include "extend32to64.h"
|
||||
|
||||
CircularBuffer<uint64_t, 200> Tim;
|
||||
@@ -40,7 +45,6 @@ uint64_t reallyNowTime = 0, reallyThenTime = 0;
|
||||
uint64_t timeDiff; // Timediff in nanoseconds
|
||||
void handleStepper(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation
|
||||
@@ -66,7 +70,7 @@ void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation
|
||||
}
|
||||
thenTime = irqTime;
|
||||
Obj.DiffT = longTime.extendTime(micros()) - irqTime; // max_Tim - min_Tim; // Debug
|
||||
Obj.D1 =0;
|
||||
Obj.D1 = 0;
|
||||
Obj.D2 = 0;
|
||||
Obj.D3 = abs(1000 * (ap2 - Obj.CommandedPosition2)); // Step2.actPos();
|
||||
Obj.D4 = 0;
|
||||
@@ -98,16 +102,25 @@ static esc_cfg_t config =
|
||||
};
|
||||
|
||||
volatile byte serveIRQ = 0;
|
||||
|
||||
#endif
|
||||
void setup(void)
|
||||
{
|
||||
Serial1.begin(115200);
|
||||
#if SGT
|
||||
rcc_config(); // probably breaks some timers.
|
||||
ecat_slv_init(&config);
|
||||
#endif
|
||||
pinMode(PA6, OUTPUT);
|
||||
pinMode(PA7, OUTPUT);
|
||||
digitalWrite(PA6, HIGH);
|
||||
digitalWrite(PA7, HIGH);
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
StepGen3 Step;
|
||||
|
||||
#if SGT
|
||||
uint64_t dTime;
|
||||
if (serveIRQ)
|
||||
{
|
||||
@@ -124,16 +137,19 @@ void loop(void)
|
||||
dTime = longTime.extendTime(micros()) - irqTime;
|
||||
if (dTime > 5000) // Don't run ecat_slv_poll when expecting to serve interrupt
|
||||
ecat_slv_poll();
|
||||
#endif
|
||||
}
|
||||
|
||||
void sync0Handler(void)
|
||||
{
|
||||
#if SGT
|
||||
ALEventIRQ = ESC_ALeventread();
|
||||
// if (ALEventIRQ & ESCREG_ALEVENT_SM2)
|
||||
{
|
||||
serveIRQ = 1;
|
||||
irqTime = longTime.extendTime(micros());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Enable SM2 interrupts
|
||||
@@ -183,6 +199,6 @@ uint16_t dc_checker(void)
|
||||
{
|
||||
// Indicate we run DC
|
||||
ESCvar.dcsync = 1;
|
||||
//StepGen3::sync0CycleTime = ESC_SYNC0cycletime(); // nsecs
|
||||
// StepGen3::sync0CycleTime = ESC_SYNC0cycletime(); // nsecs
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user