Merge branch 'master' into Issue_152

# Conflicts:
#	EBB_firmware/app.X/source/ebb.c
#	docs/EBBReleaseNotes.html
pull/156/head
EmbeddedMan 2021-04-23 07:44:36 -05:00
commit 0be65de885
6 zmienionych plików z 264 dodań i 77 usunięć

Wyświetl plik

@ -122,28 +122,35 @@
#define RefRA0_IO_TRIS TRISAbits.TRISA0
/** P E N U P D O W N *******************************************/
#define PenUpDownIO LATBbits.LATB4
#define PEN_UP_DOWN_RPN 7
#define PenUpDownIO LATBbits.LATB4
#define PEN_UP_DOWN_RPN 7
#define PenUpDownIO_TRIS TRISBbits.TRISB4
/** D R I V E R E N A B L E **************************************/
#define Enable1IO LATEbits.LATE0
#define Enable1IO LATEbits.LATE0
#define Enable1IO_PORT PORTEbits.RE0
#define Enable1IO_TRIS TRISEbits.TRISE0
#define Enable2IO LATCbits.LATC1
#define Enable2IO LATCbits.LATC1
#define Enable2IO_PORT PORTCbits.RC1
#define Enable2IO_TRIS TRISCbits.TRISC1
// Alternate enables for external drivers
#define Enable1AltIO LATDbits.LATD1
#define Enable1AltIO LATDbits.LATD1
#define Enable1AltIO_PORT PORTDbits.RD1
#define Enable1AltIO_TRIS TRISDbits.TRISD1
#define Enable2AltIO LATAbits.LATA1
#define Enable2AltIO LATAbits.LATA1
#define Enable2AltIO_PORT PORTAbits.RA1
#define Enable2AltIO_TRIS TRISAbits.TRISA1
/** D R I V E R M I C R O S T E P ********************************/
#define MS1_IO LATEbits.LATE2
#define MS1_IO_TRIS TRISEbits.TRISE2
#define MS2_IO LATEbits.LATE1
#define MS2_IO_TRIS TRISEbits.TRISE1
#define MS3_IO LATAbits.LATA6
#define MS3_IO_TRIS TRISAbits.TRISA6
#define MS1_IO LATEbits.LATE2
#define MS1_IO_PORT PORTEbits.RE2
#define MS1_IO_TRIS TRISEbits.TRISE2
#define MS2_IO LATEbits.LATE1
#define MS2_IO_PORT PORTEbits.RE1
#define MS2_IO_TRIS TRISEbits.TRISE1
#define MS3_IO LATAbits.LATA6
#define MS3_IO_PORT PORTAbits.RA6
#define MS3_IO_TRIS TRISAbits.TRISA6
/** S T E P A N D D I R ******************************************/
#define Step1IO LATDbits.LATD6

Wyświetl plik

@ -1360,6 +1360,12 @@ void parse_packet(void)
parse_QP_packet ();
break;
}
case ('Q' * 256) + 'E':
{
// QE for Query motor Enable and resolution
parse_QE_packet ();
break;
}
case ('E' * 256) + 'M':
{
// EM for enable motors

Wyświetl plik

@ -258,7 +258,12 @@
// EM command now always clears accumulators
// Reduced effective pulse width for step pulses down to
// between 1.6 and 2.3 uS.
// 2.8.0 04/22/21 - Issue 152: Move EM command to motion queue
// 2.8.0 04/22/21 - Issue 151: Added QE command to return state of motor enables
// and their microstep resolution
// Issue 152: Move EM command to motion queue
// Issue 153: Add optional parameter to ES command to disable
// motors.
// Fix bug in ES command that didn't send return packet
#include <p18cxxx.h>
#include <usart.h>
@ -2170,10 +2175,14 @@ static void process_SM(
}
// E-Stop
// Usage: ES<CR>
// Usage: ES,<disable_motors><CR>
// Returns: <command_interrupted>,<fifo_steps1>,<fifo_steps2>,<steps_remaining1>,<steps_remaining2><CR>OK<CR>
// This command will abort any in-progress motor move (SM) command.
// It will also clear out any pending command(s) in the FIFO.
// <disable_motors> This parameter is optional. If present, and if it is a 1,
// then both stepper drivers will be disabled as part of the command.
// If this parameter is not present or is not equal to 1, then
// the motors will not be disabled. (added in v2.8.0)
// <command_interrupted> = 0 if no FIFO or in-progress move commands were interrupted,
// 1 if a motor move command was in progress or in the FIFO
// <fifo_steps1> and <fifo_steps1> = 24 bit unsigned integers with the number of steps
@ -2185,58 +2194,80 @@ static void process_SM(
// command was in the FIFO.
void parse_ES_packet(void)
{
UINT8 command_interrupted = 0;
UINT32 remaining_steps1 = 0;
UINT32 remaining_steps2 = 0;
UINT32 fifo_steps1 = 0;
UINT32 fifo_steps2 = 0;
// If there is a command waiting in the FIFO and it is a move command
// or the current command is a move command, then remember that for later.
if (
(!FIFOEmpty && CommandFIFO[0].Command == COMMAND_MOTOR_MOVE)
||
CurrentCommand.Command == COMMAND_MOTOR_MOVE
)
{
command_interrupted = 1;
}
// If the FIFO has a move command in it, remove it.
if (CommandFIFO[0].Command == COMMAND_MOTOR_MOVE)
{
CommandFIFO[0].Command = COMMAND_NONE;
fifo_steps1 = CommandFIFO[0].Steps[0];
fifo_steps2 = CommandFIFO[0].Steps[1];
CommandFIFO[0].Steps[0] = 0;
CommandFIFO[0].Steps[1] = 0;
CommandFIFO[0].Accel[0] = 0;
CommandFIFO[0].Accel[1] = 0;
FIFOEmpty = TRUE;
}
UINT8 disable_motors = 0;
UINT8 command_interrupted = 0;
UINT32 remaining_steps1 = 0;
UINT32 remaining_steps2 = 0;
UINT32 fifo_steps1 = 0;
UINT32 fifo_steps2 = 0;
// If the current command is a move command, then stop the move.
if (CurrentCommand.Command == COMMAND_MOTOR_MOVE)
{
CurrentCommand.Command = COMMAND_NONE;
remaining_steps1 = CurrentCommand.Steps[0];
remaining_steps2 = CurrentCommand.Steps[1];
CurrentCommand.Steps[0] = 0;
CurrentCommand.Steps[1] = 0;
CurrentCommand.Accel[0] = 0;
CurrentCommand.Accel[1] = 0;
}
// Extract each of the value.
extract_number (kUCHAR, &disable_motors, kOPTIONAL);
// Bail if we got a conversion error
if (error_byte)
{
return;
}
// If there is a command waiting in the FIFO and it is a move command
// or the current command is a move command, then remember that for later.
if (
(!FIFOEmpty && CommandFIFO[0].Command == COMMAND_MOTOR_MOVE)
||
CurrentCommand.Command == COMMAND_MOTOR_MOVE
)
{
command_interrupted = 1;
}
// If the FIFO has a move command in it, remove it.
if (CommandFIFO[0].Command == COMMAND_MOTOR_MOVE)
{
CommandFIFO[0].Command = COMMAND_NONE;
fifo_steps1 = CommandFIFO[0].Steps[0];
fifo_steps2 = CommandFIFO[0].Steps[1];
CommandFIFO[0].Steps[0] = 0;
CommandFIFO[0].Steps[1] = 0;
CommandFIFO[0].Accel[0] = 0;
CommandFIFO[0].Accel[1] = 0;
FIFOEmpty = TRUE;
}
// If the current command is a move command, then stop the move.
if (CurrentCommand.Command == COMMAND_MOTOR_MOVE)
{
CurrentCommand.Command = COMMAND_NONE;
remaining_steps1 = CurrentCommand.Steps[0];
remaining_steps2 = CurrentCommand.Steps[1];
CurrentCommand.Steps[0] = 0;
CurrentCommand.Steps[1] = 0;
CurrentCommand.Accel[0] = 0;
CurrentCommand.Accel[1] = 0;
}
if (disable_motors == 1)
{
if (DriverConfiguration == PIC_CONTROLS_DRIVERS)
{
Enable1IO = DISABLE_MOTOR;
Enable2IO = DISABLE_MOTOR;
}
else if (DriverConfiguration == PIC_CONTROLS_EXTERNAL)
{
Enable1AltIO = DISABLE_MOTOR;
Enable2AltIO = DISABLE_MOTOR;
}
}
printf((far rom char *)"%d,%lu,%lu,%lu,%lu\n\r",
command_interrupted,
fifo_steps1,
fifo_steps2,
remaining_steps1,
remaining_steps2
);
#if defined(DEBUG_VALUE_PRINT)
printf((far rom char *)"%d,%lu,%lu,%lu,%lu\n\r",
command_interrupted,
fifo_steps1,
fifo_steps2,
remaining_steps1,
remaining_steps2
);
#endif
print_ack();
}
@ -2250,6 +2281,71 @@ void parse_QP_packet(void)
print_ack();
}
// Query motor Enables and resolution
// Usage: QE<CR>
// Returns: <motor1_state>,<motor2_state><CR>OK<CR>
// Where <motor1_state> and <motor2_state> are one of the following values:
// 0 = Motor is disabled
// 1 = Motor is enabled and step resolution is full steps
// 2 = Motor is enabled and step resolution is 1/2 steps
// 4 = Motor is enabled and step resolution is 1/4 steps
// 8 = Motor is enabled and step resolution is 1/8 steps
// 16 = Motor is enabled and step resolution is 1/16 steps
void parse_QE_packet(void)
{
UINT8 motor1_state = 0;
UINT8 motor2_state = 0;
UINT8 temp;
if (MS1_IO_PORT == 0 && MS2_IO_PORT == 0 && MS3_IO_PORT == 0)
{
temp = 1;
}
else if (MS1_IO_PORT == 1 && MS2_IO_PORT == 0 && MS3_IO_PORT == 0)
{
temp = 2;
}
else if (MS1_IO_PORT == 0 && MS2_IO_PORT == 1 && MS3_IO_PORT == 0)
{
temp = 4;
}
else if (MS1_IO_PORT == 1 && MS2_IO_PORT == 1 && MS3_IO_PORT == 0)
{
temp = 8;
}
else
{
temp = 16;
}
if (DriverConfiguration == PIC_CONTROLS_DRIVERS)
{
if (Enable1IO_PORT == ENABLE_MOTOR)
{
motor1_state = temp;
}
if (Enable2IO_PORT == ENABLE_MOTOR)
{
motor2_state = temp;
}
}
else if (DriverConfiguration == PIC_CONTROLS_EXTERNAL)
{
if (Enable1AltIO_PORT == ENABLE_MOTOR)
{
motor1_state = temp;
}
if (Enable2AltIO_PORT == ENABLE_MOTOR)
{
motor2_state = temp;
}
}
printf((far rom char *)"%d,%d\n\r", motor1_state, motor2_state);
print_ack();
}
// Toggle Pen
// Usage: TP,<duration><CR>
// Returns: OK<CR>

Wyświetl plik

@ -165,6 +165,7 @@ void parse_SC_packet(void);
void parse_SP_packet(void);
void parse_TP_packet(void);
void parse_QP_packet(void);
void parse_QE_packet(void);
void parse_SN_packet(void);
void parse_QN_packet(void);
void parse_NI_packet(void);

Wyświetl plik

@ -385,10 +385,19 @@
<h4>2.8.0 &mdash; 04/22/21</h4>
<p>
<ul>
<li>In response to <a href="https://github.com/evil-mad/EggBot/issues/152">issue #152</a> Move the EM command
to be part of the motion queue. This allows EM commands to take place at a predictable point in the motion
sequence rahter than sort of randomly during a move.</li>
</ul>
<li>
In response to <a href="https://github.com/evil-mad/EggBot/issues/152">issue #152</a> Move the EM command
to be part of the motion queue. This allows EM commands to take place at a predictable point in the motion
sequence rahter than sort of randomly during a move.
</li>
<li>
Added QE command to query the motor enable states and microstep resolutions.
</li>
<li>
In response to <a href="https://github.com/evil-mad/EggBot/issues/153">issue #153</a> the ES command was given an optional parameter to
disable the motors.
</li>
</ul>
</p>
<p/>

Wyświetl plik

@ -243,6 +243,7 @@ ul.no_bullets {
<li><a href="#PO">PO</a> &mdash; Pin Output</li>
<li><a href="#QB">QB</a> &mdash; Query Button</li>
<li><a href="#QC">QC</a> &mdash; Query Current</li>
<li><a href="#QE">QE</a> &mdash; Query motor Enables and microstep resolutions</li>
<li><a href="#QG">QG</a> &mdash; Query General</li>
<li><a href="#QL">QL</a> &mdash; Query Layer</li>
<li><a href="#QM">QM</a> &mdash; Query Motors</li>
@ -623,7 +624,7 @@ ul.no_bullets {
<h4><a name="ES"></a>"ES" &mdash; E Stop</h4>
<ul>
<li><span style="font-weight: bold;">Command:</span> <code>ES&lt;CR&gt;</code></li>
<li><span style="font-weight: bold;">Command:</span> <code>ES[,DisableMotors]&lt;CR&gt;</code></li>
<li><span style="font-weight: bold;">Response:</span><br />
<code><i>interrupted</i>,<i>fifo_steps1</i>,<i>fifo_steps2</i>,<i>steps_rem1</i>,<i>steps_rem2</i>&lt;NL&gt;&lt;CR&gt;OK&lt;CR&gt;&lt;NL&gt;</code>
</li>
@ -634,6 +635,9 @@ ul.no_bullets {
<p>
Use this command to abort any in-progress motor move (SM) Command. This command will also delete any motor move command (SM) from the FIFO. It will immediately stop the motors, but leave them energized.
</p>
<p>
For versions v2.8.0 and above there is an optional parameter <code>DisableMotors</code>. If <code>DisableMotors</code> is set to 1, then this command will not only stop all motion but will also disable both stepper motors.
</p>
<p>Returned values:</p>
<ul>
<li>
@ -656,18 +660,28 @@ ul.no_bullets {
<code>1,50,1200,18634,9848&lt;NL&gt;&lt;CR&gt;OK&lt;CR&gt;&lt;NL&gt;</code> Indicates that a command was interrupted, and that the FIFO had steps of 50 and 1200 steps queued to execute next (in axes 1 and 2), as well as 18634 and 9848 steps remaining to move (in axes 1 and 1) on the current move.
</li>
<li>
<span style="font-weight: bold;">Version History:</span>
Added in v2.2.7
<p>
Prior to v2.2.9, this command will return a "1" if it had to stop an in-progress move command, or if it had to delete a move command from the FIFO. This could indicate that some steps might be lost, since the host application may think that moves have already completed, when in fact they were aborted partway through. It will return a "0" if no motor move commands were deleted or aborted.
</p>
<p>Returned values:</p>
<span style="font-weight: bold;">Version History:</span>
<ul>
<li>
<code>1&lt;NL&gt;&lt;CR&gt;OK&lt;CR&gt;&lt;NL&gt;</code>: If an in-progress move commands was interrupted or removed from the FIFO
<p>v2.8.0</p>
<p>
In versions v2.8.0 and beyond, the optional <code>DisableMotors</code> parameter is accepted.
</p>
</li>
<li>
<code>0&lt;NL&gt;&lt;CR&gt;OK&lt;CR&gt;&lt;NL&gt;</code>: If no in-progress move commands was interrupted or removed from the FIFO
<p>Added in v2.2.7</p>
<p>
Prior to v2.2.9, this command will return a "1" if it had to stop an in-progress move command, or if it had to delete a move command from the FIFO. This could indicate that some steps might be lost, since the host application may think that moves have already completed, when in fact they were aborted partway through. It will return a "0" if no motor move commands were deleted or aborted.
</p>
<p>Returned values:</p>
<ul>
<li>
<code>1&lt;NL&gt;&lt;CR&gt;OK&lt;CR&gt;&lt;NL&gt;</code>: If an in-progress move commands was interrupted or removed from the FIFO
</li>
<li>
<code>0&lt;NL&gt;&lt;CR&gt;OK&lt;CR&gt;&lt;NL&gt;</code>: If no in-progress move commands was interrupted or removed from the FIFO
</li>
</ul>
</li>
</ul>
</li>
@ -1399,6 +1413,60 @@ ul.no_bullets {
<hr class="short" />
<h4><a name="QE"></a>"QE" &mdash; Query motor Enables and microstep resolutions</h4>
<ul>
<li><span style="font-weight: bold;">Command:</span> <code>QE&lt;CR&gt;</code></li>
<li><span style="font-weight: bold;">Response:</span> <code><i>MOTOR1_STATE</i>,<i>MOTOR2_STATE</i>&lt;CR&gt;&lt;NL&gt;OK&lt;CR&gt;&lt;NL&gt;</code></li>
<li><span style="font-weight: bold;">Firmware versions:</span> v2.8.0 and newer</li>
<li><span style="font-weight: bold;">Execution:</span> Immediate</li>
<li>
<span style="font-weight: bold;">Description:</span>
<p>
Reads the current state of the motor enable pins and the microstep resolution pins. It then returns two values which encode the motor enable/disable
state and (if enabled) microstep resolution.
</p>
<p>
There is only one value for the microstepping resolution since both motor drivers share the same MS1, MS2 and MS3 lines on the EBB. So the
two values returned by this command will either be the same (if both motors are enabled) or one or both of them will be zero. But they will
never show that the two motors are both enabled and have different microstep resolutions.
</p>
<p>The two returned values are:</p>
<ul>
<li>
<i>MOTOR1_STATE</i>
<p>
<ul>
<li>0: Motor 1 is disabled</li>
<li>1: Motor 1 is enabled and is set to full step</li>
<li>2: Motor 1 is enabled and is set to 1/2 steps</li>
<li>4: Motor 1 is enabled and is set to 1/4 steps</li>
<li>8: Motor 1 is enabled and is set to 1/8 steps</li>
<li>16: Motor 1 is enabled and is set to 1/16 steps</li>
</ul>
</p>
</li>
<li>
<i>MOTOR2_STATE</i>
<p>Same as for MOTOR1_STATE but for Motor 2.
</p>
</li>
</ul>
</li>
<li>
<span style="font-weight: bold;">Example Return Packet:</span>
<code>16,16&lt;CR&gt;&lt;NL&gt;OK&lt;CR&gt;&lt;NL&gt;</code>
<p>Both motors are enabled and set to 1/16th microsteps.</p>
</li>
<li>
<span style="font-weight: bold;">Example Return Packet:</span>
<code>0,4&lt;CR&gt;&lt;NL&gt;OK&lt;CR&gt;&lt;NL&gt;</code>
<p>Motor 1 is disabled and motor 2 is enabled an set to 1/4 steps.</p>
</li>
</ul>
<hr class="short" />
<h4><a name="QG"></a>"QG" &mdash; Query General</h4>
<ul>