Python 2B

2B is a simple protocol used to receive and send messages to Arduino, it provides a convenient method to use the device in conjunction with a PC

It uses a two ASCII chars based protocol to represent port address and value.
For example, to set port 11 to 65 (pwm port), the first char will be "VT"(vertical tab) and the second one "A". see extended version of ASCII table
In this way, the analog ports had been limited to 255 values. Any sign of 127 to 255 in ASCII table will correspond to the sign by the table as: Windows 1251 (Cyrillic), ISO 8859-7 or Windows 1252 (Latins).

The protocol uses two separate one way channels to set and read device ports. With this protocol, you can treat it as a post processor Arduino through RS232. Program in the Arduino can be easily modified as the case makes it quite flexible. In its request for an extension program could work with multiple devices simultaneously, but still needs a chief controller, and some hardware changes.


Start playing

  • Install "pyserial" (if you do not have it, download from http://pyserial.sourceforge.net/ or do "sudo apt-get install python-serial" from a console if you use Ubuntu)

  • Download and extract the archive:

  • Compile the ma_protocol.pde file contained into "arduino/ma_protocol" and upload it to Arduino

  • Connect something to Arduino, use the pin layout available here below

    • Blue: Digital Inputs
    • Green: Digital Outputs
    • Red: Pwm Outputs
    • Yellow: Analog Inputs (to address Analog ports use numeration from 20 to 25 see "PortManager.py")

  • Go into folder "arduino/python_classes" and start playing with the "controllers.py"


To Do

  • Device ID implementation to controll multiple Arduino Devices, for example: in Python >>ser("001") will define the ID of the real device. The ID will be set also in ma_protocol.pde

  • Servo Motor support


Notes

All has been tested on Ubuntu Edgy/Feisty. The "ser" python class contained into "ser.py", will search the right port for you. If the class is not able to find a valid port, check if it is like "/dev/ttyUSB*" on your system, if not, fix it in "ser.py" file

A problem with "ftdi_sio" has been detected if "brltty" is installed. Remove it if you do not need soft braille display

Enjoy it!
Marco Sangalli

Share