Simple DDA now working. All axes move as expected.
This commit is contained in:
parent
4b0e9e61bf
commit
9ec28592e5
5 changed files with 58 additions and 9 deletions
6
Move.h
6
Move.h
|
@ -53,6 +53,7 @@ class Move
|
||||||
void Exit();
|
void Exit();
|
||||||
void Qmove();
|
void Qmove();
|
||||||
void GetCurrentState(float m[]);
|
void GetCurrentState(float m[]);
|
||||||
|
void Interrupt();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,5 +74,10 @@ inline boolean DDA::Active()
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void Move::Interrupt()
|
||||||
|
{
|
||||||
|
dda->Step();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
7
Move.ino
7
Move.ino
|
@ -50,12 +50,6 @@ void Move::Spin()
|
||||||
if(!active)
|
if(!active)
|
||||||
return;
|
return;
|
||||||
Qmove();
|
Qmove();
|
||||||
unsigned long t = platform->Time();
|
|
||||||
if(t - lastTime > 1000)
|
|
||||||
{
|
|
||||||
lastTime = t;
|
|
||||||
dda->Step();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,6 +125,7 @@ void DDA::Start()
|
||||||
{
|
{
|
||||||
for(char drive = 0; drive < DRIVES; drive++)
|
for(char drive = 0; drive < DRIVES; drive++)
|
||||||
platform->SetDirection(drive, directions[drive]);
|
platform->SetDirection(drive, directions[drive]);
|
||||||
|
platform->SetInterrupt(300);
|
||||||
active = true;
|
active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -246,6 +246,8 @@ class Platform
|
||||||
|
|
||||||
int GetRawTemperature(byte heater);
|
int GetRawTemperature(byte heater);
|
||||||
|
|
||||||
|
void InitialiseInterrupts();
|
||||||
|
|
||||||
RepRap* reprap;
|
RepRap* reprap;
|
||||||
|
|
||||||
// DRIVES
|
// DRIVES
|
||||||
|
@ -360,7 +362,9 @@ inline void Platform::SetDirection(byte drive, bool direction)
|
||||||
|
|
||||||
inline void Platform::Step(byte drive)
|
inline void Platform::Step(byte drive)
|
||||||
{
|
{
|
||||||
digitalWrite(stepPins[drive], !digitalRead(stepPins[drive]));
|
//digitalWrite(stepPins[drive], !digitalRead(stepPins[drive]));
|
||||||
|
digitalWrite(stepPins[drive], 0);
|
||||||
|
digitalWrite(stepPins[drive], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int Platform::GetRawTemperature(byte heater)
|
inline int Platform::GetRawTemperature(byte heater)
|
||||||
|
|
46
Platform.ino
46
Platform.ino
|
@ -46,9 +46,51 @@ Platform::Platform(RepRap* r)
|
||||||
|
|
||||||
// Interrupts
|
// Interrupts
|
||||||
|
|
||||||
|
void TC3_Handler()
|
||||||
|
{
|
||||||
|
TC_GetStatus(TC1, 0);
|
||||||
|
reprap.GetPlatform()->Interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void startTimer(Tc *tc, uint32_t channel, IRQn_Type irq, uint32_t frequency)
|
||||||
|
{
|
||||||
|
pmc_set_writeprotect(false);
|
||||||
|
pmc_enable_periph_clk((uint32_t)irq);
|
||||||
|
TC_Configure(tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK4);
|
||||||
|
// VARIANT_MCK = 84x10^6 for the Due
|
||||||
|
uint32_t rc = VARIANT_MCK/128/frequency; //128 because we selected TIMER_CLOCK4 above
|
||||||
|
TC_SetRA(tc, channel, rc/2); //50% high, 50% low
|
||||||
|
TC_SetRC(tc, channel, rc);
|
||||||
|
TC_Start(tc, channel);
|
||||||
|
tc->TC_CHANNEL[channel].TC_IER=TC_IER_CPCS;
|
||||||
|
tc->TC_CHANNEL[channel].TC_IDR=~TC_IER_CPCS;
|
||||||
|
NVIC_EnableIRQ(irq);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void Platform::InitialiseInterrupts()
|
||||||
|
{
|
||||||
|
pmc_set_writeprotect(false);
|
||||||
|
pmc_enable_periph_clk((uint32_t)TC3_IRQn);
|
||||||
|
TC_Configure(TC1, 0, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK4);
|
||||||
|
TC1->TC_CHANNEL[0].TC_IER=TC_IER_CPCS;
|
||||||
|
TC1->TC_CHANNEL[0].TC_IDR=~TC_IER_CPCS;
|
||||||
|
NVIC_DisableIRQ(TC3_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
inline void Platform::SetInterrupt(long t)
|
inline void Platform::SetInterrupt(long t)
|
||||||
{
|
{
|
||||||
|
if(t <= 0)
|
||||||
|
{
|
||||||
|
NVIC_DisableIRQ(TC3_IRQn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint32_t rc = (uint32_t)(t*84)/128;
|
||||||
|
TC_SetRA(TC1, 0, rc/2); //50% high, 50% low
|
||||||
|
TC_SetRC(TC1, 0, rc);
|
||||||
|
TC_Start(TC1, 0);
|
||||||
|
NVIC_EnableIRQ(TC3_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Platform::Interrupt()
|
inline void Platform::Interrupt()
|
||||||
|
@ -243,6 +285,8 @@ void Platform::Init()
|
||||||
Serial.println("SD initialization failed.");
|
Serial.println("SD initialization failed.");
|
||||||
// SD.begin() returns with the SPI disabled, so you need not disable it here
|
// SD.begin() returns with the SPI disabled, so you need not disable it here
|
||||||
|
|
||||||
|
InitialiseInterrupts();
|
||||||
|
|
||||||
active = true;
|
active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ void RepRap::Spin()
|
||||||
|
|
||||||
void RepRap::Interrupt()
|
void RepRap::Interrupt()
|
||||||
{
|
{
|
||||||
|
move->Interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************************************
|
//*************************************************************************************************
|
||||||
|
|
Reference in a new issue