Please keep the discussion on the mailing list so everyone can help or
benefit.

There are 3 different Peak Detector blocks available in GNU Radio. These
block output a "1" byte when a peak is detected, and "0" otherwise.
https://wiki.gnuradio.org/index.php/Detect_Peak
https://wiki.gnuradio.org/index.php/Peak_Detector
https://wiki.gnuradio.org/index.php/Peak_Detector2
The last one has an example.

Maybe what you really want is a Threshold
https://wiki.gnuradio.org/index.php/Threshold
followed by a Burst Tagger
https://wiki.gnuradio.org/index.php/Burst_Tagger

There are a few things to learn about GNU Radio, whatever way you go. I'm
going to discourage the use of a Python block for this project because it
adds complexity, and I think most of what you need to do is already present
in blocks.

Data will not be huge (from a computer perspective) if you log every beep.
Logging a lot of data and post processing allows you to try out different
algorithms without going out and collecting data every time you want to
change something.

On Tue, Nov 21, 2023 at 10:33 AM Al Grant <bigal...@gmail.com> wrote:

> Hi Jeff,
>
> Thanks for the reply . I should have added that we won't log every
> read of the signal, that would be 90 beeps per minute for some of them
> - and the size of the file would be huge. Once per day is probably
> enough.
>
> But first I need to understand input_items, and how to do a peak
> detection on it. I was just going to use a line like: `if
> input_items[0][index-1] > input_items[0][index] and
> input_items[0][index-1] > input_items[0][index-2]:` but I think I now
> realise that work function gets called multiple times during signal
> processing and index does not equal total sample count? It gets reset
> for each chunk?
>
> So how to get peak detection?
>
> Thanks
>
> Al
>
>
> On Wed, Nov 22, 2023 at 3:02 AM Jeff Long <willco...@gmail.com> wrote:
> >
> > I'd suggest that you just log the times you saw a peak in GNU Radio to a
> file. Then use a completely separate program to measure intervals, do
> statistics, etc. There shouldn't be any need to use tags in GNU Radio for
> this project.
> >
> > Even the "debouncing" can be done externally. Just log the times when
> the signal goes high.
> >
> > Separating out the two tasks will help with development and debugging.
> Even if you want to run things "real time", log rx times to a database and
> have another program watch the database for updates.
> >
> > On Tue, Nov 21, 2023 at 3:42 AM Al Grant <bigal...@gmail.com> wrote:
> >>
> >> Background:
> >> I am trying to get GR to receive a signal from a wild life transmitter
> >> on about 160.7073Mhz and calculate the beeps per minute - with an
> >> ultimate goal of logging it to a db or csv.
> >>
> >> The project is not for profit and I work with an endangered species
> >> which are fitted with these transmitters. Because the birds are in a
> >> very remote location we would like to use a Rpi4+ and RTL-SDR to
> >> record daily the status of the birds as we only get to the remote
> >> location occasionally ( a few times a year).
> >>
> >> I may even invest in a SDRPlay which I understand is a better build of
> >> receiver. I have some java programming experience, and python looks
> >> easy enough for this...anyway to detail what I have done so far:
> >>
> >> Signal:
> >> The transmitted pulse is an unmodulated burst of RF energy about 0.2s
> >> in duration and the time between pulses can vary to indicate the
> >> animal is alive (30 beeps per minute), dead (90bpm) or incubating
> >> (48bpm).
> >>
> >> Every 10 minutes the are a series of other pulses which convery even
> >> more information, but for now I just want to determine the time
> >> between pulses and workout beeps per minute from that.
> >>
> >> In my research I see that a very similar question has already been
> >> asked by others both on this list and here
> >>
> https://dsp.stackexchange.com/questions/50103/checking-for-vhf-pulse-with-sdr-and-python
> >> with great answers from Andy Walls. I have read all of that and:
> >>
> >> 1. Read the beginner tutorials
> >> 2. Read
> https://dsp.stackexchange.com/questions/50103/checking-for-vhf-pulse-with-sdr-and-python
> >> 3. With help from another GR user got a baseband recording of the
> >> signal isolated in a GR project
> >> 4. Have completed the tags tutorial on the wiki :
> >> https://wiki.gnuradio.org/index.php?title=Python_Block_Tags
> >> 5. Tried to modify the tags tutorial as it applies to my project
> >> 6. Got as far as : https://github.com/bigalnz/tracker
> >>
> >> This is where I got stuck - I tried to create a embedded python block
> >> using the tags wiki article to my pulse isolator.
> >>
> >> I expected `for index in range(len(input_items[0])):` to result in a
> >> counter from 0,1,2,3,.....x but it just seemed to be 0 and 1?
> >>
> >> The second issue I encountered was I thought I could detect peaks with
> >> this logic:
> >>
> >> if input_items[0][index-1] > input_items[0][index] and
> >> input_items[0][index-1] > input_items[0][index-2]:
> >>
> >> But that did not put the tags on the peaks - so before I can even
> >> think about calculating time gaps I presume I need to get the peak
> >> detection working, and to do that I need to understand why the index
> >> is not iterating beyond 0 and 1.
> >>
> >> I am very grateful to those that have helped so far, and appreciate
> >> any further input I can get.
> >>
> >> Being able to capture this data will be really helpful for the future
> >> of this species - full disclosure this is not a project I am marked
> >> on, I am not a student and am not making any money from this.
> >>
> >> Much thanks in advance
> >>
> >> Al
> >>
> >>
> >> ****** CODE SNIPPET ******
> >>
> >>     def work(self, input_items, output_items):
> >>
> >>         print(f"length of input_items : {len(input_items[0])}")
> >>         for index in range(len(input_items[0])):
> >>             #print(f" the index is increasing : {index}")
> >>             if (input_items[0][index] >= self.threshold and
> >> self.readyForTag == True):
> >>                 #print("inside loop *********************")
> >>                 #print(f"index : {index} input itmes index :
> >> {input_items[0][index]}")
> >>                 #print(f"index : {index} input itmes -1 :
> >> {input_items[0][index-1]}")
> >>                 #print(f"index : {index} input itmes -2:
> >> {input_items[0][index-2]}")
> >>                 if input_items[0][index-1] > input_items[0][index] and
> >> input_items[0][index-1] > input_items[0][index-2]:
> >>                     #print(f"peak at {input_items[0][index-1]}")
> >>                     key = pmt.intern("detect")
> >>                     value =
> >> pmt.from_float(np.round(float(input_items[0][index-1]),2))
> >>                     writeIndex = self.nitems_written(0) + index-1
> >>                     #print(f"Index:{writeIndex}")
> >>                     #print(f"Value:{value}")
> >>
> >>                     self.add_item_tag(0, writeIndex, key, value )
> >>                     self.readyForTag = False
> >>
> >>             if (self.readyForTag == False):
> >>                 self.timer = self.timer + 1
> >>             if (self.timer >= self.report_period):
> >>                 self.timer = 0
> >>                 self.readyForTag = True
> >>
> >>         output_items[0][:] = input_items[0]
> >>         return len(output_items[0])
> >>
>
>
> --
> "Beat it punk!"
> - Clint Eastwood
>

Reply via email to