November 24, 2024, 04:35:57 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


some basic questions

Started by hippofeet, September 06, 2012, 11:32:21 AM

Previous topic - Next topic

hippofeet

I know i should read more, but..

In the programming, does the spacing need to be exact?

Input blah, blah             spacing             'blabberty blah

Am I counting the spaces? Or just lining up the second column wherever?

All i want is for whatever output (outx) to run a 12v dc servo, switching it as fast as possible. I assume it will be able to switch faster than the servo will operate, can I just not care? So that it activates again as soon as the servo resets? Or will it mess up the operation of the servo if I do not time it correctly?

In apple II e basic, it would look like this, if you were me and hadnt done any apple programming since you were 8 years old, and now you are 40.

line 1 =  goto line 2

line 2 = fire servo/send 12vdc to servo

line 3 =  stay on for .5 seconds

Line 4 = if .5 seconds is over turn off

line 5 = stay off for .5 seconds

line 6 = goto line 1

and then it would just repeat. if i can figure out how to get it to run forever, i will figure out a chunk of programming to make it time out in like 2 minutes, or whenever the air tank is getting empty.

I searched machine gun, but it looks so complicated to just get it to trip on and off repeatedly. I must be missing something.

Anyhow, if anyone can help, or direct me to something already written, i would appreciate it.

Hippo

hippofeet

Maybe I should add that I have a maestro controller, but you cant press the button fast enough. its like there is a lag built in to the controller. I can fire the servo faster with a push button switch, so i know the servo is resetting faster than the maestro.

IMTim

The Maestro is good but limited.  You never seem to get it quite right and have to start over...

If no one has answered your question by the time I get home from work I'll write you something to get you on the right track.  You can set it up to start as soon as you power it up or press a button.  It's actually very easy.

I'll look in and see if someone answered your question in a couple of hours.

Tim
"We had become the thing we hate. We are better dead."

Sparlimb Keelsetter "The Illearth War"

hippofeet

Thanks! Im at work, and expected to learn all about this thing FOR work. Obviously, im in trouble. Im supposed to be the welder! But I think I can design some really cool props, once i get a good basic understanding of the thing.

JonnyMac

QuoteIn the programming, does the spacing need to be exact?

No, the only thing that matters is correct syntax. That said... you do yourself no favors by sloppily entering code. I've been doing this over 35 years; it takes no more time to format a program neatly than it does to bash it in. The up-side of neat formatting is that errors are far easier to spot, and when you come back to a program written some time ago it's easier to get reacquainted with.

QuoteAm I counting the spaces? Or just lining up the second column wherever?

Again, no. White space (spaces, blank lines, etc.) do not matter. The actual working code is compiled into a special format that strips out everything except working code, and if fact turns that into what are called byte-codes. This is why we cannot retrieve a program from the memory; it has been converted to a machine-only form. So back-up your important programs.

QuoteI must be missing something.

Probably.  Have a look at the program (built in our standard template) that gives you a trigger input and can run your "machine gun" for as long as you like (okay, up to 65535 seconds, which is 1092 minutes).  The way this program works is that you press a button on P6 and it will pulse your output to the time you set (in seconds). 

There are a couple small tricks in the trigger input section, but that you can trust works (and prevents false triggers).  You can see that the operational code is quite simple.

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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Barrel          = PIN0                  ' use V+/OUT0 for valve


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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  TrOn            = 1                     ' active-high trigger
SYMBOL  TrOff           = 0

SYMBOL  IsOn            = 1                     ' active-high I/O
SYMBOL  IsOff           = 0

SYMBOL  Baud            = OT2400


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

SYMBOL  timer           = W5                    ' for debounce loop


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

Power_Up:
  ' put code here that only happens at power-up/hard reset

Reset:
  PINS = %00000000                              ' all off
  DIRS = %00111111                              ' P5..P0 are outputs


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

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  PAUSE 5                                       ' scan delay
  IF Trigger = TrOff THEN Main                  ' check trigger input
    timer = timer + 5                           ' update timer
  IF timer < 100 THEN Check_Trigger             ' check timer

  timer = 2 * 60                                ' set run time (2 min)

Machine_Gun:
  Barrel = IsOn
  PAUSE 500                                     ' hold 1/2 second
  Barrel = IsOff
  PAUSE 500
  timer = timer - 1                             ' update timer
  IF timer = 0 THEN Reset                       ' done?
    GOTO Machine_Gun                            '  no, keep going


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


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


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

hippofeet

Thank you. I am typing that exactly into the register, correct?

JonnyMac

You can drag-select, copy and paste right into the BASIC Stamp editor. Then save it.
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

Quote from hippofeet:
QuoteMaybe I should add that I have a maestro controller

Are you trying to write code for a Prop-1?

hippofeet

I am trying to write code for a prop 1. I will drag and paste the program above for the basic stamp editor, and I appreciate the help. I need to learn all the rules, I have a feeling i am going to be asked to do a lot of things with that controller, so the more i know the better. I just dont want to end up learning this at home on my time, for nothing. And i have a lot to do here when I am at work, so... I am limited on the time I have to learn. If I can get the above program to work, it will be a good start.

thanks for the help.

hippofeet

Ok. Nothing.

I pasted the program into the stamp editor, and with the prop 1 card plugged into the usb port and powered, ran the program. The editor did a thing with a bar, and it said 100%. I unplugged the usb, and hooked up a 12v dc solenoid up to V+ (red wire on solenoid) and out0 (black wire). nothing. I hit reset. nothing. I touched the black wire to ground on the card, and it trips the solenoid, and stays on. touching any wires in any combination to any other outputs, nothing happens.

I read the programming handout again. Greek,lol.

So... I dont know.

hippofeet

Got it. I needed to jump p6 w and r, to trigger the device. So i can use a motion detector as a trigger, or a pressure mat. Now i just need the program to run faster, so i will figure out how to do that in the programming.

thanks.

IMTim

To use a PIR (motion detector) you might want to change the code you have for the switch, the one with the line header: Check_Trigger

If you search the forums you'll find plenty of help on PIR's. Just cut and paste the stuff in. I highly suggest you read through the forums to get ideas on how to make the Prop-1 do what you want. 

You can check out: http://wolfstone.halloweenhost.com/Controllers/ctlmap_HauntControllerRoadMap.html

There are a lot of tips on how and why to program the Prop-1.

These are great controllers and with a little imagination you do wonders. 

Tim
"We had become the thing we hate. We are better dead."

Sparlimb Keelsetter "The Illearth War"

hippofeet

Thanks IMTim

I have it doing mostly what I want. I changed the pause values from 500 to 50, and it cycles the solenoid fast enough. now I need to insert a pause between bursts. I will look around, and see if I can find a pause routine.

JonnyMac

September 07, 2012, 11:06:17 AM #13 Last Edit: September 07, 2012, 11:10:43 AM by JonnyMac
QuoteNow i just need the program to run faster...

I suspected you would after running the program on a Trainer board -- still, I posted per your specs so you could see it.  Here's the main body of the program updated to run 10x faster (per your post).

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  PAUSE 5                                       ' scan delay
  IF Trigger = TrOff THEN Main                  ' check trigger input
    timer = timer + 5                           ' update timer
  IF timer < 100 THEN Check_Trigger             ' check timer

  timer = 2 * 60 * 10                           ' set run time (2 min)

Machine_Gun:
  Barrel = IsOn
  PAUSE 50                                      ' hold 1/20 second
  Barrel = IsOff
  PAUSE 50
  timer = timer - 1                             ' update timer
  IF timer = 0 THEN Reset                       ' done?
    GOTO Machine_Gun                            '  no, keep going


I marked in red the lines that changed. Note that as I divided the delays by 10 (from 500 to 50) we have to multiply the timer value by 10 so that the duration is maintained.

QuoteI will look around, and see if I can find a pause routine.

If you'll just spell out exactly how you want the program to behave I will write if for you. Your prop is unique to you, and you may not find anything that matches. Having written well over 1000 programs for the BS1 processor (used in the Prop-1), I know a lot of tricks and how to apply them once I have a specification. Note that the root word of specification is specific. :)
Jon McPhalen
EFX-TEK Hollywood Office

hippofeet

Actually, I managed to write in/modify the original code, to exactly what you have above. It made sense to just lower the pause values, and I got it with trial and error. Now I need a pause sequence inserted. So the solenoid fires for say 2 seconds, pauses for for 2 seconds, then repeats the cycle for 2 minutes. I tried splicing in the jack in the box code, and removing the already defined values, and variables, but it didnt work, I could not cut the right lines to get it to run. This is working, and im pretty happy with the prop 1 already.