Lumina Emulator

From Prefrontal.org
Jump to: navigation, search
LuminaEmulator.jpg

Summary:

This small microcontroller device emulates the serial output of the Cedrus Lumina LP-400 response box. In its current configuration it will provide a trigger signal (ASCII code 53) every 2 seconds. Roughly 250ms after the trigger pulse a single button press event will occur. Button presses will cycle from button 1 (ASCII 49) through button 4 (ASCII 52) and then repeat [TR1:49, TR2:50, TR3:51, TR4:52, TR5:49, etc]. You can modify the code to provide any event order you wish with just a few changes.


Parts Needed:

1 x Parallax BASIC Stamp 2 Module ($49)

1 x Parallax Super Carrier Board ($19)

If you have never done any programming with the Basic Stamp before you may need a serial cable or USB-Serial adaptor to program the chip. You might also need to download the Basic Stamp Editor from Parallax to upload the program.


Assembly:

Dead simple on this one: take the BSII module and place it in the appropriate socket on the carrier board.


Code:

Use the Basic Stamp Editor to upload the following code to the BSII chip.

' {$STAMP BS2}
' {$PBASIC 2.5}

' Define variables used in the program

leftright 	VAR	BYTE
baudrate	VAR	BYTE

' Set the serial communication rate
' Speeds: 32 = 19200, 84 = 9600

baudrate = 32
leftright = 0

' Set all pins to output

DIRS = %0000000000000000

' ----------------------------------------

'Wait two seconds from initial power-up to begin

PAUSE(2000)

DO 
	' Send trigger.  Pulse pin 15 for LED (if present)

	SEROUT 16, baudrate, [53]
	LOW 15
	PAUSE(50)
	HIGH 15

	' Wait 200ms before making response

	PAUSE(200)
 
	' Determine if a left or right button will be pressed
	' Also determine which of the two buttons on each side is pressed
	' Send the serial data and then pulse the left or right LED (if present)

	IF (leftright = 0) THEN
		SEROUT 16, baudrate, [49]
		LOW 12
		PAUSE(50)
		HIGH 12
		leftright = 1
	ELSEIF (leftright = 1) THEN
		SEROUT 16, baudrate, [50]
		LOW 12
		PAUSE(50)
		HIGH 12
		leftright = 2

	ELSEIF (leftright = 2) THEN
		SEROUT 16, baudrate, [51]
		LOW 9
		PAUSE(50)
		HIGH 9
		leftright = 3

	ELSEIF (leftright = 3) THEN
		SEROUT 16, baudrate, [52]
		LOW 9
		PAUSE(50)
		HIGH 9
		leftright = 0

	ENDIF

	' Wait out the rest of the TR before repeating

	PAUSE(1700)

LOOP


Using the Emulator:

1. Attach a 9V battery to the top left terminals.

2. Plug in your serial cable to the port on the left. The Lumina Emulator uses the same serial communication parameters that the real Lumina box typically does: 19200 baud, 8 bits of data, no parity, and 1 stop bit (8N1). These parameters can be changed if you have specific needs.

3. The first trigger will occur two seconds after the battery is connected.

4. If you need to start over or halt the sequence press the reset button on the bottom left of the board. Unless stopped the sequence will continue looping indefinitely.

5. When done, unplug your cable and disconnect the battery. With any luck your experiment is now ready to be tested on the scanner.


To Conclude

Send me an email if you run into any trouble. The nice bit about this device is that it can be reprogrammed to provide almost any sequence of serial events - very handy for prototyping and testing new experiments and equipment.

Personal tools