Proton BASIC Compiler - Mavericks's Top Tips for Beginners

  • PicŪ Basic

  • Mavericks's Top Tips for Beginners

    This post was written by Maverick and appears in the forum as a sticky in the Proton Version 3 part of the forum.
    It is copied here in the heading of 'Beginners' so it is easily found.

    So here goes Mav's top tips.

    A huge bulk of the questions asked on the forums are down to people not reading data sheets on the PICŪ they are using. Data sheets for every PICŪ can be found at , and these should be your first port of call.
    Even before you think about code you should read through the data sheet and try to understand it back to front, when coding keep a copy of the datasheet handy at all times as this will be your holy reference book.

    For example if you are going to use an 18F452 on your project ,, have it's data sheet next to you at all times as although the PDS documentation guides your hand very well , it isn't meant to explain the slight difference, registers, hardware modes on every chip, that's what the data sheets are for.

    Also have the data sheets for any other chip you may be using, be it logic expander, led drive , whatever, they are essential reading.

    What is it you want to achieve with a project ? What external components to the PIC will be required (if any) to achieve this goal ? Write down or at least mentally note what you're trying to do in the first place . It sounds silly but this can really help you keep mental clarity as you're trying to achieve these goals.

    It's a common mistake for new users to try to reach an advanced goal on their first project like an Uber tracking system or a robot with sensors to detect everything and its dog, this often ends in failure and frustration because they don't understand PICŪ or programming enough to realise their concept, it kills confidence and the fun of it.
    Start small and work your way up, even a professional programmer will tell you their first program was "hello world" and if they say otherwise they are lying.
    Learn to walk with it and become comfortable with the basics, then do a bit of jogging with something a little more complex, you will be sprinting with the rest of us soon enough.

    I don't mean literally but it can be handy when you do progress to something a little more complex, to break it down into blocks, figure out each block (for example interfacing to a memory) and once you have it cracked move to the next (say interfacing to a h-bridge) once you understand all these individual bits , it's a lot easier to pull them all together into a complex project.

    Try to think in a logical manner A leads to B leads to C, any digital system, PICŪs included by their nature work this way , everything in the universe is based around rules, PICŪ even more so PICŪ execute commands in a linear fashion 1 then 2 the 3 and so on.
    When your dreaming up your next project let your imagination run wild, once your down to coding,, become as Mr Spock, logical just like the PICŪ.
    If you can learn to think this way code becomes easy.

    I know it old fashioned but pseudo code can really help to get your approach to real code right in your head.
    Pseudo code is code you make up that simply outlines the process of the real code, and example might be

    Variable a is 50
    variable b is 20
    if variable b is greater than a then jump to the motordrive code
    otherwise end the program here

    one of the great advantages of basic is that it isn't a kick in the nuts away from pseudo in itself.

    The very act of writing this babble can get your course of action straight in your head and save confusion as to what you were actually trying to achieve once you deep in code and data sheets. Flowcode is the same if you find it more comfortable.

    Everyone here is happy to help our brethren.
    BUT try to work a problem out yourself , search the data sheets, read the manual, search the forum (as many things have already been covered), do a google, read a book.
    It's easy to just jump on the forum and ask, but you will learn far more if you try to figure out a problem yourself and it's far more satisfying and will serve you better in the long run, than if the answer is handed to you on a plate, and you will understand HOW the answer works. If your stumped after that then by all means ask, as one of the guys here will have been there, done that and bought the T-Shirt.

    Try not to get wound up when things don't work as you thought they would, see it instead as a challenge, a frustration clouded mind often just makes things a lot worse as it saps your ability to think logically.
    Try to stay calm and collected even when smoke pours forth from your circuit
    Try to think "Oh well I made a mistake , I'll figure it out and learn from it"
    It might seem silly to mention this as a tip , but trust me frustration leads to huge errors of judgement and not only is it stressful but can really put the mockers on a project.

    All hail the mighty google.
    If you're looking to achieve an end, Google it, you can find masses of information to help you understand how to get to that end, even if the results don't relate to pics directly the underlying physics are always the same.

    Bugs are very rare in PDS and the chances are that if something doesn't work as you expect it too, you're doing it wrong. Screaming BUG at the first obstacle will just get poor Les (the writer of PDS) upset and get on everyone's nerves. That's not to say that the very rare occasional bug may crop up , but statistically the chances are it's a fault on your part not the compiler. Investigate and deliberate before you shout bug, if it is a bug you have found , write it up in detail and it will be fixed.

    Most important is to have fun while your coding and designing, feel free to chuff out your chest and give yourself a huge pat on the back every time you figure out a new thing. Take pride in flashing a few LEDs , revel in your successes and brush off any failures (and pretend they just didn't happen).

    Anyway they are some of Mav's top tips , that rate high along with "never drink yellow snow at Christmas" and "Conduct a life of celibacy and emotional solitude without joining a monastery by simply living with my wife. It's more comfortable and you'll be able to watch TV and use the internet." and "Half a cocktail stick with a blob of nail varnish on the end makes an ideal "safety match" that your children can play with without the risk of setting fire to anything."