# Slow control external hardware

**URL:** <https://www.ruby-forum.com/t/slow-control-external-hardware/231238>\
**Category:** GNU Radio\
**Created:** [July 29, 2014, 2:56pm UTC](https://www.ruby-forum.com/t/slow-control-external-hardware/231238 "2014-07-29T14:56:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [July 29, 2014, 2:56pm UTC](https://www.ruby-forum.com/t/slow-control-external-hardware/231238/1 "2014-07-29T14:56:31Z")

</div>

Hello,

I need to control a RF synthesizer from within a GNURadio flowchart  
updating some parameters on the base of some measurements obtained from  
processing data collected by an USRP.

The synthesizer is connected through a RS232 serial port, thus is quite  
slow, but the bandwidth of the control is also very small, \< 1Hz. One of  
the parameters that needs to be controlled is the output power, and it  
can be adjusted only in discrete steps of 0.01 dB, therefore I need to  
correctly take care of the discretization.

What is the best strategy to do that? Should I simply implement a sink  
block? Would be better to implement the discretization in a sink block  
that then sends messages to another block that handles the communication  
with the synthesizer?

As far as my experimentation goes, there are no blocks using messages in  
the standard GNURadio distribution (version 3.7.2), therefore I don’t  
really have examples of use cases for it.

Thanks. Cheers,  
Daniele

---

<div class="post-metadata">

**Author:** ![Daniele\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/74df32/32.png) [@Daniele\_N](https://www.ruby-forum.com/u/Daniele_N)\
**Post date:** [July 29, 2014, 5:04pm UTC](https://www.ruby-forum.com/t/slow-control-external-hardware/231238/2 "2014-07-29T17:04:01Z")

</div>

On 29/07/2014 16:57, Martin B. wrote:

> Daniele,
> 
> there’s loads of blocks that use messages, as well as manual pages for  
> that. And I would recommend you use them for this case. Create a block  
> that talks to the serial port, and give it a message port.

Hello Martin,

thank for your answer. Can you please point me to an example of such  
blocks from which I can take inspiration? I would like to code it in  
python, therefore if a python block that uses the message passing  
infrastructure exists, it would be great. Meanwhile I’m going to grep  
through the code distribution…

Thanks! Cheers,  
Daniele

---

<div class="post-metadata">

**Author:** ![Daniele\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/74df32/32.png) [@Daniele\_N](https://www.ruby-forum.com/u/Daniele_N)\
**Post date:** [July 29, 2014, 4:58pm UTC](https://www.ruby-forum.com/t/slow-control-external-hardware/231238/3 "2014-07-29T16:58:57Z")

</div>

Daniele,

there’s loads of blocks that use messages, as well as manual pages for  
that. And I would recommend you use them for this case. Create a block  
that talks to the serial port, and give it a message port.

M

---

<div class="post-metadata">

**Author:** ![Daniele\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/74df32/32.png) [@Daniele\_N](https://www.ruby-forum.com/u/Daniele_N)\
**Post date:** [July 29, 2014, 7:22pm UTC](https://www.ruby-forum.com/t/slow-control-external-hardware/231238/4 "2014-07-29T19:22:24Z")

</div>

[http://gnuradio.org/doc/doxygen/page\_python\_blocks.html](http://gnuradio.org/doc/doxygen/page_python_blocks.html)

$ git grep self.set\_msg\_handler \*\*/\*.py[19:20:26]  
gr-blocks/python/blocks/qa\_python\_message\_passing.py

M

---

<div class="post-metadata">

**Author:** ![Daniele\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/74df32/32.png) [@Daniele\_N](https://www.ruby-forum.com/u/Daniele_N)\
**Post date:** [July 30, 2014, 1:41pm UTC](https://www.ruby-forum.com/t/slow-control-external-hardware/231238/5 "2014-07-30T13:41:46Z")

</div>

On 29/07/2014 19:29, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> writing/maintaining custom blocks when the functionality doesn’t  
> really require real-time access to the sample stream…

Hello,

well, writing a block that listens to messages or that emits messages  
takes less than 20 lines of python all included. I would hardly call  
this an “headache” to maintain 🙂

Cheers,  
Daniele

---

<div class="post-metadata">

**Author:** ![Daniele\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/74df32/32.png) [@Daniele\_N](https://www.ruby-forum.com/u/Daniele_N)\
**Post date:** [July 29, 2014, 7:31pm UTC](https://www.ruby-forum.com/t/slow-control-external-hardware/231238/6 "2014-07-29T19:31:19Z")

</div>

There are rather a lot of ways to choke this particular cat, writing a  
block is just one of them.

I do “control external device” things from within GRC without custom  
blocks, using “helper code” and a polling function at a low rate

that drives a simple state machine. I use this for controlling a serial  
device that turns calibration sources on/off. It can get data out

of the flow-graph if it needs to, with low-rate “probe” blocks. Some  
might call this inelegant, I call it saving the headache of

writing/maintaining custom blocks when the functionality doesn’t really  
require real-time access to the sample stream…

On 2014-07-29 13:20, Martin B. wrote:

> [http://gnuradio.org/doc/doxygen/page\_python\_blocks.html](http://gnuradio.org/doc/doxygen/page_python_blocks.html) [1]
> 
> $ git grep self.set\_msg\_handler \*\*/\*.py[19:20:26]  
> gr-blocks/python/blocks/qa\_python\_message\_passing.py
> 
> M
> 
> On 07/29/2014 05:02 PM, Daniele N. wrote:  
> On 29/07/2014 16:57, Martin B. wrote: Daniele, there’s loads of blocks that  
> use messages, as well as manual pages for that. And I would recommend you use them  
> for this case. Create a block that talks to the serial port, and give it a message  
> port. Hello Martin, thank for your answer. Can you please point me to an example  
> of such blocks from which I can take inspiration? I would like to code it in  
> python, therefore if a python block that uses the message passing infrastructure  
> exists, it would be great. Meanwhile I’m going to grep through the code  
> distribution… Thanks! Cheers, Daniele M On 07/29/2014 02:55 PM, Daniele N.  
> wrote: Hello, I need to control a RF synthesizer from within a GNURadio flowchart  
> updating some parameters on the base of some measurements obtained from processing  
> data collected by an USRP. The synthesizer is connected through a RS232 serial  
> port, thus is quite slow, but the bandwidth of the control is also very small, \<  
> 1Hz. One of the parameters that  
> needs to be controlled is the output power, and it can be adjusted only  
> in discrete steps of 0.01 dB, therefore I need to correctly take care of  
> the discretization. What is the best strategy to do that? Should I  
> simply implement a sink block? Would be better to implement the  
> discretization in a sink block that then sends messages to another block  
> that handles the communication with the synthesizer? As far as my  
> experimentation goes, there are no blocks using messages in the standard  
> GNURadio distribution (version 3.7.2), therefore I don’t really have  
> examples of use cases for it. Thanks. Cheers, Daniele  
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio mailing  
> list [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio) [2]  
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio mailing  
> list [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio) [2]  
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio  
> mailing list [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio) [2]

* * *

Discuss-gnuradio mailing list  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio) [2]

Links:

---

<div class="post-metadata">

**Author:** ![Daniele\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/74df32/32.png) [@Daniele\_N](https://www.ruby-forum.com/u/Daniele_N)\
**Post date:** [July 30, 2014, 3:43pm UTC](https://www.ruby-forum.com/t/slow-control-external-hardware/231238/7 "2014-07-30T15:43:05Z")

</div>

On 07/30/2014 07:40 AM, Daniele N. wrote:

> > Some might call this inelegant, I call it saving the headache of

It’s a big universe, there’s room for different design choices…

–  
Marcus L.  
Principal Investigator  
Shirleys Bay Radio Astronomy Consortium

> **[Live Draw HK Tercepat | Result HK | HK Pools | Live HK | HK Prize Hari Ini](https://www.sbrac.org)**
>
> Temukan live draw hk tercepat melalui halaman hk pools yang resmi dan dapatkan result hk prize melalui live hk secara langsung di situs kami.
