Translate

pymata_aio 2.7 Released

This release adds support for the Pixy Cam. It is intended to be used in conjunction with the FirmataPlusRBPixy sketch included with the release.

The sleep_tune parameter has been exposed to pymata3. The new default value for both pymata_core and pymata3 is .0001

There are also 2 typo bug fixes in stepper_config and set_sampling_interval.


Status Update

s2aio

5 November 2015



The first pass of coding has been completed. English language blocks have been tested and all the code is working for Scratch on Linux.  I have updated the .s2e extension descriptions for all languages to include the new Debug reporter block.

In testing the non-English languages, it appears that the data sent from Scratch now looks like the strings in the .s2e file extensions and not like the weird escaped strings in the xlate.cfg file used for s2a_fm. I am in the process of updating and testing all the strings in the xlate.cfg file.  Once that is complete I will test all of the languages. Once complete, I will then retest on a Windows 10 installation.

The current punch list consists of:

  1. Finish updating the xlate.cfg file.
  2. Test all languages.
  3. Retest on Windows.
  4. Update the Snap! block translations
  5. Retest blocks on Snap! (this may be in a later release)
  6. Retest Snap! blocks with Windows. (this may be in a later release)
  7. Develop a setup.py script that will allow installation of s2aio in a directory of the user's choosing. I am hoping that this can be done by passing a command line option to a pip install command.
  8. Generate documentation on a Github Wiki page.

For the debug error strings, I have come up with a numeric mapping. The major number relates to the block causing the error and the minor number is the error descriptor. The debug block will only show the numbers to alleviate having to go through another phase of translations. The map shown below will be part of the Wiki documentation.


0         No Error

DIGITAL PIN MODE
1.1      Pin Must Be Specified as an Integer
1.2      Pin number exceeds the maximum number of pins for the arduino.
1.3      Pin does not support digital input mode
1.4      Pin does not support digital output mode
1.5      Pin does support PWM mode
1.6      Pin does not support servo mode.
1.7      Pin does not support tone mode
1.8      Pin does not support SONAR mode
1.9      Unknown Pin Mode specified

ANALOG PIN MODE
2.1      Pin Must Be Specified as an Integer
2.2      Pin is not a valid analog pin

DIGITAL PIN WRITE
3.1      Pin Must Be Specified as an Integer
3.2      Pin number is invalid
3.3      Pin is not configured for digital output

ANALOG PIN WRITE
4.1      Pin Must Be Specified as an Integer
4.2      Pin number is invalid
4.3      Pin is not configured for PWM output
4.4      Value must be specified as an integer
4.5      Value must be in the range of 0-255

PLAY TONE
5.1      Pin Must Be Specified as an Integer
5.2      Pin number is not valid
5.3      Pin was not properly configured
5.4      Frequency must be specified as an integer
5.5      Duration must be specified as an integer

NO TONE
6.1      Pin Must Be Specified as an Integer
6.2      Pin number is not valid
6.3      Pin was not properly configured

SERVO POSITION
7.1      Pin Must Be Specified as an Integer
7.2      Pin number is not valid
7.3      Pin was not properly configured
7.4      Position must be specified as an integer
7.5      Position must be in the range of 0 - 180

DIGITAL_READ (Snap! Only)
8.1      Pin Must Be Specified as an Integer
8.2      Pin number is not valid

ANALOG_READ (Snap! Only)
9.1      Pin Must Be Specified as an Integer

9.2      Pin number is not valid

Status Update
s2aio

The project is coming along rather nicely and I was able to verify that all of the s2a_fm block language translations are working with s2aio.

I wanted to share a change that I will be making to the Scratch/Snap blocks for s2aio and wanted to get feedback before I finalize the design. Please let me know if you have any thoughts about this change

Currently, s2a_fm has a control block called Debugger, that enables or disables debugging information sent to the console and log file.


I will be changing the debugger block from a command block into a reporter block. As a result, debug information will no longer be saved to a file or sent to the console, but can be optionally displayed on the stage by clicking the check box next to the block.




Debug information will be displayed as a numerical value. The project's Github Wiki page will contain a table that will map the problem number to a problem explanation. By using a web browser translator, you will be able to see the explanations in your native language. 

Here is a screen shot of a sample of what the map may look like:


IMPORTANT NOTE: If you load an existing s2a_fm project into Scratch when running s2aio, the debugger command block will appear on the block pallete, but will be non-functional. If  your project script contains the debugger command block, it will be ignored, but the project  will still run.

Stay tuned for future progress reports.

Improving s2a_fm Performance

Recently, a couple of s2a_fm users had asked about improving s2a_fm's CPU utilization performance. Here is a quick Scratch test program that monitors 3 analog input devices and a single digital input device.


Running this program using the current s2a_fm code, typical CPU utilization is shown in this task manager screenshot:
We can see that Scratch is taking up about 1% of the CPU and that s2a_fm is consuming about 40% of the CPU.

These measurements were taken using Ubuntu 15.10 64bit running on an Intel i5-2600k with 8 GB of RAM installed.

Running the same exact Scratch program on a prototype asyncio implementation of s2a_fm,  we get the following results:


The asyncio version dramatically reduced CPU utilization by a factor of 10! In addition, there appears to be an improvement in responsiveness. For example, when changing the value of the pot, there is less stutter and lag.

Because these results are so promising, I am about to embark on developing the next generation of s2a_fm, to be called s2aio.

Here are some of the design goals for the new version:
  • All existing s2a_fm Scratch programs should be able to be run on s2aio without modification including existing language translation support.
  • Provide Arduino auto port detection. s2aio will be using pymata-aio that has this capability already implemented.
  • Auto launch of Scratch 2 after invoking s2aio. This is already working for Linux, and hopefully will be available for Windows as well.
  • Simpler installation - single command to install s2aio, and all of its dependencies (pymata-aio, pyserial, aiohttp, etc.).
  • All documentation to appear on the project's Github Wiki page. The goal here is that the documentation can be easily translated using Google Chrome's translation facilities.
Please note that s2aio will require the use of Python 3.5 and will not be compatible with Python 2.7. 

Stay tuned for further updates. 


pymata_aio v2.6
New Feature Release is Available

Keep Alive Link Detection

To detect when connectivity is lost between the Arduino and pymata_aio, a keep_alive link detection feature has been added.  When activated, a keep_alive message will be sent periodically to the Arduino. If the Arduino does not receive a keep_alive message in the prescribed time, it will reset itself.

Feature Prerequisite

To make use of this feature you will need to upload FirmataPlus, FirmataPlusRB or FirmataPlusLBT to the Arduino. You may still use StandardFirmata if you do not use this feature.

Enabling the Feature

To enable the feature when using one of the FirmataPlus sketches, simply call the keep_alive API method. This method has 2 defaulted parameters.

  • period - this parameter specifies how often the keep alive message is expected to be received by the Arduino. The default value is 1 second, but may be optionally set from 0 to 10 seconds. A value of 0 disables the feature if previously enabled. Once activated, if the Arduino does not receive a keep_alive message within a period time frame, it will reset itself.
  • margin - this parameter assures that the keep alive messages are sent more often than the value specified by period. It has a default value of .3, but may optionally be set to a value of .1 to .9. It is used in a calculation in conjunction with the period parameter to determine how often to send the keep_alive message to the Arduino. The margin parameter allows you to adjust for any propagation delays.

    The formula used is:
    KEEP_ALIVE_SEND_TIME_PERIOD = period - (period * margin)

    So, for example if you use the default values, a keep_alive message will be sent to the Arduino every .7 seconds. If you selected a period of 4 seconds with a margin of .1, then a keep_alive will be sent every 3.6 seconds. 


pymata_aio Version 2.5 Release


This release:

1. Merges in the lastest updates to the SparkFun RedBot experiment files from the Rose-Hulman Institute of Technology.
2. Fixes a bug introduced in v2.3 that prevented specifying the com port as a parameter.
3. Improved shutdown of pymata_iot. It now sends a reset to the Arduino upon exit.

pymata_aio v2.4 released

v2.3 removed from Pypi

The v2.3 release introduced a bug that rendered the library unusable for Windows users. Python 3.5 asyncio has a mechanism that allows registration of signals (SIGTERM, etc.), but this mechanism does not provide support for Windows. 

As a result, integrated control-c support has been removed from the library and is now the responsibility of the application developer to provide. Examples are provided for both pymata_core and pymata3 APIs here.