New Life Games LLC
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

News:

Welcome to the NewLifeGames.com message forum! 

 


NLG Site Navigation Menu


Archives of old posts can be found at...... Newlifegames.net/nlg/

Author Topic: MK6 hard meter emulated with Arduino Uno  (Read 2366 times)

0 Members and 1 Guest are viewing this topic.

Offline bogan

  • New NLG Member 3 to 100 Posts
  • **
  • Posts: 97
  • Reputation Power: 5
  • bogan New User has no influence.
  • NLG
MK6 hard meter emulated with Arduino Uno
« on: February 07, 2020, 08:46:51 PM »
For those aussies converting machines to NSW, here the first cut of the arduino code to emulate the mechanical meters. For those that dont know what an arduino is, its a small microprocessor board you can buy off ebay for under AUD$10.


Not all my work, and we may still need to do some more work on it yet. Use at your own risk




EDIT: So seems like more work to do on it yet.
EDIT 2: Fixed


EDIT 3: The code below is the working code.


Code: [Select]
volatile int slaveSelect = 0;


volatile byte readState = 1;


volatile byte data[2];


volatile byte towerLights = 1;


void setup (void)
{
/*
Pinouts for the connection to the machine
The EGM connector is the 26 pin header found
on the logic box


EGM          SPI
P6           SIGNALS   ARDUINO   
-------------------------------
  5 WHITE    MISO      12
  6 BLACK    GND       GND
  7 BROWN    RESET     A5 (not used)
  9 GREEN    SS        10
  10 RED     +5V       5V
  11 BLUE    SCLK      13
  13 ORANGE  MOSI      11


To bypass the meter cage switch, link
pins 17 and 18 together.
  17 Door Switch Normally Open
  18 GND (for door switch)
  19 Door Switch Normally Closed


  */


Serial.begin(115200);
Serial.println("Starting");


 pinMode(A0, INPUT);
 pinMode(A1, INPUT);
 pinMode(2,OUTPUT);
 //pinMode(SS,INPUT);
  // have to send on master in, *slave out*
 pinMode(MISO, OUTPUT);


 
 SPCR |= _BV(CPHA);
 
  // turn on SPI in slave mode
 SPCR |= _BV(SPE);


  // turn on interrupts
 SPCR |= _BV(SPIE);




}  // end of setup




// SPI interrupt routine
ISR (SPI_STC_vect)
{
  //the mech meters have 2 MC33298 or equivelent in series.
  // data is shifted into U1, and the data from U1 shifted into U2.
  // data from U2 gets shifted back onto the serial bus.
  //
  // so for each SS, we are esentially shifting in 16btyes, and shifting out 16 bytes.
  //
  // the MC33298 will invert each bit if the load is connected. Note, there is logic in
  // meter board that inverts the data also. When looking at MISO and MOSI on an
  // oscilloscope the data in is the same as the data out.


   
 
   if(readState < 0)
   {
    //something bad has happened
    //do nothing and resync on the SS
   }
   else
   {


      //crude but fast shift array left.
      data[0] = data[1];
      data[1] = SPDR;
     
      //Send the data back out
      SPDR = data[0];


      readState--;
    }
 


}  // end of interrupt service routine (ISR) SPI_STC_vect


void loop (void)
{
 
  // if SPI not active, clear current command
  int state = digitalRead(SS);


  if (state!=slaveSelect)
  {
    slaveSelect = state;
    if(state == HIGH)
    {
      //set the state machine back to the start so we can
      //read all 16 bits of data that are being clocked in
      readState = 1;
    }
    else
    {
      //decode the tower lights. Could output this to leds
      if (towerLights != data[0])
      {
        towerLights = data[0];
       
      }
     
    }
  }


}  // end of loop
« Last Edit: February 07, 2020, 11:36:20 PM by bogan »

Offline bogan

  • New NLG Member 3 to 100 Posts
  • **
  • Posts: 97
  • Reputation Power: 5
  • bogan New User has no influence.
  • NLG
Re: MK6 hard meter emulated with Arduino Uno
« Reply #1 on: February 07, 2020, 09:43:41 PM »
There is some bugs, as predicted. Standby whilst I fix them.

Offline pokie3

  • New NLG Member 3 to 100 Posts
  • **
  • Posts: 30
  • Reputation Power: 1
  • pokie3 New User has no influence.
  • NLG
Re: MK6 hard meter emulated with Arduino Uno
« Reply #2 on: February 08, 2020, 01:51:56 AM »
That's really awesome, nice work!

Offline Dam0

  • New NLG Member 3 to 100 Posts
  • **
  • Posts: 8
  • Reputation Power: 0
  • Dam0 New User has no influence.
  • Gender: Male
  • NLG
Re: MK6 hard meter emulated with Arduino Uno
« Reply #3 on: February 08, 2020, 05:39:21 PM »
very cool, job well done.

Offline bogan

  • New NLG Member 3 to 100 Posts
  • **
  • Posts: 97
  • Reputation Power: 5
  • bogan New User has no influence.
  • NLG
Re: MK6 hard meter emulated with Arduino Uno
« Reply #4 on: February 08, 2020, 07:51:35 PM »
Unfortunately to emulate the LAB card would be worth more than you can buy them second hand.

Offline bogan

  • New NLG Member 3 to 100 Posts
  • **
  • Posts: 97
  • Reputation Power: 5
  • bogan New User has no influence.
  • NLG
Re: MK6 hard meter emulated with Arduino Uno
« Reply #5 on: February 11, 2020, 04:48:09 PM »
I have noticed a small issue with the emulator. Occasionally I am still getting 'meter faulty' errors. Turning the audit key will fix it most of the time, however occasionally I need to reboot the machine.


One thing I did notice with the Arduino meters was there is a lot of jitter on the serial line, so its possible noise related. My alternate theory is its something to do with the arduino drivers/code slowing down the serial interrupt handling.


Either way, it still needs a little fine tuning. Its doing the job for me for now, but at some point I am going to have to take a closer look at the problem.

Offline bogan

  • New NLG Member 3 to 100 Posts
  • **
  • Posts: 97
  • Reputation Power: 5
  • bogan New User has no influence.
  • NLG
Re: MK6 hard meter emulated with Arduino Uno
« Reply #6 on: February 12, 2020, 01:00:40 AM »
I just pulled the oscilloscope leads of my test rig and now the machine wont detect the meters, so I am pretty confident its a noise/signal related issue. At some point, I will attempt to shorten the length of the wires and use ribbon cable to the arduino. Will also look at the signals on the cro with high impedance lead to see what is going on. The real meter board does have some noise filtering on it, probably for a good reason.


If anyone is going to attempt to build one, perhaps try using the ribbon cable from the plug to the arduino, as there is a ground wire between each of the signal wires. That might help. Please report back any findings.




Offline bl262000

  • Contributing NLG Member
  • New NLG Member 3 to 100 Posts
  • *
  • Posts: 7
  • Reputation Power: 0
  • bl262000 New User has no influence.
  • NLG
Re: MK6 hard meter emulated with Arduino Uno
« Reply #7 on: May 20, 2021, 08:24:52 PM »
Hello,
I know this topic is old but want to know if anyone has tried this emulator.
I have tried it but it seems to do nothing with meters disconnected error remaining.
Thanksbl262000
« Last Edit: May 25, 2021, 04:45:35 PM by bl262000 »

Offline Nik_booyahh

  • New NLG Member 3 to 100 Posts
  • **
  • Posts: 7
  • Reputation Power: 0
  • Nik_booyahh New User has no influence.
  • Gender: Male
  • NLG
Re: MK6 hard meter emulated with Arduino Uno
« Reply #8 on: July 04, 2023, 11:54:37 PM »
Any update on this?
I'm strugng to get the code to write to arduino

Offline Heihachi_73

  • NLG Member 101 to 250 Posts
  • ***
  • Posts: 230
  • Reputation Power: 14
  • Heihachi_73 New User has no influence.
  • Gender: Male
  • NLG
Re: MK6 hard meter emulated with Arduino Uno
« Reply #9 on: July 07, 2023, 08:25:31 AM »
OP no longer posts on here, he went silent after being doxxed on another forum.
https://newlifegames.com/nlg/index.php?topic=26955.msg171273#msg171273

Offline Nik_booyahh

  • New NLG Member 3 to 100 Posts
  • **
  • Posts: 7
  • Reputation Power: 0
  • Nik_booyahh New User has no influence.
  • Gender: Male
  • NLG
Re: MK6 hard meter emulated with Arduino Uno
« Reply #10 on: July 07, 2023, 01:57:08 PM »
That's very unfortunate. Iv purchased arduino based off this post but I'm not smart enough to figure this out on my own 😅

Offline a69mopar

  • Global NLG Site Moderator
  • NLG Member 501 to 10,000 Posts
  • *
  • Posts: 2105
  • Reputation Power: 83
  • a69mopar Is a force to reckon with.a69mopar Is a force to reckon with.a69mopar Is a force to reckon with.a69mopar Is a force to reckon with.a69mopar Is a force to reckon with.a69mopar Is a force to reckon with.a69mopar Is a force to reckon with.a69mopar Is a force to reckon with.
  • Gender: Male
  • NLG
    • www.gtaslots.com
Re: MK6 hard meter emulated with Arduino Uno
« Reply #11 on: July 07, 2023, 02:03:07 PM »
Make sure you select the correct port in the arduino program.

Offline Nik_booyahh

  • New NLG Member 3 to 100 Posts
  • **
  • Posts: 7
  • Reputation Power: 0
  • Nik_booyahh New User has no influence.
  • Gender: Male
  • NLG
Re: MK6 hard meter emulated with Arduino Uno
« Reply #12 on: July 07, 2023, 02:33:12 PM »
The file seems to verify ok. It's only when sending to arduino that I get error. I will try again soon and post result 👌

 

Cell Phone and Pad Mode

imode wap wap2

NLG Archives

Archives @ newlifegames.net Wayback Machine

Contact Us

NLG Shop 928 754-4147 Email Us 1788 Highway 95 30 BHC City AZ 86442
If you find this site helpful, please consider becoming a Contributing NLG Member with a monthly subscription to help cover the cost of pizza, coffee, aspirin, hosting, and bandwidth.
Contributing Members: get unlimited personal messages, can save topics and replies as drafts,
can post to the Classified ads, get unlimited access to the downloads, and also get this minty badge:



**Subscription Link** (Click Here) **Subscription Link**



           
If you would rather remain anonymous Thank You or just want to help support the site, please use this "make a donation" button:




From your entire NLG staff, thank you for supporting NLG.


New Life Games LLC 1788 HIGHWAY 95 UNIT 30 BULLHEAD CITY AZ 86442




Newlifegames.com     Newlifegames.net     Newlifegames.org

Newlifegame.com     Newlifegame.net     Newlifegame.org    Newlifegames.us

   New Life Games     NewLifeGames  NLG

 We Bring new Life to old Games    1-888-NLG-SLOTS

Are all Copyright and Trademarks of New Life Games LLC 1992 - 2022


FAIR USE NOTICE:



This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner.
We make such material available in an effort to advance awareness and understanding of the issues involved.
We believe this constitutes a fair use of any such copyrighted material as provided for in section 107 of the US Copyright Law.
In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit to those
who have expressed a prior interest in receiving the included information for research and educational purposes.

For more information please visit: http://www.law.cornell.edu/uscode/17/107.shtml
If you wish to use copyrighted material from this site for purposes of your own that go beyond fair use,
you must obtain permission directly from the copyright owner.




The NewLifeGames.com website is optimized for use with Firefox and a minimum screen resolution of 1600 x 900 pixels.

SimplePortal 2.3.5 © 2008-2012, SimplePortal