Engineering display for a 'family day'

Thread Starter

nsaspook

Joined Aug 27, 2009
13,081
I've been tasked with build a gizmo for our group. Lights, sound and action are usually winners.
The base hardware is a PIC18 K42 RS-232 port controller I designed for general use connected to an old Digital232 I/O interface for the real world interface.
ftp://ftp.mccdaq.com/Manuals/Digital232 Users Manual.pdf

The software interface will have a remote 'detonator' switch to start and pressure sensitive push button to change the action sequences.


https://www.mouser.com/datasheet/2/603/Otto_HPL_Linear_Output_Pushbuttons-1214996.pdf

For the sound I'm using three sound effect Mallory Sonalerts.
https://www.mouser.com/datasheet/2/252/Mallory_MSE28LDD7S-1177330.pdf

The lights are super-bright led lamps for programming a few 'chase' sequence but I need to careful of strobe effects.

Still need to dig up a old enclosure for the power supplies, output drivers and hardware but I've got a bottomless pit of old junk to chose from. :D

Nothing fancy yet on the software, just the basic interface stuff is done.
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,081
First completed demo game. Led Chaser. Stop on led 1 or 8. Scan speed increase after every correct button press until 10 correct presses then the sequence restarts.
Simple but hard for an old guy like me.
 

cmartinez

Joined Jan 17, 2007
8,218
First completed demo game. Led Chaser. Stop on led 1 or 8. Scan speed increase after every correct button press until 10 correct presses then the sequence restarts.
Simple but hard for an old guy like me.
That's the most useless, but cutest, gizmo ever... :) ... congrats! ... maybe you will be asked a few questions, after all. What's the average age of the kids this thing is supposed to entertain?
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,081
That's the most useless, but cutest, gizmo ever... :) ... congrats! ... maybe you will be asked a few questions, after all. What's the average age of the kids this thing is supposed to entertain?
From toddlers to tweens to teens I guess.
the-microchip-team-at-fab-4-in-gresham-oregon-recently-celebrated.jpg
A previous Family day event.

I still need a grading system display from 1 to 8 for the 'winner' to award a prize ticket for players.
microchip-employees-set-up-the-microchip-community-garden-at-our-gresham.jpg
Losers get to work in the fields. (Deep Secret: They all win a prize)
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,081
Perhaps you could throw in a pseudo-random sequence as an alternate.
Still could have them try to stop on a 1 or 8.
I'll have a few random dancing lights sequences from flash as an idle display but I think pure 'skill' game-play will be more entertaining (there is a easy mode detector in the software to slow things down with too many misses at the first levels). I have a spare presence detector input to switch from idle back to game mode with a button press or PIR signal.
 

djsfantasi

Joined Apr 11, 2010
9,156
I know you’ve already built this device, but had you considered using bigger indicators? You can get 5 on eBay for less than $10. These are 1.3” square.
08F8A58C-2A3A-4757-842A-EB0AFE86FCF6.jpeg
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,081
I know you’ve already built this device, but had you considered using bigger indicators? You can get 5 on eBay for less than $10. These are 1.3” square.
View attachment 184989
They are super-bright lamps. https://www.mouser.com/datasheet/2/26/apem_03162018_Q10 23.10.2017-1313749.pdf
I chose the indicator size and type carefully to fit in the panel space for nice linear sequence patterns with a flush low background mount. This allows for a quick mental calculation of speed and hand/eye coordination for timing from just the flashes.

Yes, I suck at it when it goes faster. :cool:
 
Last edited:

Thread Starter

nsaspook

Joined Aug 27, 2009
13,081
How are you generating the sounds? Is there a special driver/code/application for that?
https://www.mouser.com/datasheet/2/252/MSE28LWH1-1520102.pdf
FAST Whoop MSE28LWH1
DING DONG MSE28LDD7S
BIRD CHIRP MSE14LCH2
C:
#define CHIRP    0x02
#define WARP    0x04
#define SIREN    0x01

typedef struct A_data {
    uint8_t inbytes[5]; // input from Digital232 buffer
    uint8_t outbytes[5]; // output from Digital232 buffer
    bool input_ok;
    bool output_ok;
    IO_STATE io;
    D232_STATE d232;
    SRQ_STATE srq;
    uint8_t srq_value, seq_value, misses;
    adc_result_t button_value;
    uint16_t speed, slower;
    bool speed_update, sequence_done;
} A_data;

typedef struct IN_data {
    /*
    * port 0
    */
    uint8_t b0 : 1;
    uint8_t detonator : 1;
    uint8_t pir : 1;
    uint8_t b3 : 1;
    uint8_t b4 : 1;
} IN_data;

// in main
IN_data *switches = (IN_data *) & IO.inbytes[0];
...
if (!switches->detonator) {
            IO.outbytes[1] = IO.outbytes[1] | CHIRP;
            if (IO.outbytes[2]&0b00000001) { // display byte patterns
                if (TimerDone(TMR_EXTRA)) {
                    IO.outbytes[1] = IO.outbytes[1] | WARP;
                    if (IO.speed_update && IO.speed-- < 2) {
                        IO.speed = 10;
                        IO.sequence_done = true;
                        IO.seq_value = WIN_SEQ;
                        IO.slower = 0;
                    }
                    IO.speed_update = false;
                    IO.misses = 0;
                }
            }
...
}
else {
            StartTimer(TMR_EXTRA, 500);
            IO.outbytes[1] = IO.outbytes[1] & (~CHIRP);
            IO.outbytes[1] = IO.outbytes[1] & (~WARP);
            IO.outbytes[1] = IO.outbytes[1] & (~SIREN);
            IO.speed_update = true;
            if (TimerDone(TMR_SEQ))
                IO.seq_value = DEFAULT_SEQ;
        }
The software just reads, sets or clears bits on a set of output/input buffers in memory while the serial (using a cable now but could be wireless in the future) comm routine from the PIC18K42 box updates the DAQ box IO's with those buffers to drive a set of uln2803 ports to switch the lamps and sound effects. There are several flags and software timers to delay/time the sounds and a few button anti-cheat delays to stop a simple button pushing hack.
 
Last edited:

Thread Starter

nsaspook

Joined Aug 27, 2009
13,081
I have a partially populated K42 controller board at home so I can write some LCD display code for prize scoring and game stats. The LCD spi interface is the standard one I use on most small controller boards. The driver software uses the standard MCC spi I/O routines without DMA or interrupts for this simple project.

EA DOGM163 lcd display in SPI 8-bit serial mode.
https://www.lcd-module.com/eng/pdf/doma/dog-me.pdf
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,081
Now I remember why I used DMA on these slow LCD displays to save cpu time. The inter-character spacing must be several microseconds between each transmitted data byte for a reliable display. With a slow interface (400kHz spi clock) the transmission time provides the needed delay. With the fast clock here at 2MHz the serial driver needed to be slightly modified in a local version to add delays with polled transfers. The short delay here for a complete display update is not critical so it works.


C:
// MCC driver code
uint8_t SPI1_Exchange8bit(uint8_t data)
{
    //One byte transfer count
    SPI1TCNTL = 1;
    SPI1TXB = data;

    while(PIR2bits.SPI1RXIF == SPI_RX_IN_PROGRESS)
    {
    }

    return (SPI1RXB);
}

void eaDogM_WriteString(char *strPtr)
{
    uint8_t i = strlen(strPtr);
    uint8_t bytesWritten = 0;

    RS_SetHigh();
    CSB_SetLow();
    if (i > max_strlen) strPtr[max_strlen] = 0; // buffer overflow check

    while (bytesWritten < i) {
        wdtdelay(IS_DELAYSHORT); // inter-character spacing for LCD code execute delays
        SPI1_Exchange8bit(strPtr[bytesWritten]);
        bytesWritten++;
    }
}
https://forum.allaboutcircuits.com/threads/secs-ii-host-using-a-pic18f57k42.157503/

Continuous DMA transfers at 400kHz
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,081
The last bit of hardware is the OTTO potentiometer button. 12-bit ADC readout from Vdd to Vss as the button is pressed.

I need to program another simple game that uses it and the LEDs. My current plan is to make a light-bar 'balance' game where you need to keep the light(s) centered on the display while the computer tries to move it right or left with a offset generated from a RNG for rate of change (LPF function) and offset value.
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,081
I made a few sound and light boards for possible later use from the demo circuit but I will just keep the vector-board version in the demo box.



Light-balance game using the joy-stick vari-button on the ADC.
 
Top