Updated project to use RB3 as an output to control the light. Also added a new light state machine.

git-svn-id: https://eggbotcode.googlecode.com/svn/trunk@261 72233254-1b6c-9e9c-5072-401df62706fb
pull/47/head
brian.schmalz 2013-03-02 22:03:53 +00:00
rodzic bd72fac013
commit 90cc2cfc1c
9 zmienionych plików z 3786 dodań i 3773 usunięć

Wyświetl plik

@ -192,7 +192,7 @@ dist/${CND_CONF}/${IMAGE_TYPE}/app-SimpleServo.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}:
@${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE}
${MP_LD} $(MP_EXTRA_LD_PRE) "source\rm18f46j50_g.lkr" -p$(MP_PROCESSOR_OPTION_LD) -w -l"./source" -z__MPLAB_BUILD=1 -u_CRUNTIME -l ${MP_CC_DIR}\\..\\lib -o dist/${CND_CONF}/${IMAGE_TYPE}/app-SimpleServo.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED}
@echo "Creating unified hex file"
@"C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/hexmate" --edf="C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/en_msgs.txt" dist/${CND_CONF}/${IMAGE_TYPE}/app-SimpleServo.X.${IMAGE_TYPE}.hex -odist/${CND_CONF}/production/app-SimpleServo.X.production.unified.hex
@"C:/Program Files/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/hexmate" --edf="C:/Program Files/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/en_msgs.txt" dist/${CND_CONF}/${IMAGE_TYPE}/app-SimpleServo.X.${IMAGE_TYPE}.hex -odist/${CND_CONF}/production/app-SimpleServo.X.production.unified.hex
endif

Wyświetl plik

@ -15,23 +15,23 @@
# $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ...
#
SHELL=cmd.exe
PATH_TO_IDE_BIN=C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/
PATH_TO_IDE_BIN=C:/Program Files/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/
# Adding MPLAB X bin directory to path.
PATH:=C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/:$(PATH)
PATH:=C:/Program Files/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/:$(PATH)
# Path to java used to run MPLAB X when this makefile was created
MP_JAVA_PATH="C:\Program Files (x86)\Microchip\MPLABX\sys\java\jre1.6.0_32-windows-x64\java-windows/bin/"
MP_JAVA_PATH="C:\Program Files\Microchip\MPLABX\sys\java\jre1.6.0_32-windows\java-windows/bin/"
OS_CURRENT="$(shell uname -s)"
MP_CC="C:\Program Files (x86)\Microchip\mplabc18\v3.44\bin\mcc18.exe"
MP_CC="C:\Program Files\Microchip\mplabc18\v3.44\bin\mcc18.exe"
# MP_CPPC is not defined
# MP_BC is not defined
MP_AS="C:\Program Files (x86)\Microchip\mplabc18\v3.44\bin\..\mpasm\MPASMWIN.exe"
MP_LD="C:\Program Files (x86)\Microchip\mplabc18\v3.44\bin\mplink.exe"
MP_AR="C:\Program Files (x86)\Microchip\mplabc18\v3.44\bin\mplib.exe"
DEP_GEN=${MP_JAVA_PATH}java -jar "C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/extractobjectdependencies.jar"
MP_CC_DIR="C:\Program Files (x86)\Microchip\mplabc18\v3.44\bin"
MP_AS="C:\Program Files\Microchip\mplabc18\v3.44\bin\..\mpasm\MPASMWIN.exe"
MP_LD="C:\Program Files\Microchip\mplabc18\v3.44\bin\mplink.exe"
MP_AR="C:\Program Files\Microchip\mplabc18\v3.44\bin\mplib.exe"
DEP_GEN=${MP_JAVA_PATH}java -jar "C:/Program Files/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/extractobjectdependencies.jar"
MP_CC_DIR="C:\Program Files\Microchip\mplabc18\v3.44\bin"
# MP_CPPC_DIR is not defined
# MP_BC_DIR is not defined
MP_AS_DIR="C:\Program Files (x86)\Microchip\mplabc18\v3.44\bin\..\mpasm"
MP_LD_DIR="C:\Program Files (x86)\Microchip\mplabc18\v3.44\bin"
MP_AR_DIR="C:\Program Files (x86)\Microchip\mplabc18\v3.44\bin"
MP_AS_DIR="C:\Program Files\Microchip\mplabc18\v3.44\bin\..\mpasm"
MP_LD_DIR="C:\Program Files\Microchip\mplabc18\v3.44\bin"
MP_AR_DIR="C:\Program Files\Microchip\mplabc18\v3.44\bin"
# MP_BC_DIR is not defined

Wyświetl plik

@ -286,35 +286,8 @@
<property key="stack-analysis-mcc18" value="false"/>
<property key="stack-analysis-mplink" value="false"/>
</C18LanguageToolchain>
<ICD3PlatformTool>
<property key="AutoSelectMemRanges" value="auto"/>
<property key="Freeze Peripherals" value="true"/>
<property key="SecureSegment.SegmentProgramming" value="FullChipProgramming"/>
<property key="ToolFirmwareFilePath"
value="Press to browse for a specific firmware version"/>
<property key="ToolFirmwareOption.UseLatestFirmware" value="true"/>
<property key="debugoptions.useswbreakpoints" value="false"/>
<property key="hwtoolclock.frcindebug" value="false"/>
<property key="memories.aux" value="false"/>
<property key="memories.bootflash" value="false"/>
<property key="memories.configurationmemory" value="false"/>
<property key="memories.eeprom" value="true"/>
<property key="memories.flashdata" value="true"/>
<property key="memories.id" value="true"/>
<property key="memories.programmemory" value="true"/>
<property key="memories.programmemory.end" value="0xfff7"/>
<property key="memories.programmemory.start" value="0x0"/>
<property key="poweroptions.powerenable" value="false"/>
<property key="programoptions.eraseb4program" value="true"/>
<property key="programoptions.preserveeeprom" value="false"/>
<property key="programoptions.preserveprogramrange" value="false"/>
<property key="programoptions.preserveprogramrange.end" value="0xfff7"/>
<property key="programoptions.preserveprogramrange.start" value="0x0"/>
<property key="programoptions.preserveuserid" value="false"/>
<property key="programoptions.usehighvoltageonmclr" value="false"/>
<property key="programoptions.uselvpprogramming" value="false"/>
<property key="voltagevalue" value="3.25"/>
</ICD3PlatformTool>
<PICkit3PlatformTool>
</PICkit3PlatformTool>
<item path="source/BL_rm18f46j50_g.lkr" ex="true" overriding="false">
<C18>
</C18>

Wyświetl plik

@ -5,7 +5,7 @@
<confs>
<conf name="EBBv13_with_bootloader" type="2">
<platformToolSN>:=MPLABCommUSB:=04D8:=9009:=0100:=Microchip Technology, Inc. (www.microchip.com):=MPLAB ICD3 tm (www.microchip.com):=JIT091597204:=x:=en</platformToolSN>
<languageToolchainDir>C:\Program Files (x86)\Microchip\mplabc18\v3.44\bin</languageToolchainDir>
<languageToolchainDir>C:\Program Files\Microchip\mplabc18\v3.44\bin</languageToolchainDir>
<mdbdebugger version="1">
<placeholder1>place holder 1</placeholder1>
<placeholder2>place holder 2</placeholder2>
@ -23,7 +23,7 @@
</conf>
<conf name="EBBv13_no_bootloader" type="2">
<platformToolSN>:=MPLABCommUSB:=04D8:=900A:=0002:=Microchip Technology Inc.:=PICkit 3:=BUR101260159:=x:=en</platformToolSN>
<languageToolchainDir>C:\Program Files (x86)\Microchip\mplabc18\v3.44\bin</languageToolchainDir>
<languageToolchainDir>C:\Program Files\Microchip\mplabc18\v3.44\bin</languageToolchainDir>
<mdbdebugger version="1">
<placeholder1>place holder 1</placeholder1>
<placeholder2>place holder 2</placeholder2>

Wyświetl plik

@ -1,8 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">
<file>file:/D:/Projects/eggbotcode/EBB_firmware/app-SimpleServo.X/source/main.c</file>
<file>file:/D:/Projects/eggbotcode/EBB_firmware/app-SimpleServo.X/source/UBW.c</file>
</open-files>
</project-private>

Wyświetl plik

@ -95,9 +95,13 @@
#define SS_STATE_WAITING_FOR_PEN_EXIT 4
#define SL_STATE_WAITING 0
#define SL_STATE_ON 1
// Constants for servo motor speed
#define SERVO_MOTOR_STOP 17600
#define SERVO_MOTOR_RUN 20000
#define SERVO_MOTOR_STOP 17625
#define SERVO_MOTOR_RUN 22000
// Constants for timed operations
#define SS_TIMER_BOOTUP_WAIT 2000 // in milliseconds - from boot to first operation
@ -213,8 +217,10 @@ unsigned int gPulseCounters[4] = {0,0,0,0};
// SimpleSerial state variable
unsigned char SimpleServoState = SS_STATE_WAITING;
unsigned char SimpleLightState = SL_STATE_WAITING;
volatile unsigned int SimpleServoTimer = 0;
volatile unsigned int SimpleLightTimer = 0;
/** P R I V A T E P R O T O T Y P E S ***************************************/
void BlinkUSBStatus (void); // Handles blinking the USB status LED
@ -276,7 +282,13 @@ void low_ISR(void)
SimpleServoTimer--;
}
// Handle RC servo pulse generation (for next pulse/channel)
// Count down SimpleLightTimer
if (SimpleLightTimer)
{
SimpleLightTimer--;
}
// Handle RC servo pulse generation (for next pulse/channel)
// Always incriment the gRCServo2msCounter
gRC2msCounter++;
@ -722,6 +734,10 @@ void UserInit(void)
// Set up timer for bootup wait
SimpleServoTimer = SS_TIMER_BOOTUP_WAIT;
// Set up PortB pin 3 as an output, and set low (turn light off)
TRISBbits.TRISB3 = OUTPUT_PIN;
PORTBbits.RB3 = 0;
}//end UserInit
@ -773,7 +789,7 @@ void ProcessIO(void)
case SS_STATE_WAITING:
if (SimpleServoTimer == 0)
{
process_SM(2000, 0, -10000);
process_SM(2000, 0, -12000);
SimpleServoTimer = 3000;
SimpleServoState = SS_STATE_LIFT_RUNNING_DOWN;
}
@ -783,7 +799,7 @@ void ProcessIO(void)
if (SimpleServoTimer == 0)
{
RCServo2_Move(SERVO_MOTOR_RUN, 3, 0, 0);
SimpleServoTimer = 1000;
SimpleServoTimer = 100;
SimpleServoState = SS_STATE_RUNNING_MOTOR;
}
break;
@ -806,13 +822,11 @@ void ProcessIO(void)
break;
case SS_STATE_WAITING_FOR_PEN_EXIT:
if (PORTBbits.RB2 == 1)
{
if (PORTBbits.RB2 == 1)
{
process_SM(2000, 0, -10000);
SimpleServoTimer = 5000;
SimpleServoState = SS_STATE_LIFT_RUNNING_DOWN;
}
process_SM(2000, 0, -10000);
SimpleServoTimer = 5000;
SimpleServoState = SS_STATE_LIFT_RUNNING_DOWN;
}
break;
@ -820,7 +834,31 @@ void ProcessIO(void)
break;
}
// Check for any new I packets (from T command) ready to go out
switch (SimpleLightState)
{
case SL_STATE_WAITING:
if (SimpleServoState == SS_STATE_LIFT_RUNNING_DOWN)
{
PORTBbits.RB3 = 1;
SimpleLightTimer = 10000;
SimpleLightState = SL_STATE_ON;
}
break;
case SL_STATE_ON:
if (SimpleLightTimer == 0)
{
PORTBbits.RB3 = 0;
SimpleLightState = SL_STATE_WAITING;
}
break;
default:
break;
}
// Check for any new I packets (from T command) ready to go out
while (ISR_D_FIFO_length > 0)
{
// Spit out an I packet first