Putting robotics at your service™

Free shipping on orders over $75

Repeating Sequence or Subprogram FIX!

Print view Share :
Previous topicNext topic

Page 1 of 1 [ 3 posts ]

New ( offline )
Posts: 6
Posted: 2010-03-01 13:21 
It seems that there are some in this Playstation 2 Forum and the SEQ Forum that have complained about repeating sequences or subprograms when a button on the Playstation 2 controller pushed.
I was in the same boat. Every time I pushed a button on my Platstation controller, it would play that sequence, (or now in my case, subprogram) twice. It was driving me crazy!
Well, it seems to be that the program for the controller is TOO fast. And everytime a button is pushed, the index that the variable is stored in, seems to stay even through the next loop around (if that makes any since). In other words, you can't release the button fast enough before the program comes back around, which then plays that sequence again.

There is a Pause 1 on the end of the PS2 subprogram before my button assignments, so I made that a pause 200 and that seem to do the trick for me! In other words, it slowed the program down so I had enough time to take my finger off the button!

Now I don't know if this will work for the SEQ sequences, it should, but not sure. There was talk before about running the sequence only once (in the SEQ forum) and how to do that, which I did, but it still played a sequence at least twice. Here is my program I'm running for my little humanoid:

main program.bas [5.08 KiB]
Downloaded 76 times

I hope this helps anybody who was having this problem. And if anybody has any suggestions that would make it better or more efficient please let me know.
I'm all about learning and keeping an open mind!


User avatar
Novice ( offline )
Posts: 93
Posted: 2010-03-01 18:22 
I have encountered that as well. Good fix! Thanks!!
Can you post your whole program? Where are the walking sequences?

User avatar
Guru ( offline )
Posts: 4937
Posted: 2010-03-01 20:18 
Hi Anthony,

Looks good :)

Another approach is to remember the last state of the buttons and only perform the action if the new state is logically down and the previous state was not...

For example if you look at the PS2 code that is part of the phoenix you will see something like:
  low PS2SEL
  shiftout PS2CMD,PS2CLK,FASTLSBPRE,[$1\8,$42\8]   
  shiftin PS2DAT,PS2CLK,FASTLSBPOST,[DualShock(0)\8, DualShock(1)\8, DualShock(2)\8, DualShock(3)\8, |
     DualShock(4)\8, DualShock(5)\8, DualShock(6)\8]
  high PS2SEL
  pause 10   
  ; Switch bot on/off
  IF (DualShock(1).bit3 = 0) and LastButton(0).bit3 THEN   ;Start Button test

   ... end of function. 
  ;Store previous state
  LastButton(0) = DualShock(1)
  LastButton(1) = DualShock(2)

In this code he is checking the start button and if it is now 0 (pressed down) and the previous one is 1 then he does the action


All times are UTC - 5 hours [ DST ]. It is currently 2015-08-30 15:57
Feedback Form