kopia lustrzana https://github.com/evil-mad/EggBot
Version 1.9 - Added QP and TP commands, removed vestiges of DEMO_MODE, set servo to up position on reset.
git-svn-id: https://eggbotcode.googlecode.com/svn/trunk@23 72233254-1b6c-9e9c-5072-401df62706fbpull/47/head
rodzic
4b00afa998
commit
c6a4f22e3b
BIN
EBF/EBB.mcw
BIN
EBF/EBB.mcw
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik binarny nie jest wyświetlany.
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik binarny nie jest wyświetlany.
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
|
|
@ -71,7 +71,7 @@ physical extremes of its motion.
|
|||
|
||||
This RCServo2 method will only be available on the 18F45J50 based
|
||||
EggBotBoards, because it requires the PPS (perhipheral pin select)
|
||||
facility to be practical.
|
||||
facility to be possible.
|
||||
|
||||
Timer3 will be configured to clock at Fosc/4 = 12MHz.
|
||||
At this rate, a 1ms high pulse would need a CCPR2 value of 12,000.
|
||||
|
|
@ -138,7 +138,7 @@ void RCServo2_Init(void)
|
|||
gUseRCServo2 = TRUE;
|
||||
g_servo2_rate = 400;
|
||||
Process_S2(1, g_servo2_min, 4, g_servo2_rate);
|
||||
process_SP(1, 0); // Start servo up
|
||||
process_SP(PEN_UP, 0); // Start servo up
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
95
EBF/UBW.c
95
EBF/UBW.c
|
|
@ -127,15 +127,15 @@ const rom char st_LFCR[] = {"\r\n"};
|
|||
|
||||
/// TODO: Can we make this cleaner? Maybe using macros or something? One version number and one board rev.
|
||||
#if defined(BOARD_EBB_V10)
|
||||
const rom char st_version[] = {"EBBv10 EB Firmware Version 1.8.2\r\n"};
|
||||
const rom char st_version[] = {"EBBv10 EB Firmware Version 1.9\r\n"};
|
||||
#elif defined(BOARD_EBB_V11)
|
||||
const rom char st_version[] = {"EBBv11 EB Firmware Version 1.8.2\r\n"};
|
||||
const rom char st_version[] = {"EBBv11 EB Firmware Version 1.9\r\n"};
|
||||
#elif defined(BOARD_EBB_V12)
|
||||
const rom char st_version[] = {"EBBv12 EB Firmware Version 1.8.2\r\n"};
|
||||
const rom char st_version[] = {"EBBv12 EB Firmware Version 1.9\r\n"};
|
||||
#elif defined(BOARD_EBB_V13)
|
||||
const rom char st_version[] = {"EBBv13 EB Firmware Version 1.8.2\r\n"};
|
||||
const rom char st_version[] = {"EBBv13 EB Firmware Version 1.9\r\n"};
|
||||
#elif defined(BOARD_UBW)
|
||||
const rom char st_version[] = {"UBW EB Firmware Version 1.8.2\r\n"};
|
||||
const rom char st_version[] = {"UBW EB Firmware Version 1.9\r\n"};
|
||||
#endif
|
||||
|
||||
#pragma udata ISR_buf = 0x100
|
||||
|
|
@ -787,59 +787,6 @@ void ProcessIO(void)
|
|||
|
||||
BlinkUSBStatus();
|
||||
|
||||
#if defined(DEMO_MODE)
|
||||
// Check to see if user has pressed and released the PRG button
|
||||
if (!swStartDemo)
|
||||
{
|
||||
if (button_state == 0)
|
||||
{
|
||||
button_ctr++;
|
||||
|
||||
if (button_ctr == 1000)
|
||||
{
|
||||
button_state = 1;
|
||||
button_ctr = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (button_state == 1)
|
||||
{
|
||||
button_ctr++;
|
||||
|
||||
if (button_ctr == 1000)
|
||||
{
|
||||
button_state = 0;
|
||||
button_ctr = 0;
|
||||
if (DemoModeActive)
|
||||
{
|
||||
DemoModeActive = FALSE;
|
||||
comd_counter = 0;
|
||||
PenUpDownIO = 0;
|
||||
Enable1IO = DISABLE_MOTOR;
|
||||
Enable2IO = DISABLE_MOTOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
DemoModeActive = TRUE;
|
||||
Enable1IO = ENABLE_MOTOR;
|
||||
Enable2IO = ENABLE_MOTOR;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
button_state = 0;
|
||||
button_ctr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (DemoModeActive == TRUE)
|
||||
{
|
||||
DemoModeStateMachine();
|
||||
}
|
||||
#endif
|
||||
// Check for any new I packets (from T command) ready to go out
|
||||
while (ISR_D_FIFO_length > 0)
|
||||
{
|
||||
|
|
@ -1326,6 +1273,18 @@ void parse_packet(void)
|
|||
parse_SP_packet ();
|
||||
break;
|
||||
}
|
||||
case ('T' * 256) + 'P':
|
||||
{
|
||||
// TP for toggle pen
|
||||
parse_TP_packet ();
|
||||
break;
|
||||
}
|
||||
case ('Q' * 256) + 'P':
|
||||
{
|
||||
// QP for query pen
|
||||
parse_QP_packet ();
|
||||
break;
|
||||
}
|
||||
case ('E' * 256) + 'M':
|
||||
{
|
||||
// EM for enable motors
|
||||
|
|
@ -2993,27 +2952,7 @@ void BlinkUSBStatus(void)
|
|||
{
|
||||
static WORD LEDCount = 0;
|
||||
static unsigned char LEDState = 0;
|
||||
#if defined(DEMO_MODE)
|
||||
static word DemoCount = 0;
|
||||
#endif
|
||||
|
||||
#if defined(DEMO_MODE)
|
||||
if (DemoModeActive)
|
||||
{
|
||||
DemoCount++;
|
||||
|
||||
if (DemoCount == 30000U)
|
||||
{
|
||||
mLED_2_Toggle();
|
||||
DemoCount = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mLED_2_Off();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (
|
||||
USBDeviceState == DETACHED_STATE
|
||||
||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Warning[2060] D:\Projects\EggBot\SE\EBF\UBW.c 1007 : shift expression has no effect
|
||||
Warning[2060] D:\Projects\EggBot\SE\EBF\UBW.c 954 : shift expression has no effect
|
||||
|
|
|
|||
121
EBF/ebb.c
121
EBF/ebb.c
|
|
@ -2,7 +2,9 @@
|
|||
// 1.8 -
|
||||
// 1.8.1 5/19/10 - Only change is to recompile with Microchip USB Stack v2.7
|
||||
// 1.8.2 5/31/10 - Only change is to change name in USB enumeration string to Ei Bot Board - using new PID for SchmalzHaus
|
||||
|
||||
// 1.9 6/11/10 - Added two commands:
|
||||
// SQ - Solenoid Query - returns 0 or 1 for down and up
|
||||
// ST - Solenoid Toggle - toggles state of the servo/solenoid
|
||||
|
||||
|
||||
|
||||
|
|
@ -133,6 +135,7 @@ static unsigned char UseBuiltInDrivers;
|
|||
static unsigned char UseServoForUpDown;
|
||||
static unsigned int g_servo_max;
|
||||
static unsigned int g_servo_min;
|
||||
static PenStateType PenState;
|
||||
|
||||
// ISR
|
||||
// PORTB is the step and direction port
|
||||
|
|
@ -386,7 +389,6 @@ void high_ISR(void)
|
|||
// causes the compiler to generate enormous amounts of setup/teardown
|
||||
// code and things run way too slowly.
|
||||
// Process_S2(1, g_servo2_min, 4, g_servo2_rate);
|
||||
gUseRCServo2 = TRUE;
|
||||
gRC2Rate[0] = g_servo2_rate;
|
||||
gRC2Target[0] = g_servo2_min;
|
||||
gRC2Pin[0] = 4;
|
||||
|
|
@ -410,6 +412,7 @@ void high_ISR(void)
|
|||
{
|
||||
AllDone = FALSE;
|
||||
}
|
||||
PenState = PEN_UP;
|
||||
}
|
||||
else if (Command == COMMAND_PEN_DOWN)
|
||||
{
|
||||
|
|
@ -426,7 +429,6 @@ void high_ISR(void)
|
|||
// causes the compiler to generate enormous amounts of setup/teardown
|
||||
// code and things run way too slowly.
|
||||
// Process_S2(1, g_servo2_max, 4, g_servo2_rate);
|
||||
gUseRCServo2 = TRUE;
|
||||
gRC2Rate[0] = g_servo2_rate;
|
||||
gRC2Target[0] = g_servo2_max;
|
||||
gRC2Pin[0] = 4;
|
||||
|
|
@ -450,6 +452,7 @@ void high_ISR(void)
|
|||
{
|
||||
AllDone = FALSE;
|
||||
}
|
||||
PenState = PEN_DOWN;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -577,13 +580,8 @@ void EBB_Init(void)
|
|||
ANCON0 = 0xFE; // Let AN0 (RA0) be an analog input
|
||||
ANCON1 = 0x1F; // Set all the rest to digital I/O
|
||||
|
||||
#if defined(DEMO_MODE)
|
||||
Enable1IO = DISABLE_MOTOR;
|
||||
Enable2IO = DISABLE_MOTOR;
|
||||
#else
|
||||
Enable1IO = ENABLE_MOTOR;
|
||||
Enable2IO = ENABLE_MOTOR;
|
||||
#endif
|
||||
Enable1IO = ENABLE_MOTOR;
|
||||
Enable2IO = ENABLE_MOTOR;
|
||||
MS1_1IO = 1;
|
||||
MS2_1IO = 1;
|
||||
MS1_2IO = 1;
|
||||
|
|
@ -639,69 +637,19 @@ void EBB_Init(void)
|
|||
TRISC = 0; // Make portC outputs
|
||||
#endif
|
||||
|
||||
#if defined(DEMO_MODE)
|
||||
DemoModeActive = FALSE;
|
||||
#endif
|
||||
|
||||
// Set up pen up/down direction as output
|
||||
PenUpDownIO = 0;
|
||||
PenUpDownIO_TRIS = OUTPUT_PIN;
|
||||
|
||||
SolenoidState = SOLENOID_OFF;
|
||||
SolenoidState = SOLENOID_ON;
|
||||
UseBuiltInDrivers = TRUE;
|
||||
gUseRCServo1 = FALSE;
|
||||
#if defined(BOARD_EBB_V11) || defined(BOARD_EBB_V12) || defined(BOARD_EBB_V13)
|
||||
gUseRCServo2 = FALSE;
|
||||
gUseRCServo2 = TRUE;
|
||||
#endif
|
||||
PenState = PEN_UP;
|
||||
}
|
||||
|
||||
#if defined(DEMO_MODE)
|
||||
void DemoModeStateMachine(void)
|
||||
{
|
||||
unsigned int duration;
|
||||
unsigned int A1steps;
|
||||
unsigned int A2steps;
|
||||
|
||||
// If we have space for the next command
|
||||
if (AllDone)
|
||||
{
|
||||
// Then load the next command
|
||||
if (packet_list[comd_counter].comd == COMD_SM)
|
||||
{
|
||||
duration = packet_list[comd_counter].duration;
|
||||
A1steps = packet_list[comd_counter].A1steps;
|
||||
A2steps = packet_list[comd_counter].A2steps;
|
||||
|
||||
process_SM(duration, A1steps, A2steps, 0, 0);
|
||||
|
||||
AllDone = FALSE;
|
||||
}
|
||||
else if (packet_list[comd_counter].comd == COMD_SP)
|
||||
{
|
||||
process_SP(packet_list[comd_counter].duration);
|
||||
|
||||
AllDone = FALSE;
|
||||
}
|
||||
|
||||
// Advance to the next command
|
||||
comd_counter++;
|
||||
|
||||
// Check to see if we're done
|
||||
if (
|
||||
(packet_list[comd_counter].comd == COMD_END)
|
||||
||
|
||||
(packet_list[comd_counter].comd > COMD_SP)
|
||||
)
|
||||
{
|
||||
DemoModeActive = FALSE;
|
||||
Enable1IO = DISABLE_MOTOR;
|
||||
Enable2IO = DISABLE_MOTOR;
|
||||
comd_counter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Stepper (mode) Configure command
|
||||
// SC,1,0<CR> will use solenoid output for pen up/down (default)
|
||||
// SC,1,1<CR> will use servo on RB1 for pen up/down
|
||||
|
|
@ -775,7 +723,7 @@ void parse_SC_packet (void)
|
|||
#if defined(BOARD_EBB_V11) || defined(BOARD_EBB_V12) || defined(BOARD_EBB_V13)
|
||||
Process_S2(1, g_servo2_min, 4, g_servo2_rate);
|
||||
#endif
|
||||
process_SP(1, 0); // Start servo up
|
||||
process_SP(PEN_UP, 0); // Start servo up
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -1012,8 +960,47 @@ static void process_SM(
|
|||
|
||||
}
|
||||
|
||||
// Query Pen
|
||||
// Usage: QP<CR>
|
||||
// Returns: 0 for down, 1 for up, then OK<CR>
|
||||
void parse_QP_packet(void)
|
||||
{
|
||||
printf((far rom char *)"%d\n\r", PenState);
|
||||
|
||||
print_ack();
|
||||
}
|
||||
|
||||
// Toggle Pen
|
||||
// Usage: TP<CR>
|
||||
// Returns: OK<CR>
|
||||
// Just toggles state of pen arm
|
||||
void parse_TP_packet(void)
|
||||
{
|
||||
unsigned short CommandDuration = 500;
|
||||
|
||||
// Extract each of the values.
|
||||
extract_number (kUINT, &CommandDuration, kOPTIONAL);
|
||||
|
||||
// Bail if we got a conversion error
|
||||
if (error_byte)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (PenState == PEN_UP)
|
||||
{
|
||||
process_SP(PEN_DOWN, CommandDuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
process_SP(PEN_UP, CommandDuration);
|
||||
}
|
||||
|
||||
print_ack();
|
||||
}
|
||||
|
||||
// Set Pen
|
||||
// Usage: SP,<1,0><CR>
|
||||
// Usage: SP,<1,0>,<Duration><CR>
|
||||
void parse_SP_packet(void)
|
||||
{
|
||||
unsigned char State = 0;
|
||||
|
|
@ -1034,13 +1021,13 @@ void parse_SP_packet(void)
|
|||
print_ack();
|
||||
}
|
||||
|
||||
void process_SP(unsigned char NewState, unsigned short CommandDuration)
|
||||
void process_SP(SolenoidStateType NewState, unsigned short CommandDuration)
|
||||
{
|
||||
// Trial: Spin here until there's space in the fifo
|
||||
while(NextReady)
|
||||
;
|
||||
|
||||
if (NewState)
|
||||
if (NewState == PEN_UP)
|
||||
{
|
||||
ToLoadCommand = COMMAND_PEN_UP;
|
||||
}
|
||||
|
|
|
|||
10
EBF/ebb.h
10
EBF/ebb.h
|
|
@ -6,14 +6,22 @@
|
|||
#define ENABLE_MOTOR (0)
|
||||
#define DISABLE_MOTOR (1)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PEN_DOWN = 0,
|
||||
PEN_UP
|
||||
} PenStateType;
|
||||
|
||||
extern unsigned int DemoModeActive;
|
||||
extern near unsigned char NextReady;
|
||||
extern unsigned int comd_counter;
|
||||
void parse_SM_packet(void);
|
||||
void parse_SC_packet(void);
|
||||
void parse_SP_packet(void);
|
||||
void parse_TP_packet(void);
|
||||
void parse_QP_packet(void);
|
||||
void EBB_Init(void);
|
||||
void parse_EM_packet(void);
|
||||
void DemoModeStateMachine(void);
|
||||
void process_SP(unsigned char NewState, unsigned short CommandDuration);
|
||||
void process_SP(PenStateType NewState, unsigned short CommandDuration);
|
||||
#endif
|
||||
Ładowanie…
Reference in New Issue