PDA

View Full Version : Using the p40 basic stamp with a 555 timer (or similar chip)... and another que



rev
04-09-2010, 04:20 AM
I have a project wherein I'll be controlling 5 DVD players simultaneously. I need to have a common time reference that is a little more accurate than the basic stamps built in clock. Can someone point me in the direction of some basic documentation?
What I am trying to do is reset the DVD players on a periodic basis so they won't go out of sync. All players will be operating at all times, at any given time 4 of them will be displaying a still 'slug' and one will be playing a moving image. For example, if the total DVD length is 10 min, there will be 2 min of video and 8 min of still image per DVD.

Also I need to start each player as simultaneously as possible. Is this achievable using the ULN2803?

Thank you,

Revel

Tracy Allen
04-09-2010, 10:44 PM
You might as well use a real time clock chip. The DS1307 is a nice one to go with the BS2p40, I2C interface, to allow timing to the second, or even 1/2 second using the square wave output. Start commands issued in parallel through the ULN2803 would be synchronized to the millisecond.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

rev
04-10-2010, 05:23 AM
ok, thank you. is it it possible with the 555? and if so how? , because thats all I have right now, and this is pretty time sensitive.

Lucky
04-10-2010, 06:29 AM
The 555 is pretty inaccurate compared to a IC designed for real time. If you need an accurate time setup, use a dedicated IC meant for this purpose.

·Component values for the 555 actually start to get really big if you want it to run at one pulse per minute or slower. The longer the period the bigger the values and therefore there is a bigger impact on accuracy because of the components tolerances. The two resistor + capacitor setup of a 555 is inaccurate compared to a real time clock chip that uses a crystal for precision timing

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"The man who smiles when things go wrong has thought of someone to blame it on."


-Lucky

Post Edited (Lucky) : 4/9/2010 11:36:30 PM GMT

PJ Allen
04-10-2010, 06:57 AM
"is it it possible with the 555?"·

Exactly what?

With a 7555 (which is·CMOS)·you can use R up to 100MΩ and C up to 100uF (maybe more?) and you can do some major time constants that way and come up some slow one-shots and sub-Hz oscillators.· With a plain ol' bipolar 555, not nearly as much.· But still, RC will vary·given R & C will likely vary, to some degree,·with temperature, whether you're using tweak components or run of the mill.·

What's your·uncertainty threshold?· If nth degree repeatability is going to bust your gut then this is not the way to go anyway.·

Zoot
04-10-2010, 07:49 AM
Use an RTC (real time clock) as Tracy Allen suggested. It'll take minutes to wire up, will be accurate, and easy to use with Stamp I2C statements. With an (optional) battery back up your installation would still be able to resync the DVD players even if power goes out, or someone unplugs the the project accidentally, etc.

You can order an RTC like the DS1307 and a crystal for less than $5 with first-class shipping (maybe eighty cents) and prob. have it from digikey in a few days.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST

1uffakind.com/robots/povBitMapBuilder.php (http://1uffakind.com/robots/povBitMapBuilder.php)
1uffakind.com/robots/resistorLadder.php (http://1uffakind.com/robots/resistorLadder.php)

rev
04-10-2010, 09:01 AM
basically I just need to time 18 minutes somewhat accurately +/- a second or so. If there are discrepancies that multiply over time it is not necessarily a problem, as long as all of the dvd players share a common time reference. The basic stamp will be resetting dvd player # 1 - #5 every 18 min. The code needs to do something like this:

startup:
simultaneously play all dvd players #1 - #5
main 1:
pause 18 min
simultaneously reset all dvd players #1 - #5
pause 18 min
goto main 1:

Tracy Allen
04-10-2010, 09:22 AM
I guess I'm unclear on how much control the BS240 will have over the sequencing. You said, "What I am trying to do is reset the DVD players on a periodic basis so they won't go out of sync.". What is "periodic basis?" The internal clock of the BS2p40 can be pretty accurate when using timed loops to run through a sequence, but it drifts off of real clock time.

What would you expect to be gained by having the external '555?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

Zoot
04-10-2010, 09:29 AM
What Tracy means is that if, for example, your main loop always takes about 250ms to execute, then you can estimate elapsed time by incrementing a counter each time through the loop. If your loop executes with different times depending on code construction, this may or may not be close enough (over 18 minutes to within a second would need to have code built w/o IF/THEN statements and/or with padding in appropriate places so that each iteration of the main loop is fairly consistent in time). Certainly worth trying and see if it's close enough for your purposes as it wouldn't take any additional wiring or componentry.

Or, you could set up the 555 for a (relatively) slow square ware and count edges to estimate time (i.e on each pin state change, increment a counter). This may be close enough within 18 minutes -- you'd have to try it and see. See the datasheet for timing equations (essentially choosing your R and C values to generate the square wave in the range you'd like).

Or use an RTC and get very tight timing to within a second, plus the advantage of knowing human "clock" time, if you wanted to shut all the players down at the end of the day, etc. This has the advantage of being fairly plug n play with the BS2p series, along with lots of demo code for setting and reading the time.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST

1uffakind.com/robots/povBitMapBuilder.php (http://1uffakind.com/robots/povBitMapBuilder.php)
1uffakind.com/robots/resistorLadder.php (http://1uffakind.com/robots/resistorLadder.php)

rev
04-10-2010, 07:47 PM
Thanks guys. What your saying is that there is a certain 'lossyness' or time interval in basic stamp subroutines which must be taken into account when executing time sensitive tasks, correct?

I have about 4 days, and am not sure if I can acquire anything other than the 555 on such short notice. Am in NYC, so could be possible around Canal St I suppose, but not a sure thing. Now, if it isn't already apparent, I'm not an accomplished programmer. But could it be as simple as re syncing the DVD players every 18 min by implementing an 18 min pause between each play reset cycle? the way I would do this is by putting 18 1 minute pauses between the reset and play relays firing, and create a loop. (since the stamp cant pause for more than 68 seconds at a time right?)

I suppose I should describe the purpose of the project in a little more depth: Basically I have 5 dvd players. Each DVD player has a dvd of the same length in it. 4/5ths of each dvd's length is a single still image, 1/5 th of each length is a moving image. The dvd's differ only in the order of moving image vs still image. The goal is to ultimately run 5 TV's simultaneously such that only 1 TV has a moving image on it at any given time. So let - = still image and 0 = moving image for TV's 1 - 5, the playback sequence would look something like this:
1:0----
2:-0---
3:--0--
4:---0-
5:----0

I can do this by having 1 track on each dvd that cooresponds to the above sequence, or by having 2 tracks on each dvd, 1 moving and 1 still. It all depend on how quickly the players go out of sync, and whether or not it is acceptable to have all monitors briefly blink simultaneously were the 1 track solution to be implemented.

I have some 555 timers, but no idea how to go about using them. I have a bunch of uln2803's too, but am not quite sure how to get them to close multiple circuits at the same time. It has to be some way other than firing multiple pins at the same time, because the stamp is not capable of that, right? (even the BSp40?) Is it as simple as having 1 pin trigger multiple legs of the ULN2803?

I also have 1 TIPIC6595N, and a bunch of 74HC595N's, but I don't think either of those will be necessary.

If your still following along, then thanks for the help! :) It is much appreciated

Zoot
04-11-2010, 12:17 AM
I wouldn't call it lossyness; statements just take time. Small time, but time nonetheless. Additionally, if you have something like:




Main:

IF x = y THEN
HIGH 0
ELSE
IF a = b THEN
d = c/d
e = d * j
IF e > 100 THEN
HIGH 0
ENDIF
ENDIF
ENDIF

GOTO Main




The it stands to reason that if, during a given iteration of the main loop, x does NOT equal y, the loop will take much longer to execute.

A Stamp can set more than one pin at time, it just can't execute more than one statement at a time:




DIRA = %1111 ' set pins 0-3 to be outputs all at once
OUTA = %1111 ' set pins 0-3 high all at once
OUTA = %0011 ' pins 0-1 high; pins 2-3 low
OUTA = %0000 ' pins 0-3 low




So if you just want to fire your five pins staggered every 18/5 minutes, you could probably just pad with pauses and a counter to extend the count. The pause and the if/then statements themselves take time to execute, so you may want to just time how long you actually get and back off a little on the total count (hook up leds only to your pins to see it, then take working code and hook into your full circuit).




PlayerPort VAR OUTL ' pins 0-7 as a single byte
PlayerDirs VAR DIRL ' dirs

totalTime CON 18*60 ' in mins * secs
numPlayers CON 5 ' how many dvd players
interval CON totalTime/numPlayers ' time between firings in seconds
' you may want to back a few second or two off this if the pause/if/then construct takes more time, e.g.
' interval CON (totalTime/numPlayers)-3
' alternatively you could do something like PAUSE 999 instead of 1000 and see how it times

PlayerMask CON %11111111>>(8-numPlayers) ' for masking off unused pins on playerport if you need them for other purposes

time VAR Word ' up to 65535 seconds

Start:
PlayerDirs = PlayerMask ' all masked pins outputs, by default will be LOW; this is the playerport
' you can feed these 8 pins right into the inputs of a 2803A or the like and control
' the 8 2803A output pins directly in one shot
PlayerPort = %00000001 ' start with first player pin firing

Main:
time = 0 ' reset the pause till next player fires
DO UNTIL time >= interval
PAUSE 1000 ' pause one second
time = time + 1 ' increment counter
LOOP
IF PlayerPort.BIT0(numPlayers-1) = 1 THEN ' last pin fired
PlayerPort = %00000001 ' so start again with p0 high
ELSE ' otherwise just rotate so the next pin is high, others low
PlayerPort = PlayerPort << 1 ' next pin high, all others low
ENDIF

GOTO Main



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST

1uffakind.com/robots/povBitMapBuilder.php (http://1uffakind.com/robots/povBitMapBuilder.php)
1uffakind.com/robots/resistorLadder.php (http://1uffakind.com/robots/resistorLadder.php)

Zoot
04-11-2010, 12:22 AM
P.S. -- keep in mind that the above WILL NOT WORK if you need to do ANYTHING else during the long pause.... if you need to check inputs (swtiches, sensors, etc) during that time, you'll need to do something like what we described with a 555 or RTC -- using an outside reference for timekeeping so you can do what you want, when you want, in your main loop. Or estimate time for the main loop and manually increment a counter where appropriate.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST

1uffakind.com/robots/povBitMapBuilder.php (http://1uffakind.com/robots/povBitMapBuilder.php)
1uffakind.com/robots/resistorLadder.php (http://1uffakind.com/robots/resistorLadder.php)

rev
04-16-2010, 12:03 AM
great, thankyou so much for your help, it is much appreciated. I can't say I fully understand the code you so graciously compiled, but am trying my best. I've gotten a little extension in this project, which is nice. What I resorted to yesterday, since I thought it was due, was hack a universal remote and write an extremely simple loop:




' {$STAMP BS2sx}
' {$PBASIC 2.5}

main:
'PWR UP
HIGH 2
PAUSE 1000
LOW 2
PAUSE 1000
'WARM UP
PAUSE 15000
main_2:
'RESET TO 0:00:00
'STOP
HIGH 1
PAUSE 500
LOW 1
PAUSE 500
'STOP
HIGH 1
PAUSE 500
LOW 1
PAUSE 1000
'PLAY
HIGH 0
PAUSE 500
LOW 0
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 60000
PAUSE 50000
GOTO main_2:




the universal remote controls all of the players and keeps them in sync. A few questions:
-is this more or less reliable than controlling all dvd player's buttons? It would seem to me that there is less probability that something would go wrong since the system is relying on 3 relays, 1 IR trasmitter and 5 IR recievers instead of 18 relays, what do you think?
-Are ULN 2803's more reliable than reed switches?
-is there a good way to introduce some redundancy ie. if 1 dvd plaver did not power up by some fluke, the Stamp would pause the 'POWER UP cycle and turn it on before proceeding? I understand that not subroutines are possible during the long 18 min play, but this would be in main:

Zoot
04-16-2010, 12:22 AM
If it works, it's great!

The IR will only be a problem if there is interference somehow (fluorescent lights, bright sunlight, etc). Test it in place to make sure.

Reed relays can wear down and/or fuse if subjected to over-current conditions, abuse, etc. Again, if they are working and if they are rated for enough current for what you are doing with them, then it will be fine (presuming this project doesn't need to run uninterrupted for ten years straight or anything http://forums.parallax.com/images/smilies/smile.gif).

Glad you are getting it running. That's a clever solution to fire a remote at all the players rather than brute force switching them on and off.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST

1uffakind.com/robots/povBitMapBuilder.php (http://1uffakind.com/robots/povBitMapBuilder.php)
1uffakind.com/robots/resistorLadder.php (http://1uffakind.com/robots/resistorLadder.php)

rev
04-16-2010, 01:35 AM
Cool! I was thinking about making a sort of homebrew optoisolator by removing the ir recievers from the players and placing them into a housing with the IR emitter led, thereby avoiding avoiding any potential environmental disturbances. My reseration pertaining to the hacked remote solution is this: the only way I could make a solder connection to the button underlayment contacts was to use a single copper strand, so it feels quite fragile. While there won't be any vibration in the eventual installation site (which is inside of a huge sculpture of the earth,) I was wondering if there are better ways to achieve this connection.

Zoot
04-16-2010, 02:37 AM
Sounds fragile. Not sure what to tell you without seeing it.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST

1uffakind.com/robots/povBitMapBuilder.php (http://1uffakind.com/robots/povBitMapBuilder.php)
1uffakind.com/robots/resistorLadder.php (http://1uffakind.com/robots/resistorLadder.php)

rev
04-22-2010, 05:45 AM
I've recieved some flak about starting multiple threads, and I'd like to apologize for that. I figure the questions I had didn't pertain to the original subject of the thread, thus the impetus to start a new one.

The IR is working out nicely for now, however, I am also going to use a relay system as a backup in case the IR fails. This thing has to be fairly permanent. A few amateur questions regarding relays, darlington arrays, and basic stamps:

It seems that the basic stamp can safely drive a reed switch with a coil resistance of about 250 ohms (5V, 20mA). In my case I am triggering 5 relays at once, so I am using some ULN2803's to pull the load, especially since I am also driving some 1050 ohm (12V, 11mA)reed switches, which seem to work fine on 5V. Can 1 5V, 250 ohm (or 1050 ohm) reed switch turn 5 dvd players on? Can 1 leg of a ULN2803 trigger 5 reed switches? I am trying to find a way to minimize the components, especially the mechanical ones, to minimize the potential for failure. In total I am triggering 15 buttons on 5 dvd players, 5 buttons at a time.

Also, just to double check, if I am using a ULN2803 to drive the reed switches, then I don't need to wire a switching diode across the relay coil, right? Thanks!

Zoot
04-22-2010, 06:30 AM
said...
Can 1 5V, 250 ohm (or 1050 ohm) reed switch turn 5 dvd players on?


No way to know. What matters here is the max voltage and current the relay/switch can handle. See the device's datasheet.


said...
Can 1 leg of a ULN2803 trigger 5 reed switches?


Almost definitely. Each pin of the '2803 (and the device as a whole) can handle 500ma max. That doesn't mean all pins at once -- that's the max on any given pin AND all pins put together:

1 pin on = max 500ma
2 pins on = max 250ma each
4 pins on = max 125ma each

etc

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST

1uffakind.com/robots/povBitMapBuilder.php (http://1uffakind.com/robots/povBitMapBuilder.php)
1uffakind.com/robots/resistorLadder.php (http://1uffakind.com/robots/resistorLadder.php)

Chris Savage
04-23-2010, 02:29 AM
Zoot,

You're close...each pin can sink a maximum of 500mA, however once you start using multiple pins it doesn't divide 500mA by 2. At this point what matters is the total power dissapation of the driver, which is 1W and the power dissapation of the entire package. So many factors will decide this, including the voltage being switched at each output as well as the current.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage

Parallax Engineering
·

Zoot
04-23-2010, 03:06 AM
Duh. That pesky power dissipation. Most of my datasheets show 1w per pin and 2.5w total for the package.

At 5v / 1w = 200ma max per pin, 2 or 3 pins on at most
At 12v / 1w = 83ma max per pin, 2 or 3 pins on at most

At 5v / 100ma per pin = .5 w = 5 pins on at most

etc

Y'know, I've got some 12v projects where I'm probably overdriving the 2803's http://forums.parallax.com/images/smilies/smile.gif but they hardly get warm to the touch. Probably because I'm almost always using PWM, and I always stagger PWM so that some pins are always off while others are on.

In any case, Rev, you should be fine driving the relays as you want (at 250 ohms the current on each coil at 5v would be about 20ma). In re-reading your post are you talking about using relays to switch the AC outlet power to the DVD players or just the remotes? If the latter, again, see how much current the remotes use and how much current/voltage your relays can safely tolerate. If the former, STOP and get expert advice or use commercially produced after-market AC modules. AC power can kill you if not handled correctly.

If this is meant to be permanent or semi-permanent, and you are committed to breadboards, get everything mounted solidly, make sure your wiring is need and tied down where possible, etc. You don't want fragile and loose wires coming undone six months down the road.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST

1uffakind.com/robots/povBitMapBuilder.php (http://1uffakind.com/robots/povBitMapBuilder.php)
1uffakind.com/robots/resistorLadder.php (http://1uffakind.com/robots/resistorLadder.php)

Chris Savage
04-24-2010, 12:20 AM
As an aside some datasheets from one manufacturer can be different than the same part from another manufacturer. My datasheet actually refers not to a fixed 2.5W package dissapation, but rather a chart showing the power curve related to temperature I believe. Hinting that it could handle more if thermal considerations were provided. Definitely look at the datasheet when you need absolute max ratings and do the math if you have to. Getting lazy there can cause you big problems later. I made thta mistake years ago on a battery charging system. I didn't want to have to do the math to calculate the actual mAh available over the life of the battery so I treated it as if it were linear. On the bench it looked good. In the field it was later put to a real test where it failed and cost me hundreds of dollars in time and parts.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage

Parallax Engineering
·

allanlane5
04-24-2010, 12:48 AM
It looks to me as if your "relay" backup is much less reliable than your IR-LED approach. When engineering solutions, it's good to be aware that sometimes "fallback" solutions (like trying to solder on a DVD player to provide a 'button press' with a relay) may produce a MUCH less reliable solution than simply using the IR-Interface in the first place and not HAVING a "fallback".

And Digikey can next-day deliver a 1307 with a 32 Khz crystal -- the 555 timer chip is really not stable nor reliable enough for what you're trying to do.

For that matter, I kind of like these: http://www.rhombusinc.com/co-processors.html#Multi-Function

Their "CP_SAR" can generate a 'tick' for you, that you can then use to synchronize the tasks on your BS2p-40. And it's only $10 (with an 8-pin DIP and resonator)

rev
04-27-2010, 12:12 PM
Yea, I agree. The reason for the relay solution is for individual button automation possibilities down the line, though they aren't initially necessary. I'm going to go ahead and wire them up, and then go back to the IR solution and figure out a reliable way to solder it in.

Given that I do want to allow for the possibility for individual button automation, but also want the most reliable system, it made sense to wire a relay across each group of 5 buttons as well as a dedicated relay per button, ie. bridging legs A and B of each group of 5 buttons, (PWR, PLAY, STOP, etc) and wiring a relay across that (see pic). However this didn't work. Bridging leg A of the power buttons was fine, bridging leg B resulted in the button switches closing. This a ground issue?

1 in 15 reed switches is more prone to failure than 1 in 3, so three is all I need if possible. And, is there a more reliable relay?