Python on Propeller: many requests lately. . .
Ken Gracey
Posts: 7,392
Hey there,
Is there a compiler available?
Yes, we should know already.
Lately I've had many requests for Python on the Propeller, from middle school through university.
Thanks,
Ken Gracey
Is there a compiler available?
Yes, we should know already.
Lately I've had many requests for Python on the Propeller, from middle school through university.
Thanks,
Ken Gracey
Comments
Here: https://www.kickstarter.com/projects/214379695/micro-python-python-for-microcontrollers
and here: http://micropython.org/
It's under the MIT licence so I guess you could use it. Probably better to collaborate with Damien.
I don't imagine this will ever run on the Propeller 1. There just is not enough RAM space and performance would be terrible. Adding external RAM/FLASH will just make the performance an order of magnitude more terrible. The cost will never match that of an actual MicroPython board.
May be doable on the Propeller 2. Possibly maybe.
If you want to use Python and wiggle I/O pins, your best bang for the buck is a Raspberry Pi 2 for $35. If you want to add a Propeller, then one of Bill Henning's RoboPi Propeller "hats" is a fantastic combination. But you know all this.
If you want something that let's you write code in Python and then compile it down to a Propeller loadable binary, that would be a cool trick. Due to Python's dynamic typing, the actual compiled code would be a lot of calls to the Python runtime - a runtime for any language like Python would severely strain the Propeller.
...but I don't think, it is tiny enough for the propeller...
Does not seem to have had any love and updates for 6 years though.
64K would fit in a P2 just fine.
Back in the day we were introduced to computer science with BASIC. Or ALGOL if you were a going to major in CS.
Then there was a time when Pascal was everywhere.
Having watched a bunch of introductory CS courses from years gone by at places like MIT and a Stanford on YouTube recently I find they used Scheme for ages. Then Java.
Now they want to use Python.
Always some years behind in what industry wants and not necessarily the best languages for their CS educational aims.
Then I hear that Parallax has been pestered for C on the Propeller, hence the push for prop-gcc and PropellerIDE. Good job by the way. But now it's frikken Python. On micro controllers! Be serious.
Stripping Python down much below the level of MicroPython would more than likely just be another fun thing to do. It would be a disappointing user experience and a bunch of frustration for Parallax.
I know I'll get bashed by some for saying it but currently, the Raspberry Pi is the best learning tool there is. For $35 (ok, let's say $60 w/ SD, wifi, power and a nice case), it can go from grade school to university and support almost any curriculum you might want to teach in almost any language under the sun. That's hard to beat. The school lab just needs to provide monitors and keyboards (and Wifi), the kid can carry their Pi back and forth and use it in school or at home. System recovery is a SD copy away, total hardware recovery is $35 away. You can do lots of GPIO things (yes, there are critical timing issues if you need critical timing), there is bunches of online information and curriculum available. Lots of projects and how-to guides to catch kids' interests.
For Propeller programming, Spin, C and if you want an interactive experience, BASIC or Forth (Tachyon, the current leader). Nothing much else is going to work and give an enjoyable and engaging experience for a school kid. To most of those successfully, you need a companion PC to play host to your development environment.
And since we have a spiffy tool chain on the Pi, they can do SPIN, C, PASM too, in tandem with Python, or not.
Frankly, the skills one gets by doing those kinds of things are meaningful, real world useful.
What goals are the educators seeking? I think knowing more about those would help.
That's why I brought up Bill Henning's excellent RoboPi board is the perfect blend of RasPi and Propeller!
dream.
Likely driven by RaspPi, and also this news
BBC gives children mini-computers in Make it Digital scheme
["When it launches in September it will be compatible with three coding languages - Touch Develop, Python and C++. "]
Looking at python here
https://wiki.python.org/moin/SimplePrograms
it does not look like an embedded-optimal language, but a subset could work on a Prop.
As others have said, a 100% standalone python would sink the Prop1, but there are 'coupled pythons' approaches that could be useful.
These would run a host-based python, with a form of JIT compiler that creates COG code and drop that into a Prop.
like a remote, real time function.
Only a small subset of the running (development) python code would run inside the Prop, but that subset could do the useful flexible real-time IO work.
Once developed, those functions could run stand-alone in the Prop
The bulkier code that scans the output and massages it, runs on the host.
Ideally, the Prop targeted function(s) would run on the host in emulation mode, until JIT compiled.
The tool/ide would have to indicate what constructs could fit into a Prop, but I'm sure some examples would quickly show where the 'corner pegs' of such a system were.
A simpler stepping-stone approach from JIT (which is a lot of work) would be a python-call crafted [IO kernel], that packed a Prop with useful things a Host might want in the real IO space.
Those items could also have python-versions, for simulation/testing.
There are packages for these languages/environments:
Support for Firmata would allow the Propeller to appear as a smart peripheral to PC based programs just like the Arduino can. Again, there are issues if you want critical timing but many things can be done without critical timings (witness the success of the Arduino and Raspberry Pi in "controller" applications).
Just another option to consider for getting Propellers out into the world.
They seem to be expanding firmata in more macro-block form - like the i2c example.
A Prop could have all 8 COGS listening to commands, and each responding to a subset.
Virtual i2c addressing could even be used for more complex IO, but that has a speed penalty.
It would be nice to see a fast way to read a quadrature counter, for example, without so much coms-wrapping that it slows everything down.
What would be the point? Fun for you and me (cause I'd definitely want to help write the interface) but almost entirely pointless. Most everything the Propeller can do, the ARM can do too.
Sure, if you can get a common fast serial link it does not matter if the python is hosted in a local MCU, or is larger-host connected.
Given the BBC work is claimed to run Python, it is likely that's exactly what they will spawn - either some MCU running (small) python - or a hybrid remote-node ( ie they may not mean full-local-python in that vague "compatible with" claim.)
I don't care what choices Chip will make, or has to make. As long as it is bigger than the P1, a whole lot of this stuff will resolve.
That said, there is less work in "getting something going" on a RaspPi, and it can then port to a smaller part.
When I first read the BBC release, I assumed they meant it would run python, but a more careful read shows only the more vague "compatible with", so that is all Parallax need to pitch too.
A Prop 1 can be made "compatible with" python with not much effort, and some examples pitched that way.
1) Why are they asking for Python on the Propeller?
2) How are they using Python?
3) What is the expected benefit of utilizing the Propeller?
Like others have said, a RaspberryPi with a Propeller stacked on it would be an ideal solution if paired with a Python Library for all sorts of standard Propeller abilities. Let the Propeller handle the grunt work for keypads, sensors, LEDs, servos, etc, and communicate through a python library to the RPi for use in any full fledged Python program.
http://shop.pimoroni.com/products/propeller-hat
I'd be very interested in a single board which could take a keyboard and mouse (prefer USB), send video to a monitor, and allow me to program the board with just that hardware. For example if it had an ARM chip, have the ARM chip send the code to the Prop. That may be a pipe dream.
As a tutor I do get asked specifically for Python. Somehow parents have heard about it. That, and Scratch. It's probably due to the Raspberry Pi.
The nodeMCU-Firmware supports the following things: onewire, I2C, SPI, mqtt, pwm, file write/read to flash
then I looked at the filesize of the firmware-binary: 392kB. Hm seems to be too big for the propeller-chip.
Anyway the nodeMCU-firmware for the ESP8266 does the bitbanging for onewire etc. So retrieving code from the external flash seems to be
fast enough for this.
How about combining an ESP8266 with a 2MB flashrom using the nodeMCU-Firmware and a propeller-chip?
So the propeller-chip would add the real fast bitbanging for RC-servo, steppermotor, BLDC-motors, VGA-graphic-card
composite-video, rotary encoders etc. (anyone tried to create a HDMI-signal?)
and the rest could be done by the Lua-script running on the ESP8266.
For educational purposes as mentioned above
There was basic, pascal, java now python. So programming languages seem to become "seasonal fashions"
If so all you can do is teaching students concepts of programming-languages. If they understand the concepts
they are able to adapt faster to any new upcoming programming language.
best regards
Stefan
Obviously these educators have no intention of teaching anything about real-time embedded software as us old guys traditionally know it: strict timing, assembly language bit banging. No.
This must be true because if they had such an idea they would not be thinking about Python.
Perhaps they are wanting to initiate people to the world of programming by means of a really easy to start with language. Like the good old BASIC days. In which case Python on a PC or Mac is an excellent choice.
Perhaps they are wanting to inspire enthusiasm by including some real world interaction. Flash that LED and wiggle that servo. A fine idea.
So, they should use a Rasperry Pi or MicroPython or if they are in touch with the "here and now" use JavaScript and Espruino.
I find it hard to say, but I do not see anyway a Propeller or even Propeller II is a suitable vehicle for this.
As some here have pointed out, a Propeller can make an excellent "coprocessor" to a Raspi or whatever to handle the real-time, real world interfacing stuff. That is an idea that has been around these forums since before there was a Raspberry Pi.
Problem is it's an extra layer of complexity and expense that I'm sure these educators are not looking for.