Announcement

Collapse
No announcement yet.

Bonehead Part VI

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

  • #16
    Is it possible that you have another hardware issue, like missing the pullup resistor on the pin where the button is connected or have the button wired to the wrong supply rail or something? Verify the voltage at the pin with the button in both states, when NOT pressed it should be 5V, when pressed it should be 0V.

    As for the other stuff Richard is right.
    Each port has (at least) a PORT and a TRIS register. To enable the output driver for a particular pin you clear (set to zero) the corresponding bit in the TRIS register for the particular port/pin you're targeting (ie. TRISA.0 = 0). While using the PBP commands HIGH/LOW does indeed compile into code that does change the corresponding TRIS bit writing directly to the PORT register does not.

    So, if you want to toggle a pin between high/low you do:
    Code:
    TRISA.0 = 0
    Blink:
      PORTA.0 = 1
      PAUSE 100
      PORTA.0 = 0
      PAUSE 100
    GOTO Blink
    If you'd like to toggle it between low and high z, like an open collector output you'd do:
    Code:
    PORTA.0 = 0
    Blink:
      TRISA.0 = 1
      PAUSE 100
      TRISA.0 = 0
      PAUSE 100
    GOTO Blink

    Comment


    • #17
      Is it possible that you have another hardware issue, like missing the pullup resistor on the pin where the button is connected or have the button wired to the wrong supply rail or something? Verify the voltage at the pin with the button in both states, when NOT pressed it should be 5V, when pressed it should be 0V.
      even if there is no hardware issue , until the comparator issue is fixed the problem remains

      Then again, neither do answers that do not shed any light on the original question. If you would stop trying to pick the nits from other folks that answered

      i'm quite happy to leave you wallow around in a pit of misinformation and alternative facts it that is what you desire,


      and explain in a line or two what you find the error is it would help greatly
      my answer is a fully detailed clear and concise reason for your code to fail at that point. i would expect you to at least try to implement a solution before being spoon feed the fix
      give it a couple of days eh!


      I had teachers in college that would simply snap "the answer is in chapter 4 of the text, look it up yourself" and others that would open the text and explain what the answer is and a little bit about it, The time taken would be about the same, but I can name the helpers from the snots some 60 years later. And I still, after 40 years of answering the same questions of MY college students, will give them a few minutes of my time to be sure they understand what the right answer is.
      i have told you before i'm not a teacher and do not aspire to be one, your nostalgic recollections serve no purpose , they're not even interesting


      Capiche?
      whats that about



      Comment


      • #18
        Jim, As Richard has pointed out you need the statement CMCON = 00000111 which enables the digital mode for PORTA.0,.1,.2 which you are using as digital inputs. When reading PORTA all pins configured as analog will read as "0". Also without a pullup resistor on PORTA.0 you cant guarantee what state it is in when being read. Even though you are a Teacher, you still need to do some reading.....
        Iy's all in the Data sheet...
        Dave Purola,
        N8NTA
        EN82fn

        Comment


        • #19
          Thanks for the pointers Dave.

          The data sheet says that CMCON **AND** ANSEL are required to work with the analog inputs but then in another statement says that ANSEL is only defined for the 676. You can't have it both ways. My memory of logic says that the AND function means you need both of them but a later statements says that one of them is not defined for the 630.

          Take the confusion factor forward and search the PICBASIC 3 manual for CMCON. It does not exist. So how do I issue a command that the manual says is not in the language?

          Is it any wonder that the newbie comes up on a brick wall trying to use what the data sheet says to use?

          Jim

          Comment


          • #20
            Take the confusion factor forward and search the PICBASIC 3 manual for CMCON. It does not exist. So how do I issue a command that the manual says is not in the language?
            8 bit pic micro controllers come in a vast plethora of varieties that feature many variations and combinations of peripheral modules. there are quite a number of configuration inconsistencies that you will encounter,virtually making universal compiler commands impossible.
            pbp has commands only for these pic peripheral modules eusart/usart,pwm,usb,internal eeprom,adc and flash memory if incorporated in your chip and they are not all embracing.

            pbp has no commands to :-
            configure any of the many and varied oscillator possibilities
            control analog functions of any i/o pins
            configure any of the other peripherals

            there is no substitute for knowing your particular beastie. when you get stuck, post your code [properly , use code tags]
            explain the issue as best as you can, be nice if you don't understand the replies ask more questions [there's no charge].

            Comment


            • #21
              David, Henrik, and MIke...

              The sucker works as designed. Using the CMCON command to disable the analog comparator to digital worked a treat. Thank you for your responses. And I thank you on behalf of the entire freshman Robotics class at Sierra College who will build this little gem using your suggestions.

              I dismiss as blatant "el toro caca" that a program (PicBasic 3) that costs several hundred dollars and that boasts to program the Microchop PIC line does NOT include all commands, especially for a chip like the 630 that is over 10 years old. That is just lousy research, development, and marketing. Do it all, or do nothing. Don't leave the poor newbie to wander about with missing commands.

              Just for grins and giggles, I've attached an image of my test bench. Notice about $20K of ANALOG and RF test equipment on the top shelf and the little tiny circuit you all helped me on in the upper right hand corner of the white square on the prototype board on the center of the bench itself. I'm an analog/RF/microwave cat in a room full of digital rocking chairs.

              Click image for larger version  Name:	IMG_0924.JPG Views:	2 Size:	29.3 KB ID:	7824

              Thanks for all the help.

              Jim
              Last edited by jweir43; 08-20-2019, 10:16 PM.

              Comment


              • #22
                I dismiss as blatant "el toro caca" that a program (PicBasic 3) that costs several hundred dollars and that boasts to program the Microchop PIC line does NOT include all commands, especially for a chip like the 630 that is over 10 years old. That is just lousy research, development, and marketing. Do it all, or do nothing. Don't leave the poor newbie to wander about with missing commands.
                Oh for crying out loud....
                CMCON is not a command, it's a register in the particular PIC you've choosen to use, just like TRISx, PORTx, and so on. Choose another PIC and it won't have CMCON (just like your '630 doesn't have ANSEL while the '676 does because it has an ADC built in) so how on earth do you expect the PBP3 manual to contain information on every possible PIC? That's what the datasheets are for. The manual shows you how the LANGUAGE works, it's up to you to apply it to the particular PIC you choose to use.

                I don't know the age of your students but IMHO you need to learn the concepts that you're teaching - it's not enough to just "be a teacher".

                Capiche? ;-)

                Comment


                • #23
                  Capiche, molto bene, gratias.

                  Then why are TRIS, PORT and ANSEL and so on well documented in the manual and CMCOM isn't even mentioned? Sorry, that is a FATAL FLAW in the documentation.

                  My students range from 15 to 85+ and everywhere in between. And I've been teaching them successfully for 34 years now, plus another 10 years at another College. I really don't need help in my teaching. I need help understanding a new concept I'm trying to convey to them.

                  My teacher is coming out ... in your second sentence, it is CHOSEN, not choosen.

                  Thanks,

                  Jim
                  Last edited by jweir43; 08-20-2019, 11:12 PM.

                  Comment


                  • #24
                    Because in the '630 it's called CMCON while on devices with TWO comparators the registers are (usually) named CM1CON/CM2CON, there's no way to cover such information in the manual. But if you look at section 2.2.5 they do mention comparators and the need to disable them and if you look at section 8.1.4 you'll find this:
                    If there are analog inputs for converters and/or comparators on the target MCU, they will usually default to analog mode on the pins. This will interfere with digital operations performed on pins that also function as analog inputs. For digital use of pins with analog options, you must find and set a register to select digital mode for the pins.

                    Here are a few examples for a handful of MCUs, but remember that PBP supports more than 400 different devices. Don't assume that the settings are consistent from one device to the next.

                    ANSEL = %00000000 ' 16F88, 16F688, 16F690, 16F88x
                    ANSELH = %00000000 ' 16F690, 16F88x
                    ADCON1 = %00000111 ' 16F87x, 16F87xA, 18F452
                    ADCON1 = %00001111 ' 18F4620

                    In the Microchip datasheet for the specific device you are using, the analog/digital selection will be located either in the I/O Ports section or the Analog/Digital Converter section. Common register names are ANSEL, ANSELH, ANSELA-ANSELG, ANCONx, ADCONx.

                    These settings are important. Save yourself some time and search the datasheet.
                    So they DO tell you and they DO show you EXAMPLES but also tells you that you NEED to read the datasheet.
                    I understand your frustration but really, once you step up to some bigger devices, where a single peripheral can have more registers than what's in the '630 all together you'll realise that the manual simply can not cover those details - again that IS the job of the datasheet.

                    Thanks for pointing out my spelling mistake, as you might have realised English isn't my native language.

                    Comment


                    • #25
                      you would think that an experienced academic would recognise and respect complexity.

                      My teacher is coming out ... in your second sentence, it is CHOSEN, not choosen.
                      Then why are TRIS, PORT and ANSEL and so on well documented in the manual and CMCOM isn't even mentioned?
                      my programmer coming out you will never find CMCOM its CMCON

                      CHUCKLE,CHUCKLE

                      Comment


                      • #26
                        No sir, so far as I can tell, your English is perfect (and I do wish to HELL we could call it American, since it is very different from British English) is better than 90% of my students.

                        Of COURSE I need to read the datasheet, but I will maintain for a long time that somebody that takes a lot of money from me purporting to tell me how to program PICS needs to tell me stuff like this, You may call it ports. I can call it TRSA..God knows what Microchip calls it

                        WHEN I BUY A PROGRAM TO WORK WITH A DEVICE LIKE A PIC, IT NEEDS TO HAVE **ALL** THE DEVICES AND **ALL** THE COMMANDS OR VARIATIONS DEFINED. That is what I paid the money for;. Otherwise I use VisBasic or some other BASIC routine to do it myself.

                        Got it, fellers?

                        Comment


                        • #27
                          Originally posted by richard View Post
                          you would think that an experienced academic would recognise and respect complexity.





                          my programmer coming out you will never find CMCOM its CMCON

                          CHUCKLE,CHUCKLE
                          So Dick is coming our as a real Dick. Way to go, now just go away DICK .

                          I'll be glad to translate to Heinrik if he'd like.

                          Jim
                          Last edited by jweir43; 08-21-2019, 12:18 AM.

                          Comment


                          • #28
                            WHEN I BUY A PROGRAM TO WORK WITH A DEVICE LIKE A PIC, IT NEEDS TO HAVE **ALL** THE DEVICES AND **ALL** THE COMMANDS OR VARIATIONS DEFINED
                            That's almost funny. Then you'll have a manual with tens of thousands of pages. The compiler can produce code for hundreds of different devices, all with their own unique features. Some will have a CMCON register, some won't.

                            Assigning values to registers are done equally no matter what the register name is and the manual does show you how that's done. What to write TO a certain register depends on what you want to DO and the manual can't know that before hand, can it?

                            The purpose of the manual isn't to teach you to program, it's to describe how the PBP3 language and compiler WORKS. It does cover all the COMMANDS and togehter with the datasheet for YOUR chosen (see I'm learining) device it forms the documentation you're looking for.

                            Devices (and there are HUNDREDS of them) are DIFFERENT. Next time you might be working with an 16F1519, then you use the manual AND the datasheet for THAT device (it doesn't have a comparator so no CMCON register).

                            If someone (other than yourself that is) is to blame here I'd say it's Microchip who decided to default pins with analog features as analog. It must be the single most asked and answered question on forums.

                            Don't worry about translating, I understand perfectly and IMO you're out of line.

                            /Henrik (correctly spelled)

                            Comment


                            • #29
                              +1 for Henrik.

                              ...is to blame here I'd say it's Microchip who decided to default pins with analog features as analog
                              There's a very valid hardware reason for that. In their defense, all you have to do is read the datasheet and you'll see the warning.

                              One thing I learned early on working with PICs is to treat each new device as completely different than the last until proven otherwise.
                              This has served me well... every time I forget that I get bitten. THAT should probably be the first thing you teach anybody.

                              Comment


                              • #30
                                Originally posted by tumbleweed View Post
                                +1 for Henrik.


                                There's a very valid hardware reason for that. In their defense, all you have to do is read the datasheet and you'll see the warning.

                                One thing I learned early on working with PICs is to treat each new device as completely different than the last until proven otherwise.
                                This has served me well... every time I forget that I get bitten. THAT should probably be the first thing you teach anybody.
                                Thanks, tumbleweed, that is advice that I will heed. I can't believe that I get to learn a whole new dialect with each new device, but if that is the way it is, now I know.

                                Hey, it has been a REALLY frustrating week and you all in your individual ways have helped me through it and I thank you all ...

                                Jim

                                Comment

                                Working...
                                X