2013年11月24日 星期日 20:50
http://www.kickstarter.com/projects/214379695/micro-python-python-for-microcontrollers
The Python language made lean and fast to run on microcontrollers. For beginners and experts, control your electronic project with ease
Micro Python is a lean and fast implementation of the Python programming language (python.org) that is optimised to run on a microcontroller. The Micro Python board is a small electronic circuit board that runs the Micro Python language. The aim of this Kickstarter campaign is to make Micro Python open source software so you can use it in your own projects, and also to fund a small manufacturing run of Micro Python boards so that you can own one for yourself!
Python is a scripting language that is very easy to learn, yet highly expressive and very powerful, and has a huge existing community. Running on a small microcontroller, Micro Python allows you to effortlessly blink LEDs, read voltages, make motors and servos move, play sounds, write data to SD cards, communicate wirelessly, and be the brains of your robot, among countless other things. It is the perfect choice to control your next project!
When building an electronics project, like an intruder detector or a smart robot, a microcontroller is used as the "brain", and does all the decision making and control. There are two kinds of things that a microcontroller typically needs to do. It must do low-level control of lights, LCD displays, motors, etc, as well as high-level tasks such as reading and writing data and images, communicating wirelessly, and being an artificial intelligence. Micro Python allows you to do both low-level and high-level control, by augmenting the Python language with inline assembler and native types, as described below.
The Micro Python board comes preinstalled with Micro Python and is suitable for everyone, whether a beginner or an expert robot builder. It requires no set-up, no compiling and no soldering, and if you don't know Python it is very easy to learn the language.
You plug the board into your PC (Windows, Mac and Linux all work) using a USB cable. It then acts just like a USB flash drive.
To control servo motors, it is a simple as writing the following code:
Put this code in a text file and copy it to the Micro Python USB flash drive, press the reset button on the board and it will run! You can also open a terminal emulator (freely available for Windows, Mac and Linux) to connect to the board over USB and type these commands directly to the board (which gives you a Python command line), and it will run them as soon as you press the enter key.
To flash an LED once a second, you could use the following code:
To read the accelerometer and print out the x-axis value:
You have the full Python programming language at your disposal, and can write functions and classes, make lists and dictionaries, do string processing, read and write files (to the SD card or built-in flash storage), and have more sophisticated features such as generators, closures, list comprehension and exception handling. The possibilities for programming are endless!
The board has many input/output pins which can be connected to other circuits, and you can solder on wires to make it part of your own project. The board can run without a PC, as long as it is connected to a battery or other power supply between 3.6V and 10V.
Some of the rewards on offer include a kit of parts with the Micro Python board. These kits allow you to get started programming and building things straight away. There will be a set of online instructions explaining exactly how to get it all working, and detailing some example projects. Even with just the Micro Python board on its own you can still do some pretty nifty things, such as logging accelerometer data, making a Python USB mouse, and using the USB serial Python command line. These projects will also be explained online for you to follow.
You may be wondering how the Micro Python board compares with other, similar boards. Compared with an Arduino, the Micro Python board is more powerful, easier to program, and you don't need a compiler on your PC. Compared with a Raspberry Pi, the Micro Python board is cheaper, smaller, simpler (you can make one yourself, or even modify the design to fit your needs) and it uses less power. Most other boards are programmed in C, which is a low-level language and can be difficult to program correctly. On the other hand, Python is a very high-level language, which means that Python has simpler, smaller code to do the same thing as C.
It's totally up to you! But here are some pointers to get you thinking. If you would like to support the development of Micro Python and see it become free open source software, then choose the "Supporter" reward. This, and all other reward levels, will get you access to the source code and board design files a few months before they become open to the public. All reward levels allow you to have your name in the source code as a supporter, if you like.
If you want a single board on its own, go for the "Single board" reward. To have some fun making servo motors move, the "Robotics kit" is for you. If you are new to microcontrollers and electronic circuit building, and want to learn how to build and program some nifty circuits, then the "Starter kit" has everything you need (except a USB cable, which you probably alread have).
For the more adventurous, there is the "Wireless kit" which is the "Starter kit" plus a Bluetooth module, speaker, amplifier, microphone and light sensor. The "Batteries included kit" is the "Starter kit" plus a Bluetooth module, an additional Micro Python board, an additional servo, a rechargeable LiPo battery with charger, and a mini-joystick.
For the people who don't need any introduction to microcontrollers and programming, there is the "Hacker's kit" and "Jumbo hacker's kit" which have 2 or 4 Micro Python boards, pure and simple. If you want it early, there is a limited reward to get a handmade board, as well as access to all the source as soon as the campaign ends. There are also limited rewards where you can choose to have a specific Python library implemented in Micro Python, or choose to have Micro Python ported to a different board. Get in touch for details if you are interested in this.
A note on shipping. Shipping is free within the UK. For outside the UK, the shipping price is for non-tracked shipping. If you want tracking, please increase the shipping price to £10.
Certainly! Micro Python is a complete rewrite, from scratch, of the Python scripting language. It is written in clean, ANSI C and includes a complete parser, compiler, virtual machine, runtime system, garbage collector and support libraries to run on a microcontroller. The compiler can compile to byte code or native machine code, selectable per function using a function decorator. It also supports inline assembler. All compilation happens on the chip, so there is no need for any software on your PC.
Micro Python currently supports 32-bit ARM processors with the Thumb v2 instruction set, such as the Cortex-M range used in low-cost microcontrollers. It has been tested on an STM32F405 chip.
Micro Python has the following features:
The Micro Python board is an electronics development board that runs Micro Python, and is based on the STM32F405 microcontroller. This microcontroller is one of the more powerful ones available, and was chosen so that Micro Python could run at its full potential. The microcontroller is clocked at 168MHz and has 1MiB flash and 192KiB RAM, which is plenty for writing complex Python scripts. The board measures 33x40 mm and is pictured below.
The board has a built-in USB interface that presents itself as a serial device (CDC VCP) as well as a removable storage device (MSC). When connected to a PC, you can open a serial communications program and interact with the board through a Python command line. You can also print messages and read input, since the serial device acts like stdin and stdout. The board also acts as a storage device (a USB flash drive) and you can easily copy your Python scripts to the board's local filesystem or SD card, and they are then executed independent of the PC.
Powered by a battery, the board can compile and execute Python scripts without any PC connection. There is a Micro SD slot for storing large amounts of data, 2 LEDs, a switch, a real-time clock, an accelerometer, and 30 general purpose I/O pins. The I/O pins include: 5 USARTs, 2SPIs, 2 I2C busses, 14 ADC pins, 2 DAC pins, and 4 servo ports with power.
There is a special pin, BOOT0, which is used to reprogram the microcontroller. By connecting the BOOT0 pin to the 3.3V pin next to it, and resetting the board with the reset button, you enter the "device firmware upgrade" mode. This is a standard USB mode and allows you to easily put an updated version of Micro Python onto the microcontroller (using freely available software for Windows, Mac and Linux). It also allows you to download your own version of Micro Python if you want to modify it, or even download your own C program.
The Micro Python board is suitable for everyone, regardless of knowledge in hardware or software. With a few lines of Python code in a text file, anyone can start flashing LEDs and responding to accelerometer input, all without soldering, or connecting components, or installing software on your PC.
I wanted to share with you my passion for robotics and programming, and, have a chance to give something back to the open source community that I rely on everyday.
I need your support to make Micro Python open source software, and to help fund the production of the Micro Python boards. Making electronic circuits in bulk allows the cost to be kept low. Components are much cheaper when bought in bulk quantities.
With your support I can have the Micro Python boards professionally assembled at a very reasonable cost. This directly benefits you, as the reward of a Micro Python board means you can have a fantastic and powerful development board at a very low price.
If the Kickstarter campaign is successful, Micro Python and the Micro Python board will be made available under Open Source Software, and Open Source Hardware licenses. Backers will get early and complete access to the source code of Micro Python, and a few months later it will be released to the general public. You can implement new features in Micro Python or port it to your own board, or to a different microcontroller.
The Micro Python software will be released under the MIT license.
Okay! Here they are, the technical details for the Micro Python implementation and the Micro Python board. There are many extra details that are not listed here. Please ask if you would like further information, as I would be more than happy to share it with you.
The Micro Python implementation is a complete rewrite of Python specifically designed to be run on a microcontroller with minimal flash storage and minimal RAM. When design decisions were made, the first priority was to minimise RAM usage, then minimise code size, and, finally, to execute quickly. Some of the important features of the implementation are listed below.
The Micro Python language can also run on a PC (it was developed under Linux on a 64-bit machine) and can be used as a lean version of Python where low memory usage is important. The PC version of Micro Python (compiling to byte code) actually runs faster than CPython for the various benchmarks I have tested, and the native compilation option makes Micro Python run significantly faster than CPython.
You can think of Micro Python as a "mini Python operating system", and the boot-up process proceeds as follows:
Technical details of the board and microcontroller:
A pinout of the board is shown below. A pink triangle denotes that the pin is connected to a timer and can be used, for example, as a PWM output for a servo.
The software is written and working. It still lacks some more advanced features, but these will be implemented over the duration of the Kickstarter campaign, and the code will be ready to install on the production boards.
Two iterations of the Micro Python board have been produced. The PCBs for these were professionally made by EuroCircuits, and components hand soldered by myself. These prototypes are fully functional and execute Micro Python with all the features described above. The final version of the board will have only minor differences to the second prototype, pictured above.
After the Kickstarter campaign has ended and the funds are received, the first thing to do will be to order the critical components: the STM32F405 microcontroller and the MMA accelerometer. I will then source the rest of the components. Knowing the parts, I will then make final adjustments to the PCB design and send it off for manufacture.
Once all parts and the PCBs are received I can then move to the assembly stage. I have a quote from the UK company Newbury Electronics to assemble the production run of the boards, and to keep costs down, I must place a large order, which is part of the reason for the Kickstarter campaign. The assembly time will be around 25 days.
During assembly I will be organising the rewards, putting together the different kits, and working out the shipping details. I will also continue to develop the Micro Python software and start work on implementing requested libraries and other microcontroller support.
The aim is to have the boards and kits shipped by the end of March, 2014.
The video was filmed and sequenced by Viktoriya Skoryk, http://vskography.com.
The music used in the video ishttp://freemusicarchive.org/music/Broke_For_Free/netBloc_Vol_37_FIVE/07_-_Broke_For_Free_-_Something_Elated byhttp://freemusicarchive.org/music/Broke_For_Free/.
There is less risk with the software (the Micro Python implementation) than with the hardware (the Micro Python board). The software is mostly finished, except for implementing some more advanced features of the language and writing some additional Python libraries. I do not see any significant problems with finishing the software, as most of the difficult parts (compiler, memory manager, exception handler) are complete.
If software development is delayed and features are not implemented by the time the boards ship, the boards can always be reprogrammed by the user with an update available over the web.
The hardware side of things can have the following two problems: delays, and component sourcing. Delays can be in the PCB production and the assembly, but just take extra time and are not a show-stopper. Component sourcing is the biggest risk. Almost all the components can be interchanged with alternate manufacturers, most without even changing the PCB layout. The only one that cannot be interchanged is the STM32F405RG microcontroller chip itself. These chips are in "active marketing status" with STMicroelectronics, so should be available one way or the other for the coming years.
Zeuux © 2024
京ICP备05028076号