Micro Phython language and board - Page 1
Forum section: electronics / general

author: chicken
author_rank: Frequent Contributor
timestamp: November 15, 2013, 06:28:07 pm
content: Here's a nice, no-BS, Kickstarter:Micro Python: Python for microcontrollershttp://www.kickstarter.com/projects/214379695/micro-python-python-for-microcontrollersBased on a STM32F4 microcontroller.Quote

author: c4757p
author_rank: Super Contributor
timestamp: November 15, 2013, 06:38:52 pm
content: So... how many LEDs can this blink at once?Check your link.

author: chicken
author_rank: Frequent Contributor
timestamp: November 15, 2013, 07:20:55 pm
content: Doh!I need more coffee! Link fixed

author: Harvs
author_rank: Super Contributor
timestamp: November 28, 2013, 11:43:30 pm
content: It's obvious why they're doing it the way they are (making their own board), so that they actually have something to sell.But the funny bit is, this would actually be 100% more useful for the end user if they were a purely software project, and I could just grab a STM32F4 Disco board off the shelf that has all pins brought out, a microphone, stereo DAC (that can directly drive headphones), accelerometer and programer for $15 and perhaps give these guys $10 for their efforts. From what I can see, the actual hardware isn't doing anything that a Disco board doesn't have?So do you think there was a way that they could have made this a successful campaign/product selling licences for their "Micro Python" interpreter?I just noticed this:"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. "Now I really don't see the point in this kickstarter.

author: Kean
author_rank: Unknown
timestamp: December 13, 2013, 12:53:36 pm
content: I personally quite like supporting projects like this, where I get some hardware to play with, and support further open source development.Probably wouldn't have bothered looking into micro python till I saw this.

author: peter.mitchell
author_rank: Super Contributor
timestamp: December 13, 2013, 05:46:57 pm
content: Quote from: c4757p on November 15, 2013, 06:38:52 pmQuote from: chicken on November 15, 2013, 06:28:07 pmI'll go with 4, because it comes with 4, must be right!

author: strangelovemd12
author_rank: Regular Contributor
timestamp: December 13, 2013, 11:45:31 pm
content: Quote from: Harvs on November 28, 2013, 11:43:30 pmWhich is why I don't see your apparent objections. The first funding option was £10 gets you the code, have fun. (They also put your name in there, wasting 35namebytes as of funding.) Funding at a higher level is just pitching in on a run of boards that someone designed because you want one. The margin they take is compensation for writing up a (hopefully) decent open source project.QuoteQuoteBut I agree that the software is the intriguing bit, looks really efficient for one off projects. Lowering the barrier to entry is also a good thing, and this is some easy as hell interfacing.

author: free_electron
author_rank: Super Contributor
timestamp: December 14, 2013, 01:57:20 am
content: not just NO , but HELL NO !PYTHON is the BIGGEST mistake of the millenium.Any language where whitespace is important should be universally banned and its creator and users tarred, feathered and forbidden to touch anything that runs on electricity, or has anything to do with computing. This prohibition should include their descendants and ancestors up till the 5000th generation.There. i said it.

author: c4757p
author_rank: Super Contributor
timestamp: December 14, 2013, 02:02:30 am
content: I like Python a lot for scripty stuff. The whitespace bit isn't a choice I would make if I were designing it, but it's just one thing and I can deal with it. (Any proper editor manages it just fine anyway.) It's a great scripting language IMHO.As far as putting it on a micro - I wouldn't touch that with a barge pole, but I'm all for more choices of things to poke my barge pole at.

author: Marco
author_rank: Super Contributor
timestamp: December 14, 2013, 02:09:22 am
content: If I want to run an inappropriate interpreted language on a micro I'll stick toOccam.

author: ivaylo
author_rank: Frequent Contributor
timestamp: December 14, 2013, 05:52:03 am
content: You'll need a lot of tar and feathers. Whitespace is significant in C++, Java and pretty much every assembly language I can think of.

author: arekm
author_rank: Unknown
timestamp: December 14, 2013, 04:19:02 pm
content: Quote from: free_electron on December 14, 2013, 01:57:20 amInteresting. I find it the important python feature. It forces you to write readable code.http://stromberg.dnsalias.org/~dstromberg/significant-whitespace.html(and tons of other articles about the subject)

author: free_electron
author_rank: Super Contributor
timestamp: December 14, 2013, 04:50:13 pm
content: Quote from: arekm on December 14, 2013, 04:19:02 pmNonsense. Pretty formatting is the task of the IDE, the compiler should be insensitive to it.As a developer i should not have to worry about two spaces, three spaces and other stuff like that. The IDE should clean it up for me.If i send the code through email and spaces get replaced by tabs or vice verse this should NOT have an impact on the execution !Python has other problems. There are no constants for example. This is very dangerous as stuff that should be immutable all of a sudden is changeable.We tried a python experiment at work. It wasschot down by almost all engineers. We wanted to use it a s scripting for test automation.We wrote a framework and gave some sample scripts to control a fee multimeters.Most people had immense problems with the whitespace sensitivity. 'How come this line loops ? How come this is not executed ? Why does it throw an error here ?That is another problem with python. It crashes at runtime. Code is not analysed before it runs. It happens on the fly.At the same time python was transistioning form 2.xx to 3.xx and they deliberately broke the language to correct fundamental mistakes. This meant that a bunch of libraries we were using did not work on 3 and had to be ported...The end conclusion is : this is a can of worms we don't want to deal with. It is in no working state , and we are at the mercy of the people developing the language not breakong it...Python is great as an experimental platform and for people that like developing languages and compilers. As a practical usable language ... Not so.

author: krivx
author_rank: Frequent Contributor
timestamp: December 14, 2013, 08:34:16 pm
content: Quote from: free_electron on December 14, 2013, 04:50:13 pmYou really seem to have a bee in your bonnet over this experience. How long did people try to use it? I encountered nearly all the issues you listed and overcame them pretty quickly I think, none of them seem to crop up now (coming from a background in C). I use it for test automation and really like it. What language did you end up using instead, out of interest?

author: krivx
author_rank: Frequent Contributor
timestamp: December 14, 2013, 08:40:05 pm
content: As to Python on a microcontroller, I think it's interesting but it would suffer the same problems that any high-level language would. I could see it being very difficult to use in any case where deterministic timing is required.

author: tom66
author_rank: Super Contributor
timestamp: December 14, 2013, 09:28:21 pm
content: Should try and avoid this spiraling into a Python vs whatever debate but my opinion is...Python is great. It supports multiple ways of writing code, it is very powerful, it has a great library, it's intuitive and I like the whitespace feature.BTW, free, it's not as big of a problem as you describe. Python is quite good at understanding inconsistent spacing, as long as it's not too inconsistent. For example it's possible to mix tabs and spaces, as long as they are in separate blocks. Your complaint about code executing erroneously is difficult to see, because an IndentError exception is a lot more likely.Python will also analyse the code before runtime to see if it compiles successfully. If it fails the *.pyc will not be compiled and the code will fail pretty much instantly,

author: free_electron
author_rank: Super Contributor
timestamp: December 14, 2013, 09:37:05 pm
content: This is an experiment that ran over more than a year. Apart from the developers, none of the people supposed to use it liked it. Most of em would rather do the measurements by hand than having to fidget with adapting the pythons scripts.Keep in mind that this was intended to be used by HARDWARE people and test people who have very little experience writing code. They are focues on debugging a lump of hardware, they just need a scripting tool to control some instruments and collect some data in an automated fashion.The last thing you need when debugging a system is a language that is counter-intuitive and a compiler that doesn't cooperate because it doesn't like how you format your source...The idea was : it's gotta be simple to be learned by a layperson on half an hour. And it failed miserably.The key complaints ( at that time )- No IDE with autocomplete , syntax check or whatever. ( we had something called Stani's Python editor... )- sensitivity to whitespace and the lack of a good IDE made this a disaster. You would tell a 'user'. simply add this command here. they would type this in without regard to indentation and 2 minutes later they were back at my desk. 'it doesn't work ... becasue of indentation ?!? you have to be freaking nuts to design a language like that !- endless problems making a new install. you need to get python version xyz, then deploy library this and that , then deploy such and so. we need to grab like 12 different packages , the order of install was important. if package versions or language versions got updated they might break compatibility. So we needed constant monitoring and keeping our own repository of a 'golden install'. When someone found some interesting package to do graphing or whatever we could go off and figure out if it would work , if it didn't could go hunting for a version that did. Endless support nightmare.- incomplete or half arsed libraries. pyVISA is a nightmare implemented by nitwits that have no clue how GPIB works.-unstable environment. this thing was an immense memory hog when it began running we could see the number of processes running on windows shoot up and the memory claimed was tremendous. if a script crashed and was rerun it sometimes would not free up memory. after an hour or so all you could do is reboot the machine to get python (2.61 i believe )to release all the stuff it claimed. That is simply not acceptable.We switched to Visual Basic.- it's free (VB express is all you need)- comes with a kickass IDE (Visual Studio )- single click deploy- any 5 year old can write a program in BASIC without being tought- all instrument manuals come with program examples written in some flavor of BASIC- it interfaces natively with excel and powerpoint.we spent a month making a core library to do interaction for often used things. all our machines are virtualisedfor example :Code:Dim VCCsupply asd new HP3463(17) ' define a power supply at gpib address 17Dim DMM1 as new HP34401(12) ' define a multimeter as gpib address 12 . machine is a 34401Dim OVEN as new ESPEC310(9) ' define a new temperature chambersupply1.currentlimit = 0.5dmm1.function - AmpereDCDMM1.digits=6DMM1.integration = slowDMM1.oversampling = 256supply1.output=onXL.connect "myspreadsheet.xls" ' open a spreadhseet file, create new if not existXL.newsheet "mysheet" ' inject a new pageXL.Title ("Temperature / VCC current plot") ' set a titleXL.newrow ' create a new row of datafor temperature = -50 to 125 step 25oven.temperature = temperaturefor VCC = 4.5 to 5.5 step 0.5VCCsupply.voltage= vccXL.write("A", temperature) ' write in column A of current rowXL.write("B", VCC) ' write in colum B of current rowXL.write("C", DMM1.getdata) ' write in column C of current rowXL.newrownext vccnext temperatureXL.createXYplot (B,C) ' create a plot for columns B vs C' and throws it on clipboardPP.connect"mypowerpoint.ppt" ' open a powerpoint filePP.newpage ' insert new slidepp.pageheader = "Temperature/ VCC plot"pp.pagedate = Datetime.Todaypp.pagetime = DateTime.Nowpp.author = "Vincent"PP.paste ' paste the plot into powerpointPP.closeMAIL.sendfile ("vincent.himpe@gmail.com","mypowerpoint.ppt")supply1.output = offand so on...That is where we are today.We create a simple excel file , run the program once then insert the graphs once and save.when a program is rerun the graphs update automatically.We autopopulate excel spreadsheets, pull plots , copy them to powerpoint files and email the files off automatically.There is a whole framework to interact with excel, powerpoint , email and the master fileserver.these scripts run quasi automatic and create completed presentations with all measured data in a few hours.Scripts are easy to create. Everybody using it is happy.The IDE autocompletes without having the type CTRL-space (what a stupid idea was that !) , autocapitalises, case is irellevant , code is cleaned up automatically.And most important : i don't have to spend time teaching people how to use it. Anyone can write BASIC code.

author: krivx
author_rank: Frequent Contributor
timestamp: December 14, 2013, 09:47:43 pm
content: Quote from: free_electron on December 14, 2013, 09:37:05 pmI guess this is a specific usage case, people who don't do any programming. Not really a reason to poo-poo the language in every case though!I'm surprised at your other complaints though, I've found it to be pretty lightweight on memory usage. I've had a better experience deploying python installs than with any other language, virtualenv/virtualenvwrapper (https://pypi.python.org/pypi/virtualenv) makes it really easy to keep specific version of the language and the libraries in isolated "virtual environments".

author: Marco
author_rank: Super Contributor
timestamp: December 15, 2013, 12:35:07 am
content: Quote from: free_electron on December 14, 2013, 04:50:13 pmYou always are ... just ask long time Visual Basic programmers ...

author: Alexei.Polkhanov
author_rank: Frequent Contributor
timestamp: December 15, 2013, 10:52:08 pm
content: I thought people choosing Python for test automation because it has goodnumeric and mathematical modules written for it.I almost never automate anything simply because I don't work in this area but when I want to streamline some tedious task with USB DMMs tools like Agilent 34405A I use MATLAB. It reminds me that I wanted to get programmable PSU :-)If you don't need any math functions for data processing then ANY language will work for you as soon as you can send few bytes to and from COM port.

author: fake-name
author_rank: Regular Contributor
timestamp: December 20, 2013, 11:55:03 am
content: Quote from: free_electron on December 14, 2013, 04:50:13 pmWow, I just want to counterpoint here.Python is by far my favourite programming of all time. WAY better then C.Also, the white-space control flow is probably one of the major things that makes it so fantastic.All your complaints sound like you were trying to write C in python, which the language was *explicitly* designed to prevent. User error.Re: Runtime crashes. You've never had C crash at runtime? Wow, you must be perfect.I've written entire GUI applications in python, as well as done realtime video processing (that was.... involved).Also, I don't know what your issue with pyVISA was, but I recently spent a while glueing together a bunch of data-logging from a really, really cranky spectrum analyser using pyVISA and a NI GPIB card, and had zero issues that weren't me being stupid, or the spectrum analyser itself crashing (it has issues).----I think the OP's idea is brilliant. This would be awesome for quick prototyping in situations where determinacy isn't relevant, e.g. most of the places I throw an arduino at currently.

author: MacAttak
author_rank: Unknown
timestamp: December 21, 2013, 06:55:55 am
content: I thought it was a cool enough idea to support it myself.Python is a decent language, quite terse and readable. I don't care for the indentation rules, but hey you've got to have *something* to define block scope and indentation requires the least amount of vertical editor space.I've also worked on some of the internal bits of one of the popular python implementations, so it's intrinsically interesting to me on that level too.I also backed another similar project that funded around the same time - a similar dev board that runs a javascript engine. I happen to really like the core JavaScript/ECMAScript language - it's very simple and elegant in many ways - so that one was easy for me to support.I really like that people are applying other languages to these tiny platforms. C really sucks for a lot of tasks where some of those alternate languages really shine. Diversity is a really good thing for growth of the technology in general.

author: hagster
author_rank: Frequent Contributor
timestamp: December 21, 2013, 07:29:57 am
content: Synapse wireless have been selling Python based microcontrollers for years. You can do some really neat stuff because of the interpreted nature. They have a fully functional wireless python command line example that hardly required any code. For simple stuff it's brilliant.In my opinion using a 'billy basic' high level language with an overspecced uController is a perfectly valid way to reduce development time especially on low quantity systems.Python isn't perfect, but it is quick and easy.

author: mrflibble
author_rank: Super Contributor
timestamp: December 21, 2013, 08:43:47 am
content: Quote from: Alexei.Polkhanov on December 15, 2013, 10:52:08 pmAnd you would be right. I've been using python for a while now and numpy/scipy is pretty useful. It even has an interface to R for some proper statistics. Good luck doing that from VB.But hey, you can always export your data to excel and do some poor mans number fumbling there.Ever done that for something like 500M records in excel? You should try it sometimes, it's hilarious and tragic and humorous all at the same time.Quote from: hagster on December 21, 2013, 07:29:57 amIndeed. But in the end it comes down to "whatever works for you". If VB works for you + your colleagues and gets the job done, have at it! You just won't see me using VB for automation, because VB blows on many a level. In my humble opinion of course.In someone else's opininion it may be awesome. Which only goes to show how relative opinions are, and how much it is tied to your own personal use of tool XYZ.The onlyvalidpython gripes I've read so far are: 1) whitespacewtf and 2) 2.x vs 3.x library bullshit. The whitespacewtf is also one of my gripes with python (I mean seriously guys, tabs as a language construct? dieeeee!) but in regular use this does not turn out to be much of an issue. It's dumb, stupid, moronic and some other things, but it doesn't get in the way of coding. The 2.x vs 3.x library thing I have also encountered andthatactually is annoying in practice.As for "crashes a lot" ... what now? I've never had any python crash so far. Obviously I have had it bomb out when I, the lazy user, neglected to handle an exception but that is 100% user error. It's not as if java or C++ or whatever is going to be any nicer with an unhandled exception. What's that, it is? Oh you mean it really isn't but you wave it away by using a wrapper or businessblahcontainer that catches it for you.@free_electron:Were they really crashes, or unhandled exceptions? If crashes, in what parts of the program? It would surprise me somewhat if it was in python core, because so far that seems fairly solid. Maybe some obscure third party library that has compiled C in it that has not been reviewed all that much?

author: andersm
author_rank: Super Contributor
timestamp: December 21, 2013, 12:12:21 pm
content: Considering the type of crap churned out by "non-programmers", having a language that enforces at least some structure can only be a good thing.

author: fake-name
author_rank: Regular Contributor
timestamp: December 21, 2013, 12:31:15 pm
content: Quote from: mrflibble on December 21, 2013, 08:43:47 amI have to say I don't really get the whitespace complaints. If there was some way to write C code that used indentation as the block delimiter, you could probably take any C project I've written, remove the curly-braces, and compile it using that tool with no changes.The only reason I can see for complaining about this is that you are used to writing C or whatever language *without* indentation, in which case you are programming wrong. Period.---There are plenty of legitimate complaints (2-3 transition has been messy, arguably lack of private and static vars, etc...), but the block delimiter is not one of them.

author: mrflibble
author_rank: Super Contributor
timestamp: December 21, 2013, 01:28:52 pm
content: Quote from: andersm on December 21, 2013, 12:12:21 pmConsidering the type of crap churned out by "programmers", having code reviews and giving the boot to those that consistently have no clue can only be a good thing. Which is my special way of saying that I've heard the argument of "it will provide more consistent code" before, but I have yet to witness this effect. Just like with any other language there is nice and readible python code, and there is inconsistent crap. So, nope, so far haven't really seen any evidence to that effect.Anyways, I don't care overly much about the whitespace issue since like I already said it doesn't really get in the way of coding. But it doesn't really offer any tangible benefits as far as I'm concerned.And indeed lack of private and static is also annoying. Note that I did not say the two I listed are the only issues. I said they were (IMO) the only two legit ones on free_electron's list of issues. Of which only one actually gets in the way of coding (2.x / 3.x library transition).

author: Unknown
author_rank: Unknown
timestamp: December 21, 2013, 02:14:35 pm
content: I like the mandatory indentation for teaching people to code: beginners starting out with trivial programs (their first if statement, their first for loop) sometimes fail to see the point of indenting the three line blocks they write. A language that uses indentation to mark blocks makes it much easier to learn sensible indentation.

author: MacAttak
author_rank: Unknown
timestamp: December 22, 2013, 08:52:59 am
content: The whitespace issue is mainly a problem because of the variance in different editors when it comes to tab/space conversion (and showing a difference between tab and space characters). Personally, I indent my code anyways when using braces in C-style languages anyways so python's structure isn't visually unappealing to me. It's when you work in a team and some jackhole insists on using an editor that converts spaces to tabs or vice versa.I don't understand the limitations of statics and privates though? As far as I know, python supports both static fields as well as static methods. And you can always achieve the equivalence of a private member by using closures. This technique is very widespread now due to its heavy usage in modern JavaScript libraries.

author: Marco
author_rank: Super Contributor
timestamp: December 22, 2013, 07:24:07 pm
content: They should have just made the interpreter refuse code with tab indentation by default, force people to either use an editor with space replacement OR if they are sufficiently sure they will never screw tab/space indentation up let them override the behaviour. Instead you need a command line option even to get warnings of tab/space mixing.Regardless of the validity of whitespace indentation with the best practices, the interpreter rewards wrong practices with not even a warning ...PS. oh I see I'm out of date, with version 3 they finally realized this too ... lil late.

author: mrflibble
author_rank: Super Contributor
timestamp: December 23, 2013, 03:56:49 am
content: Quote from: MacAttak on December 22, 2013, 08:52:59 amThanks! I am such a python n00b... Also, I love user error. It's easy to fix.

author: MacAttak
author_rank: Unknown
timestamp: January 11, 2014, 01:11:54 am
content: The open-source activity on this one has really surprised me. Source code and schematics / pcb layout for the reference board were recently published on github, and there has been a huge amount of discussion and patch submissions (hundreds of commits already, in just barely more than a single week!).I expected some popularity of this project, but not quite so much enthusiastic support from the community.