November 21, 2024, 05:50:25 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.


Valve cycle time testing fixture

Started by gadget-evilusions, March 12, 2010, 07:24:57 AM

Previous topic - Next topic

gadget-evilusions

I am going to build a new project similar to this one, http://www.efx-tek.com/php/smf/index.php?topic=1092.msg6158#msg6158

This time I will be cycling a 24vdc solenoid that will be operating an air piloted valve. I will need to test how long it takes from the activation of the solenoid valve to the open position of the air piloted valve. Then I need to figure out a way to find the minimum and maximum values over 50,000 cycles.

So I will have Solenoid1 on Out 0, Solenoid2 on Out1, Sensor1 on Pin14, Sensor2 on Pin15.

Order of operations would be:
1)Solenoid 1 and 2 on, start timer(s),
2)when Sensor 1 activates display time elapsed, when sensor 2 actiaves display time elapsed. The sensors could be activated at the same time, or 1 could be first, or 2 could be first. Af
3)solenoid 1 and 2 off, pause 2 seconds to allow reset
4)repeat

Here are my questions:

Can I use a normally open PNP sensor with the prop-2 and this set up?

Is it possible to be testing both of these valve set ups on one prop-2 or should I use a prop-2 for each?

Is it possible to output the debug code to a text file or some other usable file so that I don't lose my date each time I restart my testing?
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

Can you give more details on the sensor?  Normally, transistor type outputs are "open collector" (NPN) which is very easy to connect to the Prop-1 or Prop-2.  If you've got a link to the sensor you want to use I can check it out. 

What kind of timing do you expect?  You may need to do some trickery with RCTIME which, in fact, is just a fast state timer.  This will give you 2us to 0.13s.

There is no way to write directly to a file using DEBUG.  You can use SEROUT to P16 which is the same as the DEBUG port and use another terminal program which may in fact make writing to a file easier. 

Jon McPhalen
EFX-TEK Hollywood Office

BigRez

March 12, 2010, 11:16:03 AM #2 Last Edit: March 12, 2010, 11:21:55 AM by bigrez
Quote from: gadget-evilusions on March 12, 2010, 07:24:57 AM
Is it possible to output the debug code to a text file or some other usable file so that I don't lose my date each time I restart my testing?

What about using a Parallax Memory Stick data logger or a RogueRobotics uMMC (or uMP3) device or something similar to record the test results?  They'll log the data onto a memory stick/card that you can save or transfer to the PC.

Not sure about the Parallax device, but the Rogue uMMC has a clock/time feature so that you can work with actual time values (i.e. durations) within the program.

gadget-evilusions

Here is the sensor data sheet. I know you had said previously that NPN is easier to work with, but all we have at work are PNP sensors, our electricans normally use PLC's so it's not an issue.

As for timing, I belive what we tested a few years ago was on average between 30 and 70ms.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

Okay, I think you'll want to connect that sensor as shown in the attached diagram.  The divider should give you a valid high on the input pin when the sensor is active.

You will have to use RCTIME as a high-speed timer (which is what it is).  After you trigger the circuit the next line should be an RCTIME that looks like this:

  RCTIME TimerPin, 1, period

... where period is in 2us increments.


Jon McPhalen
EFX-TEK Hollywood Office

gadget-evilusions

Below is the program I am trying. This would be my first time starting a prop-2 program from nothing so I used Jon's template.

Currently the solenoid valve is cycling and my sensor is seeing the movement (based on it's own led indicator) however my debug comes back as "On...00000" every time. Any help would be appreciated.

' =========================================================================
'
'   File......Bevcorp_Valve_Test_2.bs2
'   Purpose...
'   Author....Brian Warner
'   E-mail....gadget@evilusions.com
'   Started...3-13-2010
'   Updated...
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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


Sensor          PIN     14                      ' SETUP = UP
Solenoid        PIN     0

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

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

#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T2400       CON     396
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T2400       CON     1021
    T38K4       CON     45
  #CASE BS2PX
    T2400       CON     1646
    T38K4       CON     84
#ENDSELECT

Open            CON     $8000
Baud            CON     Open + T38K4            ' B/R jumper installed


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

timer           VAR     Byte
period          VAR     Word

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

Reset:
  OUTS = $0000                                  ' clear all outputs
  DIRS = $0FFF                                  ' make P0-P11 outputs


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

Test:
  period = 0
  Solenoid = IsOn
  RCTIME Sensor, 1, period
  'period = period * 500                      'convert microsecond to millisecond i think
  DEBUG "On..", DEC5 period, CR
  PAUSE 1000
  solenoid = IsOff
  PAUSE 1000
  GOTO Test


' -----[ Subroutines ]-----------------------------------------------------
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

Sorry, Brian, I fouled you -- your program needs the SETUP jumper DN and a change in the RCTIME state parameter.  The state needs to be zero because that what the input is until the valve goes active (which makes the pin high).

' =========================================================================
'
'   File...... Bevcorp_Valve_Test_2.bs2
'   Purpose...
'   Author.... Brian Warner
'   E-mail.... gadget@evilusions.com
'   Started... 3-13-2010
'   Updated... 13 MAR 2010 (JW)
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

Sensor          PIN     14                      ' SETUP = DN
Solenoid        PIN     0


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

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

#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T2400       CON     396
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T2400       CON     1021
    T38K4       CON     45
  #CASE BS2PX
    T2400       CON     1646
    T38K4       CON     84
#ENDSELECT

Open            CON     $8000
Baud            CON     Open + T38K4            ' B/R jumper installed


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

period          VAR     Word
samples         VAR     Word

ms              VAR     Byte


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

Reset:
  OUTS = $0000                                  ' clear all outputs
  DIRS = $0001                                  ' make P0 output

  DEBUG CLS, "Solenoid Speed Test", CR, CR

  Samples = 10

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

Main:
  Solenoid = IsOn
  RCTIME Sensor, 0, period
  PAUSE 1000
  Solenoid = IsOff

Report:
  DEBUG DEC5 samples, ": "
  ms = period / 500                           ' convert to milliseconds
  IF (ms > 99) THEN                           ' right-justify output
    DEBUG DEC3 ms, CR
  ELSEIF (ms > 9) THEN
    DEBUG " ", DEC2 ms, CR
  ELSE
    DEBUG "  ", DEC1 ms, CR
  ENDIF
  PAUSE 1000

  samples = samples - 1
  IF (samples > 0) THEN Main

  DEBUG CR, "End of Test."
  END
Jon McPhalen
EFX-TEK Hollywood Office

gadget-evilusions

Sorry for my trouble with this project.

I am still only getting 0's with your program Jon.

I ran the below program, and I am seeing a state change from 0 to 1 when metal is detected. So the sensor is working.

' =========================================================================
'
'   File...... Bevcorp_Prox_Sensor_Test.bs2
'   Purpose...
'   Author.... Brian Warner
'   E-mail.... gadget@evilusions.com
'   Started... 3-13-2010
'   Updated... 13 MAR 2010
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

Sensor          PIN     14                      ' SETUP = DN



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

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

#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T2400       CON     396
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T2400       CON     1021
    T38K4       CON     45
  #CASE BS2PX
    T2400       CON     1646
    T38K4       CON     84
#ENDSELECT

Open            CON     $8000
Baud            CON     Open + T38K4            ' B/R jumper installed


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

period          VAR     Word
samples         VAR     Word

ms              VAR     Byte


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

Reset:
  OUTS = $0000                                  ' clear all outputs
  DIRS = $0001                                  ' make P0 output

  DEBUG CLS, "PNP Prox Sensor Output Test", CR, CR



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

Main:
  DEBUG " ", DEC2 Sensor, CR
  PAUSE 1000
  GOTO main

Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

Hmmm.... if you can see the sensor change state then the duration may be more than 131 milliseconds -- max value for RCTIME.  Do you have a 'scope you can use to watch the output?  You'd need to trigger on the control channel (going from low-to-high) and then measure the period until the sensor input goes high.

Just for grins, remove the SETUP jumper and the ULN influence on the sensor pin.  The parallel resistance of the SETUP jumper and the pull-down in the ULN may be causing the low side of the divider to be on the ragged edge of the low-to-high transition.
Jon McPhalen
EFX-TEK Hollywood Office

gadget-evilusions

I would say I am overrunning the RCTIME function then.

I simplified and went with this

Main:
period = 0
Solenoid = IsOn
FOR reps = 1 TO 250
  period = period + 1
  IF sensor = 1 THEN Report:
NEXT

Report:
  solenoid = IsOff
  DEBUG DEC4 period, ": " ,CR
  PAUSE 1000
  GOTO Main:
  END

It's not as accurate, but it will work for what I need I belive. It's returning values of between 112 and 120. I am not sure how that offically converts into ms but I am not that worried.

Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

This morning I remembered that my friend, Dr. Tracy Allen (the coolest PhD I know), had done extensive timing tests on the BS2 family and published them here:

http://www.emesystems.com/BS2speed.htm

Looking further, he has a specific for pulse timing that exceeds what RCTIME can handle -- that is here:

http://www.emesystems.com/BS2speed.htm#longpulse

Just a note: he's using P0 as the input and that *could* make a small difference in timing.   For the timing being, though, I think this will get you very close to measuring the sensor timing and converting to milliseconds:

' =========================================================================
'
'   File...... Bevcorp_Valve_Test_3.BS2
'   Purpose...
'   Author.... Brian Warner
'   E-mail.... gadget@evilusions.com
'   Started... 3-13-2010
'   Updated... 14 MAR 2010 (JW)
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

Sensor          PIN     14                      ' SETUP = DN
Solenoid        PIN     0


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

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

#SELECT $STAMP
 #CASE BS2, BS2E, BS2PE
   T2400       CON     396
   T38K4       CON     6
 #CASE BS2SX, BS2P
   T2400       CON     1021
   T38K4       CON     45
 #CASE BS2PX
   T2400       CON     1646
   T38K4       CON     84
#ENDSELECT

Open            CON     $8000
Baud            CON     Open + T38K4            ' B/R jumper installed


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

cycles          VAR     Word
period          VAR     Word
ms              VAR     Word


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

Reset:
 OUTS = $0000                                  ' clear all outputs
 DIRS = $0001                                  ' make P0 output

 DEBUG CLS, "Solenoid Speed Test", CR, CR


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

Main:
 cycles = 0

Test:
 period = 0
 Solenoid = IsOn

Run_Timer:                                      ' 0.705ms per loop
 period = period + 1
 BRANCH Sensor, [Run_Timer]

 Solenoid = IsOff

Report:
 ms = period ** 46217                          ' ms = period x 0.705
 DEBUG DEC ms, CR
 PAUSE 1000
 cycles = cycles + 1
 IF (cycles < 100) THEN Test

 DEBUG CR, "End of Test."
 END


I would still caution you that a verification with another piece of test equipment should be used -- loop timing on P14 as the input could be different.  If you have a Prop-SX I could write a program that would be more precise.
Jon McPhalen
EFX-TEK Hollywood Office

gadget-evilusions

Thanks Jon.

I am now getting between 150 and 160. So I was over running the RCTIME by just a little.

I think in the future I may try to integrate the parallax datalogger that BigRez linked to higher in this thread, but I will be just fine for a while.

Thank you.

Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

gadget-evilusions

My day job now wants me to build two of these fixtures, each using a seperate prop-2 and datalogger. I have looked at the docs on the parallax data logger http://www.parallax.com/Store/Accessories/CommunicationRF/tabid/161/CategoryID/36/List/0/Level/a/ProductID/434/Default.aspx?SortField=ProductName%2cProductName and would like to incorporate it into the last program that Jon posted.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

gadget-evilusions

Jon,

I have two options for continuing with this project.

1) I need some help with the code to output my data to the parallax datalogger instead of the debug screen. http://www.parallax.com/Store/Accessories/CommunicationRF/tabid/161/CategoryID/36/List/0/Level/a/ProductID/434/Default.aspx?SortField=ProductName%2cProductName

2) I need to output the min, max, and average timing values along with the number of cycles to an lcd screen.  https://www.parallax.com/tabid/768/ProductID/50/Default.aspx

Which ever is easier.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

Brian,

I really think you're going to want to go with Option 1; the 16-bit math limit of the BASIC Stamp may hamper your ability to keep a running average after more than just a few samples.

I've never used the Parallax data logger -- will have to get one.  That said, you can go step-by-step by using DEBUG for the time being.  What you would want to do is use DEBUG to create what looks like a CSV (comma-delimited file).  Later, when you have the data logger connected, you can convert the DEBUG statement to a SEROUT that is directed to an open file on the data logger.

Here's the program modification:

' =========================================================================
'
'   File...... Bevcorp_Valve_Test_4.BS2
'   Purpose...
'   Author.... Brian Warner
'   E-mail.... gadget@evilusions.com
'   Started... 4-13-2010
'   Updated... 01 APR 2010 (JW)
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

Sensor          PIN     14                      ' SETUP = DN
Solenoid        PIN     0


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

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

#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T2400       CON     396
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T2400       CON     1021
    T38K4       CON     45
  #CASE BS2PX
    T2400       CON     1646
    T38K4       CON     84
#ENDSELECT

Open            CON     $8000
Baud            CON     Open + T38K4            ' B/R jumper installed


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

cycles          VAR     Word
period          VAR     Word
ms              VAR     Word


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

Reset:
  OUTS = $0000                                  ' clear all outputs
  DIRS = $0001                                  ' make P0 output

  DEBUG CLS                                     ' clear screen


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

Main:
  FOR cycles = 1 TO 100
    GOSUB Test_Valve
    DEBUG DEC cycles, ", ", DEC ms, CR          ' create CSV output
    PAUSE 1000
  NEXT

  STOP


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

Test_Valve:
  period = 0
  Solenoid = IsOn

Run_Timer:                                      ' 0.705ms per loop
  period = period + 1
  BRANCH Sensor, [Run_Timer]

  Solenoid = IsOff
  ms = period ** 46217                          ' ms = period x 0.705

  RETURN


When the test is done you have to get the data from the DEBUG window -- manually.  Press Ctrl-A to select everything and then Ctrl-C to copy it to the clipboard.  You must use the keyboard to do this as any mouse click will deselect the data.  Now open Notepad and use Ctrl-V to paste the data in.  Save this with a .CSV extension.  You can open this file in Excel and do anything you want with it, with far more mathematical precision than just using the BASIC Stamp.

Once you've got that working we'll sort out the data logger.

Jon McPhalen
EFX-TEK Hollywood Office