Slow-downs in program, BASIC Stamp limitation?
randempedestrian
Posts: 14
I recently purchased the BASIC Stamp HomeWork Board and completed all the lessons in the book. I'm having trouble with a circuit I've made since then, and I am wondering if it is a fundamental limitation of the BASIC Stamp.
I have a Frequency to Light converting chip (TSL230) and an infrared LED on the board. With a IR pass filter over the TSL230, when I move my hand over the board (dark or light), the output of the TSL230 changes perfectly. My problem arises in making use of this, however. I put a bright white LED in a project box about a foot away and wired it into the circuit. In my program I have:
COUNT In, 20, cnt
DEBUG HOME, "TSL230:", DEC5 cnt
inside a DO loop, which works fine. What I want to happen is when I run my hand over the board, the light gets brighter proportionately (so the closer my hand is to the board the brighter, etc.). The problem is, and maybe it's my mistake, is that if the change in light is significant enough to tell the program to turn on the light, my program slows down when it does that. I'm using the AD5220 digital potentiometer circuit from the book to adjust the brightness of the LED. But when the program goes to move the wiper terminal, the rest of the light-sensing loop slows down, causing some very strange results. As a result, the light sometimes gets stuck on, or isn't on-time with the sensor (delayed or plain wrong).
My question is essentially: Is this more likely something wrong in the way I wrote my program, or is it a fundamental drawback of the BASIC Stamp not being able to do both processes at once?
Ideally I'd like to have the loop always sensing with the TSL230 and adjusting the digital potentiometer circuit on the fly, in time together to maximize the fluency.
Any help would be greatly appreciated! Thanks!
-Brian
I have a Frequency to Light converting chip (TSL230) and an infrared LED on the board. With a IR pass filter over the TSL230, when I move my hand over the board (dark or light), the output of the TSL230 changes perfectly. My problem arises in making use of this, however. I put a bright white LED in a project box about a foot away and wired it into the circuit. In my program I have:
COUNT In, 20, cnt
DEBUG HOME, "TSL230:", DEC5 cnt
inside a DO loop, which works fine. What I want to happen is when I run my hand over the board, the light gets brighter proportionately (so the closer my hand is to the board the brighter, etc.). The problem is, and maybe it's my mistake, is that if the change in light is significant enough to tell the program to turn on the light, my program slows down when it does that. I'm using the AD5220 digital potentiometer circuit from the book to adjust the brightness of the LED. But when the program goes to move the wiper terminal, the rest of the light-sensing loop slows down, causing some very strange results. As a result, the light sometimes gets stuck on, or isn't on-time with the sensor (delayed or plain wrong).
My question is essentially: Is this more likely something wrong in the way I wrote my program, or is it a fundamental drawback of the BASIC Stamp not being able to do both processes at once?
Ideally I'd like to have the loop always sensing with the TSL230 and adjusting the digital potentiometer circuit on the fly, in time together to maximize the fluency.
Any help would be greatly appreciated! Thanks!
-Brian
Comments
It would help if you attached your complete program to a message for people to look at. There may be some specific suggestions that could help you do what you want despite the Stamp's limitations. Make sure you include a description or schematic of how your HomeWork Board is connected to the TSL230 and AD5220.
The AD5220 is a 128 position up/down counting digital pot and the time it takes to change the setting depends on the amount of change in its position. It could take quite some time if the change is large and the Stamp can't overlap functions.
Post Edited (Mike Green) : 6/17/2008 2:36:41 PM GMT
If by any chance you are getting slowed down by the wiper moving on your digipot, this may be a good upgrade.
Upload your code, and let us take a look at it.
Also, the MCP41XXX sounds great! I'm new to microcontrollers if you couldn't tell, so I wasn't really aware of the single command digital pot. I'm not new to computers or electronics by any means, and I'm a fast learner, but I'm still learning how to best use this great community and its vast resources (such as yourselves). I thought the AD5220 was a little inefficient and unnecessary, guess I was right
Thanks again for everything, guys. I appreciate the help.
-Brian
The SX has been around for a long time.· There are a lot of good tools for it including a Basic compiler (SX/B)·that accepts programs that are very close to the Stamp's PBasic.· There are also a lot of excellent tutorials and books on both assembly language and SX/B programming, most of them available for free.· The SX is a single processor, but with an interrupt mechanism that lends itself to easily providing multiple "virtual peripherals" that use interrupts to make it look like there's multi-processing going on (more than one processor).
The Propeller is relatively new.· It has 8 identical processors on the chip along with 32K of shared memory and is very fast.· Its programming languages include assembly and Spin which has some features of C and Pascal with a little bit of object-oriented support added.· There's also a newly released commercial C compiler.· There's a library of programs/objects/routines available for everything from direct video display of text and/or graphics, analog to digital or digital to analog conversion, voice synthesis with virtual positioning along a left to right axis, direct SD card access with a PC-compatible FAT file system, and more.· Most people report that learning Spin is easy, that learning how to make use of the multiple processors and other unique features of this chip is harder since it's different from most of what's "out there", but not too hard.· One of the libraries is a set of routines in Spin that mostly duplicate the more complex statements in PBasic to help make conversion easier.
Sorry to make you repeat yourself. I'm not surprised that my questions were common, but sometimes it's surprisingly hard to find the answers I'm looking for by browsing the forums. Maybe I'm lazy
Anyway, your information was a great help! I like the sound of the Propeller a lot. I know a good enough amount of C that learning to use it shouldn't be too hard, and since I'm not really "used to" anything else out there, hopefully I wont have too much difficulty learning the rest of the features.
Ideally I'd like to eventually be able to make a number of identical circuit boards, and put identically programmed Propeller chips on each one (interactive light panels to start with). What kit, etc would you recommend for learning on (a learning guide like my BASIC Stamp HomeWork board but for Propeller would be great), that I can also then mini-mass produce my programmed chips with? All the different kits and chips and add-ons get a little confusing.
Thanks again!
The author of "What's a Microcontroller?" has also created the Propeller Education Kits and a series of labs to go with them.· These are purely breadboard-based kits.·The 40-pin DIP version makes for easy, inexpensive chip replacement while learning, and the PropStick USB·version allows for a very rapid setup of the platform but the module is more expensive to replace if damaged.·You can download all the labs·and see the kit contents in the Propeller Education Kit Labs sticky-thread in the Propeller forum. There are more labs and accesories for these kits in the works.
If you have the 40-pin DIP PE Kit·for doing the labs and experimenting with your custom circuits,·you can also use it for programming multiple chips.·· Even easier and still fairly inexpensive would be·to port your final design to the Propeller Proto Board. There is also a USB version.··
Yes, we have lots of choices! I hope this helped.
-Stephanie Lindsay
Editor, Parallax Inc.
Needless to say, that information is a great help. I do still have a few questions, however.
One: You said I can program multiple chips with the 40-pin DIP version. Is that to say that I cannot with the PropStick version? I guess my question kinda of is can the PropStick version not program those 40-pin chips? I'm going to want to program multiple chips to be added to permanent circuits.
Two: Is there any reason I should get the Propeller Starter Kit instead of the 40-pin/PropStick versions? Is the only difference the user-friendly manual that the Starter Kit comes with? If that's the case, don't the free labs for the other versions do essentially the same thing? I don't want to be stuck not knowing how to do anything, being that I've only completed the BASIC Stamp book so far. Do I need the starter kit, or is it easy enough to dive right into the 40-pin DIP version?
Three: In what case would I need a Prop Plug/Prop Clip?
Sorry for the multi-layered questions! Any more information would be greatly appreciated...again!
-Brian
The PropRPM board has socketed DIP chips
www.parallax.com/Store/Microcontrollers/PropellerTools/tabid/143/CategoryID/19/List/0/SortField/0/Level/a/ProductID/443/Default.aspx
Also, what is the real purpose of something like the Propstick USB, if you always have to have that unit? I cant imagine making complex, nifty circuits, but always having to have that whole unit there to run it. Doesn't that defeat the purpose? Isn't the idea of a microcontroller to eliminate as much part-age as possible? I'd like to use a unit like this to test and finalize a program for a DIP chip, then take that and add it to a permanent pcb, or multiple pcbs.
My original questions remain:
One: You said I can program multiple chips with the 40-pin DIP version. Is that to say that I cannot with the PropStick version? I guess my question kinda of is can the PropStick version not program those 40-pin chips? I'm going to want to program multiple chips to be added to permanent circuits.
Two: Is there any reason I should get the Propeller Starter Kit instead of the 40-pin/PropStick versions? Is the only difference the user-friendly manual that the Starter Kit comes with? If that's the case, don't the free labs for the other versions do essentially the same thing? I don't want to be stuck not knowing how to do anything, being that I've only completed the BASIC Stamp book so far. Do I need the starter kit, or is it easy enough to dive right into the 40-pin DIP version?
Three: In what case would I need a Prop Plug/Prop Clip?
The Propeller can access other attached EEPROM, either attached to the same I2C bus as the boot EEPROM or to any other pair of I/O pins. If you have a permanent PCB with a socketed EEPROM, it's very easy to use a PropStick or Protoboard as an EEPROM programmer. FemtoBasic (a simple Basic interpreter for the Propeller) has a COPY command that will copy a 32K program "page" from one EEPROM to another.
2) The PropStick modules have all the necessary support circuitry for the Propeller like a crystal, EEPROM, programming interface, 3.3V regulator, yet provide access to essentially all the Propeller's pins. They're very convenient for use with a breadboard. The non-PropStick Propeller Education Kit comes with the individual parts and has to be wired up before it can be used. The Propeller Starter Kit comes with the Demo Board which uses many of the I/O pins for specific purposes and provides convenient connectors for audio including a built-in microphone, VGA and TV video, PS/2 keyboard and mouse. The Protoboard provides all the necessary support circuitry including 1A regulators for 5V and 3.3V and a 64K EEPROM with extra storage for data or a 2nd program. It also has provisions for connectors for a VGA display and PS/2 keyboard and mouse (in the Protoboard Accessory kit).
3) You need some kind of programming interface, mostly to handle level shifting between a serial port and the Propeller's 3.3V I/O. The Prop Plug/Clip provides that for USB. The original Protoboard and Propeller Education Kit use this. The Demo Board, Hydra, and the PropStick modules have their own interface circuitry as does the new USB Protoboard.
Post Edited (Mike Green) : 6/19/2008 2:37:51 PM GMT
The Propeller "environment" consists of the Propeller processor itself, and an 'attached' 32K or more separate eeprom chip. And a crystal to provide 'clock' for the Propeller.
When the Propeller starts up, it first loads the first 32K bytes of the attached eeprom into itself -- as far as I know, there IS no 'embedded eeprom' on the Propeller chip. Note a PIC chip DOES have 'embedded eeprom', and the BS2 has on-module eeprom.
Having 'copied' the eeprom code into itself, the Propeller now 'runs' out of local RAM. Now, the Propeller does have 8 "cogs" on-chip (each one a processor with 512 bytes of RAM). So to be accurate, the Propeller has 32 KBytes of "Main RAM", and an additional 8 X 512 bytes of "cog local" ram. In the "SPIN" environment, the first thing that happens is the "SPIN" interpreter is loaded into the cog zero's 512 bytes of ram. The "SPIN" interpreter then reads bytes from "Main RAM" and calls library code in the SPIN interpreter in Cog zero. This process runs quite a bit slower than 'native' Propeller assembly code, but since the Propeller runs at about 80 MIPS, you can afford the speed loss.
One of the SPIN instructions will download 'native' Propeller code from "Main RAM" into a cog's 512 bytes and execute it 'natively' from there. So you CAN get 80 MIPS through-put in this way.
So, that's the environment. Now, the Propeller is available in several different packages (which is what everybody is talking about in earlier posts).
There IS a 40-pin socketed Propeller processor. This is easily replaced should you blow up an I/O pin during testing. But the board it plugs into STILL has to have an external eeprom for the Propeller to initialize from.
There is a separate board: http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/ProductID/509/List/1/Default.aspx?SortField=ProductName,ProductName
which for $39. contains a surface mount Propeller chip along with a 64KByte eeprom, and 5 volt and 3.3 volt linear regulators. Did I mention the Propeller is a 3.3 volt processor?
For $99 theres: http://www.parallax.com/Store/Microcontrollers/PropellerProgrammingKits/tabid/144/CategoryID/20/List/0/SortField/0/Level/a/ProductID/382/Default.aspx
This is a board with surface mount Propeller AND eeprom AND crystal AND external ports for PS/2 keyboard and Mouse AND a prototyping area. AND a composite video output AND a VGA output.
This is probably the best 'starter' kit for the Propeller. You can write code (or download Parallax code) to interface to all those ports using the free Propeller SPIN IDE.
#
If you're used to 'more conventional' processors, you MAY want to go to the 28SX route. This processor runs at 75 MIPS or so, is a "super PIC", has on-chip program storage, does interrupts, and has a decent size Register/RAM space.
http://www.parallax.com/Store/Microcontrollers/SXDevelopmentBoards/tabid/141/List/0/CategoryID/54/Level/a/SortField/0/Default.aspx
Note the SX48 board for $10 can be 'dropped in' to your project, and only needs 5 volts to run.
Now, to program an SX chip, you'll need an "SX-Key" -- which comes as part of http://www.parallax.com/tabid/140/List/0/CategoryID/17/Level/a/SortField/0/Default.aspx
You only need one of these, and once 'programmed' your program is save in the SX chip itself -- which is more what people are used to here.· The SX IDE supports "SX/Basic", which is a Basic language variant that runs very close to assembly to give you extremely high performance.
Well, at least to answer your questions:
1. The PropStick is a complete "module", like the BS2 is a complete "Module". They both have all the resources needed to be "dropped in" to a project and run. The PropStick is NOT an interface to program another chip.
2. The $100 kit is probably the BEST way to get started with the Propeller. It allows you to try out several different applications as a prototype to prove what can be done, and how you want to do it.
3. A PropClip or PropPlug would be used with the $20 protoboard: http://www.parallax.com/Store/Microcontrollers/PropellerDevelopmentBoards/tabid/514/CategoryID/73/List/0/Level/a/ProductID/423/Default.aspx?SortField=ProductName%2cProductName
To cut costs, this board was made without a 'native' USB interface, the PropPlug provides the particular USB to 3.3 volt serial programming interface. This programs the on-board eeprom, which the on-board surface-mount Propeller then downloads into itself when it starts running.
Well, having gone around the barn two or three times, I guess I'm unsure what goal you have, what you're really trying to do. Parallax has VERY capable hardware, but it can be difficult to choose from their offerings which exact platform you wish to use.
What was your goal again?
If you could post your code, we could check it out and see if it IS a logic problem. Click the little "pencil" at the top right to edit your post, click "Attachement Manager" and upload your code.
All clear as mud now?
Since you found "What's a Microcontroller?" to be useful, I thought you might appreciate the PE Labs. I recommended the $80 Propeller Education Kit - 40-pin DIP version to you because the base circuit you build to program the chip can stay on the board, while you swap out DIP chips.· The PE Kit PropStick USB version has different base circuit which would not work for just swapping out with a DIP chip for programming.·
The Propeller Starter Kit has a Propeller Demo Board, which is great for trying out peripherals but you cannot program other chips with it.· The Propeller Manual which comes with the kit is available for separate purchase, and the PDF is free·from the Propeller Downloads Page·so there is no reason to purchase the kit to get the book.
You will shortly have the option of using peripherals with the PE Kit breadboards, as we will soon be carrying PS/2-to-breadboard and RCA-to-breadboard adapters.··Attached is a picture of the PE Kit - PropStick USB version with a mouse and NTSC display hooked up.
Because I think the OP is thinking "program other Propeller chips with it". When (unless I've got this completely off) it IS the eeprom which holds the Propeller program.
Edit: Oh, just found : http://www.parallax.com/Store/Microcontrollers/PropellerTools/tabid/143/CategoryID/19/List/0/SortField/0/Level/a/ProductID/443/Default.aspx
This is the "PropRPM" Rapid Prototyping Module.· Though ALL the chips are socketed on this one, it IS the eeprom which holds the Propeller program.
The PropRPM module was designed for people who want to build their own Propeller based applications.· In this case, you build your board, and the only 'socketed' part needs to be the eeprom.· 'Write' the eeprom on your RPM module using the IDE, then swap the eeprom around to your application board for running.
Or, you could 'gang program' eeprom chips using an appropriate burner, for "industrial quantities".· Note a Propeller 'native' chip is $12 or so in individual quantities -- which is quite pricey compared to PIC or AVR chips -- but it is one way to go.
Post Edited (allanlane5) : 6/19/2008 7:35:22 PM GMT
Most of my confusion branches from a simple misunderstanding I had. Actually, I knew all along that the program itself is stored in the EEPROM, but it wasn't registering. It didn't help that I was confusing a chip such as the 40-pin DIP Propeller with a PIC, I guess because they look the same. (The Propeller isn't a PIC, right? lol) Sorry for the amateur oversight.
Anyway, all of your great answers and descriptions are helping greatly. I think at this point, being as I'm still quite amateur and I'm also indecisive, it'd be best to answer allanlane's question "What was your goal again?"
My goal, at least initially, is this: I want to make interactive light...things. Ok, too brief? Basically I want to be able to create many different interactive light circuit, and be able to have them become permanent in something without losing my whole Propstick, etc setup, which I need to be able to test/develop different things. And obviously I don't want o have to buy a new Propeller kit for every ''thing'' I put an interactive light system into. So I want to have a kid that I can create/test circuits on (like my BASIC Stamp HW Board, but now Propeller I guess), but then transfer my program to an EEPROM chip I guess, that going into one of said permanent circuits. I'd imagine if I find out how to wire up my own Propeller chips, crystals, and EEPROM chips, I'd be golden. I'm guessing I can build permanent circuits with Propeller chips and just have the EEPROM socketed?
Sorry, I think I started to ramble and lose sight of my point. Anyway, do you guys get what I mean? I half know what I need, but all the info you guys gave me to consider makes me want to be 100% sure before a shell out the $$$. I don't want to get a sweet Propeller kit then be the idiot that didn't get the related parts that are needed to use it correctly.
Thanks in advance for all your help everyone! [noparse]:)[/noparse]
-Brian Paul
You'll need the $80 "SX-Key" to program them, but after that they're self-sufficient. And at 50 MIPS or so, they'll do almost anything you ask of them in terms of speed.
Btw, are the SX chips PICs then?
As Steph suggested, how about a Propeller Education Kit? You could built it up on the breadboard, work through the tutorials, and do your experimentation on the breadboard. When you're ready for something more permanent, you could design your own PCB and move all the components over.
Other options for something more permanent, but still flexible include:
www.wulfden.org/PRC/index.shtml
This has the advantage of having "servo" headers for pretty much all of the I/O pins so you can run a supply voltage, ground, and an I/O
pin off-board and have a current limiting resistor in series with each I/O pin. It also has a small breadboard for testing ideas. You can use
the programming port for controlling it from your PC. For simple testing, look at DongleBasic in the Propeller Object Exchange. This is a
simple interpreted integer Basic written in Spin that allows access to all the I/O pins and uses the PC as its "console".
If all you want to do is sense some light-levels, and use those do drive some output light levels, the SX has more than enough horsepower.
By the way, if you're building LOTS of these (more than 10) then going with a "native PIC" solution might be more cost effective. In that case, you'll need to spend around $300 for the development system, programming interface, and compiler. But your target boards can cost $5.00 in that case if you make enough of them.
Ok, so I'm sold on the SX. Well, first I must make sure...I'll be wanting to do projects with servos in the future, is all that still very possible with the SX? I noticed there was a very nice servo board for the Propeller series with loooots of servo control ports, but there's nothing like that for the SX. [noparse]:([/noparse] What gives?
Anyway, assuming the SX can do all the fancy servo stuff, I'll be going with that. So now my question is...what all do I need? I took a look at the one starter kit who's page works (2/3 don't) and, well, I already have a slew of the USB A to mini B cords, I have a power supply, and I can get the manuals free here in PDF. So, I guess I'll be buying the things I still need individually.
I apologize in advance for the number of questions that follow:
1). Am I correct to assume I need something like the tech board for cranking out some chips? And I guess I can get proto boards to make my more permanent things? Of course, I'll get the SX-Key too.
2a). SX28 or SX48? It seems the only difference if the number of I/O pins and the RAM size, correct? Is there any reason I'd need 262 bytes of RAM in the SX48 versus 136 in the SX28, or is 136 sufficient for most needs? Or in the case that it isn't I guess i could use two SX28's?
2b). I imagine the SX28 DIP is much easer for quick swapping and "cranking out of chips"?
3). What's all this about resonators? What are they for exactly? They're cheap so I could just buy them anyway, but what's their function? Do I need them for every permanent circuit too?
4). On the Getting Started page, www.parallax.com/Default.aspx?tabid=270, under the SX section > "OR purchase..." heading, the first alternative lists: SX48 Protoboard + Serial Cable + SX Key (or SX Blitz). My question is why does that suggest you need a serial cable, when the SX48 protoboard uses the SX-Key, which is also listed? Or was this left behind from an old proto board version?
Again, sorry for all the questions and sub questions and sub sub questions, haha. I know I ask too many, but I just cant help my curiosity.
THANK YOU IN ADVANCE!
2) Go for the SX48. If a particular design is doable with the simpler of 2 chips, you can always simplify the program and recompile. It's always handy to have a bit more memory or a few extra I/O pins when you're developing a design. You can always use them to help with debugging.
3) The resonator (or crystal) provides for a frequency standard. If you plan to do serial I/O, you need the stability of a resonator or crystal. The internal clock source isn't stable enough for that.
4) The serial cable is for use with the SX Key or SX Blitz. Now that there's a USB SX Key, you might not need it. If you use a USB to serial adapter, you might be able to connect it directly to the SX Key or SX Blitz and avoid the use of the serial cable.
Do download some of the free on-line tutorials and books on the SX.
The Parallax Servo Controller uses an SX processor to do the work of controlling multiple servos. Why add an external controller when the basic chip is pretty good at the functionality you need. If you need to control lots of servos (like 8-16), you may want to use the Parallax Servo Controller as a model, but develop your own software for your specific application.
As you may have expected, follow up questions:
1). Cool!
2). I'm still wondering how I can swap the SX48 chip in and out though? It looks like the tech board is only for the SX28 DIP, which means I wouldn't have a development platform, right? I'd only be able to use the SX48 proto board?
3). What does serial I/O mean, and what is the alternative? Is that serial as in the serial cable connecting the unit to the computer?
4). I don't even see a non-USB SX Key for sale anymore. I was planning on getting the USB SX Key anyway.. So I don't need a serial cable or port at all, right? Just computer USB to SX Key USB?
Thanks [noparse]:)[/noparse]
3) Serial as in asynchronous serial communications or serial port. It's logically the same as the serial cable coming out of a computer. Electrically, it's usually RS232 which is a voltage standard and is NOT COMPATIBLE with a direct connection to any kind of logic circuit. You have to have some kind of voltage translation. Sometimes this can be as simple as a resistor in series with an output line from a PC for example.
4) Yes, just a USB SX Key
Post Edited (Mike Green) : 6/22/2008 10:43:22 PM GMT
You can't "swap" a surface mounted chip in and out, obviously.
The SX28 Protoboard/development kit is VERY good for prototyping. Once you have what you want, you download it to the $10 target board and chip for use in the field.
Serial I/O is the serial cable connecting the unit to the computer, yes. And yes, if you use the USB SX-Key, you won't need an additional serial cable.
Thanks so much again.
I see now that the proto boards are AWESOME, haha.
Two more quick questions:
1). If I use the USB SX-Key, are the resonators necessary?
2). Is the small SX28 built into the sx28 proto board the identical to the larger SX28 DIP chip, only bigger to make it pluggable?
In conclusion, does this make sense: I'll buy the SX Tech Board for easy breadboarding while learning, then buy proto boards once I have a working model? And since the tech board is SX28 DIP only, I imagine I can use my programs on an SX48 proto board just fine by just changing I/O definitions if necessary?
THANKS!
2) The SX28 chip inside the package is identical no matter what type of package is used.
There are some small differences between the SX28 and SX48 in terms of programming. You have to change some definitions at the beginning of your program. There's documentation about this process, but I don't have links to it. I'm sure someone can chime in with the details when you need them.
Thank you all so much for your help.
Mike, I can tell why you have almost 8000 posts! Same goes for you, allanlane!
I'll be placing my orders tonight. I'm sure I'll be back here very soon
Hopefully in time I'll have some knowledge I can lend to this community in return.
Wish me luck!
Why are there different possible resonators? In what cases would you need each?