November 22, 2024, 07:28:22 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Issues with pots - also need help with code (I think)

Started by BrandonKelm, April 09, 2012, 12:53:38 PM

Previous topic - Next topic

BrandonKelm

April 09, 2012, 12:53:38 PM Last Edit: April 09, 2012, 02:07:36 PM by JonnyMac
Hey guys,

My name is Brandon.  I'm a newbie when it comes to the EFX-TEK products, but I have a pretty solid grasp when it comes to electronics in general. 

I'm having some issues with getting some POT's to work on my Prop1.

Currently what I have configured is; (4) POT's on 7, 5, 4 and 3.  Trigger on 6.  Output to valves on 0, 1 and 2.

When I go into POT Scaling, the POT's on 7 and 5 read fine, giving me readings of 255 when fully CCW and 117-121 when fully CW.  The POT's connected to 4 and 3 stay at 255, regardless of their position.  If I check the "POT Value" box, I get readings of 2-15 for either of them, depending on position.  If I swap "known good pots" from pin 7 to either pin 3 or 4, still no dice.  The pots are 10k linear's with a 0.1uF poly film cap on the white line (I'm assuming this is for smoothing?)

Using a 2083 array, pins 1, 3, 4 and 5 (and their neighbor to the right) are bent up for POT usage. 

Using the code below, it sort of works but has some issues. 

When triggered, OUT0 is going high for 2 seconds, when it should be OUT2. 

From there, the pre-delay pot works, as does the AirPot and AirValve.  The WaterValve comes on for a brief moment, I'm assuming this has to do with it not reading the WaterPot correctly.  The PostPot doesn't work at all.

While we're having this conversation, can someone explain to me how the timing works in reference to the POT?  IE, "raw * 20 MIN 50", what kind of real world time is that going to be?  Also, in the code below, prior to "raw" in the POT line, that is where the scaling value is entered, correct?

Thanks for the help.

-Brandon

' =========================================================================
'
'   File...... Machine_gun.BS1
'   Purpose...
'   Author.... 
'   E-mail.... 
'   Started...
'   Updated... 10 OCT 2006
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  PrePot          = 7
SYMBOL  Trigger         = PIN6
SYMBOL  AirPot          = 5
SYMBOL  WaterPot        = 4
SYMBOL  PostPot         = 3
SYMBOL  PulseOut        = PIN2
SYMBOL  WaterValve      = PIN1
SYMBOL  AirValve        = PIN0


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

SYMBOL  IsOn            = 1                     ' for active-high input
SYMBOL  IsOff           = 0

SYMBOL  Variable        = 0                     ' use Prop-Pot, variable



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

SYMBOL  raw             = B2                    ' raw pot reading
SYMBOL  delay           = W1                    ' valve delay
SYMBOL  timer           = B3


' -----[ EEPROM Data ]-----------------------------------------------------


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

Reset:
  DIRS = %00000011                              ' make P0,P1 an output

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

Main:


  timer = timer + 5 * Trigger                       ' advance/clear timer
  IF timer < 250 THEN Main                       ' wait for valid signal

HIGH PulseOut                                   ' send pulse to trigger external controller
PAUSE 2000
LOW PulseOut

Pre:
  POT PrePot, 121, raw                          ' read pot, 0 - 255
  delay = raw * 20 MIN 50                     ' make 5 - 5,000
  PAUSE delay

Air:                                      ' get time from POT
  POT AirPot, 117, raw                          ' read pot, 0 - 255
  delay = raw * 20 MIN 50                       ' make 5 - 5,000
  AirValve = IsOn
  PAUSE delay
  AirValve = IsOff

Water:                                      ' get time from POT
  POT WaterPot, 103, raw                          ' read pot, 0 - 255
  delay = raw * 20 MIN 50                       ' make 5 - 5,000
  WaterValve = IsOn
  PAUSE delay
  WaterValve = IsOff

Post:
  POT PostPot, 103, raw                          ' read pot, 0 - 255
  delay = raw * 20 MIN 50                       ' make 5 - 5,000
  PAUSE delay

GOTO Main



' -------------------------------------------------------------------------
- Brandon Kelm
Evilusions

JonnyMac

April 09, 2012, 02:07:15 PM #1 Last Edit: April 09, 2012, 04:26:44 PM by JonnyMac
Welcome to the forums and EFX-TEK.

Here's an update.  I've re-assigned variables to ensure one doesn't stomp on another and fixed the code that does the pulse output (renamed that pin, too).  You cannot use HIGH and LOW with a SYMBOL defined with PINx -- that's why I have the IsOn and IsOff constants.

See this thread: http://www.efx-tek.com/php/smf/index.php?topic=1773.0

Here's a clean version of the program.  Note that it's always a good idea to update the header; I don't think that's a machine gun program and I didn't write it. ;)  (I removed my name from the code in your post).

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated... 09 APR 2012
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  PrePot          = 7                     ' no SETUP, remove ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  AirPot          = 5                     ' remove ULN
SYMBOL  WaterPot        = 4                     ' remove ULN
SYMBOL  PostPot         = 3                     ' remove ULN
SYMBOL  PulsePort       = PIN2
SYMBOL  WaterValve      = PIN1
SYMBOL  AirValve        = PIN0


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

SYMBOL  IsOn            = 1                     ' for active-high input
SYMBOL  IsOff           = 0


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

SYMBOL  timer           = B2                    ' debounce timer
SYMBOL  raw             = B3                    ' raw pot reading

SYMBOL  delay           = W5                    ' valve delay


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

Reset:
  PINS = %00000000                              ' all off
  DIRS = %00000111                              ' make P0..P2 outputs


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

Main:
  timer = timer + 5 * Trigger                   ' advance/clear timer
  IF timer < 250 THEN Main                      ' wait for valid signal

  PulsePort = IsOn                              ' pulse to ext controller
  PAUSE 2000
  PulsePort = IsOff

Pre:
  POT PrePot, 121, raw                          ' read pot, 0 - 255
  delay = raw * 20 MIN 50                       ' make 50 - 5,100
  PAUSE delay

Air:                                            ' get time from POT
  POT AirPot, 117, raw                          ' read pot, 0 - 255
  delay = raw * 20 MIN 50                       ' make 50 - 5,100
  AirValve = IsOn
  PAUSE delay
  AirValve = IsOff

Water:                                          ' get time from POT
  POT WaterPot, 103, raw                        ' read pot, 0 - 255
  delay = raw * 20 MIN 50                       ' make 50 - 5,100
  WaterValve = IsOn
  PAUSE delay
  WaterValve = IsOff

Post:
  POT PostPot, 103, raw                         ' read pot, 0 - 255
  delay = raw * 20 MIN 50                       ' make 50 - 5,100
  PAUSE delay

  GOTO Main
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

QuoteWhile we're having this conversation, can someone explain to me how the timing works in reference to the POT?  IE, "raw * 20 MIN 50", what kind of real world time is that going to be?  Also, in the code below, prior to "raw" in the POT line, that is where the scaling value is entered, correct?

On the scaling... This is important as the POT circuit is an RC value and things can change, component to component.  By scaling (using the internal utility) we can update the POT command so that it returns a value between 0 and 255.  Note that on the Prop-1 it will never go all the way down to zero because we have a small resistor in series with the pin on the board for protection.

On the math... On the Prop-1 you're going to get a value between about 5 and 255 from the pot.  By multiplying by 20 you modify that value from 100 to 5100.  The MIN operator will ensure that your delay is at least 50, but I don't think you'll ever see this happen -- again, the inline protection resistor puts a minimum value on the pot circuit.

Important note: Math on the Prop-1 is evaluated strictly left-to-right; there is not operator precedence.

Jon McPhalen
EFX-TEK Hollywood Office

BrandonKelm

Thanks for the help with the code Jon.

Any idea on the POT's on pin's 3&4 not working?
- Brandon Kelm
Evilusions

JonnyMac

Hard to say.  Check your pot circuits and try them on known working pins.  As a quick test I would completely pull the ULN just to make sure that is not an issue.
Jon McPhalen
EFX-TEK Hollywood Office

BrandonKelm

Thanks again for the help Jon.

After speaking with you on the phone, your suggestion of there being an issue with the ULN still contacting the socket was in fact the problem.  I bent the pins completely up with the help of a 1/8" flat screwdriver so they no longer make contact with the socket.  All 4 POT's are working now, as are all of the outputs. 

- Brandon Kelm
Evilusions

JonnyMac

Jon McPhalen
EFX-TEK Hollywood Office