pysimCoder integration with NuttX
PysimCoder is as an open source Rapid Control Application Development Tool which is able to transfer block diagrams into C code. Combined with NuttX, it can be used in real time control application and as an alternative to expensive licensed programs and prototyping platforms. Example of DC motor control application with PID controller and blocks for encoder, PWM, GPIO and sending data over TCP to real time plotter can be seen on NuttX Channel.
This documentation describes the steps that are needed to run application generated by pysimCoder on NuttX and also keeps the track of peripherals that are supported by pysimCoder for NuttX RTOS.
Peripheral Support
The following list shows the peripherals and fuctionalities supported in pysimCoder for NuttX RTOS.
Peripheral |
Notes |
---|---|
ADC |
|
CAN |
Including SocketCAN |
DAC |
|
ENC |
|
GPIO |
|
PWM |
Multichannel support |
UART |
Serial output |
Sensors |
Basic support for DHTXX |
TCP |
|
UDP |
Please note that the actual support for NuttX peripherals can be wider that what is mentioned here in case this documentation was not updated when new fuctionalities were added to pysimCoder.
NuttX Configuration
Several configuration options are neccessary to be set in order to succesfully compile pysimCoder with NuttX. The list is the following:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In case you want to use Network and blocks like TCP or UDP, following configuration options are required:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Board and application specific configuration like setting up peripherals or boot options might also be required, please refer to board and platform documentation for those information. Once NuttX is configured it can be build by simply running:
$ make
Then we need to export build NuttX which can be done by executing command
$ make export
This creates a zip file nuttx-export-xx.x.x.zip where xx.x.x is the version of NuttX. This file then have to be moved to pysimCoder directory pysimCoder/CodeGen/nuttx, unzip there and then renamed just to nuttx-export. Then enter the pysimCoder/CodeGen/nuttx/device directory and execute
$ make
This compiles pysimCoder files that controls functions of separate blocks. PysimCoder can be either installed on the system (please refer to the pysimCoder manual) or script pysim-run.sh can be used to run pysimCoder without the installation. This script can be found in pysimCoder root directory and is run by executing command
$ ./pysim-run.sh
Please note that PYSUPSICTRL variable has to be set/exported in order to succesfully compile NuttX application designed with pysimCoder.
Using pysimCoder to design NuttX application
After running pysimCoder, separate blocks can be selected from the library menu on the left hand side. The menu contains several libraries, NuttX specific blocks can be found in library “NuttX”. It is also possible to use blocks from other libraries like “input”, “output”, “math” and so on. Several blocks can have specific parameter options and various number of inputs/outputs. Double left click on the block openes parameter settings while single right click on the block leads to number of inputs/outputs setup. The pysimCoder interface can be seen in the picture below.
The NuttX template Makefile nuttx.tmf has to be selected in order to generate code for NuttX target. This can be done in the top menu by clicking on Block settings icon which is highlighted in the red circle.
Block settings option open the following window (showed in the picture below) where you can set template Makefile and also Python skript with parameters for the controllers.
C code can be generated by selecting Generate C-code icon (highlighted in the green cirle). Executeble files are then generated and can be flashed into the target. The flashing procedure can be target specific, please refer to plaftorm´s documentation. The generated application can be then run from NuttX command line by executing:
nsh> main