Photodiode Stimulus Detection to TTL Output

Discussion in 'The Projects Forum' started by Gregoun, May 19, 2015.

  1. Gregoun

    Thread Starter New Member

    May 19, 2015
    3
    0
    Hi All,

    Literally just stumbled across this forum in a search for answers. I am currently being rushed, with very limited knowledge of analog circuits let alone digital ones, into attempting to build a photo-detection circuit. As a complete novice with a rudimentary understanding of electronics, I am easily out of my depth here. I have been reading through the textbook here but must admit I am struggling. I would greatly appreciate any help!

    I have read through the posting FAQ and apologise if I've written this up wrong.

    Here is the project that I require some help with, for research.

    We are looking to control a TMS (a transcranial magnetic stimulation) machine by the use of one of the two input serial COM ports it has on the back. Many studies reference the following setup but none explain the electronics which is why I'm scouring the internet for help and guidance.

    The following is the 'expected' sequence of events: stimulus is presented using MATLAB software on a regular cheap as chips PC monitor with a small, discrete white (or other lightly coloured dot) appearing in a part of the monitor that the participant can't see - possibly by creation of a small hood. A photodiode is used to detect the appearance of this dot and sends a 5 volt TTL 'high' signal - according to the company that made the machine - to the TMS. The TMS has three pins that it works off: Pin 1 is Trigger Input, Pin 2 is Trigger Output and Pin 3 is a Ground/Reference pin. Once it receives the TTL trigger, it sets off the TMS.

    It can understand CMOS and can use standard RS232 connectivity. We have tried, unsuccessfully, to create a serial cable where we wired to Pins 1-3 from the computer, using an RS232 port on an old machine to communicate with the TMS. It is now the prevalent thinking that we instead use the photodiode set up which we can't find explained in further detail anywhere.

    Now I do not even know where to begin with such a circuit - let alone which photodiode to use to avoid infra-red light accidentally setting it off (which would be bad as the TMS delivers small localised disruptions to brain function).

    I have consulted other technicians in other departments, as well as friends in other institutions, but unfortunately it's not a common build/design where I work.

    I do not even have a starting circuit or a circuit sketch/diagram to work from/to - so apologies.

    Hopefully you guys can make sense of this and thanks for reading - like I said, I'm exhausting all routes here that I can!
     
  2. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,516
    1,246
    "It can understand CMOS and can use standard RS232 connectivity."

    No, it can't; not at the same time.

    First, more background data. What is the make/model of the TMS machine? Is there an electronic copy of its user manual, data sheet, or anything that explains its control interface? 800 number for tech support, anything?

    Second, we need to get some terms straightened out. You might be confusing the RS-232 communications protocol (a 3V to 12V bipolar signalling system) with the common 9-pin or 25-pin connectors found on most devices with "serial ports". That connector is over 75 years old, and is used for all kinds of input/output signalling in addition to serial ports. A clue is that minimal RS-232 uses pins 2, 3, and 7 of a 25 pin connector and pins 2, 3, and 5 on a 9 pin connector, not pins 1, 2, and 3. Also, RS-232 does not respond to a single input transition like a change from 0 to 1 from a CMOS gate.

    Your pinout description (trigger in, trigger out, gnd) suggests that it is a direct control input, not a serial port. If you are trying to communicate with a serial port output from a pc, that probably will not work. Coming up with the correct computer interface might be easier than growing an optical trigger.

    As I understand your description, Matlab puts up two things simultaneously on the screen: visual stimulus for the subject, and an optical trigger dot outside the subject's view. You want to sense the dot and use it to trigger the TMS.

    What is the repetition rate of the dot, and what is its period (duration)?
    How much time delay between the appearance of the dot and the trigger signal to the TMS is acceptable?
    Must the trigger to the TMS be in the 1 state for the entire appearance of the dot, or can it be a narrow pulse that is independent of the dot duration?
    Is the dot in a constant location? If so, can a sensor be taped over the dot space to eliminate interference from room lights, etc.?
    Post the schematic of the serial cable you tried to use. Also, photos of the back of the control computer and the back of the TMS would help.
    What software was going to signal the TMS through the cable?
    What hardware was going to generate the CMOS signal?

    That's enough for round 1.

    ak
     
  3. Gregoun

    Thread Starter New Member

    May 19, 2015
    3
    0
    Hi AnalogKid,

    Thank you very much for your response - it has definitely helped set me straight on a number of points.

    The make of the TMS machine is a Medtronic Magpro X100. Unfortunately there's no 800 number for tech support - just an electronic email response form, all of which I got back in response to my query about externally triggering it:
    "
    For the best accuracy one should use the Trigger in/ trigger out interface. A five volt TTL pulse can be used to trigger the MagPro once the MagPro is configured to be triggered by external trigger. On the timing menu, select "external trigger" rather than "sequence". As the Medtronic devices are some years old already, I don't know if you have any ability to control anything on the stimulator other than triggering of stimulation."

    There is a physical manual and a digital one - I have included the physical one in my attachments but they appear, at least to me, to contain very little information. The TMS PDF has pictures of the - as now I understand - 9 pin ports both on the back of the machine and the back of the computer. This is what I called a 'serial cable' and this is what we attempted to use. Unfortunately the person who made the cable is currently away - hence why I've been stuck with it - and I have no access to the schematic of this cable or understanding of what was done to it. It's essentially a 9 pin to 9 pin cable.

    Currently the experiment has not been programmed past just a test image with the dot on - just so we could get it working. The dot will repeat every 1000ms, appearing before the main stimulus - an image - to offset for latency. It's duration shouldn't be longer than the minimum we can get away with - we were hoping it would be in the range of 20-100ms or even faster, if possible. Obviously a set duration each time it's presented. The academic in charge of the research has not yet decided on the breaks, or interstimulus intervals (ISI), between images so my 1000ms is just a guess at this point.

    The idea is that once we figure out the latency of the detection circuit, we then present the stimulus by accounting for it after the dot is presented. For this, I have recommended using a different monitor for the record - we have some CRTs that I suspect may be better at this than current LCDs. To answer how much time delay is acceptable - as few milliseconds as possible. And hopefully, as none of the other parameters change - this would be a constant offset.

    The trigger just has to be set off by the dot (pulse width is given by the manual) but I don't believe there has to be a set duration.

    The dot will remain in a fixed position with the photodiode fixed as close as necessary. The room, minus the light from the computer, will be in a blackout state - ie no lights on, blacked out windows and attempts at mimising light leakage into the room. I realise this is almost impossible in university labs at the moment but as minimal as possible - it can be taped into position basically.

    As for the previous attempt - it was with Superlab V4.5 which is apparently capable of sending out a serial output. We couldn't get Superlab - which appeared to want to send out ASCII on the serial ports only - to trigger the TMS using our 9 pin to 9 pin connector.

    I do not know the rules on linking but the superlab manual is available at: http://www.superlab.com/manual/superlab-manual.pdf (it says it's too large to upload here?) and the digital manual of the TMS Machine is available from: http://www.mccauslandcenter.sc.edu/tms/wp-content/uploads/Mag_Pro_Manual.pdf.

    Hopefully that covers the first few questions.
     
  4. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,516
    1,246
    Page one of the cable pdf shows two true serial ports and one generic I/O connector. Page 3 shows a true serial port on the computer, which will not work in your application. Page 34 of the user manual shows the full I/O connector pinout, with a present. It supplies +5V, so your screen sensor will not need a separate power source. Look at this:

    http://www.ti.com/product/opt101

    Great part for your application. This might be all you need, depending on how picky the TMS trigger input is. See figure 5 on page 10.

    Where are you located?

    ak
     
    Last edited: May 19, 2015
  5. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,516
    1,246
    Depending on how fast your display response time is, what its contrast ratio is, how bright the trigger dot is, the OPT101 might make an output pulse that has a fast enough leading edge to trigger the TMS accurately. If not, or if you need a defined narrow pulse width for rapid retriggering, then you need to trigger a monostable that makes an independent and repeatable pulse. The whole thing can be powered by the TMS control port, and fit on a small piece of perfboard. Something like this:
     
    Last edited: May 19, 2015
  6. Gregoun

    Thread Starter New Member

    May 19, 2015
    3
    0
    Hi AnalogKid, - sorry about not replying as I had something come up last night.

    Just wanted to say a big thank you for your expertise here.

    Located in the UK - at Lincoln. Thank you for the diagram! I'll give it a go with the OPT101 - I would never have found that by myself in a million years so I appreciate it.
     
Loading...