# Type to use in registers

**URL:** <https://forum.opencyphal.org/t/type-to-use-in-registers/1688>\
**Category:** Applications & Usage\
**Created:** [June 16, 2022, 1:58pm UTC](https://forum.opencyphal.org/t/type-to-use-in-registers/1688 "2022-06-16T13:58:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pat1](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/p/43a26b/32.png) [@pat1](https://forum.opencyphal.org/u/pat1)\
**Post date:** [June 16, 2022, 1:58pm UTC](https://forum.opencyphal.org/t/type-to-use-in-registers/1688/1 "2022-06-16T13:58:02Z")

</div>

Sorry for my approach as beginner; we are working on a project for a professional weather station migrating from a previous implementation I2C based  
[https://github.com/r-map/rmap](https://github.com/r-map/rmap) .  
I am not sure how use registers in applications.  
I have defined some simple registers  
[Cyphal-demos/public\_regulated\_data\_types/reg/rmap/metadata at main · r-map/Cyphal-demos · GitHub](https://github.com/r-map/Cyphal-demos/tree/main/public_regulated_data_types/reg/rmap/metadata)  
and I am trying to use them in a derivated demo application  
[Cyphal-demos/main.c at main · r-map/Cyphal-demos · GitHub](https://github.com/r-map/Cyphal-demos/blob/main/module_th/src/main.c)

Is not clear to me witch type I have to use for registers; now I use uavcan.register.Value.1.0 that is a union (is the union more memory expensive than a simple integer ?)  
Can I use any type for registers or I have to use uavcan.register.Value.1.0 only?  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [June 16, 2022, 2:05pm UTC](https://forum.opencyphal.org/t/type-to-use-in-registers/1688/2 "2022-06-16T14:05:45Z")

</div>

> [@pat1](#):
>
> I have defined some simple registers

These are not registers but data types. Wrong link?

> [@pat1](#):
>
> Is not clear to me witch type I have to use for registers; now I use uavcan.register.Value.1.0 that is a union (is the union more memory expensive than a simple integer ?)

A register cannot be a union. It may be any of: array of `[u]int{8,16,32,64}`, array of `float{16,32,64}`, array of `bool`, string, or bytes. All possible types for a register are defined in [`uavcan.register.Value`](https://nunaweb.opencyphal.org/api/storage/docs/docs/uavcan/index.html#uavcan_register_Value_1_0). It is not possible to define a register of any other type.

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [June 16, 2022, 2:11pm UTC](https://forum.opencyphal.org/t/type-to-use-in-registers/1688/3 "2022-06-16T14:11:22Z")

</div>

To get a better feel of registers, consider using Yakut with the register manipulation commands. See its README, section [“Working with registers”](https://github.com/OpenCyphal/yakut#working-with-registers) and then [“Node configuration example”](https://github.com/OpenCyphal/yakut#node-configuration-example).

It helps to picture registers as either configuration parameters or performance counters.

---

<div class="post-metadata">

**Author:** ![pat1](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/p/43a26b/32.png) [@pat1](https://forum.opencyphal.org/u/pat1)\
**Post date:** [June 27, 2022, 1:29pm UTC](https://forum.opencyphal.org/t/type-to-use-in-registers/1688/4 "2022-06-27T13:29:09Z")

</div>

Thanks a lot for your response Pavel,  
my question was written with a lot of confusion…  
OK, now is clear and our demo works as expected with yacut using our defined registers, pub/subscribe and services starting from DSDL.  
We are going to evaluate how to use plug and play and all the Cyphal specifications in our project.  
We have one master board that will manage GSM communication, data storage and works as orchestrator. Other (slave) board have sensors connected (sample time 0.25 / 3 sec); every 15 minutes elaborate some statistical elaboration of data (mean, max, min …), collected by master that compose a report (a collect of statistical elaboration of data synchronized in time).  
We are evaluating pros and cons using some register to drive the plug and play process (we can have two or more identical boards making the same measure with only some different metadata) following this process:

- write slave register with metada unatantum (in the factory)
- on master launch a PnP node-ID allocator and assign all node-IDs
- on master read slave register with metada
- master assign subject-IDs and service-IDs linked to metadata
- sync time in the network
- start to measure by commands
- collect data on the master board every 15 minutes by subscribe or services.

Thanks for any suggestions

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [June 27, 2022, 1:50pm UTC](https://forum.opencyphal.org/t/type-to-use-in-registers/1688/5 "2022-06-27T13:50:34Z")

</div>

That sounds okay but I wouldn’t rely on PnP in a production setting too much. If possible, consider static allocation as it would remove some complexity and variability from your system.
