Notifications
Clear all

Using Python

16 Posts
5 Users
9 Likes
604 Views
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
Topic starter  

@rob42101 wrote at,

https://forum.dronebotworkshop.com/help-wanted/stepper-and-load-cell/paged/7/#post-45953

I believe that you'll get to grips with the coding side of your project, much quicker by using MicroPython.

Bill covers the use of Python,
https://dronebotworkshop.com/python-free-resources/
https://dronebotworkshop.com/esp32-2024/
https://dronebotworkshop.com/pi-pico-circuitpython/
https://dronebotworkshop.com/pi-pico/

 


   
Marvin reacted
Quote
Marvin
(@rob42101)
The Paranoid Android
Joined: 2 months ago
Posts: 32
 

That is real helpful: thank you.

@the-apprentice

You may also find this thread useful. Keep in mind that Micropython.org released version 1.21 of its build, just last year (October, I believe), which was a major upgrade, so you'll need to keep an eye on this relatively fast moving and evolving environment. You'll find that some of the built-in modules have been renamed and as such, if you're using v1.21, but following a tutorial that was written for v1.20 (or earlier), which, at this stage, will be almost all of them, you may fall over a module rename, which could be a little confusing, if you're unaware of the changes; just something to keep in mind.

The only thing necessary for the triumph of evil is for good men to do nothing.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1117
 

@rob42101  

Just to note that whilst micropython has now gone for CPython module names, such as time instead of the original utime or asyncio instead of uasyncio etc. they kept the ability to import the modules by the old name as well so all the older micropython examples should still work OK


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6827
 

@byron Since Python is so popular amongst the SBC crowd, maybe a few members (even me) might be interested in checking it out. For me (others may be different) a web site with a list and description of the various 'libraries' (not sure if that is what they are called) so we get a feel for the capabilities of the language. Another site (may be the same) for just the syntax, and finally something like the Arduino IDE Built in examples would be helpfull.

Screenshot 2024 02 19 at 11.55.37

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
Topic starter  

@zander 

Since Python is so popular amongst the SBC crowd, maybe a few members (even me) might be interested in checking it out.

I checked it out before it was such a popular and well supported language and didn't like it. However now it is so popular and so well supported I made the effort to learn to read and write Python programs. Although in my own project I don't use it I know if I ever have to use it I can.  If you want to communicate with other people you have to share a language and if their only language is Python ...

Python’s interpreter is written in C and now a lot of its modules are written in C++.

 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6827
 

@robotbuilder I wonder if people who prefer OO style languages like Python and C++ are wired differently than folks who prefer procedural languages like C and Pascal. We have a similar thing with analysts and designers/programmers. It was established back in the 70's that they have a strong relationship to right brain vs left brain (I don't remember which is which) dominance. While at IBM I was often sent to customer shops to 'fix' their software development environment and while there often saw the disasters caused by the wrong brained people in various jobs. I suspect the same is likely to be true today with regards to language use.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
Topic starter  

@zander

I wonder if people who prefer OO style languages like Python and C++ are wired differently than folks who prefer procedural languages like C and Pascal.

I don't prefer one over the other. I am just too lazy to code classes although I did spend a lot of time learning how to do it. Programming is just a hobby that complements my interest in electronics and I try and keep it simple and readable.  (Professional programming is a completely different ball game requiring knowledge and skills I don't have.)  The old C code used printf which is for me not as readable compared with cout or the using the string class.  Although I could write my own classes I usually don't and thus I guess my code is a mix of OOP and procedural programming?

Although I took the trouble to learn to read and write Python code I am not currently using it instead I use FreeBASIC which is sufficient for my current ongoing project and runs on a laptop and an RPi computer. I am not however adverse to using Python or Arduino C++ should I ever want to share a project with others. With my Arduino projects I use Arduino C++.  The other easy to learn, use, read and understand language I really like is Processing.

https://processing.org/


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1117
 

Posted by: @zander

@byron Since Python is so popular amongst the SBC crowd, maybe a few members (even me) might be interested in checking it out.

Posted by: @zander

@robotbuilder I wonder if people who prefer OO style languages like Python and C++ are wired differently than folks who prefer procedural languages like C and Pascal.

Ron, Python can be used in a procedural way, or one can use OO style, your choice. 

But I digress.  My point to you is that learning a new language, even for those proficient in another language still takes a significant amount of effort.  Are your really wanting to put in this effort to program whatever it is that you may have in mind that you could probably do right now in C with your eyes closed.

The programming environment using Micropython for knocking up something new for your ESP32 or rpi pico is undoubtedly rather more instantly productive as the code is more readable and no need to compile. Code up and immediately run, test out code lines in the REPL and no need to even run the code.  But for old C programmers you will probably find the code indents and no curly braces to be an irritant in your python learning curve and will find yourself plopping on a lot of no needed semicolons.  At the end of the day you wont be programming anything you could not do with C.

For the likes of the raspberry pi SBC, that just runs the same Python as you can put on your Mac or PC.  The rpi SBC has some extra libraries to facilitate the use of its GPIO pins etc.

A few years back the most prominent forum member at the time RoboPi who was likewise a proficient C (and in his case also C++) programmer, found it advantageous to learn Python as he found that a lot of stuff he was interested in like speech recognition, AI, or whatever it was he was up to, had a lot of example code in Python.  He became quite enthusiastic about some of its capabilities.  So it can be advantageous to get up to speed in Python.  However, I will be cheeky enough to opine that taking on Python may not really be up your street.

But delighted if you choose to prove me wrong 😀 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6827
 

@byron It was another conversation that caused me to bring it up but I am curious. I change my mind, forget what I am doing, and start new projects on almost a daily basis. Sort of like 'Groundhog Day'. I am hoping that if/when I get my pacemaker it will improve the oxygenation and blood flow to my brain so I can improve my organizational skills. Then I might be able to fit in learning a new language, but I do have a lot of other projects to do first. I am counting on the theory that a person who is highly focused on future events will live at least that long. Fingers crossed!

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Inst-Tech reacted
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
Topic starter  

@byron 

A few years back the most prominent forum member at the time RoboPi who was likewise a proficient C (and in his case also C++) programmer, found it advantageous to learn Python as he found that a lot of stuff he was interested in like speech recognition, AI, or whatever it was he was up to, had a lot of example code in Python.

How time passes. RoboPi shared an interest in AI and robotics. Back then I still had a lot of enthusiasm for building a working robot.  Recently I chanced upon a secondhand fully functioning electric wheelchair for sale, an item I thought would make a good outdoor robot base, but now realize my enthusiasm for the project has vanished, I don't enjoy the process anymore and I wouldn't be able to muster the effort required to achieve anything worthwhile.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1117
 

@robotbuilder @zander

You two old buggers,  (whoops I guess I will have to include myself in that category). How time passes indeed.  Enthusiam waining, oxygenation required ...  

Perhaps:

Do not go gentle into that good night, Old age should burn and rave at close of day; Rage, rage against the dying of the light.

But:

Our wills and fates do so contrary run, that our devices still are overthrown; our thoughts are ours, their ends none of our own.

So:

Well its time for a nice cup of tea ... and a biscuit.... or two.  


   
DaveE reacted
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
Topic starter  

@zander 

I am counting on the theory that a person who is highly focused on future events will live at least that long. Fingers crossed!

From what I have observed people who live a long life have a good set of genes. No mutations that result in cancer, cardiovascular disease, stroke or high blood pressure and so on. The other factor is physical exercise such as walking or swimming an hour a day. Diet also plays a role. Not many old fat people. My father in law (94 yrs) is as skinny as a praying mantis. He is also mentally as sharp as he was when I first met him. Also long lived people don't just focus on the future they focus on the present. If you exercise your brain with learning new things it should, I imagine, mean that, baring any genetic problems resulting in dementia, your brain will stay healthy and fit.

Hope you can get a pace maker as it will greatly improve your well being if it is needed. In Australia we have a fairly good medical system (except for dental care) to help those without enough finance to afford medical insurance. My father in law has some machine that generates oxygen in the room not sure how it works.

Using your experience and know how to help people with their problems on this forum seems to be a rewarding and worthwhile mental exercise?

Although I keep fit and eat healthy I don't worry about how long I live I just enjoy the NOW which is all we ever have.

 


   
Inst-Tech, DaveE and Ron reacted
ReplyQuote
Inst-Tech
(@inst-tech)
Member
Joined: 2 years ago
Posts: 554
 

@robotbuilder ..Indeed, I have to agree with every thing you said..I just turned 77, and with my family history, If I'm lucky, I'll live to be in the high 80's or 90's...lol

But yes, genes and exercising your brain, along with physical exercise, is the ticket!

I don't worry anymore about how long I'll live, but concentrate on how I can give back some of that knowledge that was imparted to me by so many in my life, that they are to many to mention! The world needs us, not just to pass on our knowledge of electronics, MPU,MCU's.. but in general to the knowledge of a long ago past where education was a premium and sought out for the good of mankind..Indeed, Ron and yourself, are included in that..

As a student of history, as well as the study of electronics that has been for the past 60 years or so, I recognize the value of helping others, and in doing so, create a better world for those that follow us..Thanks to people like Bill, and yourselves, the world is a much better place for our children and grand children. I'm proud to be a member of such a group, and hope that all of you live a long and fruitful life.

Now I'll get off my soapbox! 😎 

Sincerly, Best regards,

LouisR

LouisR


   
huckOhio reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6827
 

@robotbuilder I do have good genes as well, but exercise is not possible while my heart is acting up (periodically stops for a while).

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Inst-Tech reacted
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
Topic starter  

@inst-tech 

As a student of history, as well as the study of electronics that has been for the past 60 years or so, I recognize the value of helping others, and in doing so, create a better world for those that follow us.

"Give a man a fish and you feed him for a day, teach a man to fish and you feed him for a lifetime."

I think the best thing you could impart to a young person is the ability to think clearly using logic and reason and knowing the limitations of those skills so they don't have the arrogant assumption that they actually know anything for sure. Thus my interest in what we have learned about how the brain actually works including why it can get things so wrong. We have have cognitive illusions which we cannot detect by introspection alone.

 


   
Inst-Tech reacted
ReplyQuote
Page 1 / 2