Announcement

Collapse
No announcement yet.

MCU PI discriminator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Originally posted by Aziz View Post
    Relocatable code = position independent code

    see on wiki:
    http://en.wikipedia.org/wiki/Position_independent_code

    Typically, relocatable code is more compact due to smaller relative program counter jumps, which can be coded in most cases directly in the assembly code (no additional operands needed). This part of code can be placed anywhere (moveable code).
    Absolute branching needs more operand code size (jump position). Code is not moveable and needs to be placed at particular address.

    Aziz
    Thanks for the link.
    Tinkerer

    Comment


    • #17
      PI discriminator

      OK, here is a circuit to work with.

      Tinkerer
      Attached Files

      Comment


      • #18
        Originally posted by Tinkerer View Post
        Thanks for the link.
        Tinkerer
        Ignore that link, that is nonsense, you are programming a PIC. So, the deal is very simple, yet very powerful. Relocatable code is nothing else than an object module that can be linked with others using a linker. Microchip provides a linker for using relocatable code as well as templates for all their microcontrollers. What are the advantages?
        1. You can write and debug a piece of code and use it many times without the need for debugging it again.
        2. All the ram memory stuff in the PIC is handled automatically and a map file is generated for you. So, say you want to allocate memory for a circular buffer or any chunk of data, then the only thing you have to do is tell the linker to do so. For instance if you want to reserve 16 bytes for a buffer you can do it like this:
        buffer RES 16
        That is, instead of allocating every byte separately.
        3. The linker has many useful macros, for instance, instead of figuring out in which bank your variable is and then switching banks with the STATUS bits, it is possible to do like this:
        banksel Var
        The linker will find out the proper bank and insert a macro accordingly.
        4. you can create libraries of related modules for reusing them when needed.
        5. when using routines from Microchip or from anywhere else, you don't have to worry about their memory allocation because if it fails the linker will issue a warning.
        There used to be a very good starting tutorial at the Microchip website, but I don't know if they still have it.
        In short, the learning curve is a bit steeper, but the advantages and benefits so many that I don't even know why the keep the absolute code thingy anymore.
        Let me know if you get stuck,
        Regards
        R.A.

        Comment


        • #19
          Originally posted by Aziz View Post
          Relocatable code = position independent code

          see on wiki:
          http://en.wikipedia.org/wiki/Position_independent_code

          Typically, relocatable code is more compact due to smaller relative program counter jumps, which can be coded in most cases directly in the assembly code (no additional operands needed). This part of code can be placed anywhere (moveable code).
          Absolute branching needs more operand code size (jump position). Code is not moveable and needs to be placed at particular address.

          Aziz
          Nonsense, stop quoting wikipedia on matters you know nothing about. From the same article you are quoting:

          "Position-independent code can be copied to any memory location without modification and executed, unlike relocatable code, which requires special processing by a link editor or program loader to make it suitable for execution at a given location."

          position-independent code NOT EQUAL TO relocatable code

          you missed the part about "link editor" or "program loader".

          Regards
          R.A.

          Comment


          • #20
            Using the linker

            Originally posted by gwzd View Post
            Ignore that link, that is nonsense, you are programming a PIC. So, the deal is very simple, yet very powerful. Relocatable code is nothing else than an object module that can be linked with others using a linker. Microchip provides a linker for using relocatable code as well as templates for all their microcontrollers. What are the advantages?
            1. You can write and debug a piece of code and use it many times without the need for debugging it again.
            2. All the ram memory stuff in the PIC is handled automatically and a map file is generated for you. So, say you want to allocate memory for a circular buffer or any chunk of data, then the only thing you have to do is tell the linker to do so. For instance if you want to reserve 16 bytes for a buffer you can do it like this:
            buffer RES 16
            That is, instead of allocating every byte separately.
            3. The linker has many useful macros, for instance, instead of figuring out in which bank your variable is and then switching banks with the STATUS bits, it is possible to do like this:
            banksel Var
            The linker will find out the proper bank and insert a macro accordingly.
            4. you can create libraries of related modules for reusing them when needed.
            5. when using routines from Microchip or from anywhere else, you don't have to worry about their memory allocation because if it fails the linker will issue a warning.
            There used to be a very good starting tutorial at the Microchip website, but I don't know if they still have it.
            In short, the learning curve is a bit steeper, but the advantages and benefits so many that I don't even know why the keep the absolute code thingy anymore.
            Let me know if you get stuck,
            Regards
            R.A.
            gwzd,
            now this is really helpful. I did download the linker, but had not yet enough confidence to look at it. I will now. Your advice is encouraging.
            The "Low Pin Count Demo Board" comes with a tutorial, but what do I do when its code causes an error message with the simulator?
            The learning curve must feel steeper to some than to others.
            At least I am old enough to be able to blame old age, ha, ha, ha.

            All the best

            Tinkerer

            Comment


            • #21
              Originally posted by gwzd View Post
              Ignore that link, that is nonsense, you are programming a PIC. So, the deal is very simple, yet very powerful. Relocatable code is nothing else than an object module that can be linked with others using a linker. Microchip provides a linker for using relocatable code as well as templates for all their microcontrollers. What are the advantages?
              1. You can write and debug a piece of code and use it many times without the need for debugging it again.
              2. All the ram memory stuff in the PIC is handled automatically and a map file is generated for you. So, say you want to allocate memory for a circular buffer or any chunk of data, then the only thing you have to do is tell the linker to do so. For instance if you want to reserve 16 bytes for a buffer you can do it like this:
              buffer RES 16
              That is, instead of allocating every byte separately.
              3. The linker has many useful macros, for instance, instead of figuring out in which bank your variable is and then switching banks with the STATUS bits, it is possible to do like this:
              banksel Var
              The linker will find out the proper bank and insert a macro accordingly.
              4. you can create libraries of related modules for reusing them when needed.
              5. when using routines from Microchip or from anywhere else, you don't have to worry about their memory allocation because if it fails the linker will issue a warning.
              There used to be a very good starting tutorial at the Microchip website, but I don't know if they still have it.
              In short, the learning curve is a bit steeper, but the advantages and benefits so many that I don't even know why the keep the absolute code thingy anymore.
              Let me know if you get stuck,
              Regards
              R.A.
              gwzd,
              now this is really helpful. I did download the linker, but had not yet enough confidence to look at it. I will now. Your advice is encouraging.
              The "Low Pin Count Demo Board" comes with a tutorial, but what do I do when its code causes an error message with the simulator?
              The learning curve must feel steeper to some than to others.
              At least I am old enough to be able to blame old age, ha, ha, ha.

              All the best

              Tinkerer

              Comment


              • #22
                Tinkerer,
                don't be afraid it's not going to explode. Download the MPLAB IDE from Microchip's website if you already don't have it, use the template for the mcu you are intending to use as the source file. Don't forget to include in the project the linker script and the header. If you don't know how to do that let me know so I can give you a hand.
                Don't worry about the simulator, it works fine with relocatable code as well.
                About the age, what we have lost with the passed years in eyesight and breath we have gained in patience and perseverance. So, I wouldn't be too worried about it, the idea is clear and the benefits many.
                Let me know if I can help you.
                Regards,
                R.A.

                Comment


                • #23
                  Discriminating PI?

                  Originally posted by Tinkerer View Post
                  OK, here is a circuit to work with.

                  Tinkerer
                  Is this circuit supposed to function? Does it really discriminate between iron and gold?

                  Monolith

                  Comment


                  • #24
                    PI discriminator

                    Originally posted by Monolith View Post
                    Is this circuit supposed to function? Does it really discriminate between iron and gold?

                    Monolith
                    Yes it works, I tested it on the breadboard. Does it work in the field? I say add the peripherals and it will.

                    Does it discriminate between gold and iron. Yes it discriminates perfectly for coins rings, nails, cannon balls etc.
                    For some strange reason it classifies gold foil as FE. I am talking of the kind of gold foil used for gilding. It does detect the 5 miligram gold foil at several inches, but in this instance the discrimination does not work.
                    Tinkerer

                    Comment


                    • #25
                      Hi Tinkerer,

                      Have a peek at the following link.

                      http://goldprospecting.invisionplus....t=0&#entry3443

                      With an 18 inch nuggett finder coil, 240uS TX, preamp gain (amplification) 500, a coke can at 1.2 metres inside an EMI noisy workshop.

                      regards
                      bugwhiskers

                      Comment


                      • #26
                        I would buy a couple of boards Carl.
                        this sounds interesting BW.
                        Been thinking about what else has not been done or thought of yet and here you answer my question. Actually had the thought about this this morning on the way to work. Not what you are suggesting though. Thanks for thinking outside of the Box.
                        RayNM

                        Comment

                        Working...
                        X