(Topic ID: 223603)

LISY35: help with bally lamp driver code needed

By bontango

5 years ago


Topic Heartbeat

Topic Stats

  • 22 posts
  • 4 Pinsiders participating
  • Latest reply 5 years ago by bontango
  • Topic is favorited by 4 Pinsiders

You

Linked Games

No games have been linked to this topic.

    Topic Gallery

    View topic image gallery

    LISY35_Board_beta_02 (resized).jpg
    ZeroCrossingDetector100Hz.jpg
    LISY35_Board_beta (resized).jpg
    #1 5 years ago

    Hello,
    now as my LISY1/LISY80 stuff is running fine (www.lisy80.com), I'm working on the next step, meaning providing 'LISY35' where the plan is to emulate all these old bally/stern games which were produced between 1977 and 1985.
    See picture of LISY35 prototype attached, which has working displays, switches and solenoids (at least for my Mata Hari pinball) so far.

    For the lamps however I have some difficulties, as it looks like that theory and practice do differ.

    Ballys 'Theory of Operations' says:
    When an SCR is turned on, it will stay on for the reminder of the supply line alternation (1/120 second) and turn off
    at the next zero crossing. It will stay off unless the next update again drives the gate high.

    For me this means:
    Each of the 15 SCR assigned to one Decoder (14514) is energized 1/120 second and will be off while the other 14 lamps are energized ( 14/120 seconds ).
    Each 'switch' of lamps will be initiated by an zero crossing interrupt. So in theory I should see 15 zero crossing interrupts for each update interval.
    However by looking into pinmame and look 'what happens' by inserting some debug lines, I see only one zero crossing interrupt at the beginning of the whole update interval.

    Is my 'theory' wrong or do I just miss some debug outputs from pinmame?
    Anyone have a code 'snippet' (‘C’ preferred) which shows how the lamp driver can/should be controlled?
    Any help appreciated.

    thanks
    Ralf

    LISY35_Board_beta (resized).jpgLISY35_Board_beta (resized).jpg
    #2 5 years ago

    Take this with a grain of salt as my attempts to do similar haven't been successful either, but by my understanding, *every* zero-crossing, all lamps will turn off. You need to strobe every energized lamp each time. Also note that you can strobe the lamp in all four banks (of 15) at once

    #3 5 years ago

    All 15 SCRs on each 4514 decoder are processed *every* zero crossing interrupt and the SCRs are activated based on a lamp memory cache. So each zero crossing interrupt will loop and process all 60 SCRs.
    Games with Aux lamp boards will also have all their SCRs processed each zero crossing interrupt after the main lamp driver board is processed.

    BTW, nice work!

    #4 5 years ago

    zacaj Quench Many thanks for your feedback,
    so looks like the debug messages from pinmame are OK, where my theory is wrong ...

    Thinking now how to implement it in my PIC Chips, can you give me some advice on the 'timing'?

    Background:
    I pasted below the first seven activities in a typical update cycle together with a time stamp in microseconds.
    These time stamps may not be accurate as coming from pinmame, but at least I can see the relation to the zero crossing.
    Within pinmame I see:
    - one zero crossing each 5ms ( I would expect to see it each 10ms, because of the 50Hz here in Europe, so we may have to multiply with two here)
    - approximate 500 microseconds for one full update cycle

    Each 4-line block is updating four SCR in parallel ( because of four decoder chips ), and I can see the address going up: 0,1,2,3,4,5,6
    But looking to the time between the command after the strobe which sets the inhibit lines for the decoders
    and the start of the next sequence which sets all inhibits to '1' again (resulting in all lamps going off)
    it is only around 7-8 microseconds where one lamp is ON in each update sequence.

    Having 100 updates each second one lamp is ON only 0,7-0,8ms out of one second
    because of the inaccurate timing out of pinmame lets assume its 2ms.

    I still wonder if that's enough to give the user the imagination that the lamp is steady ON, as it is only 0,2% of the time?!

    Do you know what is the correct 'on time' for each SCR in one update cycle?

    thanks
    Ralf

    ----

    24110725 zero cross
    24110789 pia A: address:0x00 data(inhibit)0x0f
    24110796 strobe(CB2) 1
    24110802 strobe(CB2) 0
    24110807 pia A: address:0x0f data(inhibit)0x0e

    24110815 pia A: address:0x01 data(inhibit)0x0f
    24110821 strobe(CB2) 1
    24110826 strobe(CB2) 0
    24110831 pia A: address:0x0f data(inhibit)0x0f

    24110838 pia A: address:0x02 data(inhibit)0x0f
    24110844 strobe(CB2) 1
    24110849 strobe(CB2) 0
    24110854 pia A: address:0x0f data(inhibit)0x0f

    24110861 pia A: address:0x03 data(inhibit)0x0f
    24110867 strobe(CB2) 1
    24110872 strobe(CB2) 0
    24110877 pia A: address:0x0f data(inhibit)0x0f

    24110884 pia A: address:0x04 data(inhibit)0x0f
    24110890 strobe(CB2) 1
    24110896 strobe(CB2) 0
    24110901 pia A: address:0x0f data(inhibit)0x0f

    24110907 pia A: address:0x05 data(inhibit)0x0f
    24110913 strobe(CB2) 1
    24110918 strobe(CB2) 0
    24110924 pia A: address:0x0f data(inhibit)0x0e

    24110930 pia A: address:0x06 data(inhibit)0x0f
    24110936 strobe(CB2) 1
    24110942 strobe(CB2) 0
    24110947 pia A: address:0x0f data(inhibit)0x0f

    #5 5 years ago
    Quoted from bontango:

    Having 100 updates each second one lamp is ON only 0,7-0,8ms out of one second
    because of the inaccurate timing out of pinmame lets assume its 2ms.

    I still wonder if that's enough to give the user the imagination that the lamp is steady ON, as it is only 0,2% of the time?!

    Do you know what is the correct 'on time' for each SCR in one update cycle?

    Once the lamp is on long enough for the SCR to 'latch' it should stay on until the next zero crossing

    #6 5 years ago

    ^^^
    What zacaj said.
    When voltage is applied to the gate pin of a SCR, once current between the anode and cathode reaches the "holding current" specification of the SCR (typically around 5.0ma), the gate voltage can be removed and the SCR will stay latched on until current through the SCR drops below holding current specification. This happens at the end of the DC lamp voltage phase.

    The ROM zero crossing interrupt code loops through all 16 decoder "addresses" and writes the lamp state to the four decoders in parallel at that address, as you're seeing from the PinMAME output above.
    The lamp code does not switch lamps off, it can only switch lamps on. Lamps that should be off are essentially not activated.

    @Ralf, in your PCB picture above it doesn't seem like you have the zero crossing detector components fitted. How are you detecting it and how are you handling zero crossing frequencies of 100Hz vs 120Hz?

    Below is the waveform recorded out of the zero crossing detector circuit:

    ZeroCrossingDetector100Hz.jpgZeroCrossingDetector100Hz.jpg

    #7 5 years ago
    Quoted from Quench:

    This happens at the end of the DC lamp voltage phase.

    Curious unrelated question: how does this work since the lamp voltage is DC? I know on 6803/Playmatic games they use AC with two lamps per SCR, so it makes sense the voltage goes to 0 when the zero-crossing occurs. Is it just because the DC lamp voltage is unfiltered? (and if so, would putting a filter cap on it make the lamp driver malfunction?)

    #8 5 years ago
    Quoted from zacaj:

    how does this work since the lamp voltage is DC?

    The lamp voltage is rectified DC but unregulated & unfiltered so the voltage goes to zero during the cycle.

    Quoted from zacaj:

    (and if so, would putting a filter cap on it make the lamp driver malfunction?)

    Yes if you did this with a large enough capacitor, the lamps would never switch off because the current through the SCRs would never go below holding current specification and so they'd stay latched on permanently.

    #9 5 years ago
    Quoted from Quench:

    The lamp code does not switch lamps off, it can only switch lamps on.

    That's it, I was under the imagination hat the code does also switch off the lamp, but yes we have a thyristor here, not a transistor driving the lamp

    Quoted from Quench:

    @Ralf, in your PCB picture above it doesn't seem like you have the zero crossing detector components fitted. How are you detecting it and how are you handling zero crossing frequencies of 100Hz vs 120Hz?

    Yes, soldering the missing components are now the next step. I just wanted to have the lampcode for the PIC ready, until now it was only pinmame debug.
    The output of the zero crossing detector will go to an interrupt line of the PIC, which will do the lamp refresh, and I may spend an extra LED indicating that there is a (working) zero crossing detection in the next hardware release of LISY35.

    Many thanks for enlighten me , will update this thread as soon as it all works

    #10 5 years ago

    You might want to think of ways of having the PIC code continuously updating the lamp board to prevent LEDs from flickering - common problem with the original design.

    #11 5 years ago
    Quoted from Quench:

    You might want to think of ways of having the PIC code continuously updating the lamp board to prevent LEDs from flickering - common problem with the original design.

    I guess that should be possible as, in contrary to the original design, with LISY switch strobing and display refresh is done by separate components (PICs).
    Do you have an advice/link for me to a type of LED device where flickering is visible best?

    UPDATE:
    Took a bit more time than expected, but finally it works now
    It turned out that the interruptroutine on the PIC was too fast, so that the ignition of the thyristors came in an early state.
    Now with a delay of 80 microseconds the lamps looking OK.

    I would like to prevent to identify the best delay with 'try and error', so anyone has the right delaytime
    for me (time between interrupt condition -zeor cross - and first activation of a thyristor)
    and (second question) any idea how to implement the delay in hardware rather than to have a delay in an interrupt routine?

    #12 5 years ago
    Quoted from bontango:

    I would like to prevent to identify the best delay with 'try and error', so anyone has the right delaytime
    for me (time between interrupt condition -zeor cross - and first activation of a thyristor)

    I guess the only real answer would be hooking a scope up to the zero crossing and lamp strobe of a bally? Trying to interface with bally hardware it's amazing how much the timings matter

    #13 5 years ago
    Quoted from bontango:

    Now with a delay of 80 microseconds the lamps looking OK.

    I'm looking at a particular games Zero Crossing code, after first updating ram based counters/timers there is a 240us loop delay (if my calculations are correct) before the lamp refresh code starts. Calculating the CPU cycle times taken for the ram based counter/timer updates shouldn't be hard but it may be different between different system ROMs on that hardware

    Quoted from zacaj:

    Trying to interface with bally hardware it's amazing how much the timings matter

    What problems have you had?

    #14 5 years ago
    Quoted from Quench:

    What problems have you had

    The aformentioned timing before starting the lamp update, how long to pulse the lamps for, multiple timing issues in the display update (still haven't gotten that to be reliable). And then all this changes when going to MPU-200 boards because of the different clock speed, etc. Meanwhile with williams boards I haven't had a single timing issue writing drivers for all of that.

    #15 5 years ago
    Quoted from Quench:

    Calculating the CPU cycle times taken for the ram based counter/timer updates shouldn't be hard

    I just quickly calculated it on the code from a 1978 game, the CPU cycle count from start of interrupt acknowledge to the end of lamp refresh looks to be around 2 milliseconds. This sounds longer than I expected.
    Best if you hook up an oscilloscope to measure/confirm it as zacaj said.

    Quoted from zacaj:

    The aformentioned timing before starting the lamp update, how long to pulse the lamps for, multiple timing issues in the display update (still haven't gotten that to be reliable). And then all this changes when going to MPU-200 boards because of the different clock speed, etc. Meanwhile with williams boards I haven't had a single timing issue writing drivers for all of that.

    Ok. I modified the lamp refresh and display codes on one of my Ballys and didn't have any issues.
    From the calculations, it's about 780us before the lamp refresh code starts after interrupt acknowledgement. The lamp board decoders function in the nanoseconds so lamp strobe time is not critical.
    The displays aren't processed entirely linearly due to the Credit/Ball in Play display being activated off a different PIA.

    Yes, Stern MPU200 will presumably update the lamps sooner than Bally/MPU100.

    #16 5 years ago
    Quoted from Quench:

    The lamp board decoders function in the nanoseconds so lamp strobe time is not critical.

    You needed to be on long enough to trigger the SCR though, right?

    In general though, it feels dirty to me to be writing code by just looking at how the bally code does it and copying that

    #17 5 years ago
    Quoted from zacaj:

    In general though, it feels dirty to me to be writing code by just looking at how the bally code does it and copying that

    Yes, that's true. In general I look how bally does it and 'rewrite/optimize it as I need to code it in 'C' for the PIC anyway.
    So from the original timing you posted, I'm way shorter with my 80us already.
    I will go with the 'try and error' method then by shortening that 80us delay and see where the boundaries are,
    let you know about the result

    PS:
    If you are interested in the details:
    For LISY35 I'm totally independent of the timing in the bally rom code.
    Within pinmame, when running the bally code, I just 'look' what lamps should be activated and send that as
    a command via I2C bus to the PIC. ( 'e.g. switch lamp 23 to ON' ). The lamp driver refresh code runs in an interrupt routine on the PIC.

    See below excerpt of the interruptcode, where AD0..3 are the adresslines, PD0..3 are lamp data and LAMPSTR1 is strobe 1.
    The array inhibit[] is set in the PIC main loop to keep the interruptcode short, and will be modified there according to the received commands.

    for ( address.byte = 0; address.byte <= 15; address.byte++ )
    {
    //set strobe to high
    LAMPSTR1 = 1;
    //inhibit (data) is all 1, we deactivate all decoders
    PD0 = PD1 = PD2 = PD3 = 1;
    //set the address
    AD0 = address.bitv.b0;
    AD1 = address.bitv.b1;
    AD2 = address.bitv.b2;
    AD3 = address.bitv.b3;
    //wait a bit (needed?))
    _delay_us(10);
    //set strobe to low, this will strobe address into the decoders
    LAMPSTR1 = 0;
    //wait a bit before ignition (needed? yes, but value to be determined))
    _delay_us(80);
    //set the rigth inhibit for this address
    PD0 = inhibit[address.byte].bitv.b0;
    PD1 = inhibit[address.byte].bitv.b1;
    PD2 = inhibit[address.byte].bitv.b2;
    PD3 = inhibit[address.byte].bitv.b3;
    }

    #18 5 years ago
    Quoted from zacaj:

    You needed to be on long enough to trigger the SCR though, right?

    The 4514 decoders on the lamp board "latch" the selected address output via the lamp strobe signal which holds the SCR gate active long enough for it to also latch. The Bally code immediately releases the lamp strobe after asserting it. There are no software delays between latching new lamp decoder addresses and the lamp decoder data does not change between strobe activations.

    Quoted from zacaj:

    In general though, it feels dirty to me to be writing code by just looking at how the bally code does it and copying that

    I think I understand your reasons and that's cool. No one here is saying to copy the original code.

    Quoted from bontango:

    For LISY35 I'm totally independent of the timing in the bally rom code.
    Within pinmame, when running the bally code, I just 'look' what lamps should be activated and send that as
    a command via I2C bus to the PIC. ( 'e.g. switch lamp 23 to ON' ). The lamp driver refresh code runs in an interrupt routine on the PIC.

    Just curious since I'm not familiar with your system, is there a reason you don't simply pass the PinMAME 6821 PIA output to the PIC and have the PIC control the lamp driver board "live"?
    i.e. is there a reason you don't update the lamps immediately at the time the game code updates them in PinMAME?

    #19 5 years ago
    Quoted from Quench:

    Just curious since I'm not familiar with your system, is there a reason you don't simply pass the PinMAME 6821 PIA output to the PIC and have the PIC control the lamp driver board "live"?
    i.e. is there a reason you don't update the lamps immediately at the time the game code updates them in PinMAME?

    You are right, I do convert it within pinmame, send it to the PIC and convert it 'back' there.
    I could do send just the PIA outputs which would spare me a bit of converting on the pinmame side.
    It's more coding yes, but debugging within pinmame is much simpler ( I do the same for coils, switches, displays )
    and the time delay for two times converting are not that much, so it's (kind of ) immediate too.

    Another plus is that I can use the same 'lower' LISY routines within pinmame and on the PICs, especially for the I2C communication
    for all my LISY systems ( LISY1, LISY80, LISY35) which helped me a lot creating LISY1 and LISY35 after LISY80 ( the first system) was ready.

    #20 5 years ago

    So, marked this as 'solved' here. I modified then interrupt code in the way that there
    is a big delay at the very start ( 800us, thanks to Quench for the calculation ) and deleted the others in the loop.
    Works perfect so far See below corrected interrupt routine
    Thanks for your help

    if (INTCON3bits.INT1IE && INTCON3bits.INT1IF) //external INT/RB1 interupt
    {
    //this is the refresh cycle for the lampdriver

    bitv_t address;

    //wait a bit before first ignition
    _delay_us(800);

    for ( address.byte = 0; address.byte <= 15; address.byte = address.byte +1)
    {
    //set strobe to high
    LAMPSTR1 = 1;
    //inhibit (data) is all 1, we deactivate all decoders
    PD0 = PD1 = PD2 = PD3 = 1;
    //set the address
    AD0 = address.bitv.b0;
    AD1 = address.bitv.b1;
    AD2 = address.bitv.b2;
    AD3 = address.bitv.b3;
    //set strobe to low, this will strobe address into the decoders
    LAMPSTR1 = 0;
    //set the rigth inhibit for this address
    PD0 = inhibit[address.byte].bitv.b0;
    PD1 = inhibit[address.byte].bitv.b1;
    PD2 = inhibit[address.byte].bitv.b2;
    PD3 = inhibit[address.byte].bitv.b3;

    }

    INTCON3bits.INT1IF = 0; // clear this interrupt condition
    }

    2 months later
    #21 5 years ago

    @Ralf, in your PCB picture above it doesn't seem like you have the zero crossing detector components fitted. How are you detecting it

    I am curious as well how you are detecting zero crossing.

    #22 5 years ago

    At the point in time the picture was taken, the PCB was just incomplete, see attached current situation.
    It is the circuit Bally is using, the output then feeds an external interrupt pin on my PIC.

    btw: First tests with different Bally games finished, at least Evel Knievel, Eight Ball, Mata Hari and Harlem Globetrotters are reported to work 100%
    So Testphase II with Version 1.0 of LISY35 will start soon

    LISY35_Board_beta_02 (resized).jpgLISY35_Board_beta_02 (resized).jpg

    Reply

    Wanna join the discussion? Please sign in to reply to this topic.

    Hey there! Welcome to Pinside!

    Donate to Pinside

    Great to see you're enjoying Pinside! Did you know Pinside is able to run without any 3rd-party banners or ads, thanks to the support from our visitors? Please consider a donation to Pinside and get anext to your username to show for it! Or better yet, subscribe to Pinside+!


    This page was printed from https://pinside.com/pinball/forum/topic/lisy35-help-with-bally-lamp-driver-code-needed and we tried optimising it for printing. Some page elements may have been deliberately hidden.

    Scan the QR code on the left to jump to the URL this document was printed from.