STM32F103 BPSK

What are you developing?
ChrisMicro
Posts: 259
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: STM32F103 BPSK

Post by ChrisMicro » Sat Aug 12, 2017 3:33 pm

US=ultra sound

red and blue are both received signals. See the code:

Code: Select all

/*
  US modulatéd sender
  hardware:
    STM32F103 BluePill, 72Mhz
  Arduino Framework:
    STM32GENERIC

  Aug. 2017 ChrisMicro
*/

#include "HardwareTimer.h"

#define SOUNDPIN PB1

#define SIGNALLENGTH 24
uint8_t Signal[SIGNALLENGTH];
int SignalIndex = 0;

void interrupt()
{
  if (SignalIndex < SIGNALLENGTH)
  {
    digitalWrite(SOUNDPIN,Signal[SignalIndex]); 
    SignalIndex++;
  }
}

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(SOUNDPIN, OUTPUT);

  // T=1/f = 1/40000
  int frequency_Hz = 40000;
  //Timer1.setPeriod(1000000/frequency_Hz/2); // half period interrupt
  Timer1.setPeriod(6); // 41.67khZ half period interrupt ( error of factor 2 in setPeriod )

  Timer1.attachInterrupt(interrupt);
  Timer1.resume();
}

void loop()
{
  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));

  // blue signal
  for (int n = 0; n < SIGNALLENGTH; n++)
  {
    Signal[n] = n & 0x01; // zero degree phase signal
  }
  SignalIndex = 0; // send new Signal
  delay(10);

  // red signal
  for (int n = 0; n < SIGNALLENGTH; n++)
  {
    if (n < SIGNALLENGTH / 2) Signal[n] = n & 0x01; // zero degree phase signal
    else Signal[n]=(n-1) & 0x01; // 180 degree phase signal
  }
  SignalIndex = 0; // send new Signal
  delay(10);
}

jean-paul
Posts: 11
Joined: Thu Aug 10, 2017 11:56 am

Re: STM32F103 BPSK

Post by jean-paul » Sat Aug 12, 2017 7:10 pm

Oh ok I see.
This is what I got:
Sent pulse
Image
Sent and receiced at around 1.7m, with 20ms data.
Image

I think the US has problem doing 180° phase shift. I think it's better to do frequency shift but these sensors are low bandwith.

Jean-Paul
Attachments
sent.jpg
sent.jpg (50.72 KiB) Viewed 125 times
roof.jpg
roof.jpg (32.74 KiB) Viewed 125 times

ChrisMicro
Posts: 259
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: STM32F103 BPSK

Post by ChrisMicro » Sat Aug 12, 2017 9:51 pm

Nice pictures. My impression is that the transducers are neither suitable for phase coding nor for frequency coding. They have a too large self resonance.
If you goal is to realize indoor positioning the new way is using UWB time of flight measurement. There are now the first application boards also usable with Arduino:
https://www.decawave.com/products/overview

User avatar
RogerClark
Posts: 6374
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: STM32F103 BPSK

Post by RogerClark » Sat Aug 12, 2017 10:03 pm

Decawave looks interesting, but is quite expensive.

Another option is the laser based Time Of Flight devices from STM.
There is another thread about using these,
I have some of the long range version, but the range is limited to below 2m

jean-paul
Posts: 11
Joined: Thu Aug 10, 2017 11:56 am

Re: STM32F103 BPSK

Post by jean-paul » Sun Aug 13, 2017 11:31 am

Yes you are right, I tried to send another frequency and it resonantes at a different one with a lot of harmonics!

FFT of pulses at 41 KHz
Image


FFT of pulses at 44 KHz
Image

I need to find a better transducer...
Attachments
35 pulse - timer 870 fft.jpg
35 pulse - timer 870 fft.jpg (20.24 KiB) Viewed 99 times
35 pulse - timer 820 fft.jpg
35 pulse - timer 820 fft.jpg (33.62 KiB) Viewed 99 times

ChrisMicro
Posts: 259
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: STM32F103 BPSK

Post by ChrisMicro » Mon Aug 14, 2017 2:55 pm

I'm just looking for the schematic of the HC-SR04.
Could this be the right one?
Image

jean-paul
Posts: 11
Joined: Thu Aug 10, 2017 11:56 am

Re: STM32F103 BPSK

Post by jean-paul » Wed Aug 16, 2017 6:35 am

Hello,

Yes I think it's right. But on mine I don't have the 2 transistors!

zmemw16
Posts: 1293
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: STM32F103 BPSK

Post by zmemw16 » Wed Aug 16, 2017 3:31 pm

i've seen smd packages with complementary transistors in them.
srp

ChrisMicro
Posts: 259
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: STM32F103 BPSK

Post by ChrisMicro » Thu Aug 17, 2017 5:06 am

Yes I think it's right. But on mine I don't have the 2 transistors!
I think Q1 is only for threshold level adaption which is probably not really necessary and Q2 is for power saving which they removed to save costs.
The interesting point is the MAX232 RS232 driver which they misuse as sender driver.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests