Just getting started, a few application Q's, and recommendations for learning r
iandh
Posts: 5
Hello all,
I just picked up a BS2e and carrier board for a project I am doing. I have programmed in Basic before, although my knowledge was very limited. About five years ago I used a stamp to build a control system for the cooling tower at work; it controls the fans and circulating·pumps, and an algaecide injector pump and electric·drain·valve using an opto board, along with a few 3-phase·contactors. I think the whole program is something like 50 lines.
I have entered a computer case building competition, and would like to use the stamp to control motorization, lighting, and possibly fans/cooling system. I have a little more than two months to educate myself and complete the project. I don't expect anyone here to do my homework for me, but being that I am time limited, anything that anyone has to offer including code, learning·resource suggestions, parts sources, or advice would be greatly appreciated.
I have already loaded the·Stamp editor·program and the help section·seems like a good place to start to re-familiarize myself with basic syntax.
I will list out the things I am considering using the stamp for; if you all could give me an idea of the relative difficulty of each task it would help me quite a great deal with time management:
-Control two servos using a single momentary pushbutton for each servo. Press button·once, door opens, press again, door closes. One servo would control the front door of the case for access to the drives, and one would pop up a hidden control panel from the top of the case.
-Randomly flash one LED out of a group of ten every second; I am building a "star ceiling" inside the case using fiber optics, with white LED's as the illumination. *I may choose to use a mechanical chopper instead as I feel it would give a more realistic gradual blinking effect*
-Flash 5-6 Leds sequentially with adjustable speed and reverse at end of each flash series (think knight rider)
-The computer will be water cooled, so I am entertaining using the stamp to slowly·ramp up fan speeds after·the water reaches a certain temperature threshold. I may use manual control for this anyways though because listening to the fans ramp up and down all the time may be a nuisance.
-I may use a serial LCD display for status indication, but mostly for looks. It isn't really necessary, so if you all think that this may be a bit much for a beginner please let me know.
Regarding the LED's, I assume I would probably need to use some sort of multiplexer so I don't tie up all of my ports? What is the best way to get power to everything? I can pull 12V·and 5V·from the molex cables so would those be suitable for the carrier board and servos?
I'd like to thank you all for your time in advance.
·
I just picked up a BS2e and carrier board for a project I am doing. I have programmed in Basic before, although my knowledge was very limited. About five years ago I used a stamp to build a control system for the cooling tower at work; it controls the fans and circulating·pumps, and an algaecide injector pump and electric·drain·valve using an opto board, along with a few 3-phase·contactors. I think the whole program is something like 50 lines.
I have entered a computer case building competition, and would like to use the stamp to control motorization, lighting, and possibly fans/cooling system. I have a little more than two months to educate myself and complete the project. I don't expect anyone here to do my homework for me, but being that I am time limited, anything that anyone has to offer including code, learning·resource suggestions, parts sources, or advice would be greatly appreciated.
I have already loaded the·Stamp editor·program and the help section·seems like a good place to start to re-familiarize myself with basic syntax.
I will list out the things I am considering using the stamp for; if you all could give me an idea of the relative difficulty of each task it would help me quite a great deal with time management:
-Control two servos using a single momentary pushbutton for each servo. Press button·once, door opens, press again, door closes. One servo would control the front door of the case for access to the drives, and one would pop up a hidden control panel from the top of the case.
-Randomly flash one LED out of a group of ten every second; I am building a "star ceiling" inside the case using fiber optics, with white LED's as the illumination. *I may choose to use a mechanical chopper instead as I feel it would give a more realistic gradual blinking effect*
-Flash 5-6 Leds sequentially with adjustable speed and reverse at end of each flash series (think knight rider)
-The computer will be water cooled, so I am entertaining using the stamp to slowly·ramp up fan speeds after·the water reaches a certain temperature threshold. I may use manual control for this anyways though because listening to the fans ramp up and down all the time may be a nuisance.
-I may use a serial LCD display for status indication, but mostly for looks. It isn't really necessary, so if you all think that this may be a bit much for a beginner please let me know.
Regarding the LED's, I assume I would probably need to use some sort of multiplexer so I don't tie up all of my ports? What is the best way to get power to everything? I can pull 12V·and 5V·from the molex cables so would those be suitable for the carrier board and servos?
I'd like to thank you all for your time in advance.
·
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
First... your going to have pin problems. Here's a quick breakdown:
Servo Control:
4 pins
Ten LEDs:
10 pins (maybe 6 using charlieplexing)
6 Knight Rider LEDs:
6 pins
Serial LCD:
1 pin
There are ways to increase the number of pins you can use. I've never personally used any of them, but I believe they are
called bitshifters.
Charlieplexing is a technique using normal transistors that can let you use multiple LEDs... especially when you only have one
or two on at a time. I recommend checking the wiki for it.
I'm not sure what you mean by mechanical chopper... if you mean something like a spinning wheel that has holes cut in it
to make the LEDs cycle on and off in a pattern... that'll reduce that 10 pin count to 1 (a servo).
As far as the "Knight Rider" affect... I recommend an LED driver IC... these are mainly meant for 7-segment displays but I'm
pretty sure you could program them to work with your plan.
A serial LCD will most likely be the easist part of your project... I highly recommend getting either one by Parallax or one you
like with a #117 serial backpack kit.
I do have a few questions for you:
Which carrier board do you have?
Do you have experience with soldering?
What is your budget for this project?
Can you handle all the mechanical aspects?
Sorry about being vague with my advice. I'll look into more detail for you if no one else offers better help.
The basic stamp project I built years ago:
Here is a servo controlled "dipper" I built for out ultrasonic cleaner at the shop, it is controlled using Labview (which I am much more comfortable with than basic... sad considering it is considerably more complex) and a USB I/O card. I scratch-fabricated the whole assembly.
This is an interface box I built for one of our coating machines:
I could publish a whole picture book of the computer controlled electro-mechanical assemblies that I've built at work, but honestly that is not why I am here. I just wanted to give an idea of my experience level.
In any programming language, there typically are several ways to acheive a given result... actually in any endeavor for that matter. I am trying to see if I can get the "elegant" solutions to my problems that come with experience, rather than struggling to write some clunky code and ending up ticking myself off to acheive the same result, or even worse... wasting money. This project is already bleeding cash. My budget is basically the least possible to get the job done.
I don't mind reading any literature I am pointed towards, but OTOH as I mentioned before I have a very limited amount of time, so I don't want to learn anything I don't absolutely need to get the job done. Maybe sometime in the future though. [noparse]:)[/noparse]
By mechanical chopper, I mean pretty much exactly what you describe, I would arrange the LED's in a circular formation and then get a small 12V gear motor, say 10-20rpm with an arm attached to it. It wouldn't even need to be attached to the stamp, I could just power it with 12v and let it run.
The carrier board is just the cheap $16 one... Basic stamp 2 carrier board.
Post Edited (iandh) : 4/19/2008 2:42:39 AM GMT
-Control two servos using a single momentary pushbutton for each servo. Press button once, door opens, press again, door closes. One servo would control the front door of the case for access to the drives, and one would pop up a hidden control panel from the top of the case.
> 2 servos + 2 buttons = 4 pins total so far
-Randomly flash one LED out of a group of ten every second; I am building a "star ceiling" inside the case using fiber optics, with white LED's as the illumination. *I may choose to use a mechanical chopper instead as I feel it would give a more realistic gradual blinking effect*
> get an LED driver. This will let you drive many LEDs using just 3 pins for a SPI interface (data, clock, enable lines) and best of all -- one resistor to set maximum current for all LEDs. + PWM so you can get some level of brightness (if you want). Keeps part count wayyyyy down. One such driver is the MAX7219 (Maxim, carried by Parallax) though I prefer the MAX7221 which is essentially the same chip with better supression of EMF when multiplexing and because it's true SPI (e.g., a false pulse won't enable the chip). These drivers will run up to 64 LEDs, so you'd be covered for pretty much all of them.
> 4 pins + 3 SPI pins = 7 pins total so far
-Flash 5-6 Leds sequentially with adjustable speed and reverse at end of each flash series (think knight rider)
-The computer will be water cooled, so I am entertaining using the stamp to slowly ramp up fan speeds after the water reaches a certain temperature threshold. I may use manual control for this anyways though because listening to the fans ramp up and down all the time may be a nuisance.
> Running a simple PID (or PI or PD as suits you) on the Stamp is not complex and may keep things nice and stable without a lot of fan ramping. There are some simple examples both in the Stamps in Class forums and in Parallax's Industrial Control with the Stamp book/download. Presuming you know about this kind of control schema already, but having some of the ready-to-go fan/temp examples for the Stamp in the book will surely save you time.
> What are you going to use to measure water temp? Run the fan? For argument, and because they are readily available, lets say you use some kind of SPI A/D converter to a temp probe or a sensor. Any SPI devices can all share the same data and clock lines, needing just enable lines. So say one more enable line for A/D or sensor, and then there's the fan... which I'll leave off till below.
> 7 pins + 1 pin = 8 pins total so far
-I may use a serial LCD display for status indication, but mostly for looks. It isn't really necessary, so if you all think that this may be a bit much for a beginner please let me know.
> 8 pins + 1 pin = 9 pins total so far
Regarding the LED's, I assume I would probably need to use some sort of multiplexer so I don't tie up all of my ports? What is the best way to get power to everything? I can pull 12V and 5V from the molex cables so would those be suitable for the carrier board and servos?
> See above re LEDs. If the 5v is beefy (5amp? higher?) then I would run all the servos and electronics from that. You're only running two servos, so the draw won't be much. Maybe put 1000uf caps across the servo power rails to help with surge during stall/startup of the servos. And if you have the clean 5v already in the case, you could skip the regulator on the carrier board altogether and run the 5v to Vdd instead of >6 volts to Vin.
By mechanical chopper, I mean pretty much exactly what you describe, I would arrange the LED's in a circular formation and then get a small 12V gear motor, say 10-20rpm with an arm attached to it. It wouldn't even need to be attached to the stamp, I could just power it with 12v and let it run.
> If you run the LEDs from a driver (or Stamp pins) then you can program in as many patterns as you can dream up, and with one of the external drivers, you can have them "fade" in and out (as a set, btw, not individually). Much much better and more reliable then another motor. Quite easy.... say you have 15 leds -- you'd use a Word for the "bitmap" and you can manipulate the Word and send it to the appropriate LED bank(s) in the driver, e.g. this would run a single LED in a "circle" if you had 15 LEDs in a circle:
OK, now there's two issues you may need to think about and decide what works for you as a possible tradeoff between programming ease, flexiblity and hardware requirements. If you are going to be running servos, and possibly running a driver for a fan, the Stamp does not do servo pulses nor PWM in the background. For the servos you would need to have the servos get refreshed every 20ms -- this can be quite tricky if you are ALSO wanting to measure temp, run a fan, update 10-15 leds, monitor two buttons. For example, if a decent debounce for a button is 5-15ms then you've already chewed up a lot of time between pulses. See what I mean? That said, for only two servos I'm not sure than external servo driver is worth it (e.g. the Parallax Servo Controller lets you sent a few bytes via a single serial pin to run up to 16 servos with ramp speeds). You could stagger sensor readings and outputs from pulse to pulse, e.g.:
- send pulse to servos
- read temp
- send pulse to servos
- send fan
- send pulse to servos
- send leds
- send pulse to servos
- read buttons
- do it all again
That gives any one task up to 20ms (or so) to complete and still refresh the servos in time. The whole loop would be about 110ms-160ms though, which could be slow (about 5-6 times per second). Remember Stamps are not incredibly fast, and the overhead for instructions to actually execute can be steep sometimes.
If you need actual speed (PWM?) for the fan, then that might have to be offloaded from the Stamp. By my count, presuming anything remotely like the above, you still have a good number of pins free, so hooking up extra peripherals will not be a problem if the need arises. Note that some serial (asynchronous) devices can sometimes share the same single serial line, so again, pin count shouldn't be too much of a problem.
This sounds like a really cool project and I never heard of such a competition. Is this like a contest for those custom tricked out neon-lit transparent gamers' PCs and such that I've seen occasionally?
P.S. -- in an ideal world, I would suggest using a Stamp for the main brain on your case, then program an SX as a single peripheral -- the SX could do all the servos in the background, and could do the temp reading and PID/PWM work for the fan. Such an SX would be controlled by the Stamp via single serial pin. But I think that is prob. more than you want to take on in two months? Maybe a better question is "What's your budget?" -- if budget is not tight, a ServoPal and a PWMPal would take care of the background stuff for you, and be pretty plug-n-play.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Post Edited (Zoot) : 4/19/2008 5:01:17 AM GMT
I'm about to call it a night, but I'll look over the LED driver you suggested and the rest of your suggestions as well.
Another way that I've done a·cheesy fan control was using a mosfet with a thermistor and variable resistor on one leg, unfortunately I don't have a way to easily adjust "ramp slope", only threshold temp.
The computer power supply I am using can supply up to 30A on the 5V rail so I think I should be good there.
Thanks for your suggestions, I'll do homework over the weekend and post back in a few days. The main thing that I am going for is the servo function, so perhaps I will concentrate on getting that running and use my patch-job methods to handle my other problems for now. I like your suggestion to use the Basic stamp as a hub controller with the SX chips as peripherals, so I could always expand in the future. I'm not really horribly budget limited, as far as in that I can spend what I need to, I just want to keep as close to my original spending limit as I can.
Honestly, the ability to expand the setup, experiment,·and learn more in the future is the main reason I chose to use·a stamp, otherwise I likely would have just used a DPDT rocker with a couple of small limit switches for my motorization functions.
edit: Saying the hardware and mechanical side are my forte is an excellent way to put it; I am most definitely a NOVICE programmer. I am going to try my best not to annoy you guys with stupid questions that I could have answered with some reading, it is just hard to sort through page after page to find a specific solution sometimes.
Post Edited (iandh) : 4/19/2008 5:16:04 AM GMT
On the drivers, my recommendation is just off the top of my head. There are a lot of drivers out there -- some will only run 16 leds, but let you control intensity individually on each one, some may have greater or lesser *total* current limits, etc. Do a search at Digikey.com or Jameco.com or Mouser.com and you'll turn up lots of options. The main thing to look for if you're using a Stamp is if the driver is SPI (serial with clock/data/enable) or I2C. The former will prob. be easier (sorry, I can't remember if the BS2e has the I2CIN and I2COUT commands; I believe it doesn't).
For the fan, if you can do PWM then you should be able to control speed through the MOSFET, right? So again, the question would be where to offload that -- the PWMPal is ready to go and for a one-shot, would be cheaper then buying an SX-Key. But the latter would get you set up for programming (in a form of Basic) the blazingly fast SXes with the ability to do "background" servo pulses, PWM, communcation, etc. That said, I think the SX-Keys may be back-ordered so time could be an issue for you. And while SX/B (the basic variant on the SX) is not complex, you know how it can be -- you might or might not find yourself up against deadline while slogging through details on TWO language variants. The ServoPal is a ~$20 item for running two servos in the background. I think it's a bit pricey, but sometimes having something ready-to-go (and physically small) is equally valuable.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
I'll check out the ServoPal, sounds like it could be handy, and may free me up a bit for other things. Well, gotta grab some paper towels and check how bad I am bleeding.
·