November 22, 2024, 03:02:12 PM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Is this possible with a Prop 1?

Started by CoffinBound, March 15, 2008, 11:28:21 AM

Previous topic - Next topic

CoffinBound

After a quick search, I couldn't find anything related to this, so forgive me if this has already been asked...

Is it possible to use a prop1 to perform the following type of prop?

Basic Idea:
A control panel with a "status" bar that changes based off of an adjustable wheel.


Particulars:
I was thinking of using a row of 2 yellow, 3 green, and 2 red LEDs as the "status" bar (the qty of LEDs really isn't important for the effect, but the more I could use the better I think it would look).  The adjustable wheel could be a potentiometer (or something else??). 

What I was hoping to do was have the the first yellow LED on all the time and as you turned the wheel clockwise, the rest of the LEDs would light up from left to right until you reached the end of travel on the wheel (at which point all the LEDs would be on).

I know I have seen something like this in the movies, but I can't think where.  Most likely some SciFi movie.  But that's the general idea.  Any thoughts???

CoffinBound

JonnyMac

You can do that with the Prop-1.  You would use the POT command on P7 to read the potentiometer position, divide the value into six equal segments (as you have six variable lights), and then use LOOKUP or READ to create the bar graph.  I'm an two seconds from getting in my truck and driving to Transworld, so I'll write you a demo program when I'm in Las Vegas and settled.
Jon McPhalen
EFX-TEK Hollywood Office

CoffinBound

Cool!  Take your time, John.  Enjoy yourself at Transworld.  I wish I could be there with you and the rest of the Halloween freaks.

Thanks for your hard efforts!

CoffinBound

JonnyMac

Here you go.

' =========================================================================
'
'   File...... Bar_Graph.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              see: http://creativecommons.org/licenses/by/3.0/us/
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  LvlKnob         = 7                     ' SETUP = out; no ULN


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  level           = B2                    ' reading from pot
SYMBOL  idx             = B3                    ' index into table


' -----[ Initialization ]--------------------------------------------------

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %01111111                              ' make P0-P6 outputs


' -----[ Program Code ]----------------------------------------------------

Main:
  POT LvlKnob, 105, level                       ' read the potentiometer
  idx = level / 42                              ' divide into 7 segments
  READ idx, PINS                                ' convert to bar graph
  PAUSE 100
  GOTO Main


' -----[ Subroutines ]-----------------------------------------------------


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------

Bar_Graph:
  EEPROM (%00000001)
  EEPROM (%00000011)
  EEPROM (%00000111)
  EEPROM (%00001111)
  EEPROM (%00011111)
  EEPROM (%00111111)
  EEPROM (%01111111)
Jon McPhalen
EFX-TEK Hollywood Office

CoffinBound

Once again, no hurry on this, but can you answer a couple more questions?

1. Is Out 0 going to be the first Yellow LED working my way up to Out 6 being the final Red LED?
2. Does it matter what value potentiometer I use?
3. Am I correct in thinking that I need to swap out the ULN2803 so as to not interfere with the pot (like with the Trainer board)?

Also,

If I wanted to have more LEDs (to give a finer tuning appearance), would I need to use a Prop 2 because of the more outputs, or is there some way I can lite more than just 7 LEDs using the prop1 (without turning them on two or three at a time)?  If I need to use a prop 2, does the code change significantly?

I think that is it. Thanks again for your help!

JonnyMac

1. This is correct
2. Yes.  Use a 10K with a 0.1 uF cap -- see the POT instruction in the help file for a schematic
3. Yes, the POT pin needs to be clear

You could use a Prop-2 for more outputs. Or... if you're good at building electronics you could build up a circuit using a 74HC595 shift register (see the SHIFTOUT example in the PBASIC help file).  The BS1 doesn't have the SHIFTOUT command, but I can synthesize it in BS1 code.  If you wanted just a single LED lit you could do more with a BS1, but it requires a tricky wiring scheme called Charlieplexing (do a search on that phrase in our forums -- I've posted on it before).

If you went with the Prop-2 the program would be structurally similar.  The POT command would change to RCTIME and you would be working with Words instead of bytes, but nothing amazingly difficult.
Jon McPhalen
EFX-TEK Hollywood Office

CoffinBound

Jon,
Turns out I don't have a Prop1 to use for this prop.  Instead, I have a Basic Stamp 2 BOE just sitting around that I would like to use instead.  Can you give me some help converting your code to something I can use with a BS2?

I appreciate your help and expertise.

Kevin

JonnyMac

March 21, 2008, 11:05:59 PM #7 Last Edit: March 22, 2008, 12:02:55 AM by JonnyMac
I hope you'll consider purchasing a Prop-2 and Prop-Pot to run this program.

' =========================================================================
'
'   File...... Bar_Graph.BS2
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              see: http://creativecommons.org/licenses/by/3.0/us/
'   Started...
'   Updated...
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

LvlKnob         PIN     15                      ' SETUP = out; no ULN


' -----[ Constants ]-------------------------------------------------------

IsOn            CON     1                       ' for active-high in/out
IsOff           CON     0


' -----[ Variables ]-------------------------------------------------------

level           VAR     Word                    ' reading from pot
idx             VAR     Byte                    ' index into table


' -----[ Initialization ]--------------------------------------------------

Reset:
  OUTS = $0000                                  ' clear all outputs
  DIRS = $7FFF                                  ' make P0-P14 outputs


' -----[ Program Code ]----------------------------------------------------

Main:
  HIGH LvlKnob                                  ' charge RC circuit
  PAUSE 1
  RCTIME LvlKnob, 1, level                      ' read pot setting
  idx = level / 41                              ' divide into 15 segments
  READ Bar_Graph + (idx * 2), Word OUTS         ' convert to bar graph
  PAUSE 100
  GOTO Main


' -----[ Subroutines ]-----------------------------------------------------


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------

Bar_Graph       DATA    Word %0000000000000001
                DATA    Word %0000000000000011
                DATA    Word %0000000000000111
                DATA    Word %0000000000001111
                DATA    Word %0000000000011111
                DATA    Word %0000000000111111
                DATA    Word %0000000001111111
                DATA    Word %0000000011111111
                DATA    Word %0000000111111111
                DATA    Word %0000001111111111
                DATA    Word %0000011111111111
                DATA    Word %0000111111111111
                DATA    Word %0001111111111111
                DATA    Word %0011111111111111
                DATA    Word %0111111111111111


Jon McPhalen
EFX-TEK Hollywood Office

CoffinBound

I would consider buying a Prop-2, if the project was going to be one I would use more than once.  This prop is going to be used as an "April fools" type joke for the office.  Everyone complains that the "network runs too slow," so I thought I would give them a way to boost it.  We are going to mount all this stuff into a project box and mount it on the wall beside the door to the server room.  We are then going to dangle a couple network cables from the ceiling and have them plug into the top of the project box.  We are also looking into getting a small web camera we can mount somewhere to capture some action shots of users adjusting the network speed, that we can then post to the intranet page.


Your comment does have me curious though.  What would some of the benefits be to using a Prop-2 over the BS2?  I know using a BS2 for this is kinda like using a sledge hammer to kill a fly, but it is what I have available.

Thanks for the code, by the way.  It looks like I was kinda on the right track when I tried to convert your original version.  I had some things wrong, but my mistakes make sense now that I see the right way it should be done.

JonnyMac

Well, using the Prop-2 would let you drive more current as the outputs are buffered by ULN2803s -- and you'd be supporting the company that is helping you with code.
Jon McPhalen
EFX-TEK Hollywood Office

CoffinBound

OK, I should have seen that second comment coming a mile away.  I don't always remember the separation between the Prop-1 line and Parallax.  I still kinda think of them as one in the same.  Sorry about that.

I do plan on picking up some more controllers.  I personally can't wait to try the Prop-2 & SX controllers (along with some of the other boards you guys have.)   I am just waiting for that good old government check to come in.   Either that, or I need to win the lottery.  ;)

davisgraveyard

By now the joke must have already been played.    I am curious though,  why not use the DC-16 for extra LED's?

CoffinBound

Dang, am I behind or what.  Sorry about that DavisGraveyard.

I personally wouldn't of had a problem using a DC-16 for extra LEDs, as long as the end result could have been accomplished.  At the time, I didn't have time or money to pick one up.  I already had the BS2 in hand and it theoretically doubled the number of outs I could drive.  For me, it was a no brainer at the time.

CoffinBound