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: OT: Ipac Controller -----> Excel  (Read 2029 times)

0 Members and 1 Guest are viewing this topic.

Jim

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 2
  • Last login:March 06, 2003, 02:00:44 am
  • I want my own arcade controls!
OT: Ipac Controller -----> Excel
« on: March 05, 2003, 05:12:32 am »
Heres a different one to have a look at.

We have used an IPAC controller at work to connect the counters from 4 injection molding machines to a PC.

We are looking for a cheap and easy solution and after building my cabinet I had some ideas.

What I am trying to do is use the simulated key presses from the IPAC to record how many parts each machine has made. As we already use excel for a lot of our planning we would like each keypress to increase the value in a particular excel cell by 1.

EG CELL A1 value increase by 1 each time the "s" key is pressed.
     CELL B1 value increase by 1 each time the "a" key is pressed.

This needs to run continuously and perhaps have an easy way of reseting any of the cells to 0

Unfortunately I spent too much time playing arcade games as a kid and not enough learning skills like excel / vba programming. ;D

We are only a small company and do not have an IT department that we can rely on. I have asked around elsewhere and someone did give me the following VBA solution but my skills dont extend far enough to implement it....

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Application.OnKey "a", ""
Application.OnKey "s", ""
Application.OnKey "d", ""
Application.OnKey "f", ""

End Sub

Private Sub Workbook_Open()

Application.OnKey "a", "AddOne"
Application.OnKey "s", "AddOne"
Application.OnKey "d", "AddOne"
Application.OnKey "f", "Addone"

End Sub

Then this in standard module

Sub AddOne()

Sheet1.Range("A1").Value = Sheet1.Range("a1").Value + 1

End Sub


I am taking a shot that there is someone here who can see what I am trying to do and could perhaps help me out or point me in a direction of people who could.

Hey if someone could sort it for me I am sure we could work out some $ for them.

Sorry for the OT . Jim

Minwah

  • Trade Count: (+3)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7662
  • Last login:January 18, 2019, 05:03:20 am
    • MAMEWAH
Re:OT: Ipac Controller -----> Excel
« Reply #1 on: March 05, 2003, 09:24:54 am »
Must it be in Excel??  I could write a VB program to do that in <5 minutes...

FractalWalk

  • Trade Count: (0)
  • Newbie
  • *
  • Offline Offline
  • Posts: 0
  • Last login:September 20, 2010, 06:12:37 pm
  • Life is time spent fighting entropy.
Re:OT: Ipac Controller -----> Excel
« Reply #2 on: March 05, 2003, 12:08:59 pm »
The code you have looks pretty good except it only increments one cell. Therefore, you couldn't track seperate key entries. To do that you would either need seperate subroutines or incorporate a way to recognize the keypress within the AddOne sub.


Try This:

Open a new Excel workbook..

Go to the VBA editor by pressing Alt+F11 or clicking Tools, Macro, Visual Basic editor

In the Project Window, you should see a project called VBAProject(?) The ? is whatever the name of the workbook is.
Expand that project until you see the "This Workbook" entry.
Double-Click on it and it should open the code window for "This Workbook"
Copy the following code and paste it in the window.


Private Sub Workbook_BeforeClose(Cancel As Boolean)

Application.OnKey "a", ""
Application.OnKey "s", ""
Application.OnKey "d", ""
Application.OnKey "f", ""

End Sub

Private Sub Workbook_Open()

Application.OnKey "a", "Add1"
Application.OnKey "s", "Add2"
Application.OnKey "d", "Add3"
Application.OnKey "f", "Add4"

End Sub



Then Insert a module by selecting Insert, Module (duh).
This will open a new code window. Copy and paste the following code into this window.


Sub Add1()
    Range("A1").Value = Range("a1").Value + 1
End Sub

Sub Add2()
    Range("A2").Value = Range("a2").Value + 1
End Sub

Sub Add3()
    Range("A3").Value = Range("a3").Value + 1
End Sub

Sub Add4()
    Range("A4").Value = Range("a4").Value + 1
End Sub

Save and close the workbook and then re-open it for the macros to be recognized. If you have done it correctly, then every time you hit "a" cell A1 will increase in value by 1. Every time you hit "s", Cell A2 increments by one etc.

You can substitue the key presses for whatever you want, just change the references to the letters in the preceding code. Remember however, that the way this code is set up you always have to close an re-open the workbook before your edits will change.
saint ganked my avatar.

FractalWalk

  • Trade Count: (0)
  • Newbie
  • *
  • Offline Offline
  • Posts: 0
  • Last login:September 20, 2010, 06:12:37 pm
  • Life is time spent fighting entropy.
Re:OT: Ipac Controller -----> Excel
« Reply #3 on: March 05, 2003, 02:01:25 pm »
Here is an alternate way with a bit simpler code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Application.OnKey "a", ""
Application.OnKey "s", ""
Application.OnKey "d", ""
Application.OnKey "f", ""

End Sub

Private Sub Workbook_Open()

Application.OnKey "a", "'Add 1'"
Application.OnKey "s", "'Add 2'"
Application.OnKey "d", "'Add 3'"
Application.OnKey "f", "'Add 4'"

End Sub


The above code passes a variable to the macro so it knows what key was pressed (i.e. a=1, s=2 etc.) Note that I did more than just add a numerical argument to the procedure call. The procedure 'Add' and its argument '1' (or 2,3,4) is embedded in single quotes, which is in turn embedded in double quotes. Without the quotes within quotes, it won't work.


Then the macro code change would be:

Sub Add(x)
    Range("A" & x).Value = Range("A" & x).Value + 1
End Sub


Same result as my previous post but just a little cleaner. If you need to customize something, I would be happy to help at no charge. Just be warned, I'm not a programmer and so I can't do any of the fancy stuff, but I can do what you have outlined.
saint ganked my avatar.

Lilwolf

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4945
  • Last login:July 31, 2022, 10:26:34 pm
Re:OT: Ipac Controller -----> Excel
« Reply #4 on: March 05, 2003, 03:02:55 pm »
trouble you will find is it's not certified.

I work in software controlling manufacturing equipment in the semiconductor industry.  I had the same idea when people need to control / monitor just a few inputs... but nobody would go for it.

btw, there are certified equipment that does that for 150 bucks or so that will continue to work if dropped 20 feet in the middle of a hurrican...

the trouble isn't the hardware, its the software.

Jim

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 2
  • Last login:March 06, 2003, 02:00:44 am
  • I want my own arcade controls!
Re:OT: Ipac Controller -----> Excel
« Reply #5 on: March 06, 2003, 02:06:34 am »
Thanks FractalWalk for your help it works just as I was hoping it would. I appreciate your offer and all of your assistance :D

We should have this completely up and running well ahead of schedule. Should give us a big help in knowing exactly where our production schedule stands.

Thanks for your input as well Lilwolf.   :D Being a small business if we are happy that it gives us what we need then that is enough for me.

Again thanks for all the help great board, great people, now I can spend some more time playing games then worrying about schedules.