Same as mallet... but distance
Dependencies: EthernetInterface NetworkAPI mbed-rtos mbed
Fork of MalletFirmware by
Revision 23:9e5141647775, committed 2014-12-03
- Comitter:
- timmey9
- Date:
- Wed Dec 03 06:22:46 2014 +0000
- Parent:
- 22:523e316cbe70
- Child:
- 24:a5891669afc5
- Commit message:
- Compiles and works with MATLAB with everything uncommented except for Sampler.attach_us(%timed_sample,yadadada
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Dec 03 05:30:45 2014 +0000 +++ b/main.cpp Wed Dec 03 06:22:46 2014 +0000 @@ -96,7 +96,7 @@ DigitalOut led_green(LED_GREEN); DigitalOut led_blue(LED_BLUE); -/* + // motor control and angle encoder MotorControl motor(PTC2, PTA2, PERIOD, ON_OFF_TIME); // forward, backward, period, safetyPeriod AngleEncoder angle_encoder(PTD2, PTD3, PTD1, PTD0, 8, 0, 1000000); // mosi, miso, sclk, cs, bit_width, mode, hz @@ -104,9 +104,9 @@ DigitalIn AMT20_B(PTC1); // input for quadrature encoding from angle encoder // Analog sampling -Ticker Sampler; -Timer timer; -Timer timeStamp; +//Ticker Sampler; +//Timer timer; +//Timer timeStamp; AnalogIn A0_pin(A0); AnalogIn A2_pin(A2); @@ -130,12 +130,12 @@ // Important globabl variables necessary for the sampling every interval int rotary_count = 0; uint32_t last_AMT20_AB_read = 0; -*/ + //using namespace network; using namespace std; int main() { - uint32_t sample_array[TOTAL_SAMPLES]; + for(int i = 0; i < TOTAL_SAMPLES; i++) {sample_array[i] = i;} led_blue = 1; led_green = 1; @@ -143,20 +143,20 @@ pc.baud(230400); pc.printf("Starting Server\r\n"); - /* + analog_initialization(A0); analog_initialization(A2); // setup this timer - timeStamp.stop(); - timeStamp.reset(); + //timeStamp.stop(); + //timeStamp.reset(); // Start the sampling loop current_sample_index = WAITING_TO_BEGIN; - Sampler.attach_us(&timed_sampling, SAMPLING_RATE); - __disable_irq(); // Disable Interrupts - timer.reset(); - timer.start(); + //Sampler.attach_us(&timed_sampling, SAMPLING_RATE); + //__disable_irq(); // Disable Interrupts + //timer.reset(); + //timer.start(); uint32_t trigger_count = 0; @@ -166,7 +166,7 @@ int32_t pointer = 0; double duty_cycle = 0.25; - */ + // flash red LED led_red = 0; wait_ms(500); @@ -187,10 +187,6 @@ interface.init(); #endif - // turn on yellow led - led_red = 0; - led_green = 0; - interface.connect(); pc.printf(NAME); pc.printf("IP Address is: %s\n\r", interface.getIPAddress()); @@ -200,7 +196,7 @@ pc.printf("Port is: %i\n\r", PORT); // ethernet setup failed for some reason. Flash yellow light then uC resets itself - /*if(interface.getIPAddress() == 0) + if(interface.getIPAddress() == 0) { for(int i = 0; i < 5; i++) { @@ -212,7 +208,7 @@ wait_ms(1000); } NVIC_SystemReset(); - }*/ + } network::Select select; network::tcp::Socket server; @@ -239,9 +235,12 @@ led_red = 1; led_green = 1; led_blue = 0; - wait_ms(1000); + wait_ms(500); led_blue = 1; - + wait_ms(200); + led_blue = 0; + wait_ms(500); + led_blue = 1; do { // Wait for activity @@ -380,10 +379,10 @@ } while (server.getStatus() == network::Socket::Listening); } -/* + void timed_sampling() { __disable_irq(); // Disable Interrupts - timeStamp.start(); + //timeStamp.start(); // The following performs analog-to-digital conversions - first reading the last conversion - then initiating another uint32_t A0_value = adc_hal_get_conversion_value(0, 0); @@ -431,10 +430,10 @@ else { current_sample_index++; } } - int tempVar = timeStamp.read_us(); - timeStamp.stop(); - timeStamp.reset(); - pc.printf("TimeStamp: %i\r\n", tempVar); + //int tempVar = timeStamp.read_us(); + //timeStamp.stop(); + //timeStamp.reset(); + //pc.printf("TimeStamp: %i\r\n", tempVar); __enable_irq(); // Enable Interrupts } @@ -481,4 +480,3 @@ } } -*/ \ No newline at end of file