Python on Propeller: many requests lately. . .

Ken GraceyKen Gracey Posts: 5,994
edited March 2015 in Propeller 1 Vote Up0Vote Down
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
«13456789

Comments

  • 261 Comments sorted by Date Added Votes
  • David BetzDavid Betz Posts: 11,396
    edited March 2015 Vote Up0Vote Down
    Ken Gracey wrote: »
    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
    I doubt it would be possible to run any version of Python on the P1 without using XMM. Maybe you could add a SPI flash chip to the new ActivityBoard WX? :-)
  • Heater.Heater. Posts: 19,355
    edited March 2015 Vote Up0Vote Down
    The only Pyhon I know that stands a chance of running on a Propeller is MicroPython by Damien George as used on his MicroPython board.
    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.
  • David BetzDavid Betz Posts: 11,396
    edited March 2015 Vote Up0Vote Down
    I would agree that using external RAM is probably not going to result in good enough performance. So you don't think MicroPython could run with, say, 1mb of code space and 24k of RAM? If not, then I think you're right that it isn't going to run on P1 at all.
  • mindrobotsmindrobots Posts: 6,488
    edited March 2015 Vote Up0Vote Down
    The only microcontroller python I know of is micropython - it runs well (considering) on the ST Micro STM32F405RG, a 168MHz micro with 1MB flash and 192Kram. It's a pretty big micro being in the ARM Cortex-M4 category. It provides an acceptable user experience. Anything less and python would suffer to the point of being unusable and more discouraging than encouraging.

    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.
    MOV OUTA, PEACE <div>Rick </div><div>"I've stopped using programming languages with Garbage Collection, they keep deleting my source code!!"</div>
  • yetiyeti Posts: 321
    edited March 2015 Vote Up0Vote Down
    http://www.tinypy.org/ looks... eeehhhh... tiny...

    ...but I don't think, it is tiny enough for the propeller...
    Windows.
    No Source – No Go!
    Please help: http://rosettacode.org/wiki/Category:Spin
    Why Asimov's Laws of Robotics Don't Work - Computerphile
    DNA is a four letter word.
  • Heater.Heater. Posts: 19,355
    edited March 2015 Vote Up0Vote Down
    Hei, TinyPi looks cool.

    Does not seem to have had any love and updates for 6 years though.

    64K would fit in a P2 just fine.
  • David BetzDavid Betz Posts: 11,396
    edited March 2015 Vote Up0Vote Down
    Heater. wrote: »
    Hei, TinyPi looks cool.

    Does not seem to have had any love and updates for 6 years though.

    64K would fit in a P2 just fine.
    If it fits in 64K including code then I think it has a decent chance of running well on a P1 with external SPI flash. I imagine quite a bit of that 64k is code and that can live in external memory without too huge a performance penalty. If it is possible to recode the VM in PASM then the performance might even be decent. Probably would take a fair amount of work to shoehorn it into a P1 though.
  • Heater.Heater. Posts: 19,355
    edited March 2015 Vote Up0Vote Down
    What's up with these educators?

    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.
  • potatoheadpotatohead Posts: 8,799
    edited March 2015 Vote Up0Vote Down
    Does it make sense to strip PYTHON down in any way? Maybe some of the projects mentioned do that already. Just thought it worth a mention.
    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: http://forums.parallax.com/showthread.php?123709-Commented-Graphics_Demo.spin<br>
  • David BetzDavid Betz Posts: 11,396
    edited March 2015 Vote Up0Vote Down
    potatohead wrote: »
    Does it make sense to strip PYTHON down in any way? Maybe some of the projects mentioned do that already. Just thought it worth a mention.
    You may be right about this. Parallax will be continually asked why this or that feature is missing.
  • mindrobotsmindrobots Posts: 6,488
    edited March 2015 Vote Up0Vote Down
    MicroPython is running on a large enough micro to make it useful. You can include Espruino in this group - it also does well with the hardware it is on in presenting an interactive microcontroller experience. Of course, if you want to get the most out of your STMF4, program it in C but if you know Python (or Javascript) or want a REPL experience to develop your micro based project, then MicroPython (or Espruino) is a viable solution to complete quite a large number of successful projects.

    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.
    MOV OUTA, PEACE <div>Rick </div><div>"I've stopped using programming languages with Garbage Collection, they keep deleting my source code!!"</div>
  • potatoheadpotatohead Posts: 8,799
    edited March 2015 Vote Up0Vote Down
    I see this too. Maybe a Pi board "plate' with a Prop on it, running some code to do comms coupled with a Python library would help here?

    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.
    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: http://forums.parallax.com/showthread.php?123709-Commented-Graphics_Demo.spin<br>
  • potatoheadpotatohead Posts: 8,799
    edited March 2015 Vote Up0Vote Down
    Sorry for double post, edits on this device are not tolerable....

    What goals are the educators seeking? I think knowing more about those would help.
    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: http://forums.parallax.com/showthread.php?123709-Commented-Graphics_Demo.spin<br>
  • mindrobotsmindrobots Posts: 6,488
    edited March 2015 Vote Up0Vote Down
    potatohead wrote: »
    Maybe a Pi board "plate' with a Prop on it, running some code to do comms coupled with a Python library would help here?

    That's why I brought up Bill Henning's excellent RoboPi board is the perfect blend of RasPi and Propeller!
    MOV OUTA, PEACE <div>Rick </div><div>"I've stopped using programming languages with Garbage Collection, they keep deleting my source code!!"</div>
  • ratronicratronic Posts: 1,451
    edited March 2015 Vote Up0Vote Down
    I have used programs in Python on the Raspberry Pi then have it send the results in serial to the Propeller. But Python on a Propeller 1 I think is a marketing

    dream.
    Fix it, if it ain't broke! .......... D Rat .......... Dave ..........
  • jmgjmg Posts: 10,248
    edited March 2015 Vote Up0Vote Down
    Ken Gracey wrote: »
    Lately I've had many requests for Python on the Propeller, from middle school through university.

    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.
  • mindrobotsmindrobots Posts: 6,488
    edited March 2015 Vote Up0Vote Down
    A bigger payback might come from developing a Propeller program to support the Firmata protocol.[url]
    Firmata is a protocol for communicating with microcontrollers from software on a computer (or smartphone/tablet, etc). The protocol can be implemented in firmware on any microcontroller architecture as well as software on any computer software package (see list of client libraries below).

    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.
    MOV OUTA, PEACE <div>Rick </div><div>"I've stopped using programming languages with Garbage Collection, they keep deleting my source code!!"</div>
  • David BetzDavid Betz Posts: 11,396
    edited March 2015 Vote Up0Vote Down
    I'm sure this is a hopeless suggestion but what about a Parallax board with an ARM chip to run Python or JavaScript and a Propeller to handle I/O? I'd love to work on the code to interface the two!
  • jmgjmg Posts: 10,248
    edited March 2015 Vote Up0Vote Down
    mindrobots wrote: »
    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).
    Yes, that could be a good transport layer for my second suggestion.
    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.
  • DavidZemonDavidZemon Posts: 2,366
    edited March 2015 Vote Up0Vote Down
    David Betz wrote: »
    I'm sure this is a hopeless suggestion but what about a Parallax board with an ARM chip to run Python or JavaScript and a Propeller to handle I/O? I'd love to work on the code to interface the two!

    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.
    David
    PropWare: C++ HAL (Hardware Abstraction Layer) for PropGCC; Robust build system using CMake; Integrated Simple Library, libpropeller, and libPropelleruino (Arduino port); Instructions for Eclipse and JetBrain's CLion; Example projects; Doxygen documentation
  • jmgjmg Posts: 10,248
    edited March 2015 Vote Up0Vote Down
    David Betz wrote: »
    I'm sure this is a hopeless suggestion but what about a Parallax board with an ARM chip to run Python or JavaScript and a Propeller to handle I/O? I'd love to work on the code to interface the two!

    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.)
  • David BetzDavid Betz Posts: 11,396
    edited March 2015 Vote Up0Vote Down
    jmg wrote: »
    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 guess I figured that a single board solution would be more likely to be accepted than something like a RaspberryPi with an add-on Propeller board.
  • potatoheadpotatohead Posts: 8,799
    edited March 2015 Vote Up0Vote Down
    We really need our P2.

    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.
    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: http://forums.parallax.com/showthread.php?123709-Commented-Graphics_Demo.spin<br>
  • David BetzDavid Betz Posts: 11,396
    edited March 2015 Vote Up0Vote Down
    potatohead wrote: »
    We really need our P2.

    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.
    I'm not sure that's true. Do you think something like Python will be viable on a P2 with 512k of hub memory? Sounds like it already requires more than that on an ARM. And how will code density on the P2 with hub execution compare with the ARM?
  • jmgjmg Posts: 10,248
    edited March 2015 Vote Up0Vote Down
    David Betz wrote: »
    I guess I figured that a single board solution would be more likely to be accepted than something like a RaspberryPi with an add-on Propeller board.
    I think they both have their place, but it is getting easier to add larger-ARMs - the NUC505 ?
    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.
  • WBA ConsultingWBA Consulting Posts: 2,631
    edited March 2015 Vote Up0Vote Down
    I have a few questions:
    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.
    Andrew Williams
    WBA Consulting
  • Keith YoungKeith Young Posts: 489
    edited March 2015 Vote Up0Vote Down
    I can't speak to all the technical discussion going on. However in the pursuit of educating kids I've been considering this product:

    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.
    Founder of Kinvert
    https://www.kinvert.com/
  • StefanL38StefanL38 Posts: 2,285
    edited March 2015 Vote Up0Vote Down
    I took a look at the nodeMCU firmware for the ESP8266-WiFi-modules.
    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
    [x] <== SLAM in nail here to hook up the new screen! :lol:
  • Heater.Heater. Posts: 19,355
    edited March 2015 Vote Up0Vote Down
    What is going on here?

    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.
  • ersmithersmith Posts: 2,080
    edited March 2015 Vote Up0Vote Down
    Python-on-a-chip (https://code.google.com/p/python-on-a-chip/) claims to run in 55K of ROM and 8K of RAM. They have an AVR port. It is a subset of Python, though (they claim a "significant subset").
Sign In or Register to comment.