Shop OBEX P1 Docs P2 Docs Learn Events
Discussion of Stamp I/O Registers - Page 2 — Parallax Forums

Discussion of Stamp I/O Registers

2

Comments

  • Genetix

    Making a few sidetrips to look at how other microcontrollsers handle I?O.

    Sticking with Stamp 1 for experiments.

    Thanks!

  • Genetix

    DIRS = 1

    PINS = 1

    Stamp Editor took these statements.

    How do you use them?

    There are 8 bits in each byte of DIRS and PINS.

    Is this setting all bytes to O or !?

    Thanks!
  • JonnyMacJonnyMac Posts: 9,156
    edited 2017-01-11 19:44
    Don't want to muddy the water here but I should tell you we have a BS2P24.

    That makes a _B_I_G_ difference!

    Somewhere, I was under the impression that you were using the BASIC Stamp 1. There are language differences between PBASIC 2.x and PBASIC 1.0 that are significant. The BS2 makes IO a little easier to think about in that it has DIRS, OUTS, and INS registers (the BS1 only has DIRS and PINS). The diagram that I drew for you assumed the BS1. For the BS2 family, PINX in that diagram becomes OUTX, and = PINX becomes = INX.

    The BS2 family allows bit-level access to any variable, and this is helpful. The BS1 only allows bit access to DIRS, PINS, B0, and B1 (W1).

    Have a look at my book, StampWorks (it's available as a PDF at Parallax) for practical coding techniques for the BS2 family.

  • Johnny

    ' The BS1 only allows bit access to DIRS, PINS, B0, and B1 (W1).'

    Do you mean you can only use high, low input output with a pin number and

    only change one bit?

    Now that I would believe.

    When I run Debug DIRS and Debug PINS I'm only getting back one value .

    Thanks!

  • microcontrolleruser,

    The BS2 is a lot more powerful than the BS1 and there are many more books written for it.

    DIRS = PINS = 1 means that you are setting P0, which is Bit #0 and has a value of 1, to Output-High.

    Each bit controls each pin:
    Bit #7 = 2^7 = 128 ---> P7
    Bit #6 = 2^6 = 64 ---> P6
    Bit #5 = 2^5 = 32 ---> P5
    Bit #4 = 2^4 = 16 ---> P4
    Bit #3 = 2^3 = 8 ---> P3
    Bit #2 = 2^2 = 4 ---> P2
    Bit #1 = 2^1 = 2 ---> P1
    Bit #0 = 2^0 = 1 ---> P0

    You could use either binary or decimal, or hex if you prefer.
    DIRS = %10101010 ' Sets the odd pin to Output (P7 is the leftmost bit and P0 is the rightmost)
    PINS = %01010101 ' Sets the even pins to High (5V) for output
    

    DIRS and PINS are useful if a group of pins need to be set or reset.
    DIRS = 255 ' 255 = 1111-1111, sets all pins to output
    DIRS = 0 ' 0 = 0000-0000, sets all pins to input or turns everything off
    

    You can also manipulate individual bits in DIRS and PINS using the bitwise operators.
    For example, say P7 is an input and connected to a switch, so you want to know if the switch is on or off.
    Switch = PINS & 128 ' P7 is Bit #7 and & (AND) will get rid of every other bit since only 1 AND 1 = 1.
    
    Anything AND 0 = 0.

  • Genetix

    Well, it looks like the gauntlet has been thrown down.

    I will be attempt to rise and be worthy of such an answer.

    I have printed out the body of your answer and will

    keep staring at it and see if anything emerges.

    Thanks!
  • Genetix

    Regarding BS1 and BS2.

    My thinking is not to add any more

    commands and reserved words to learn.

    When looking at BS1 commands I see BS2 sections

    and even I can see how some things are better.

    Thanks!

  • microcontrolleruser,

    This is one of many texts that were written for the BS2 and it was written for beginners.
    https://www.parallax.com/sites/default/files/downloads/28123-Whats-a-Micro-v3.0.pdf

    The biggest differences between the BS2 and BS1 are the BS2 has 8x more EEPROM (2K vs 256 bytes), is 5x faster (20 MHz vs 4 MHz), and has twice as many I/O pins (16 vs 8).
    The BS1 and BS2 share many commands though the BS1 may not have as many options.
    There are a few command though that are different.
    EEPROM on the BS1 resembles DATA on the BS2
    POT on the BS1 resembles RCTIME on the BS2
    SOUND on the BS1 resembles FREQOUT on the BS2

    The BS2 also supports PBASIC 2.5 which has a number of new commands that make programming easier.
    Also be aware that if you use BS2 code on your BS2p24 that many of the commands will use different time values since the BS2p24 is much faster than the BS2.

  • Genetix

    'EEPROM on the BS1 resembles DATA on the BS2
    POT on the BS1 resembles RCTIME on the BS2
    SOUND on the BS1 resembles FREQOUT on the BS2

    Have potentiometer on my list from another project so that'll work!

    I think I should have started out with READ and WRITE except

    registers for :PINS and DIRS were first in Basic Stamp Help.

    What does that means 'PORT' being over PINS and DIRS?

    Thanks!



  • JonnyMacJonnyMac Posts: 9,156
    edited 2017-01-13 15:30
    POT (BS1) and RCTIME (BS2) use different circuit configurations -- be mindful of this.

    READ and WRITE apply to EEPROM, not RAM registers. RAM registers don't require a special command; they can be read with:
      variable = REGISTER
    
    and written with
      REGISTER = value
    

    PORT is a 16-bit value that contains PINS and DIRS which are each 8 bits.
      PORT = %0000111100000000
    
    is the same as
      PINS = %00000000
      DIRS = %00001111
    


  • Mac

    Going to stay in order.

    Let me experiment with PORT.

    See if I can absorb any of this.

    Have POT on my mind because next thing to test on PPDB was potentiometers.

    Thanks!
  • PublisonPublison Posts: 12,366
    edited 2017-01-13 16:56


    Have POT on my mind because next thing to test on PPDB was potentiometers.

    Are you referring to the Basic Stamp Development Board? The PPDB refers to the Propeller Professional Development Board.
  • microcontrollerusermicrocontrolleruser Posts: 1,194
    edited 2017-01-13 19:04
    Publison

    No. Propellor version.

    Have a spare stamp one you would part with?

    Need to hardware test our PPDB pot circuitry.

    Might squeeze in getting up to speed on POT with Stamp 1.

    Thanks!

  • You need to specify your hardware platforms. You started out asking questions about BS1, then BS2p, and now Propeller.

    BS2 does not work on PPDB.
  • Publison

    I believe that's called an 'aside'.

    Genetix listed commands including POT that reminded

    me to hardware test the potentiometer on the Propellor board.

    Genetix said PX24 has more commands than BS!.

    Meantime I'm gathering steam to get back to study PORT on Stamp 1.

    Thanks!
  • Mike GreenMike Green Posts: 23,101
    edited 2017-01-14 04:17
    One of the primary design goals for all of the Basic Stamp models was to take a "hard to understand" and unruly microcontroller like the PIC and SX and make them more presentable to new users. The details of the actual hardware are mostly hidden and replaced with an (at the time) familiar programming language with handy features like DEBUG, simple access to the I/O pins, some handy functionality for timing, and specialized I/O like PWM and SHIFTIN/OUT.

    Experiment and have fun
  • microcontrollerusermicrocontrolleruser Posts: 1,194
    edited 2017-01-14 19:26
    Mike

    Not ready to check my brain at the door yet.:)

    See new post about lesson in What's a...

    Thanks!
  • microcontrolleruser,

    If you look at What's a Microcontroller (WAM), RCTIME is introduced in Chapter 5 for reading a Pot, and READ and WRITE don't come until Chapter 8 when music is introduced. This only applies to the BS2.

    There are Application Notes for the BS1 which is a good reference for circuits and code
    https://www.parallax.com/sites/default/files/downloads/BS1-IC-BASIC_Stamp_1_AppNotes.pdf
    #7 uses POT with a Thermistor, #18 also uses POT, #20 also uses POT

    You don't need a microcontroller to check a pot. If you connect a DMM in resistance mode to one end and the middle pin of the pot then you should see the resistance change as you rotate it. Just remember that your pot may have a tolerance as high as 20% in each direction.
  • Genetix

    Big excitement here!

    Found some new reserved words in WAM.

    DIRH and OUTH. Might be an INH too.

    Good tip about ohmeter.

    Will do that with puttting battery in P24 board.

    We're working on Appnotes.

    Connecting LCD to BOE.

    Thanks!
  • microcontrolleruser,

    DIRH and OUTH control the upper 8 pins (P8-P15) of the BS2, while INH reports the input state of P8-P15.
    DIRS and OUTS control all 16 pins, and INS gives the input of all 16 pins.
    There are also nibble (4-bit) and bit forms too.
  • Genetix

    Well play time's over. It's back to work learning assembler

    on another brand of processors.

    Propellor assembler lost out because of adding multi processors to

    the mix.

    Only one article on SX assembler.

    Propellor hardware and documentation is very well done.

    Just is not for me right now.

    Excellent BS2 info.

    Thanks!
  • microcontrolleruser,

    What is it that you are trying to do?

    Propeller Assembly or PASM is only needed if you doing something that is time critical, otherwise Spin or the Propeller's BASIC-like language should do the job.

    Unless you are doing something exotic or highly specialized there is a good chance a Propeller Object or library already exists.

    Also, the Propeller can be programmed in C.

    First you ask about the BS1, then a non-Parallax board that uses the BS2p, and now the Propeller.

    What is you end goal for this project?
    Maybe Parallax doesn't have a solution that will work for you but how can WE know if you won't say what it is you want to do.

    Parallax makes great products and has some of the best support in the industry.
    Many forum members use other microcontrollers or development systems such as the Arduino.
    It all depends on the application.

    Again, what is that you want to do so that we can find a solution that meets your needs.

  • Genetix

    :Program the Stamp 1 in Assembly.

    We'd accept the PIC it came from.

    Thanks!
  • ElectrodudeElectrodude Posts: 1,660
    edited 2017-01-17 03:48
    You can't program the Stamp 1 or 2 in Assembly. The Stamp is a PIC with a BASIC environment on top of it. It's for people who don't want to deal with PICs. If you are comfortable with PICs, use a PIC and not a BASIC Stamp.

    On the other hand, there is the Propeller, which is an entirely different processor that has no relation to PICs. The only similarity between the Propeller and the Basic Stamp is that they are made by the same company, and that Spin, the language used on the Propeller, bears a few similarities to PBASIC.

    The Propeller can be programmed in assembly, which is incredibly powerful when you need to get many time-critical tasks done at the same time - instead of bothering with interrupts, you just have separate cores (called cogs) do the separate tasks, interacting through hub ram common to all eight cogs.

    The Propeller is also great when you don't need strict timing, but just don't want to deal with interrupts. In that case, there's Spin, which is a high-level language that's much easier than assembly but produces much slower code. In addition to that, there is a C/C++ compiler (PropGCC) that's often faster than Spin, a few Forth systems (Tachyon Forth), the PropBASIC Basic to PASM compiler, and some other various programming environments.
  • Fellows

    We have a winner!

    http://www.johnloomis.org/ece445/stamp/stexe21.htm

    Little hotrod Stamp 1.

    Thanks!
  • Electrodude

    I would rather use Harvard or Von Neuman architecture to start out.

    I agree tons and tons of good documentation have been done for Propellor.

    Thanks!

  • ElectrodudeElectrodude Posts: 1,660
    edited 2017-01-17 05:18
    The Propeller is a von Neumann architecture processor. Each cog's 2KB of cogram is used for both data and code. People like referring to them as if they were executable registers, but it's really just standard SRAM. The 32KB of hubram linking the cogs can't be executed directly, but code can easily be loaded or interpreted from there.
  • microcontrolleruser,

    The PIC in the BS1 is a fossil and nobody in their right mind would use it except for in a legacy product which is what the BS1 is.
    Besides there are newer PICs that can run rings around it.

    If you can use a BASIC Stamp then you can use a Propeller with Spin.
    The Propeller is 3.3V while the BASIC Stamp is 5V but other than that hooking up devices to the Propeller is just as easy.
    If you liked What's a Microcontroller then look at the Propeller Education Kit text which was written by the same person.
    https://www.parallax.com/sites/default/files/downloads/122-32305-PE-Kit-Labs-Fundamentals-Text-v1.2.pdf
    If you prefer C then go here - http://learn.parallax.com/tutorials/propeller-c
  • Developers

    Thought I had a new post about Stamp1 assembler?

    Maybe it was my imagination.

    Will keep you updated about learning assembler.

    All I saw in Programming and Customizing Propellor was

    list of Assembler commands, Need more than that.

    Thanks!
  • Fellows

    We have a winner!

    http://www.johnloomis.org/ece445/stamp/stexe21.htm

    Little hotrod Stamp 1.

    Thanks!

    That programmer was 10-15 years old. Parallax no longer sells that for a long long time. You may find one on ebay.
Sign In or Register to comment.