independant codes?
ERM
Posts: 34
Can a stamp operate two seperate codes independantly?· i.e., can you write into memory a set of flash patterns, have a button or switch as an input to flash one pair of led's and another switch to flash a second set of led's.· Keep in mind the two sets of led's will each be on their own flash pattern (One double flash and one quad flash).· You can turn on one or both pair by the flip of either switch or both switches.· Can the BS do this?
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I just spent over an hour trying to find it, but I can't.· Does anyone have any idea what I am talking about?· I hope I am not just imagining it.
All of the PBASIC Stamps other than the BS-1 and plain BS-2 support multibank programming. Each of the program banks can contain up to 2 K in program code. There are a total of 8 banks in most of the Stamps.
One simple scheme would be to write a switch bit in EEPROM and alternate it on each execution of the program. For lack of a better terminology, call it even and odd. On even excursions, banks 2,4,6,and 8 are used and on odd excursions, banks 1,3,5, and 7 are used. It could just as easily be "split" as 1-4, and 5-8 if that's easier to understand. In all cases, bank 0 is used for the main program which decides which of the program banks to use.
Even with that all said, no multiple program execution occurs simultaneously as you seemed to want. Program execution can be concurrent (during the same time period), but not simultaneous (at the same time). That's just the nature of single tasking processors.
I can only guess that's what you'd been reading.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Just a thought.
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Thanks for the response. I drew a diagram of what I am trying to do. From what you are telling me, it is not possible with the BS2. As you can see, I wanted to have three switches controlling three pairs of outputs. The two lines from each output represents an output going to an led, so two leds per output. I wanted switch 1 to turn on a flash pattern for output 1, switch 2 and 3 to turn on their respective outputs and all three of them to have seperate flash patterns. Is this possible with the BS2 or do I have to get another chip that can do this and do you know what chip?
Your question still lacks a good deal of clarity, but the diagram does help somewhat. Is the following logic what you want the Stamp to do, based on the condition of the input pins:
1. Any time an output pin is turned on, apply power to two devices connected to that pin.
If so, you need a drive transistor on the output pin. The drive transistor is turned on by the Stamp, when appropriate, and it in turn supplies the power to one or more external LEDs. This prevents overloading of the Stamp pin by the current requirement of the output device(s) (LED or otherwise).
2. If Input pin one is ON (logical 1) then Output Pin one is turned ON or set to logic 1.
If so, you are looking to do this:
IF IN1 = 1 THEN
OUT1 = 1
ENDIF
3. If Input pin two is ON (logical 1) then Output Pin two is turned ON or set to logic 1.
If so, you are looking to do this:
IF IN2 = 1 THEN
OUT2 = 1
ENDIF
3. If Input pin three is ON (logical 1) then Output Pin three is turned ON or set to logic 1.
If so, you are looking to do this:
IF IN3 = 1 THEN
OUT3 = 1
ENDIF
There was never a need for simultinaity, or concurrency, nor for any fancy considerations. This is simple, straight line, sequential logic, pure and simple, if I'm understaning your requirements correctly.
Regards,
Bruce Bates
Yes, it's possible to do what you want. Show me the respective patterns and I'll show you the code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
000
001
010
011
100
101
110
111
Each bit representing a state of one of the switches. This project may be a fun excuse to practice doing some work in Octal (base 8 [noparse];)[/noparse]
Each state will have an associated 'pattern' - the patterns are derivatives of the mixing of the individual patterns you wanted.
Ryan
Possible pseudo code:
Scan switches-
Set 'patterns' by switch pattern
Flash 'cycle'
Rescan switches- if unchanged go back to flash cycle- if changed, update 'patterns'
(I am oversimplifying- I'm heading out the door)-
Ryan