Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking loop dev #25

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
560 changes: 546 additions & 14 deletions apps/cdma_rx_hier.grc

Large diffs are not rendered by default.

2,299 changes: 1,719 additions & 580 deletions apps/cdma_txrx.grc

Large diffs are not rendered by default.

1,131 changes: 1,131 additions & 0 deletions apps/early_late_pi_hier.grc

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion grc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ install(FILES
cdma_freq_timing_estimator.xml
cdma_amp_var_est.xml
cdma_switched_peak_detector_fb.xml
cdma_pac_err_cal.xml DESTINATION share/gnuradio/grc/blocks
cdma_pac_err_cal.xml
cdma_pi_controller.xml DESTINATION share/gnuradio/grc/blocks
)
51 changes: 51 additions & 0 deletions grc/cdma_pi_controller.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0"?>
<block>
<name>pi_controller</name>
<key>cdma_pi_controller</key>
<category>cdma</category>
<import>import cdma</import>
<make>cdma.pi_controller($Kp, $Ki, $reset)</make>
<callback>set_Kp($Kp)</callback>
<callback>set_Ki($Ki)</callback>
<callback>set_reset($reset)</callback>
<!-- Make one 'param' node for every Parameter you want settable from the GUI.
Sub-nodes:
* name
* key (makes the value accessible as $keyname, e.g. in the make node)
* type -->
<param>
<name>Kp</name>
<key>Kp</key>
<type>float</type>
</param>
<param>
<name>Ki</name>
<key>Ki</key>
<type>float</type>
</param>
<param>
<name>Reset</name>
<key>reset</key>
<type>int</type>
</param>

<!-- Make one 'sink' node per input. Sub-nodes:
* name (an identifier for the GUI)
* type
* vlen
* optional (set to 1 for optional inputs) -->
<sink>
<name>in</name>
<type>float</type>
</sink>

<!-- Make one 'source' node per output. Sub-nodes:
* name (an identifier for the GUI)
* type
* vlen
* optional (set to 1 for optional inputs) -->
<source>
<name>out</name>
<type>float</type>
</source>
</block>
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ GR_PYTHON_INSTALL(
cdma_parameters.py
freq_timing_estimator.py
kronecker_filter.py
DESTINATION ${GR_PYTHON_DIR}/cdma
pi_controller.py DESTINATION ${GR_PYTHON_DIR}/cdma
)

########################################################################
Expand Down
1 change: 1 addition & 0 deletions python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@

from kronecker_filter import kronecker_filter
from freq_timing_estimator import freq_timing_estimator
from pi_controller import pi_controller


79 changes: 79 additions & 0 deletions python/pi_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2018 <+YOU OR YOUR COMPANY+>.
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#

import numpy
from gnuradio import gr

class pi_controller(gr.sync_block):
"""
docstring for block pi_controller
"""
def __init__(self, Kp, Ki, reset):
gr.sync_block.__init__(self,
name="pi_controller",
in_sig=[numpy.float32],
out_sig=[numpy.float32])
self.Kp = Kp
self.Ki = Ki
self.reset = reset
self.ff_taps = numpy.array([Kp + Ki, -Kp], float)
self.x = numpy.zeros(2, float)
self.y = numpy.zeros(2, float)


def work(self, input_items, output_items):
in0 = input_items[0]
out0 = output_items[0]

if (self.reset != 0):
self.x[:] = 0
self.y[:] = 0
out0[:] = 0
else:
for i in range(len(in0)):
self.x[1] = self.x[0]
self.x[0] = in0[i]
self.y[1] = self.y[0]
self.y[0] = self.y[1] + numpy.sum(self.x * self.ff_taps)
out0[i] = self.y[0]

return len(output_items[0])

def get_Kp(self):
return self.Kp

def set_Kp(self, Kp):
self.Kp = Kp
self.ff_taps = numpy.array([self.Kp + self.Ki, -self.Kp], float)

def get_Ki(self):
return self.Kp

def set_Ki(self, Ki):
self.Ki = Ki
self.ff_taps = numpy.array([self.Kp + self.Ki, -self.Kp], float)

def get_reset(self):
return self.reset

def set_reset(self, reset):
self.reset = reset