New Life Games LLC

**Video Poker, Keno, Slots, 21** Gaming machines => Aristocrat Video Gaming Machines => Topic started by: bogan on February 07, 2020, 08:46:51 PM

Title: MK6 hard meter emulated with Arduino Uno
Post by: bogan 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
Title: Re: MK6 hard meter emulated with Arduino Uno
Post by: bogan on February 07, 2020, 09:43:41 PM
There is some bugs, as predicted. Standby whilst I fix them.
Title: Re: MK6 hard meter emulated with Arduino Uno
Post by: pokie3 on February 08, 2020, 01:51:56 AM
That's really awesome, nice work!
Title: Re: MK6 hard meter emulated with Arduino Uno
Post by: Dam0 on February 08, 2020, 05:39:21 PM
very cool, job well done.
Title: Re: MK6 hard meter emulated with Arduino Uno
Post by: bogan 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.
Title: Re: MK6 hard meter emulated with Arduino Uno
Post by: bogan 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.
Title: Re: MK6 hard meter emulated with Arduino Uno
Post by: bogan 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.



Title: Re: MK6 hard meter emulated with Arduino Uno
Post by: bl262000 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
Title: Re: MK6 hard meter emulated with Arduino Uno
Post by: Nik_booyahh on July 04, 2023, 11:54:37 PM
Any update on this?
I'm strugng to get the code to write to arduino
Title: Re: MK6 hard meter emulated with Arduino Uno
Post by: Heihachi_73 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
Title: Re: MK6 hard meter emulated with Arduino Uno
Post by: Nik_booyahh 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 😅
Title: Re: MK6 hard meter emulated with Arduino Uno
Post by: a69mopar on July 07, 2023, 02:03:07 PM
Make sure you select the correct port in the arduino program.
Title: Re: MK6 hard meter emulated with Arduino Uno
Post by: Nik_booyahh 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 👌
SimplePortal 2.3.5 © 2008-2012, SimplePortal