Talk About Developing and Structuring a Large Zerynth Project


I am an old hardware engineer from transistor age :slight_smile:

When I first started dealing with electronics as a hobby the radio tubes were leaving their places to transistors and integrated circuits were not in the market yet. Obviously there were no microprocessors, no C around. Computers were room size. Then I met the IC, afterwards the uP, I did many serious hardware projects with ICs, I wrote my first programs on Sinclair ZX Spectrum (a valuable toy) in Z80 Assembly language and in Basic  during university education.  At that time I was dreaming writing reusable structured embedded software in C but the uP speeds and memory capacities were not sufficient enough to realize this. Then my career took me from engineering to management positions and I stayed away from ongoing developments in this technology. Now, after about 35 years, as a retired engineer I turned back to my hobby and trying to fill the gap between the Z80 and STM32. Not easy, takes time.

The question: How could be the best embedded way to develop and manage a large Python project in general and particular for Zerynth? The project (or package) shall probably consist of several files each about different part of the project and due to step by step development, however, I/O and Interface definitions have to be together in same file to prevent possible conflicts. Building the documents, publishing, sharing is another side of this issue. (Examples found here in the documents are all small applications dedicated to a single I/O, interface or feature).

I appreciate guidance of experienced developers very much. 

I suggest you to put all the configuration related to hardware I/O and connection modules in the top section of the main and then follow with the code related to the “behaviour”. You could implement the various functional libraries you need as python modules written in separated files. In order to use functions and classes implemented in external files you need to import them on the main

Thanks @floyd , I’ll follow your advise.

Hi ta1db,

In Zerynth you can create your project structure as you prefer:
 - you can create a specific lib for every component you need and insert it under zerynth2/dist/r2.0.10/libs/official following the Zerynth Official Library structure -->  in this way you can import your library as any other Zerynth lib;
 - you can create several Python module in your project folder and import them with:
      - import file if you create a “” in your project folder
      - from folder import file if you create a “” inside a “folder” in your project folder
 - you can create a file where all I/O and Interface definitions are collected;
 - you can share entities, peripherals, resources by opportunely defining them and paying attention to not use them concurrently (you can take advantage of Locks or Semaphores).

Keep me posted and if you need more advice try to explain me more precisely your project structure so I can better understand :) 

Hi Matteo,

I am working on a lighting controller. Imagine a large and high saloon with window openings on side walls and on the roof. The controller will measure ambient light in the saloon at several locations and will adjust light outputs of several dimmable led luminaire to compensate incoming daylight effects to keep uniformity of light distribution -as constant as possible- with an intelligent algorithm. I plan to make light measurements with TSL2561 modules connected with I2C lines at slow speed and to control the led drivers with pwm at slow speed again. 16x2 LCD character display with 5 keys seem sufficient as user interface. There will be some extra Digital I/O,  IR remote control, wifi connection for remote access and mobile application as well. I want to make this work structured and thus reusable.  By the way: did you see any PID controller example around ? :slight_smile:

Hi ta1db,

Unfortunately, we haven’t an example ready to be used for a PID controller.
By the way, on the internet, you can find many implementations, libraries, examples of this from basic to very complex algorithm.

You can choose which one you want (obviously among those compatible with Zerynth ecosystem) and we will happy to support you implementing it if you need some other help or advice.