Previous in Forum: Batteries   Next in Forum: High Frequency Mixers and Ultrasonic Amplifiers
Close
Close
Close
8 comments
Rate Comments: Nested
Associate

Join Date: Dec 2008
Posts: 29

Best Programming Language for Electronics

01/26/2009 8:17 AM

whats the best programme language for writing scripts in order to access ports fast?

__________________
vampiro
Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

Good Answers:

These comments received enough positive votes to make them "good answers".
2
Guru
United Kingdom - Member - Olde Member!! Engineering Fields - Instrumentation Engineering - New Member

Join Date: Jul 2006
Location: Dunstable, England
Posts: 2821
Good Answers: 45
#1

Re: best programme language for electronics

01/26/2009 8:50 AM

For the fastest execution to access ports you would have to use native machine code.

__________________
A little knowledge is a dangerous thing - Googling is far worse!
Register to Reply Good Answer (Score 2)
Commentator

Join Date: Jul 2008
Location: LA, CA
Posts: 97
#2
In reply to #1

Re: best programme language for electronics

01/26/2009 10:45 AM

I totally agree - if you know it that is. With compiling higher level code - there usually is some problems with that; too many to list. With machine level - 'you know' exactly what you want to do and what it should be doing. But with higher level code, the compiler is the one that decides what is going on. In theory it works excellently, but as we all know in the real world, that isn't always the case.

__________________
Bla - de - bla - de - BLA!!! "That's Me!!!"
Register to Reply
Power-User

Join Date: Jul 2008
Location: United States of America
Posts: 429
Good Answers: 3
#3
In reply to #2

Re: best programme language for electronics

01/26/2009 12:31 PM

I would suggest assembly language given that machine language is almost never taught any longer or even used pervasively. Failing that then the C-paradigm is the next option as it is the cleanest of the higher languages, although I would suggest using the GNU compiler for the compilation step because of its compilation of C-codes into intermediate assembly code that could be examined for efficiency or development insight.

__________________
EditorGBAnalysts - Give a boy fish and he will eat may be for a day, but teach him how to fish and he will eat everyday.
Register to Reply
Active Contributor
United States - US - Statue of Liberty - New Member Engineering Fields - Software Engineering - New Member

Join Date: Jan 2008
Location: New Jersey, USA
Posts: 12
Good Answers: 1
#8
In reply to #1

Re: best programme language for electronics

01/27/2009 11:01 PM

Yes, machine code is the fastest to run, but maybe 10X slower to write, so you will want to use it very sparingly. (Assembly code is just a human readable representation of machine code; its execution speed is identical.)

However, only a fraction of port I/O routines MAY need to be coded in machine language. A higher level language is so much easier to write in. You may get all the speed you need from carefully written C code which will run within a factor of 2 of the speed of machine code. If and only if the C code is not fast enough, you can rewrite only the critical part in hand coded assembly code in-line with the C code. Still, most of your code will not be in that critical path, and so can remain in a higher level language, such as C.

If you have GUI code or complex algorithms to write, you will want a higher level language than C, such as Python (currently my favorite language). Python and C can be mixed easily. In fact, I'd recommend starting out writing in Python, and switch to calling C routines only for the low level code close to the hardware or any other time critical routine.

__________________
hparker
Register to Reply
Guru
Popular Science - Biology - New Member Hobbies - Musician - New Member APIX Pilot Plant Design Project - Member - New Member Hobbies - CNC - New Member Fans of Old Computers - ZX-81 - New Member

Join Date: Jan 2007
Location: Centurion, South Africa
Posts: 3921
Good Answers: 97
#4

Re: Best Programming Language for Electronics

01/26/2009 12:37 PM

What system and CPU are you using and what is on the other side of the port?

I am also in favour of Assembler / machine level programming but using a higher level language also have advantages. Ports are accessed by name, it may do better error handling and handle protocol correctly without you having to know much about it.

Also note that high level languages includes inline assembler programming in any case.

__________________
Never do today what you can put of until tomorrow - Student motto
Register to Reply
Guru
Engineering Fields - Systems Engineering - New Member Popular Science - Weaponology - New Member

Join Date: Jun 2006
Location: Borrego Springs
Posts: 2636
Good Answers: 62
#5

Re: Best Programming Language for Electronics

01/26/2009 2:27 PM

Worth noting is the type of port, RS-232 is pretty easy to reach for, USB or TCP are layered protocols which I *think* might argue for a higher level language for ease.

__________________
"If you want to get somewhere else, you must run at least twice as fast as that!"
Register to Reply
Guru

Join Date: May 2007
Location: Geelong, Australia
Posts: 1084
Good Answers: 54
#6

Re: Best Programming Language for Electronics

01/27/2009 12:49 AM

There's no correct answer, it depends on what you want to do and what you're doing it on.

But note that modern PC's and programming methods don't let you access the ports directly (like you could in the good old DOS days) and most users want a pretty GUI. You could look a something like Visual Basic, it's pretty and, once you understand the classes, quite powerful.

As an old C/assembler programming elec engineer, I never thought I'd ever say that.

__________________
If there's something you don't understand...Then a wizard did it. As heard on "The Simpsons".
Register to Reply
Guru
Hobbies - Model Rocketry - New Member

Join Date: Jun 2007
Location: East of Seattle, Washington state Republic of the 50 states of America
Posts: 2045
Good Answers: 36
#7
In reply to #6

Re: Best Programming Language for Electronics

01/27/2009 2:20 AM

Very true the answer is hardware and application specific. I can't say yet for Linux but it is very hard to do with M$ OSs now. It can be done but it is made difficult by M$ design. They want you to pay for Visual Basic.

Also is just a connection being made for communicating (like a tunnel) or is the control root level at all parts (like CNC)?

A command line control is doable but a GUI brings its own issues.

Brad

__________________
(Larrabee's Law) Half of everything you hear in a classroom is crap. Education is figuring out which half is which.
Register to Reply
Register to Reply 8 comments

Good Answers:

These comments received enough positive votes to make them "good answers".
Copy to Clipboard

Users who posted comments:

edignan (1); editorgbanalysts (1); Electroman (1); ffej (1); Hendrik (1); hparker (1); U V (1); Walts_Worker (1)

Previous in Forum: Batteries   Next in Forum: High Frequency Mixers and Ultrasonic Amplifiers

Advertisement