GithubHelp home page GithubHelp logo

davidzwa / advanced-iot-lisat Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 151.87 MB

LISAT code for Avanced IoT course

C++ 1.13% Python 0.12% MATLAB 0.09% C 2.41% Objective-C 0.01% Batchfile 0.07% HTML 0.29% Makefile 1.97% CMake 0.41% Shell 0.01% G-code 93.51%

advanced-iot-lisat's People

Contributors

amjadmajid avatar davidzwa avatar terrasfear avatar tomasvr avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

advanced-iot-lisat's Issues

Add long buffer processing black-box

struct valin_tdoa_input {
   uint16_t tdoa1;
   uint16_t tdoa2;
   uint16_t tdoa3;
}
valin_tdoa_input processThreeLongBuffer(int16_t* micBuffer1L, int16_t* micBuffer2M, int16_t* micBuffer3R, int16_t bufferLength) {
    // ... calculate tdoa's with buffers and bufferLength

   // ... call processSingleBuffer x3 if wanted

    return valin_tdoa_input;
}

some_return_type processSingleBuffer(int16_t* micBuffer1L, int16_t bufferLength) {
   // ... extract features/validation on single buffer
}

Software tasks - demo

  • Implement differentialDrive and tachometers
  • Build-up MQTT backbone to ESP |   | David | Test/done | Need to fix 50/50 receiving bug, need to speed up setup roundtrip.
  • Build-up serial interface passthrough |   | David | Test/done | Does the ESP need to filter on MQTT topic? Might be nice to filter on a certain unicast message, if we every going to use that.
  • Build-up audio interface with START/STOP GPIO | Tomas
  • Implement short/long buffer mode toggle | David
  • Develop quick Matlab verification correlator | Casper
  • Setup digital sensors line detection | Tomas
  • Develop C++ implementation of smart audio correlator | David, Casper
  • Functional system (FSM) | Tomas
  • Develop C++ implementation of preamble detector | David, Casper
  • Implement ESP Serial threading | David
  • Finalize implementing line sensors | Tomas
  • Develop PID for straight driving | David
  • Test tachometers with real distance | David
  • Python CLI to monitor simulation and gather data |   | David |   | Need to send MQTT/serial (MVP): type experiment, max speed. - Need to receive: robot audio detection LEFT/RIGHT/FORWARD/BEHIND
  • Python MQTT CLI coupling |   | David |   (#65)
  • Finalize DOA detection
  • Finalize MQTT and DOA/RMS blocks
  • Finalize demo range/junction

ESP8266 3mic 'energy' measurement challenges

Yesterday [10/04/2020] I did some coarse coding and measuring. I dont share the measurements as they were very unreliable.

I did the following:

  • Couple interrupts to 3 pins
  • Set Mode pin to 1 pin (so all mics are reset to Wake-on-sound at the same time)
  • Use a trigger from 1 specific mic (leader) to start sampling mic
  • Sample for an amount of ms (usually about 200ms)
  • Sum up amplitude of BPF(EMA) filtered signal, secondly average out amplitude of raw signal, thirdly determine min and max.

So far the min/max seems at least a bit promising.

We need to scrutineer the code. A lot. Otherwise this is not gonna work on this Arduino level.

Distance measurement challenges

Yesterday [10/04/2020] I did some coarse coding and measuring. I dont share the measurements as they were very unreliable.

I did the following:

  • Couple interrupts to 3 pins
  • Set Mode pin to 1 pin (so all mics are reset to Wake-on-sound at the same time)
  • Use a trigger from 1 specific mic (leader) to start sampling mic
  • Sample for an amount of ms (usually about 200ms)
  • Sum up amplitude of BPF(EMA) filtered signal, secondly average out amplitude of raw signal, thirdly determine min and max.

So far the min/max seems at least a bit promising.

We need to scrutineer the code. A lot. Otherwise this is not gonna work on this Arduino level.

Define IO allocation for new PMM-3738-VM1010-R mics + trigger

I should find a suitable allocation where we want

  • digital Interruptable pins for each mic
  • analog ADC pins for sampling after interrupt has triggered

Currently using

    ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A15, false);  // Pin A15, P6_0
    ADC14_configureConversionMemory(ADC_MEM1, ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A12, false);  // Pin A12, P4_1
    ADC14_configureConversionMemory(ADC_MEM2, ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A10, false);  // Pin A10, P4_3
    ADC14_configureConversionMemory(ADC_MEM3, ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A7, false);   // Pin A7,  P4_6

Function specification

#defines 

struct valin_tdoa_input {
   uint16_t tdoa1;
   uint16_t tdoa2;
   uint16_t tdoa3;
}
valin_tdoa_input processThreeLongBuffer(uint16_t* micBuffer1L, uint16_t* micBuffer2M, uint16_t* micBuffer3R, int16_t bufferLength) {
    // ... calculate tdoa's with buffers and bufferLength

   // ... call processSingleBuffer x3 if wanted

    return valin_tdoa_input;
}

some_return_type processSingleBuffer(uint16_t* micBuffer1L, int16_t bufferLength) {
   // ... extract features/validation on single buffer
}

Remote drive

Send MQTT messages with driving commands to test update rate and delays.

Hardware and DIY tasks - assembly and demo

  • Re-design 3D print + CURA slice | 10/25 | David, Britt
  • Get to Ewoud/Sujay for 3D print agreement | 10/27 | David
  • Slice, produce and postprocess 3D print | 10/30 | David
  • Solder/tape bundle cables for Mics |   | Casper, David
  • Put robot together (+2/3 from Amjad) |   | Casper, Tomas
  • Get batteries x24 (Action, Aldi) |   | Casper
  • Get all mics to Casper |   | Amjad, David
  • Test 'non-LineOfSight'/shadowed mic setup (lollypop sticks) |   | Casper?

This issue might be outdated at any time. Please refer to:
https://docs.google.com/spreadsheets/d/1xfLJalJ33kFLRBhn2JFWGeNL8D0fKpyxuKJtPzLRWn8/edit?usp=sharing

preamble detection

function prototype to give a matching-score for the preamble

q15_t preamble_match(q15_t* mic_buffer)
{
	int16_t ADC_buffer_size_short
	int16_t preamble_sample_length = ADCBUFFERSIZE_SHORT;
	q15_t preamble_sample [preamble_sample_length] = {sinus ....}

	q15_t multiplication_array [ADC_buffer_size_short];
	q15_t correlation_output;
	q15_t absolute_correlation_output;
	q15_t match_score = 0;

	for( int16_t i = 0; i < 1/2 * preamble_sample_wave_length_samples; i++)
	{
		arm_mult_q15(mic_buffer, preamble_sample + i, multiplication_array, ADCBUFFERSIZE_SHORT);
		
		for( int16_t j = 0; j < ADCBUFFERSIZE_SHORT; j++)
		{
			arm_add_q15(&correlation_output, &multiplication_array, &correlation_output, 1);
		}
		
		arm_abs_q15(&correlation_output, &absolute_correlation_output, 1);
		
		if (absolute_correlation_output > match_score)
		{
		    match_score = absolute_correlation_output;
		}

		// Optimally calculate what we need to know
		if (absolute_correlation_output > match_score)
		{
		      match_score = absolute_correlation_output;
		}
		return match_score;
	}
}

3-robot line correction 'piece-wise/deltaT' algorithm

We need a small sketch, a write-up/diagram for this week and simulation + C implementation before next week based on the interface discussed:

How I see it in C/C++:

MspCommandPacket* calculateDeltaTNavigation(int selfPositionX, int selfPositionX, float errorEstimate,  ... other robot metadata?) {

 // ... determineBest 'piecewise' approach to get us in line with 2 other robots
}

Migrate ADC + trigger scheme from ESP to MSP

Everything online points at that the ESP is not meant for analog sampling (also looking at the fact that there is only one ADC on it of only 10 bits). Secondly, we dont think the timer precision of the ESP is good enough due to the fact that there supposedly are only 2 priorities on the interrupts, which cannot be changed in the Arduino ESP environment. (WiFi on timer0 will go above anything on timer1). This is a blocking problem and to avoid it we need to go back to the MSP.

At least we have a point of reference now and good experiments (#14), which we should try and rebuild with the MSP432 + logic analyzer.

The final challenge is then incorporating the Serial interface in such a way that UART gets 'the right priority' on the MSP. So the ESP is silent when the MSP is listening by agreement (time slotting). We should only allows communication from Serial on high priority packets (so Stop command).

Provide final pinout overview

CCS10 Syscfg for final pinout
https://github.com/davidzwa/advanced-iot-lisat/blob/master/src/MSP432LISAT/MSP432P401R_LISAT_ccs/MSP432_LISAT2_new.syscfg

Written out
This is more to make sure we dont exceed the pins and avoid assigning too many to the MSP432. The ESP8266 can also do some tasks if needed.

External

  • Speaker (PLAY/STOP, has own battery, runs on ~4.7V) = 2 GPIO (or 3)
  • Mic x3 (WOS/DOUT/VOUT) = 2+2 GPIO in/out, 2 ANALOG-IN GPIO
  • ESP RX/TX = 2 UART GPIO
  • LED x4 (check if MSP432 output can drive LED's)

Internal/chassis board

  • Tacho x2 (pulse direction and speed signal) = 2 GPIO + 2 GPIO (timer capture)
  • Motor x2 (DIR, SLEEP, POWER) = 4 GPIO, 2 PWM
  • Line sense x8 (11 pins, OUTx8, 3V3, GND) = 8 GPIO INPUT + 1 LED GPIO OUTPUT

Total required:
External: 2+6+2=10
Chassis: 2+6+9=17
Total: 27 pins
Available: a lot more

Define final MVP for report

Report is much earlier than demo, so should contain

  • data & simulations in final state
  • hardware & software implementation argumentation & final concept description
  • demo vs reality expectations: future project possibilities and success/failure of laid foundation

Build O_robot DiffDrive on TI-Driver level + sysconfig

Goal:

Calibrate tachometers together with setting 'millimeter per second' speed of wheels. Integrate with differentialDrive calculations to drive robot straight ahead.

Formulas:

(Pinout config from O_robot):

  • P1_6, P1_7 are motor direction
  • P2_6, P2_7 are power (pwm?)
  • P3_6, P3_7 control sleep

Improve tachometer

There seems to be some questions unsolved about the quadrature 2-signal encoder.
https://www.pololu.com/product/3542

Would be nice to:

  • implement the correct ratio (12 seems to match up with reality, but advise was to use 3 as we have 1 signal and 1 edge)
  • use both signals to get much better speed estimates as the estimation error is detrimental at low speeds right now
  • figure out the compare/capture concerning the fact that not both can be used as GPIO interrupt

Use https://www.pololu.com/product/3542 data instead of TI Module reference.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.