Shop OBEX P1 Docs P2 Docs Learn Events
BASIC Stamp 2P40 Interpreter Chip (TQFP) — Parallax Forums

BASIC Stamp 2P40 Interpreter Chip (TQFP)

hmlittle59hmlittle59 Posts: 404
edited 2012-07-23 20:54 in General Discussion
Hello All,

I've designed/changed a current PCB design from the OEM BS2e Interpreter to this 40 pin chip. Is there any thing special that yall can tell me about on how to access the I/O pins? I've used Shift Registers before to increase my pin count, but this new chip will be cleaner (less chip count). Some sample code on the pin commands would be nice. I noticed that some pins start with (P) and (X), how are they accessed and is there any thing tricky that I have to look out for.

I just need a good starting point and any (OOOPs) don't do this information. My current program is for the BS2 and BS2e (5 ram slots), so the BS2e code is the one that will be modified to access the extra pins.

Thanks for any HEADS UP info.

Howard
www.GarageDoorValet.com

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-07-16 08:05
    Look in the Stamp Manual for the MAINIO and AUXIO statements. The BS2p40 accesses I/O pins as two sets of 16. These two statements switch sets. The state of the I/O pins is preserved, so whatever state you leave them in, they'll stay that way, but you can only get to 16 at a time.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2012-07-16 08:23
    When a program starts, all the pin commands address the low bank, pins p0 to p15. When you want the high bank, use the AUXIO command. Now alll the pin commands are directed to pins x0 to x15. Switch back to p0 to p15 with the MAINIO command. Pins all keep the state that the program last put them in. The BS2p can still do only one thing at a time. For example, you can have a FREQOUT to two pins in succession, but not at the same time:
    AUXIO
    FREQOUT 3,1000, 1000   ' 1kHz to pin x3 for one second
    MAINIO
    FREQOUT 7, 500, 50       ' 500Hz to pin p7 for 50 ms
    

    This does introduce a new class of bugs, where a program expects to be addressing one bank, but some other program code has left it in the opposite bank. You have to start thinking about that systematically. It is generally a good idea to group the external interfaces so that the pins for each external device are concentrated on either the p bank or the x bank.

    One hurdle in moving to the BS2p is that many of the timing parameters are different than the BS2 and BS2e. A PAUSE is in units of milliseconds in either case, but other things such as baud rate parameters for SEROUT and SERIN are different, and also timing for things such as the PULSIN PULSOUT etc. etc. It is all laid out in the Stamp manual, command by command. Of course the program code itself also runs faster, so you may have to account for that if you have program loop delays.

    The BS2p offers commands that are not found in the BS2 and BS2e. For example, there is I2CIN I2COUT to ease interface to I2C peripherals. The I2C commands can reference only p0, p8, x0 or x8, so that is unusual in that most commands can reference any pin. There are POLLing commands on the BS2p that do certain pin actions automatically apart from running program code, and they can be great in certain very specific situations, . The BS2p also has more flexible cross-slot access to the 8 eeprom memory banks, and also 127 bytes of scratchpad RAM.
  • hmlittle59hmlittle59 Posts: 404
    edited 2012-07-16 17:00
    Hello Mike and Tracy,
    Thanks for your replies. I read through some of the Commands in the help files and it does not look user friendly. I don't know whats going to cost more, leaving the extra parts on the board or changing the code. I will be needing 24 I/O pins so I hope to keep the bouncing back and forth to a minimum. Some pins have to constantly be monitored and others just turn on/off LED's. My initial thinking now with your info is that this will be a problem. I may have to move certain parts to "AUXIO" and bounce back to "MAINIO" for my pseudo real time monitoring. This may get real tricky. I monitor what ever pin(s) that I need to in any slot now, but that may not work with this chip.
    The PCB layout is done but I have not ordered any new ones yet. I may have to buy a BS2p40 module and see if I can get the code to work like I want.

    Thanks again for the info, any more thoughts please let me hear about them.

    Howard
    www.GarageDoorValet.com
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2012-07-16 20:24
    It is really not that complicated. Not unfriendly. The switchover between the banks of pins is very fast. You can change from MAINIO to AUXIO at any point in your program and in any program slot, to address any of the pins for monitoring or LEDs.

    It would indeed be a good idea to try it out with a BS2p module before you commit to a PC board. I gather from your topic that you're planning to build this up on your own board using the TQFP chip.
  • hmlittle59hmlittle59 Posts: 404
    edited 2012-07-17 08:45
    Hello Tracy,
    Thanks for the reply. Yes I'm want to do my own PCB for this project. After spending some quite time thinking this over I think that I have a plan of attack. Currently things are a bit mixed up and in the wrong place, but I did group a lot of the same parts on one side of the PCB to keep it in some kind of order, but now they are on the bank. I will lay out the PCB in the next 2 days and study some more of the commands. I'll be getting back with you when that's done. Again, some parts are LED's or SSR's so it may very well work.

    Thanks again

    Howard
    www.GarageDoorValet.com
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2012-07-18 07:31
    Hello Howard,

    Are you going to use the BS2p40 module or the OEM chip? If you are just starting with the BS2p40 OEM chip I have a board that you can use to mount that chip to help get familiar with the OEM version of the chip. You can see the docs for the board here:

    http://www.robotworkshop.com/robotworkshop/projects/parallax/BS2p40oem.pdf

    http://www.robotworkshop.com/robotworkshop/projects/parallax/BS2p40OEMschematic.pdf

    Boards are $2.95 each plus shipping....

    Robert
  • hmlittle59hmlittle59 Posts: 404
    edited 2012-07-20 18:36
    Hello RobotWorkshop,

    Sorry I didn't reply back right away. I did look at your links but I think that I would rather build my own OEM PCB's and get it to work. I'm burning through lots of cash any way, whats a couple of hundred bucks more. WOW...Some day I may see a return on my investment. The PCB is done and now I will go over it for the next week or 2 before I think about placing an order from some place in the USA or Overseas.

    Thanks.

    Howard
    www.GarageDoorValet.com
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2012-07-21 16:56
    Take a small jump at first! A good shared panel service for prototypes is dorkbotpdx. Very nice quality, low cost. You pay a flat rate of simply $5 per square inch, for three copies of you board.

    When the boards come back a week or two later, then stuff them, test them and see if your design is already perfect (!) or if it needs further minor or major adjustments. A stencil helps make it come out really nice, and a good economical source for the stencil is oharap.
  • hmlittle59hmlittle59 Posts: 404
    edited 2012-07-21 22:54
    Thanks Tracy, I will try them. Never had a stencil before, that will be another learning curve. Question about pin assignment. I've modified the code in the places needed to go from MAINIO to AUXIO, but how do I do pin (NAMES) work for the second BANK? The DS1302 has pins 0 - 2 with the name CLk etc. but now I want to name the Auxio pin 0. What is the syntax for that?

    1) CLK PIN 00.....Mainio

    16) PIEZO PIN 00...Auxio

    Will the second assignment over write the first assignment and in BANK1 change the assignment? Hope this is clear. I can't find a clear explanation with the on line help. The Syntax checker in the EDITOR says it's OK. I can't test it yet without my boards.

    Thanks again
    Howard
  • davejamesdavejames Posts: 4,047
    edited 2012-07-21 23:57
    hmlittle59 wrote: »
    Thanks Tracy, I will try them. Never had a stencil before, that will be another learning curve. Question about pin assignment. I've modified the code in the places needed to go from MAINIO to AUXIO, but how do I do pin (NAMES) work for the second BANK? The DS1302 has pins 0 - 2 with the name CLk etc. but now I want to name the Auxio pin 0. What is the syntax for that?

    1) CLK PIN 00.....Mainio

    16) PIEZO PIN 00...Auxio

    Will the second assignment over write the first assignment and in BANK1 change the assignment? Hope this is clear. I can't find a clear explanation with the on line help. The Syntax checker in the EDITOR says it's OK. I can't test it yet without my boards.

    Thanks again
    Howard

    Howard,

    In the online help under AUXIO (under Quick Facts at the top), the manual says:

    I/O Pin IDs...0 - 15 (just like main I/O, but after the AUXIO command, all references affect physical pins 21 - 36).

    So it looks like you'd have two pin definitions referencing the same pin number in the header section of the code. Then you'd use the second pin name after issuing the AUXIO command.

    Hope that made sense...
  • hmlittle59hmlittle59 Posts: 404
    edited 2012-07-22 05:00
    Hello Davejames,
    Thanks for the reply. I did read that and was hoping that's what it meant but I was not sure. In my thinking it just don't seem right. Good , I'm going to keep coding that way until I get my boards in for testing.

    Thanks again

    Howard
    www.GarageDoorValet.com
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2012-07-22 20:57
    hmlittle59 wrote: »
    ...Question about pin assignment. I've modified the code in the places needed to go from MAINIO to AUXIO, but how do I do pin (NAMES) work for the second BANK? The DS1302 has pins 0 - 2 with the name CLk etc. but now I want to name the Auxio pin 0. What is the syntax for that?

    1) CLK PIN 00.....Mainio

    16) PIEZO PIN 00...Auxio

    Will the second assignment over write the first assignment and in BANK1 change the assignment? Hope this is clear. I can't find a clear explanation with the on line help. The Syntax checker in the EDITOR says it's OK. I can't test it yet without my boards.

    Thanks again
    Howard


    They're just names and are closely related to CONstant declarations. Just as one pin in Mainio can have multiple names, you can use the same names or different ones for the pins in Auxio. You just have to keep them straight in your own mind as you write the programs. Sometimes people use a prefix like "p" or "m" for mainio, or "x" or "a" for auxio, but that is just a mnemonic. For example, you might have
    pLEDred PIN 7
    xLEDred PIN 7
    or you might just have
    LEDred PIN 7
    and the first form might help you remember which LED is which, but correct operation would depend on doing the MAINIO or AUXIO instruction in either case.
  • hmlittle59hmlittle59 Posts: 404
    edited 2012-07-23 20:54
    Hello Tracy,

    Thanks for the different example's to help make it clear. I put 3 of the same kind of parts + 1 other type on the second BANK and they only work from one ram slot so I should be OK. Like I said before this is from a larger program thats being modified and they were already coming off the Shift Register. I was also able to keep the LED's on BANK 1 which really helped because that code is in every slot. So now only one (1) slot has any code that will need to do any switching.
    Will look over the PCB(Diptrace) again tomorrow for a final ck before ordering from the site you gave me. May order the stencil also. Not sure yet.

    Thanks again

    Howard
    www.GarageDoorValet.com
Sign In or Register to comment.