I am working on a project to detect the position of an impact using three vibration sensors each one of them linked to a micro-controller(in my case STM32F4) .

Using ADC and UART ,I can plot with a python script the graphic for each of the data received,thus when i do a tap inside the triangle of the three devices(vibration sensor+STM32F4) i can see that there is a delay between the three line chart.

My goal is to detect where the impact has occured and then plot it. I saw that i can do that using triangulation. I would like to do that with a python script and plotting for example the triangle and when an impact occurs inside of it,it shows me its position. As far as i saw,the triangulation is a solution to this but i don't know where to begin or what to do .

How can I do that with triangulation ?

  • \$\begingroup\$ Welcome to EE.SE. What delay did you see? (How many ns / ms?) You need to show a bit of effort with the triangulation calculation? What did your research teach you and where did you get stuck? \$\endgroup\$
    – Transistor
    Mar 17, 2016 at 16:44
  • \$\begingroup\$ As I have a project that does precisely this, I will give you a hint to get you started: You will need a capture timer for each sensor. As noted, we will help, but we won't do the whole thing for you. \$\endgroup\$ Mar 17, 2016 at 16:48
  • \$\begingroup\$ I don't think I understood, you have everything yet done, but you don't know how to calculate the triangulation? Perhaps is this question more suitable for math forum. \$\endgroup\$ Mar 17, 2016 at 18:26
  • \$\begingroup\$ I have a timestamp Thanks to the internal clock (RTC) . For the devices everything is OK,Now is left the part to analyse the charts and do a triangulation but I don't know how to do that \$\endgroup\$ Mar 18, 2016 at 9:29
  • \$\begingroup\$ Your question is about trilateration, not triangulation. In triangulation you locate a point in space using angle measurements, while in trilateration you solve the position using distance measurements only. More specifically you are seeking to do differential time of arrival trilateration, since you cannot measure the impact time directly, instead having to solve the distance based on how much longer the wave took to arrive at the other sensors relative to the first. \$\endgroup\$
    – jms
    Mar 20, 2016 at 5:16

1 Answer 1


You don't need a timestamp, because the triangulation works on difference of time, so the absolute RTC time has no significance and adds unecessary burden to the MCU. You have to start recodrding with deterministic time (aka cyclic interrupt)in RAM all channels in a circular buffer, when you detect the impact you end the recordings.
Then I would use a cross corelation between each dataset to determine the delay, A vs B, B vs C, A vs C (A,B,C are signals), te cross corelation will give you the rate of similarity between each signal, at its peak value you have the most probable delay between towo signals, then all you have to do is triangulation math.

  • \$\begingroup\$ How to record with deterministic Time? because i have three devices not three sensors with a single microcontroller so I don't have multiple channels. Then how i can achieve cross correlation? \$\endgroup\$ Mar 21, 2016 at 13:14
  • \$\begingroup\$ So i have three txt files having as follow value,time Now how do i do the cross correlation in python then how to triangulate? \$\endgroup\$ Mar 21, 2016 at 16:08
  • \$\begingroup\$ Firs of all, I never heard that STM32F4 can be programmed in python, then you have to describe what is your setup, who can know if you have one device or multiple devices. If those devices are located appart then I guess you have to synchronize them and probably you will need GPS synced Xtal oscilator for each MCU, since the signal recording will differ in lenght if the MCUs don't have exact clock. \$\endgroup\$ Mar 21, 2016 at 16:15
  • \$\begingroup\$ Stm32f4 just get the data and from a python script on the laptop i get the data through the serial port then save it in a file. I have multiple devices(three actually) ,i explained it in my question . They don't have exact clock,but with the python script,i launch three python scripts that each one read from a serial port of each of the devices ,i run them in the same time so that they can be synchronized \$\endgroup\$ Mar 21, 2016 at 17:03
  • \$\begingroup\$ @YoussefKamoun Each device has it's own sytem clock, XTAL of MCU which are not 100% exact further they drift due to temperature. Once you do the cross-correlation these small differences of clock makes the result of cross-correlation useless. \$\endgroup\$ Mar 21, 2016 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.