| Reference | Downloads | Github

Hardware connection

Hallo Friends,
In my application, I would like to show this kind of process.

  1. Tell subject via bilder like test: sweet
  2. wait for one second
  3. Give command to hardware (pump) to give specific amount of liquid for specific amount of time
  4. take feedback from subject via bilder in 4 seconds
  5. repeat the process

I am using CETONI GmbH’s pump, now I would like to know, how can I write program for Hardware (DC servo motor and Valve). Is it possible to do it in coder? if yes then, How can I load that program to hardware?
Please give me some suggestion.
Thanking you in advance.


There are few options available to interface hardware to a PsychoPy experiment.

PySerial is a serial port access library that allows you to communicate to external devices through a RS-232 port/dongle. If your hardware has this interface and provides documentation, using PySerial is usually enough to send commands and data to the hardware.

If the hardware uses simple TTL signals (simple 5V on/off), PsychoPy’s parallel port interface may be adequate.

Finally, some hardware might ship with a software library (such as a DLL) that handles communication with the device via USB. In this case, you need a wrapper library to access the library’s functions. If there isn’t one provided or pre-made one the internet somewhere, you will need to write your own using Python’s ctypes library or Cython.


Thank you very much for your reply, mdc.

There are many dll files in software. How I can get to know that, some particular library is responsible for communication with device via USB? In the software file there are two files (CamUsb_API.dll and USBCAN32.dll) which I can say related to USB connection. Am I right? And one more thing, Can you provide me some more information about wrapper library to access the library’s function. I am totally new in Python and Psychopy. If you can give me some example code for that or something to read. That would be really helpful for me.

Thanking you in advance.