November 22, 2024, 10:15:22 AM

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.


Selector Switch/POT Command

Started by Tim-M, January 07, 2008, 11:30:48 AM

Previous topic - Next topic

Tim-M

Group,

I'm wiring a multi-mode selector switch for an industrial machine control that's based on the Prop-1.  I'd like to save inputs and use the POT command so that only one I/O will be needed to select between the three machine modes.

BACKGROUND DETAILS:
- The selecor switch will be 10-12 feet from the Prop-1 that it's connected to.
- Wiring is difficult to pull through the machine and a shielded two-conductor cable is already in place to use.

QUESTION:
Can I get away with putting the capacitor and resistors (for the POT command) at the selector switch end of the cable and thereby only need the two conductors that are already there, or will the capacitor and resistors have to be at the Prop-1 end and I'd be forced to pull more wire?

By the way the POT command works, it looks to me that I may be able to get away with this 10-12 foot length given that the cable is shielded.

Any experience or thoughts?

Thanks,

Tim

JonnyMac

It's ugly, Tim, but then, I tend to be very conservative with my designs (hence I have little trouble with them...).

I would put the cap near the Prop-1 so that the wires and pot form the resistance.  Once you have a reliable POT reading you can divide the reading (which should be somewhere between near 0 and 255) by the number of selections.  Keep in mind that if you have a noisy electrical environment, even with shielded cable you may see the POT value bounce around.  I'd do a lot of testing before putting this into a mission-critical application.
Jon McPhalen
EFX-TEK Hollywood Office

Tim-M

Jon,

Thanks for the information... you've confirmed what I'd hoped was not true, in that it's an ugly way to go.  Since I only need to differentiate bewteen three switch positions, I thought fixed resistors with lots of value difference between them and the POT command might work.  I may do some testing to get a look at the results, but I agree with you that very conservative designs are the better part of wisdom.  The application is not very critical but I would like reliability just the same.

Any other ideas about how to distinguish between three modes using two conductors?

Tim

JonnyMac

January 07, 2008, 03:10:30 PM #3 Last Edit: January 07, 2008, 03:14:08 PM by JonnyMac
Using the POT command is the simplest solution.  Since you're only trying to differentiate between three switch you should be okay.  Use this circuit:



Remember:

1) The cap goes near the Prop-1
2) Remove the ULN for the pin that will be running the POT command (P7 is easy; change the ULN2803 to a ULN2003)

Here's a bit of code to get you started.  Before you actually use this, connect the circuit and move the switch to S3 (10K position) to get the scale value for the POT reading -- it should be somewhere near 100 for those components.  Don't skip this step; you need an accurate scale value for POT for everything else to work correctly.

' =========================================================================
'
'   File...... Pot_Select_3x.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2007 EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Selector        = 7                     ' SETUP = out; no ULN


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

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


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

SYMBOL  selectVal       = B2                    ' read with POT circuit


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

Reset:


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

Main:
  POT Selector, 100, selectVal


Check_S1:
  IF selectVal > 85 THEN Check_S2

Run_S1:
  ' do #1 things here
  GOTO Main


Check_S2:
  IF selectVal > 170 THEN Run_S3

Run_S2
  ' do #2 things here
  GOTO Main


Run_S3:
  ' do #3 things here
  GOTO Main

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


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


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


Since you've got three switches the program divides the max value (255) into thirds for comparisons to determine the position of the selector switch.
Jon McPhalen
EFX-TEK Hollywood Office

Tim-M

Thank you much Jon, this is exactly what I had pictured...  I don't quite understand what changed your mind about this being an ugly solution though?  Or is it that this actually is still ugly, but you feel that it will be reliable enough to be doable?  As you had mentioned, I also came across the POT command scaling information in the help section of the PBasic editor, and it sounds like the correct scaling is critical to any hope of repeatable results.  I had not considered the affect of the ULN2803 on the I/O pin, thank you for that.  Do you recomend a particular type of capacitor for best results with the POT command?

Thanks again for your help and code layout,

Tim

JonnyMac

Well, she's less ugly (since there's only three switches), but I'd be leery about dating her...   ;D

Just don't use a paper cap; get a mylar or something similar.

And ladies, I'm being funny -- no hate mail, please.
Jon McPhalen
EFX-TEK Hollywood Office

Tim-M

I think I have some mylar caps around...  When this is together I'll do some testing and report back on the results.

Thanks for the help and advice Jon!

Tim

Tim-M

I have some epoxy dipped, monolithic ceramic capacitors (+/- 20%) that I like to use as bypass capacitors on all the IC's in my projects.  I'm going to give that a try for this project.  I hope they are not too temperature sensitive for this use.

Tim

JonnyMac

If you keep your project in an enclosure -- especially if the whole thing is indoors -- you shouldn't see wild swings.  The reason for doing the POT scaling after building your circuit is to deal with component variations.  Since you're breaking the POT range into very coarse divisions minor temperature variations should not have an adverse effect on the outcome.
Jon McPhalen
EFX-TEK Hollywood Office

Tim-M

Then we should be O.K.  Yes, the project be fully enclosed (shielded) within the machine that it will be providing automatic functions for.  The machine resides is a partially heated warehouse environment.  Winters in the Pacific Northwest, and summers for that matter, are pretty mild so I'll guess that this project will see a temperature range of 45-80 degrees F at most.  The three course divisions for the POT command are what I'm counting on here, that's for sure.

Tim

Tim-M

Just a quick note....

The company has made another project Priority-1 right now, so I'll be back to this one soon.  Testing and results will be reported on, they will just be delayed a couple of weeks or so.

Tim

P.S. The priority project is also Prop-1 based, by the way!

Tim-M

UPDATE: Initial Testing

  I wanted to test a worst case cable length with the selector switch, so I wired it to the Prop-1 as described above, through 30 feet of cat-5 ethernet cable.  Yep, I said thirty feet!  With the Prop-1 connected to my laptop and running the POT scaling feature in the PBASIC editor, the results look good... much more reliable than was expected.  The resistor values of zero (no resistor used), 4.7K and 10K provide values back from the POT command of 14, 174 and 215.  What surprises me is how repeatable those values are and how little they change when I play with all that cable and the switch.  Plus and minus 1-2 points is all.  First glance seems to show that this may be workable.... we'll have to see how it does when it's is in a more electrically noisy environment.

Tim

JonnyMac

That's great news.  And you may know this, but every pin is protected with a 220-ohm resistor, so that is part of your series resistance (hence your "0-ohm" position is actually 220).
Jon McPhalen
EFX-TEK Hollywood Office

Tim-M

Yes, that's why the no-resistor selection, or capacitor only switch position yields a value of 14 and not 0, if I understand this correctly.

Tim

JonnyMac

The long cable is contributing a little as well.  With the Prop-Pot or Prop-1 Trainer right on the board we usually see a "zero" value of 5 or so.
Jon McPhalen
EFX-TEK Hollywood Office