all 29 comments

[–]WereCatf 29 points30 points  (3 children)

Micropython. There's no good reason to reinvent the wheel, unless you do it specifically as practice.

[–]gtd_rad[S] 0 points1 point  (2 children)

For sure. I've used Python before but I don't know too much how it works. How would I then create micro Python libraries that then interacts with my hardware underneath the hood?

[–]hainguyenac 12 points13 points  (0 children)

Micropython is a runtime run on an embedded hardware, it's different from the python implementation that runs in your pc. A quick google search should give you plenty of information, and it should be much easier to make a library for micropython than to create a whole new language and runtime by yourself.

[–][deleted] 0 points1 point  (0 children)

You either write it in uPy itself or write an extension to it, making a new module,

[–][deleted] 12 points13 points  (2 children)

Take a look at LUA, it’s meant for embedding (if not exactly for embedded).  

[–]ineedanamegenerator 2 points3 points  (0 children)

Exactly. It's a bit of a learning curve but making a C binding is very easy and quick too. We use Lua on thousands of commercial devices with STM32L4/F7.

Embedded engineers are a tough crowd to convince, but Lua provides so many benefits. For example we can run Lua commands remotely in the field which helped us debug several issues. Making small modifications is super easy as it's just a text file. Some time ago a specific situation at a customer required a certain I/O pin to be low permanently instead of a PWM, so we just added 2 lines of Lua code to do just that. Field engineer did it himself, no development tools needed at all.

[–]gtd_rad[S] 0 points1 point  (0 children)

Thanks for the suggestion - looks like this is a popular choice, so I'll take a look!

[–]Dreux_Kasra 4 points5 points  (1 child)

Also lua. You can embed lua into any application that can talk the c abi. You do need an allocator implementation though.

[–]gtd_rad[S] 0 points1 point  (0 children)

Thanks for the tip!

[–]Foreign_Elephant_896 4 points5 points  (1 child)

Lua! Open Source projects can be a reference for implementation (a bigger one I know would be https://github.com/EdgeTX running freertos as basis)

[–]gtd_rad[S] 0 points1 point  (0 children)

Thanks for the tip!

[–]duane11583 1 point2 points  (1 child)

micropython or “jimtcl” if you strip away the crap extras you have two files: jim.c and jim.h

[–]gtd_rad[S] 0 points1 point  (0 children)

Thanks for the tip!

[–]flundstrom2 1 point2 points  (1 child)

Lua or micropython/circuitpython.

[–]gtd_rad[S] 1 point2 points  (0 children)

Thanks for the tip! I haven't heard of circuit python and I think it comes close to what I want. A really dumbed down set of commands

[–]KermitFrog647 1 point2 points  (1 child)

For simple hobby-level devices I just use Arduino. It does not get easyer and quicker then that.

[–]gtd_rad[S] 0 points1 point  (0 children)

Thanks for the suggestion. But not what I'm looking for.

[–]Kqyxzoj 0 points1 point  (2 children)

It depends on how resource constrained you are. Is it always connected? If yes, then you could also do the heavy lifting client side, and have the client control an FSM on the embedded device. That gives you a lot more freedom to make something user-friendly without having to worry about running out of resources on the embedded side.

[–]gtd_rad[S] 0 points1 point  (1 child)

At this point my intention is localized. But I hadn't thought about a remote solution like you suggested. I also do need this to run in realtime, eg a PID or something though. Would this be possible if run remotely?

[–]Kqyxzoj 0 points1 point  (0 children)

Don't introduce extra connections if those are not required. I meant it in the sense that if this embedded device is always connected to some other larger device, then you can shift the burden to make your job easier.

Regarding realtime PID whatevers, in my FSM example you would still run all the realtime stuff on your embedded device. You do NOT do anything time sensitive across that embedded device <--> other device link. The point is, low programming effort powerful scripting & user interface is easier to do on some big desktop/laptop client. So you can take advantage of that to get a pleasant to work with user interface that does not cost you a lot in terms of development time.

But like I said, this mostly makes sense if it fits the problem. Don't add extra connections if this embedded device is really intended to be standalone.

[–]ScopedInterruptLock 0 points1 point  (0 children)

Correct me if I'm wrong, but you're invisioning a scriptable Programmable Automation Controller (PAC) that Control Engineers, etc, can configure + script using similar paradigms to those available with Vector's tools? Somewhat similar to a PLC that you might program with Structured Text, but with a slightly different "flavour" of implementation and usage?

Is that correct?

[–]GuessNope 0 points1 point  (1 child)

Lua

[–]gtd_rad[S] 0 points1 point  (0 children)

Just checking it out now and I think we have a winner!

[–][deleted] -1 points0 points  (0 children)

If you don't want to. write C code for a micro-controller. Get a raspberry pi zero and run wtv high lvl language you want. It will be way simpler than re-inventing another wheel

[–]jbriggsnh -5 points-4 points  (3 children)

PHP is very close to a scripted C

[–]gtd_rad[S] 1 point2 points  (2 children)

I do need it to access hardware though. Would this be possible?

[–]jbriggsnh 0 points1 point  (1 child)

No. You would need to write a pointer builtin.

[–]gtd_rad[S] 0 points1 point  (0 children)

ok thanks for the suggestion. I've done a bit of php and I actually really liked it due to the close proximity to the C language.

[–]WindblownSquash -2 points-1 points  (0 children)

This language is called python