1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

PIC language?

Discussion in 'Microcontrollers' started by uaefame, Nov 5, 2008.

  1. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    Unless you are doing large production runs why use the 10F and 12F family? Maybe pin count or huge production runs. I have one of two of the 12F on the shelf and have been wanting to play with them but the desire/need has not reached the top of my stack. I used the CCS compiler for 16F code and liked it.

    Last summer I wrote an unpublished article that compared the code generated by C18, BoostC and Swordfish. The idea was to show the user how similar they actualy were. I ran into some interesting things.

    A comparision article would be a very good thing. Perhaps Bill would like to publish it in JPUG.

    If it has not already been said: It is a bad idea to try to optimize C code when using a compiler with an optimizer. Optimizers tend to know how to optimize simple logical code. Tricky C code may be tighter but the generated machine code is often larger.

    3v0
     
  2. arhi

    arhi Member

    Joined:
    Apr 17, 2008
    Messages:
    887
    Likes:
    12
    Location:
    Belgrade, .rs
    To be honest, because I'm cheap and stuped :(

    In more details ... I used to play with electronics some ~10+ years ago, and then I stopped as "bread and butter" job took over 100% of my time (sys development, realtime applications, database systems - i work for mysql now as mysql cluster consultant & developer). Some short time ago (~1year ago) I got some time on my hands and returned back to playing with electronics, brushed up old tools etc.. found that I forgot whole bunch of it and started from scratch... at the time, pic was the most appealing uC to play with, and I found a bunch of samples for 12F and 16F pic's .. so I went and got me a bunch of them in local store, purchased mikroelektronika's tool (easypic4, mikroC) and started playing with it ..
    EDIT: I do not use mikroC nor EasyPic almost at all as pickit2 + picc for 16F and C18 for 18F get the job done "faster"

    Now, I purchase only 18F (as there is really no real price difference for hobby use, and there are some pretty small 18F's too) but still have bunch of 12F and 16F's .. (think I still have ~50 16F84 :( .. and darn thing was more expensive then 16F268)

    hence - I use 12F's and 16F's where I can, just to "use them up" :)

    conclusion - yup, /me stuped

    post it post it :) would give me good place to start :)

    let me first write it :)

    I'm pretty familiar with optimisations, optimisation bug's, compilers etc... as system developer, one must know those things :( sometimes the slower but shorter code is actually going to be faster as it will fit in the cpu cache, on the other hand a simple mistake can slow things down with factor of 10 .. now, with uC's this is bit different, actually, lot different, especially with pic's architecture, and in most cases one do not have to worry about it - but some "general pointers" are good to have when one decide to use one particular compiler.
     
    Last edited: Nov 9, 2008
  3. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    You are a lucky person if you can hold down a high tech job and have enough energy left to play with uC's.

    When I was working I had a neat job. I was a software engineer but the lab staff treated all engineers the same and I could request any parts I wanted through them for free. The company encouraged tinkering and was happy to provide the parts and most tools so long as we gave them first shot at whatever we came up with.

    Lab stock was a nice little room to visit.

    About 15 years ago things changed. The hours got longer and the pressure to get products to market were such that you would either have to be super man or crazy to work on anything outside of work. From what I hear that is quite common.

    3v0
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. arhi

    arhi Member

    Joined:
    Apr 17, 2008
    Messages:
    887
    Likes:
    12
    Location:
    Belgrade, .rs

    laws change :) .. I have to have 36 uninterrupted hours of "not working" every week, hence -> free time :), the primary work brings enough doe so I do not have to have a secondary, tertiary ... job .. 8h per day include both work and followup on the "new technologies" so, working in sun is kinda good :D .. I'd say better then in most technology oriented companies.

    and really, the uC play keeps me happy, after many years of "sysdev work" one get frustrated as what you did few months ago is already "old news" and you cannot "touch" anything you make .. after many years, what do I have to show for, how to explain to non tech person what I do :) ...

    when you build a small jump towards the light robot, it is not much work, not much brains involved, but you can touch it, and when you give it to a nephew he play with it for days (until he try to find what is inside :D :D :D ) ... I do not have enough space around here and if I did, I'd probably do some woodwork or something else completely non-technical, but with limited space, "moving, jumping, squeeking" toys are great fun :) and much better way for spending time then watching TV :)
     
  6. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    I did woodworking and fancy goldfish.

    In my experience the one thing that upsets people most is canceled projects. It sucks when management has you working long hours for months on end and then cancels the project. It is even worse when they explain how due to the last flop you will be working long hours...

    I was lucky in that I did not see much of that. I knew people who had not released a project/product in 4 years. That had to hurt.

    We have gotten a bit off topic. PIC Languages. There is JAL which I have never tried and forth which is a lot of fun. It is very extensible.
     
  7. arhi

    arhi Member

    Joined:
    Apr 17, 2008
    Messages:
    887
    Likes:
    12
    Location:
    Belgrade, .rs
    tried JAL but missed to see the point :) .. I gave it only 1 day so might missed something

    forth .. interesting, but not sure I see the point :) would be easier to write in asm directly :) only if there is some nice forth interpreter for PIC, that would be interesting.

    what about interpreters, I know there was some nice basic interpreter for 8051, pretty useful stuff .. I tought about making one for PIC but have no use for it still .. maybe there is one available ?
     
  8. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,212
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE
    I used Forth many years ago, I never liked it at all (but not as much as I hated C) - Forth is a really poor choice for a PIC, as it's a completely stack based language - something PIC's don't have much of.

    Forth may have seemed 'extensible' back in the 70's, but Pascal is just as 'extensible' (as is C) - you simply write functions and procedures to add to the language.
     
  9. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,180
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    I used Forth for a while, I thought it was OK.

    With regard to to 'C', I think the 'C' stands for C-hinese.

    It started out OK years ago, but as it grew it ran out of meaningful symbols.

    Sorry Pommie.:rolleyes:
     
  10. arhi

    arhi Member

    Joined:
    Apr 17, 2008
    Messages:
    887
    Likes:
    12
    Location:
    Belgrade, .rs
    :D :D :D :D :D

    C is like "universal assembler" :) .. and it just get the job done
    as forth is concerned I used it only on calculator .. some HP something while back ..
    as for pascal, it is great tool, possibly best for what it is made for - teaching procedural language. It was never supposed to be used as dev tool
     
  11. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,212
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE
    No, you didn't use Forth, you used RPN (Reverse Polish Notation) - which is the style that Forth uses as well.
     
  12. arhi

    arhi Member

    Joined:
    Apr 17, 2008
    Messages:
    887
    Likes:
    12
    Location:
    Belgrade, .rs
    nope, it was forth .. and yes i know it uses rpn. I used to write program to calculate some forces acting on something when something .. forgot the whole thing .. but loops, jumps, imput params, output txt .. it was forth .. I learned it from some big heavy book I still probably have somewhere in the house :) .. iirc the HP (I think it was hp) had at least 8K of battery powered ram .. full keyboard .. serial port... and it was pretty darn expensive

    EDIT: looked pretty much like this: HP-71B - Wikipedia, the free encyclopedia but I cannot be sure if this is the right model
     
    Last edited: Nov 9, 2008
  13. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,212
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE
    Perhaps they made a Forth version then?, the one you linked to ran BASIC - but all HP calculators used to use RPN, even the non-programmable ones.
     
  14. arhi

    arhi Member

    Joined:
    Apr 17, 2008
    Messages:
    887
    Likes:
    12
    Location:
    Belgrade, .rs
    from wiki
    now, it looked like the on on the pic ...donno if that was the one .. iirc it had 2 lines lcd display, this one has 1 line according to wiki ... but, that was some 15+ years ago .. I got it from fathers friend and used for ~6 months .. if it had forth by default or he purchased the "upgrade" - i have no idea :) ... all I can say that it was a great toy :)

    and yes, if you wanted to use it as calculator, you had to use rpn

    anyhow, I never liked forth, never understood the point and never used it afterwords
     
  15. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,011
    Likes:
    317
    Location:
    Brisbane Australia
    It's past midnight here and that made me laugh out loud.:D I never thought I would be thought of as a C curmudgeon.:rolleyes: I'm an asm guy and just happen to know C. A few years ago I tried the HiTech C and found it bug ridden and extremely frustrating. However, in the last couple of years the C compilers for Pics have become so much better that it now makes a lot of sense to use them.

    I will still advice any newcomer to learn asm or rather learn the register level functionality of the chips as this will give them a greater understanding of the underlying hardware and enable them to write better code in any language.

    Mike.
     
    Last edited: Nov 9, 2008
  16. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    When there were no free C compilers or good IDE's forth was good choice. Once the interpreter kernel was programed a RS232 serial link to a PC would allow one to develop and test code interactively. This was far easier then erasing and programming UVPROM memory.

    C is for the most part just another procedural language. It is not 'extensible' in the sense that forth is. C code looks and feels like C code.
    This link.

    I think of forth as a language kit. In forth it is typical to see inline assemblers coded in forth. A set of words are defined which correspond to the processors assembler mnemonics. It is quite easy to write a old school basic interpreter in forth too.

    For most programming procedural languages such as C (and BASIC) work well. It is only when you step outside traditional programming boarders that forth becomes a very useful tool. Think AI. One of the most useful features is the ability to have a program extend itself.

    As Nigel pointed out forth is a stack language. People have gotten it working on the 16F and 18F chips but the last time I checked they were compiled rather then interpreted. There is a new 18F version called flash forth that uses self writable flash that could be worth looking into.

    The TI 9900 family was a very good target.

    3v0
     
    Last edited: Nov 9, 2008
  17. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,180
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi Mike,:)
    Had to look that up.!
    Dont use that 'curmudgeon' word in my neck of the woods, loosely translated to colloquial,
    I'm often called a miserable old fart.!

    Started my 77th Solar orbit yesterday.:)
     
    Last edited: Nov 9, 2008
  18. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,011
    Likes:
    317
    Location:
    Brisbane Australia
    Happy Solar Orbit Eric. Here's wishing you many more SOs.

    I have a sneeky feeling that the curmudgeon word may come back to haunt me.:(

    Mike.
     
  19. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    You are an inspiration :)
    Happy (birthday+1)

     
  20. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,212
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE
    Congratulations on your birthday Eric - and on been a 'miserable old fart' - I'm still working up to it, from being a 'boring old fart' :)
     
  21. BeeBop

    BeeBop Active Member

    Joined:
    Dec 22, 2005
    Messages:
    1,281
    Likes:
    23
    Location:
    Vancouver Canada
    First and foremost,

    Happy Birthday Eric!
    :):):):):):):):):):):):):):):):):)


     

Share This Page