Shop OBEX P1 Docs P2 Docs Learn Events
Very New to this, need a push to the right Direction — Parallax Forums

Very New to this, need a push to the right Direction

mchistimchisti Posts: 11
edited 2012-01-23 13:49 in General Discussion
Hey, I'm completely really new to electronics and just getting started. I read a book and understand the basic laws & concepts of DC & AC, but nothing hands on. Can someone recommend me any kits that teaches me the basics of electronic components with hands on (shows how a transistor, diode, etc. work in a circuit) and about what micro controllers (What is the difference between Arduino and Propeller?) are able to do. I do a little Java Programming and hear that Spin or PBasic is not object oriented and slows programming speed down. Also programming, I hear a lot of bad rep for assembly language & C, but notice that a lot of micro controllers uses Assembly, C & Pascal. Why is that? These are extremely old programming languages. I also want to ask, what's the best versatile micro controller language. Will learning PBasic or Spin (Is this exactly the same as assembly language?) transit to other micro controllers too? Is it worth spending time learning Assembly, C or Pascal? Any other additional information would be greatly appreciated :smile: Thank You

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-01-22 09:36
    PBasic, like the Basic language it's derived from, was designed for relatively simple tasks in an educational setting. As such, it's an excellent beginner's programming language. It can be compiled into a very compact code which is a good match for the limited resources of small microcontrollers like the Stamps.

    Assembly is widely used, particularly for small microcontrollers. Pretty much any "high-level" programming language requires some overhead to support the higher-level features of the language. Larger microprocessors often have special instructions to support these. Smaller, less complex processors don't. Assembly allows efficient, relatively small programs to be written for the smaller processors with tight control of timing ... often difficult to do with higher level languages.

    C and Pascal are often used as the high-level languages for microcontrollers since they, with some restrictions and simplifications, can be compiled into low overhead efficient code. They may be "old" programming languages, but they were very well thought out. There's really nothing that has supplanted them for this sort of purpose. C++ is an extension, built on top of C, that does have some features that are very useful and need not add to the overhead. Some of the object-oriented features fall into this category and some do not.

    Spin is derived partially from C, C++, Pascal, and Python. It has some object oriented features. It's an interpreted language whose interpreter is included in the Propeller's ROM and is automatically loaded when the Propeller is started up. Most programs for the Propeller consist of a mixture of Spin and Assembly. Many of the high speed I/O drivers have portions written in Assembly and portions written in Spin. The floating point library also works this way. A cog (processor) either runs an Assembly program or the Spin interpreter (also an Assembly program) and usually one cog using the Spin interpreter acts as the main processor and the "glue" binding everything together. Spin is very appropriate for this purpose since the main program is often not compute-intensive and the slower speed of the Spin interpreter doesn't affect the overall speed of the program.

    C and Assembly are the programming languages most used for microcontrollers. Keep in mind that the (important) details of Assembly vary from one microprocessor to another. Once you become proficient with one Assembly language, it's relatively easy to pick up another, but it does take some time to get good with the new one. For a lot of the microcontrollers, there's a tremendous amount of information you have to learn about the peripheral processing blocks that vary, sometimes subtly but critically, from one model to another. The same instructions might be available, but that won't help you.
  • mchistimchisti Posts: 11
    edited 2012-01-22 09:56
    Thank You! Greatly appreciated. That does make more sense, assembly takes up a lot less space. I'll start out with PBasic, then to Assembly & Spin.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-01-22 10:15
    If you want to start with the Propeller, there is a PropBasic compiler that translates a variant of PBasic to Spin which then gets compiled automatically. You can mix PropBasic, Spin, and Assembly if you want. You can find the Propeller QuickStart board at some RadioShack and Microcenter stores. If you're not in a hurry, the Propeller Board of Education (PropBOE) is new and expected to ship in about two weeks. It will be the center of Parallax's educational curriculum going forward and there's supposed to be a bunch of educational materials available already when it ships. I'd recommend the PropBOE if you can wait.
  • mchistimchisti Posts: 11
    edited 2012-01-22 10:32
    Thank you again for being a big help. I'll take your word and wait for the PropBOE, I hope it gives me a much more solid understanding.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-01-22 10:49
    Start exploring all the information that's available. Look at the Propeller Education Kit tutorials and other beginner information available from the two "sticky" threads at the top of the Propeller Forum thread list. Look at what's available on the Resources webpage and the Downloads webpage for the Propeller including the Nuts and Volts Columns specifically on the Propeller ("The Spin Zone"). Download the software and manuals you'll need from the Downloads webpage. Get the PropBasic manual and software. Note that PropBasic uses a version of the Spin compiler / Assembler written by a 3rd party (called BST ... Brad's Spin Tool) that has some special features that PropBasic makes use of. It also has the advantage that it will run under Linux and the MacOS as well as Windows.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-22 10:57
    I was just about to suggest skipping PBasic and go directly to the Propeller but Mike beat me to it.

    The Basic Stamps are arguably easy to start programming than a Propeller but Basic Stamps cost a lot more than a Propeller and can do a lot less.

    When I first started to learn about microcontrollers, I purchased both Basic Stamps and Propellers. I regret spending so much money of Stamps that could have been used to buy more sensor or more Propeller boards.

    While you're waiting for the PropBOE, you ought to get a QuickStart board or a Propeller Proto board.

    The main problem with starting with the Prop as your first microcontroller, is you wont realize how good you've got with the Propeller since you wont have the other chips to compare it against.

    I personally would suggest starting with Spin. It not a hard language IMO. The ability to run code in parallel takes a little getting used to but it's a lot of fun. The Propeller Education Kit (found in the "Help" menu of the Propeller Tool) walks you through learning Spin.

    Of course there are lots of people here on the forum willing to help when you need it.

    Edit: I see Mike already suggested the PEK material and lot of other good stuff.
  • mchistimchisti Posts: 11
    edited 2012-01-22 11:11
    THANK YOU :lol: You are making this very easy for me. I did go through those sticky threads & links and found tons of information to learn from. I'm going to continue looking through these and I'm look forward to it.
  • Heater.Heater. Posts: 21,230
    edited 2012-01-22 11:21
    mchisti,

    Welcome to the club.
    I hear a lot of bad rep for assembly language & C, but notice that a lot of
    micro controllers uses Assembly, C & Pascal. Why is that? These are extremely
    old programming languages. I also want to ask, what's the best versatile micro
    controller language. Will learning PBasic or Spin (Is this exactly the same as
    assembly language?) transit to other micro controllers too?

    Who are these people giving C and assembler a bad rap and what do they know
    about anything?

    C might be rude and crude compared to some languages and it may well be old. But
    think of it this way, the reason it is old and still in wide spread use is a
    testament to the fact that nothing better has come along in the mean time.
    Consider that Linux is written in C, all it's useful programs are written in
    C/C++ (I consider C++ to be C but more so). Windows is written in C/C++. Most
    useful apps are written in C/C++. Most of those supposedly superior languages
    of the week, Java, Javascript, Python, Ruby etc are implemented in C.

    As noted C is is the most widely used language in embedded systems. Especially
    if you want reasonable performance with a handle on worst case execution time
    (No random pauses as a garbage collector fires up in Java for example) and you
    want code that can easily be moved from architecture to architecture (ruling
    out assembler).

    As for assembler, I'm old fashioned and I think everyone programming computers
    should be at least have written some code in assembler. Just to get a feel for
    what a computer actually is. The Prop instruction set and assembler are one of
    the easiest to use I have ever come across.

    Pascal is OK but has fallen out of favor for whatever reasons.
    Is it worth spending time learning Assembly, C or Pascal?

    Sure is. I'd rate them as ultimately more widely useful than Spin or any
    variant of BASIC for micro-controllers.
  • mchistimchisti Posts: 11
    edited 2012-01-22 11:39
    Thanks Duane for the warning & advice. I was actually going to buy the Stamp basics before Mike did suggest the PropBOE to me. I wasn't sure if I was able to dive right into Propeller but am sure I could now since you confirmed it. It seems more knowledgeable to learn from the mistakes you've made, so I'll learn Spin first. I really do want to learn as efficient as possible without having to repeat mistakes of others. I can see how helpful the forum is and am very fond of if.
  • mchistimchisti Posts: 11
    edited 2012-01-22 11:52
    Heater. wrote: »
    mchisti,

    Welcome to the club.

    Thanks for the Welcome Heater.

    I have just heard C isn't object oriented and learning it will make it harder for me to learn other language. I have even been told that learning C makes it harder to learn C++ and that I should learn C++ before learning C. I ended up being most proficient in Java because of it being able to run on any OS.

    For assembly, I was told that it was tedious and takes too long to write and slows down progress. But it seems that I have been told these from programmers who themselves have not programmed in Assembly or C and I also realized that they may never dwell into Micro Controllers. I was just worried that C & Assembly might become obsolete or not used widely.

    After hearing that it is still used widely I'm not too worried of ending up learning a language and having no use for it. Thanks again, you guys have been great. :smile:
  • Heater.Heater. Posts: 21,230
    edited 2012-01-22 12:49
    mchisti,
    I have just heard C isn't object oriented and learning it will make it harder
    for me to learn other language.

    That makes me laugh. Back in the day, when I started out programming in the
    late 70's, people used to say that "Learning BASIC gives you brain damage and
    make it harder to learn a proper "structured programming language".

    I've always thought that was non-sense, I started out with BASIC and assembler
    run on a big old mainframe. A year later I was into Algol, the mother of all
    structured programming languages.
    I have even been told that learning C makes it harder to learn C++ and that I
    should learn C++ before learning C

    Utter non-sense. Some people would say that C not being object orient is an
    advantage:) If you want to program in C++ you are going to learn C anyway as it
    is a subset of C++.
    For assembly, I was told that it was tedious and takes too long to write and
    slows down progress

    For large chunks of code or whole projects yes. Too long to write, easier
    to make bugs, hard to change once you have written it. Most importantly
    normally unportable from one OS to another and totally unportable from one CPU
    architecture to another. If you are going to invest a lot of time in a large
    project you probably want your creation to be long lived and survive OS and
    processor changes.

    But it seems that I have been told these from programmers who themselves have
    not programmed...

    Sounds like you should send them here for a bit of straightening out:)
    I was just worried that C & Assembly might become obsolete or not used widely.

    That is not even remotely on the horizon. One might not use assembler much but
    someone has to understand such things else where do all the compilers and
    operating systems come from?


    Now, what about YOU. You see it all depends where you are coming from and where
    you want to go (Which you might not know yet).

    With little knowledge of electronics but a lot of enthusiasm to learn. With a
    knowledge of programming in Java. I think the Propeller and Spin is a perfect
    place to start out.

    Spin is simple, it is the BASIC for the Propeller, with the advantage that it
    is "structured" as they clamored for back in the day. It is designed to make
    the best of the Prop. It creates compact code so you can get more functionality
    in.

    With that experience under your belt the Props assembler will be needed if you
    want to get into writing maximally fast code. But the Props assembler language
    is dead easy compared to most others, I love hacking away in PASM.

    When you are familiar with the Prop and some electronic gadgets to wrap around
    it the GCC C compiler for the Prop will be ready and you can experiment with
    C/C++.
  • bill190bill190 Posts: 769
    edited 2012-01-22 18:55
    For learning, just hang around here in the Basic Stamp and/or Propeller forums. Nature will take its course about EVERYTHING! (Over time.)

    That includes discussion of various languages from time to time. People here have done just about anything you can imagine computer related.

    So far as different microcontrollers and different languages are concerned, each might be the best choice for a certain task, but might not be a good choice for other tasks.

    So in some cases assembly language might be the best choice. For something else C might be the best choice. For another Spin. Or PBasic.

    If I want to make LED lights blink, I might choose a Basic Stamp and PBasic. For an IR remote control, maybe a PIC and assembly language. And for a solar water heater project I am planning, the Propeller and Spin will be a good choice (I would NOT want to do that in assembly!)

    So I have no favorites. For a particular project, a certain microcontroller and language will begin to look very good and others not so good.

    Sort of like vehicles and tasks...
    Drive a person across town - Small car will do the job!
    Drive 30 people across town - A bus would be a good idea.
    Take 45 people to Hawaii - A plane or boat would be much better than a car!
    Etc.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-23 08:18
    bill190 wrote: »
    If I want to make LED lights blink, I might choose a Basic Stamp and PBasic.

    Once someone has learned to use the Prop, I don't see any reason why they would every use a Basic Stamp in a project. Edit: Except for reason I give at the end of this post.

    I could make a LED blink much easier with a Prop than with a Basic Stamp. Plug a QuickStart into my USB and I it's ready to be programmed. The QS board costs less than any of the Basic Stamp boards I know of. I could either use a LED on the QS board or use a breadboard next to it wih a LED and resistor.

    Basic Stamps cost a lot more than Propellers and they can do a lot less. I just don't see an upside once one knows how to program a Prop.

    I'm sure I'm not the only one who has let their Basic Stamps gather dust since learning to use the Prop. Edit: Except for the reason given at the end.

    So what it it's overkill. If it's cheaper to overkill a project than to use something good enough, why use something just good enough?

    In your car example, the Prop is a cheap inexpensive small (flying) car that can comfortably hold as many as a bus and that can fly to Hawaii. (It would also get excellent mileage.)

    I will admit there are times when other microcontroller are a better choice for some projects (when you need lots of something very cheap and simple), I just don't see the Basic Stamp (expensive and simple) as being one of those microcontrollers.

    I think I don't have the same soft spot for the Stamps as many forum members because I hadn't used them very long before making the switch to the Prop. I suppose if I had years of fond memories of making projects using Basic Stamps, I might still be looking for ways of incorporating them into my current projects. But to me, Basic Stamps are the controller that I spent too much money on before learning there wasn't anything a Stamp could do that a Prop couldn't do better while costing less.
  • mchistimchisti Posts: 11
    edited 2012-01-23 13:49
    Heater.,

    You do bring up a good point that a lot of people will have their own opinions for their own programming styles and also how what you want to do does influence your opinions for programming languages. I guess you can say knowing a programming language at all is an advantage then not knowing one at all. I was going to get into Assembly & C before getting into Electronics & Micro Controlling, this does make me look forward to Assembly, C & C++ with Micro Controllers. I love learning something and finding out I can use that knowledge and input it into something else.

    Bill190,

    Yes, I will be making more posts in the forums, there is a lot of knowledge and help floating around here.

    That is true about certain languages and I like your car example :smile:

    Duane,

    If I can learn Spin and not have to learn BASIC then I'll take the advice. I like having a lead.

    To All,

    I really can't have a solid say in any of this really until I get my hands dirty as well. So far I'm choosing to go with the Propeller, learn SPIN, Assembly & then onto C, C++. I hope the PropBOE is a good investment and really looking forward to the new learn.parallax.com website that will be launched with it.

    :lol: Thank you to all for helping :lol:
Sign In or Register to comment.