Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Monitor rotation-interfacing with Mala - help request (SOLVED)  (Read 4523 times)

0 Members and 1 Guest are viewing this topic.

TopJimmyCooks

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2097
  • Last login:March 26, 2024, 01:18:39 pm
The story so far:
I have made a little proof of concept model for my upcoming rotating LCD project.  It is based on the Pololu simple motor driver connected to the PC via USB.  2 limit switches and a Pololu geared motor from them complete the system.  It's the same equipment as DNA Dan ended up with in his Plain Old Arcade build.  Everything works great, I can run the motor via Pololu's Simple Motor Controller windows software, as well as by their SMCCMD command line setup.  I can even use AHK to control the motor via keyboard commands.  Right now the motor runs to the reverse limit when the left bracket key is pressed, and vice versa on right bracket key.

What I want to do:
I want to auto rotate on mala start of a game in the opposite orientation, same as everybody.
I want to auto rotate back to horizontal on mala exit (i.e. keep the state by always starting from horizontal.
It would be nice to be able to switch on a key combination or something to recover if something gets messed up.

What I have tried to do:
Under Mala 174, I downloaded and installed Startcom from the mala-fe.net site.  I compiled an AHK script to exe and named it rotate both ways.  It works under windows, rotating each way per the bracket keys as noted above.  I put this exe in the top "rotating program" slot in the plugin configuration.  In the boxes for the rotation calls, I put the brackets.  Tried it out, no dice.  I realize startcom was intended for Mrotate, which I don't have installed, since I am not doing the parallel port.  I tried other stuff, like leaving the script running, entering mala, deleting the rotate program path from startcom, leaving the bracket calls.  No dice, obviously I'm barking up the wrong tree.

Is there an easy way to do what I'm looking at?  Either send command line arguments prior to game launch or keystrokes that get to AHK?  If so, how do I get the information about whether the game is horizontal/vertical?  

I have reviewed other build threads to see if someone has resolved this:
  • Ond: going to write a VB program to rotate controlled via Serial.  (I can do virtual serial port per the Pololu manual)
  • DNA Dan:  going to rotate via switch until HS 2.0 comes out.
  • Da Old Man, weisshaupt, cornchip, dannygalaga, others - variations of the parallel port system well described by DaOldMan.

Thank you.


« Last Edit: June 08, 2011, 11:26:46 am by TopJimmyCooks »

DaOld Man

  • Trade Count: (+4)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5139
  • Last login:December 13, 2023, 12:03:14 am
  • Wheres my coffee?
    • Skenny's Outpost
Re: Monitor rotation-interfacing with Mala - help request
« Reply #1 on: June 06, 2011, 09:27:25 pm »
I dont see why it wouldnt work. Maybe startcom is broke with that version of Mala?
Im using 162G.
I will try to download 174 and do some testing with MRotate.

DaOld Man

  • Trade Count: (+4)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5139
  • Last login:December 13, 2023, 12:03:14 am
  • Wheres my coffee?
    • Skenny's Outpost
Re: Monitor rotation-interfacing with Mala - help request
« Reply #2 on: June 06, 2011, 09:53:54 pm »
Ok, I tested Mala 1.74 with Mrotate2, and it seems to work just fine for me.
I tried changing horizontal command to [ and vertical to ] and they worked.
Im not sure what your problem is, maybe if you can email me your AHK script I can troubleshoot it better.
PM if interested.
Also, make sure your path to the AHK file in startcom is correct, startcom wont warn you if its not.

EDIT: The "program" box in startcom must contain complete path and program name in it.
Example: "C"\Mrotate\mrotate.exe"   (minus the quote marks)

One More EDIT: A picture is worth a thousand words:
« Last Edit: June 06, 2011, 10:09:24 pm by DaOld Man »

TopJimmyCooks

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2097
  • Last login:March 26, 2024, 01:18:39 pm
Re: Monitor rotation-interfacing with Mala - help request
« Reply #3 on: June 07, 2011, 09:08:20 am »
Here is what I tried.  I am new to AHK and basically understand it but I don't have any experience to fall back on.  I took the example script Pololu gave and just changed the hotkeys.

Code: [Select]
;rotate both ways.ahk later converted to .exe

[:: Run smccmd --resume --speed 1500,,Hide
]:: Run smccmd --resume --speed -1500,,Hide
Return


Works ok in windows xp, I can manually run the exe, keypress runs it forward or back until it hits the switch, then on keypress it will only go the other way until it hits the other switch.  I had the full path to the .exe in the top startcom window.  When I exit mala after it doesn't work, the script is running in the system tray.

I know i need to change the script to either close down after one run, or to handle being re initiated, a box pops up the 2nd time it is called asking if it should be re-run. there is a command in AHK that controls this, just haven't studied it yet.  maybe taking out the return statement would take care of it.

I really appreciate the help and good to know that startcom should work in this situation.   

TopJimmyCooks

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2097
  • Last login:March 26, 2024, 01:18:39 pm
Re: Monitor rotation-interfacing with Mala - help request
« Reply #4 on: June 07, 2011, 05:22:25 pm »
I had the idea to try leaving autohotkey out of it.  In startcom:

changed the path to rotation program to the location.  Note, this smccmd program runs from any prompt regardless of whether I'm in the right directory, so it's set up in the registry or whatever allows that.  In this case:

C:\Program Files\Pololu\Simple Motor Controller\Bin

changed the horiz and vert commands to the command line program with arguments

smccmd --speed 1500
and
smccmd --speed -1500

saved and tried to run in mala.  I used the desktop control program to set the motor somewhere in the middle, then closed it and opened a dos prompt window.  Tried to run a couple of vertical then horizontal games.  one time Mala crashed, 2 times I could play the game but no movement on the motor.  I exited and went to the command prompt window, the command was there.

Still experimenting, any input is welcome.  I need to see if mala can run in a window so I don't have to exit to the desktop and restart everytime I need to do anything. 

DaOld Man

  • Trade Count: (+4)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5139
  • Last login:December 13, 2023, 12:03:14 am
  • Wheres my coffee?
    • Skenny's Outpost
Re: Monitor rotation-interfacing with Mala - help request
« Reply #5 on: June 07, 2011, 07:43:05 pm »
Im not sure, but in startcom try taking out the dashes (--)
You can also try to run a dos bat file called from startcom.
Then the bat file can call the other script. If the script works from DOS CMD window, a bat file should have no trouble running it.


TopJimmyCooks

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2097
  • Last login:March 26, 2024, 01:18:39 pm
Re: Monitor rotation-interfacing with Mala - help request
« Reply #6 on: June 07, 2011, 08:05:34 pm »
.bat is a good idea, I will do that and report back.  The dashes are part of the required smccmd syntax.   

I am considering getting a different version of the motor controller; they have one that accepts feedback on the position of the motor/counts pulses.  could be the beginning of a no limit switch system similar to the step motor guys.  If I do, I could send you this controller - donate it to the cause so to speak, if you are interested in messing with it.   

TopJimmyCooks

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2097
  • Last login:March 26, 2024, 01:18:39 pm
Re: Monitor rotation-interfacing with Mala - help request
« Reply #7 on: June 07, 2011, 08:24:54 pm »
Ok, I can rotate either way from windows by calling .bat files from dos box or windows explorer.

RotatePositive.bat
c:\mala174\smccmd --speed 1500

RotateNegative.bat
c:\mala174\smccmd --speed 1500

I tried:
*using one of these bat's as the program in the first startcom box, with path, using the 2 batch files, with and without path, no dice.  I get "loading screen" then a quick flash back to the layout, then game start.  I have never gone back to a 1 second view of the layout after loading screen, before game start before, and it goes away if I take out startcom.

*same thing with nothing in the program location box, same results. 

does startcom have to reference an executable in the first box, then get arguments from the horiz and vert box?  this is what happens with Mrotate, right?  you establish mrotate as the executable and it runs mrotate.exe [horizontal or vertical argument]?

is there such thing as a bat file that you run and supply arguments to?  variables?  I will look into this but let me know if the executable is required. 
Thanks for working with me on this. 

DaOld Man

  • Trade Count: (+4)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5139
  • Last login:December 13, 2023, 12:03:14 am
  • Wheres my coffee?
    • Skenny's Outpost
Re: Monitor rotation-interfacing with Mala - help request
« Reply #8 on: June 07, 2011, 08:40:47 pm »
Startcom has to have the exe or bat file in the program box then the command line arguments in the other boxes.
You can send arguments to a batch file.
Its been a while but  I think its similar to :

In the bat file:

If %1 goto :rotateh
If %2 goto :rotatev
goto :end

:rotateh
'''' your rotate horiz. code here
goto :end
:rotatev
''' your rotate vert code here
:end

Then startcom would call the bat file with arguments of 1 or 2, based on rotation needed.

Im not sure if the above syntax is correct, but it should be similar.
Google "batch file arguments" or "batch file commands", you should find examples.

TopJimmyCooks

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2097
  • Last login:March 26, 2024, 01:18:39 pm
Re: Monitor rotation-interfacing with Mala - help request
« Reply #9 on: June 07, 2011, 11:06:53 pm »
I will work on the bat file thing tomorrow, I'll go into work a little early and study up on them.  Thanks.

TopJimmyCooks

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2097
  • Last login:March 26, 2024, 01:18:39 pm
Re: Monitor rotation-interfacing with Mala - help request
« Reply #10 on: June 08, 2011, 12:57:54 am »
Ok, I got the batch file thing working on my system.  Mad props to the king of all rotation, DaOldMan!  :burgerking:

here it is for the edification of future DOS challenged (like me) usb rotistas. 
Code: [Select]
If "%1"=="1" goto rotatepositive
If "%1"=="2" goto rotatenegative
goto end

:rotatepositive
smccmd --speed 1500
goto end

:rotatenegative
smccmd --speed -1500
:end

As per the thread above, the smccmd and speed stuff is related to the particular usb motor controller in use here, but the rest is good to go for any motor control software to be run via .bat.  As per startcom documentation, I put the full path of the .bat file in the first box, and the arguments 1 and 2 for horiz and vert in the appropriate boxes and it works great. 

Again, great help and you've got first dibs on this usb controller if I replace it.  I will pm you.   :cheers:

DaOld Man

  • Trade Count: (+4)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5139
  • Last login:December 13, 2023, 12:03:14 am
  • Wheres my coffee?
    • Skenny's Outpost
Re: Monitor rotation-interfacing with Mala - help request
« Reply #11 on: June 08, 2011, 06:43:54 am »
Im glad you got it figured out.
Im looking forward to seeing pics and videos of your work.
If you want to play around with startcom without the bat, try placing smccmd along with the path in the program box,
then --speed_1500 in horizontal box and --speed_-1500 in vertical. (Substituting SPACE with  UNDERSCORE)

It may be the space in the command boxes that startcom doesnt like.

But if the bat file does what you want it to, then you may want to leave well enough along.

Thanks for the kudos and the only thing Im king of is the house, and thats only when its ok with the wife :)