Skip to content

Commit

Permalink
Setting up to time packet send speed.
Browse files Browse the repository at this point in the history
  • Loading branch information
apullin committed Feb 9, 2013
1 parent d73be63 commit ca6f00a
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 14 deletions.
81 changes: 72 additions & 9 deletions firmware/nbproject/configurations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
<itemPath>../../imageproc-lib/dfilter_avg.h</itemPath>
<itemPath>../../imageproc-lib/gyro.h</itemPath>
<itemPath>../../imageproc-lib/pid_hw.h</itemPath>
<itemPath>../../imageproc-lib/stopwatch.h</itemPath>
<itemPath>../../imageproc-lib/pid.h</itemPath>
<itemPath>../../imageproc-lib/ams-enc.h</itemPath>
<itemPath>../../imageproc-lib/spi_controller.h</itemPath>
<itemPath>../../imageproc-lib/dfmem.h</itemPath>
<itemPath>../../imageproc-lib/tih.h</itemPath>
<itemPath>../../imageproc-lib/adc_pid.h</itemPath>
</logicalFolder>
<logicalFolder name="lib" displayName="lib" projectFiles="true">
<itemPath>../lib/motor_ctrl.h</itemPath>
Expand All @@ -35,15 +35,15 @@
<itemPath>../lib/sensors.h</itemPath>
<itemPath>../lib/estop.h</itemPath>
<itemPath>../lib/telem.h</itemPath>
<itemPath>../../imageproc-lib/dfmem.h</itemPath>
<itemPath>../../imageproc-lib/i2c_driver.h</itemPath>
<itemPath>../lib/leg_ctrl.h</itemPath>
<itemPath>../lib/tail_queue.h</itemPath>
<itemPath>../lib/tail_ctrl.h</itemPath>
<itemPath>../lib/sys_service.h</itemPath>
<itemPath>../lib/hall.h</itemPath>
<itemPath>../lib/ams-enc.h</itemPath>
<itemPath>../lib/imu.h</itemPath>
<itemPath>../../imageproc-lib/sclock.h</itemPath>
<itemPath>../lib/or_telem.h</itemPath>
</logicalFolder>
<itemPath>source/cmd.h</itemPath>
<itemPath>source/settings.h</itemPath>
Expand Down Expand Up @@ -76,8 +76,9 @@
<itemPath>../../imageproc-lib/pid.c</itemPath>
<itemPath>../../imageproc-lib/version.c</itemPath>
<itemPath>../../imageproc-lib/sclock.c</itemPath>
<itemPath>../../imageproc-lib/ams-enc.c</itemPath>
<itemPath>../lib/debugpins.c</itemPath>
<itemPath>../../imageproc-lib/spi_controller.c</itemPath>
<itemPath>../../imageproc-lib/ams-enc.c</itemPath>
</logicalFolder>
<logicalFolder name="lib" displayName="lib" projectFiles="true">
<itemPath>../../imageproc-lib/delay.s</itemPath>
Expand All @@ -94,8 +95,8 @@
<itemPath>../lib/sys_service.c</itemPath>
<itemPath>../lib/hall.c</itemPath>
<itemPath>../lib/imu.c</itemPath>
<itemPath>../lib/adc_pid.c</itemPath>
<itemPath>../lib/or_telem.c</itemPath>
<itemPath>../lib/adc_pid.c</itemPath>
</logicalFolder>
<itemPath>source/cmd.c</itemPath>
<itemPath>source/main.c</itemPath>
Expand Down Expand Up @@ -748,8 +749,70 @@
<property key="oXC16glb-macros" value="PID_HARDWARE;__IMAGEPROC2"/>
<property key="output-file-format" value="elf"/>
</C30Global>
<RealICEPlatformTool>
</RealICEPlatformTool>
<ICD3PlatformTool>
<property key="ADC 1" value="true"/>
<property key="ADC 2" value="true"/>
<property key="AutoSelectMemRanges" value="auto"/>
<property key="Freeze All Other Peripherals" value="true"/>
<property key="I2C1" value="true"/>
<property key="I2C2" value="true"/>
<property key="INPUT CAPTURE 1" value="true"/>
<property key="INPUT CAPTURE 2" value="true"/>
<property key="INPUT CAPTURE 3" value="true"/>
<property key="INPUT CAPTURE 4" value="true"/>
<property key="INPUT CAPTURE 5" value="true"/>
<property key="INPUT CAPTURE 6" value="true"/>
<property key="INPUT CAPTURE 7" value="true"/>
<property key="INPUT CAPTURE 8" value="true"/>
<property key="OUTPUT COMPARE 1" value="true"/>
<property key="OUTPUT COMPARE 2" value="true"/>
<property key="OUTPUT COMPARE 3" value="true"/>
<property key="OUTPUT COMPARE 4" value="true"/>
<property key="OUTPUT COMPARE 5" value="true"/>
<property key="OUTPUT COMPARE 6" value="true"/>
<property key="OUTPUT COMPARE 7" value="true"/>
<property key="OUTPUT COMPARE 8" value="true"/>
<property key="PWM" value="false"/>
<property key="QEI" value="true"/>
<property key="SPI 1" value="true"/>
<property key="SPI 2" value="true"/>
<property key="SecureSegment.SegmentProgramming" value="SegmentProgrammingAll"/>
<property key="TIMER1" value="true"/>
<property key="TIMER2" value="true"/>
<property key="TIMER3" value="true"/>
<property key="TIMER4" value="true"/>
<property key="TIMER5" value="true"/>
<property key="TIMER6" value="true"/>
<property key="TIMER7" value="true"/>
<property key="TIMER8" value="true"/>
<property key="TIMER9" value="true"/>
<property key="ToolFirmwareFilePath"
value="Press to browse for a specific firmware version"/>
<property key="ToolFirmwareOption.UseLatestFirmware" value="true"/>
<property key="UART 1" value="true"/>
<property key="UART 2" 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="0x157ff"/>
<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="0xff"/>
<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>
</conf>
</confs>
</configurationDescriptor>
7 changes: 7 additions & 0 deletions lib/debugpins.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "p33fj128mc706a.h"
#include "debugpins.h"
#include "utils.h"

//Pins are ordinally numbers from outboard (1) to inboard (6)

Expand All @@ -17,6 +18,12 @@ void debugpins_init() {
TRISDbits.TRISD2 = 0;
TRISDbits.TRISD3 = 0;
TRISDbits.TRISD4 = 0;
debugpins1_set();
debugpins2_set();
debugpins3_set();
debugpins4_set();
debugpins5_set();
debugpins6_set();
debugpins1_clr();
debugpins2_clr();
debugpins3_clr();
Expand Down
16 changes: 14 additions & 2 deletions lib/telem.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
#include "sys_service.h"
#include "cmd.h" //for CMD codes
#include <string.h> //for memcpy
#include "debugpins.h"
//This include will set the telemtry format
#include "or_telem.h"

#define TIMER_FREQUENCY 300 // 400 Hz
#define TIMER_PERIOD 1/TIMER_FREQUENCY
#define DEFAULT_SKIP_NUM 1 //Default to 150 Hz save rate
#define DEFAULT_SKIP_NUM 2 //Default to 150 Hz save rate
//#define LSB2DEG 0.0695652174 //DEFINED IN TWO PLACES!

#if defined(__RADIO_HIGH_DATA_RATE)
Expand Down Expand Up @@ -92,7 +93,14 @@ void telemSetup() {
//Telemetry packet size is set at startupt time.
telemDataSize = orTelemGetSize(); //OctoRoACH specific
//Allocate telemetry packet data buffer on heap.
telemBuffer.telemData = (unsigned char*) malloc(telemDataSize);
unsigned char* memptr = malloc(telemDataSize);
if(memptr){
telemBuffer.telemData = memptr;
}
else{
//Major failure, cannot allocate telemetry buffer
while(1);
}

telemPacketSize = telemDataSize
+ sizeof(telemBuffer.sampleIndex) + sizeof(telemBuffer.timestamp);
Expand Down Expand Up @@ -123,9 +131,11 @@ void telemReadbackSamples(unsigned long numSamples) {
dfmemReadSample(i, sizeof (sampleData), (unsigned char*) (&sampleData));
//Reliable send, with linear backoff
do {
debugpins1_set();
telemSendDataDelay(delaytime_ms);
//Linear backoff
delaytime_ms += 2;
debugpins1_clr();
} while (phyGetLastAckd() == 0);

delaytime_ms = READBACK_DELAY_TIME_MS;
Expand Down Expand Up @@ -155,7 +165,9 @@ void telemSendDataDelay(int delaytime_ms) {

// Handles pld delete: Assigns pointer to payload in packet
// and radio command deletes payload, then packet.
debugpins2_set();
radioSendPayload(macGetDestAddr(), pld);
debugpins2_clr();

delay_ms(delaytime_ms); // allow radio transmission time

Expand Down
3 changes: 1 addition & 2 deletions python/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ def main():
# 85, 85, 6500, MOVE_SEG_CONSTANT, 0, 0, 0, STEER_MODE_YAW_DEC, int(round(shared.deg2count*160.0)),
# 85, 85, 6200, MOVE_SEG_CONSTANT, 0, 0, 0, STEER_MODE_YAW_DEC, int(round(shared.deg2count*240.0))]

numMoves = 2
numMoves = 1
moveq1 = [numMoves, \
0, 0, 250, MOVE_SEG_CONSTANT, 0, 0, 0, STEER_MODE_OFF, 0,
0, 0, 250, MOVE_SEG_CONSTANT, 0, 0, 0, STEER_MODE_OFF, 0]

#No movements, just for static telemetry capture
Expand Down
2 changes: 1 addition & 1 deletion python/or_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def setupImudata(self, moveq):
self.runtime = sum([moveq[i] for i in [(ind*MOVE_QUEUE_ENTRY_LEN)+3 for ind in range(0,moveq[0])]])

#calculate the number of telemetry packets we expect
self.numSamples = int(ceil(300 * (self.runtime + self.leadinTime + self.leadoutTime) / 1000.0))
self.numSamples = int(ceil(150 * (self.runtime + self.leadinTime + self.leadoutTime) / 1000.0))
#allocate an array to write the downloaded telemetry data into
self.imudata = [ [] ] * self.numSamples
self.clAnnounce()
Expand Down

0 comments on commit ca6f00a

Please sign in to comment.