& gate operation plus
stbrnrd
Posts: 35
Hello smart people
I was wondering if there are any programs to make the bsx2 behave like an 'and' gate for five different signals...i have 5 signals that are coming from 5 different items, and these signals turn on module (A), what i need is an indicator of the signal being present (an led for each signal) but the combination of the 5 to give single a 5vdc out that would be used to overide the other signals to make this module turn on. (there are some faults that have happened because of loss of one or more of the signals with the remaining ones on) but if i centralize them, and only if they're present would this 5vdc signal be generated. i might be asking for a lot, but annnny help would be greatly appreciated.
if anything a better direction would also be greatly appreciated.
thanks in advanced for the input
J.A.
I was wondering if there are any programs to make the bsx2 behave like an 'and' gate for five different signals...i have 5 signals that are coming from 5 different items, and these signals turn on module (A), what i need is an indicator of the signal being present (an led for each signal) but the combination of the 5 to give single a 5vdc out that would be used to overide the other signals to make this module turn on. (there are some faults that have happened because of loss of one or more of the signals with the remaining ones on) but if i centralize them, and only if they're present would this 5vdc signal be generated. i might be asking for a lot, but annnny help would be greatly appreciated.
if anything a better direction would also be greatly appreciated.
thanks in advanced for the input
J.A.
Comments
·· By connecting all your inputs to the same port grouping, they can all be read at the same time.· Say your 5 inputs are connected to P0-P4.· Just do:
This will make P8 HIGH only when all 5 inputs (P0-P4) are HIGH.· If you need LEDs for each input that would be easy to implement too.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (Chris Savage (Parallax)) : 10/1/2005 6:59:22 PM GMT
it is obvious i need help, but how far off am I?
your reply will be appreciated.
' IF-THEN-ELSE.BS2
' The program below generates a ompilation of signals from 5 different inputs,
' then turns one pin high; in turn if any of the pins fail, the output of
' that designated pin is low.
' {$STAMP BS2}
' {$PBASIC 2.5} ' version 2.5 required
Main:
DO
IF (INL & %00011111) = %11111 THEN
HIGH 8
ELSE
LOW 8
ENDIF
GOSUB Pin_Compilation001 NEXT
GOSUB Pin_Compilation002 NEXT
GOSUB Pin_Compilation003 NEXT
GOSUB Pin_Compilation004 NEXT
GOSUB Pin_Compilation005 NEXT
LOOP UNTIL LOW 12 ' off pin command
END ' end program
Pin_Compilation001: ' freq pin between 10-100 khz
COUNT (PIN number)freqGen
DEBUG feq ? freqGen
IF >=10khz & =< 100khz THEN
HIGH 8
ELSE
LOW 8
RETURN ' go back to 1st instruction
Pin_Compilation002: 'ground pin
IF (PIN number) <= (PIN number)THEN
HIGH 8
ELSE
LOW 8
RETURN
Pin_Compilation003: ' voltage pin
IF (PIN number) < (PIN number) THEN
LOW 8
IF (PIN number) => (PIN number) THEN
HIGH 8
RETURN
Pin_Compilation004: ' off pin
IF (PIN number) LOW THEN
LOW 8
RETURN
Pin_Compilation005: ' on pin
IF (PIN number) HIGH THEN
DO
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
thanks
·· This is where clarity in posts really helps out.· No mention was made of this in your original message, or any replies up to now.· So everything you've gotten was based on 5 high/low inputs generating a high/low output.· Your original message specified that the BS2sx act like an AND gate, and that's what the code does that I provided.· But if you're introducing other type of signals, that complicates things.· I get the impression an AND gate isn't really what you need.· Perhaps you should provide more details about what the 5 input signals look like?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I appreciated the codes you have provided. maybe you are right and i should look at something else instead of the stamp;
I just thought that a single program could be written on one component instead of having 3-9 other components on a board to make things more complicated.
thanks again for your efforts and sorry for the confusion.
I'm not sure where you're getting the impression that the Stamp can't read your inputs, apply some decision logic to those inputs, and set one or more outputs accordingly. In fact, that's one of the functions that any microcontroller can do best.
What IS being said is that the provided code, while still correct in its logical analysis of the signals being presented, must work on conditioned inputs, and not directly on the input pins themselves. One must obtain each separate (possibly hardware conditioned) input, based on its type (analog, digital, pulse, etc) then apply any necessary software filters to it (range, high-low limit, etc) and then set one BIT as the output indicator for that particular input. The input either meets, or doesn't meet the conditioning criteria. If it does, the assigned input status BIT is set ON. If not, the input status BIT is set OFF.
This process continues until all inputs are fielded (with the appropriate software commands) and all 8 BITS (more or fewer as the case may be) have been either set ON or set OFF. Unused BITs in the input status BYTE are classically are set to the OFF condition, but that may vary with the specific logic applied to it. At the end of this process, you now have a conditioned BYTE (or multiple BYTEs) which represents the met or unmet critera (as tested) for each of the fielded signals, regardless of their type. All input signals now have a common modality and status, all contained in that one (or more) input status BYTE .
That input status BYTE can now be processed successfully by the prior logic provided, although it must be modified to inspect this "conditions" BYTE as opposed to viewing the raw input from the pin ports.
I hope that all makes sense. It's not nearly as complicated programatically as it is to describe the process
Regards,
Bruce Bates
·· Again the point was that not enough information was given to decide how best to proceed, but you still haven't provided that information so anyone could help you.· I never said the BASIC Stamp wouldn't work, just that more information was needed, because you indicated the code given wouldn't work.· I don't know what signals will be present to determine that.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com