Optische Komponente ansteuern



  • Wir haben einen deformierbaren Spiegel, auf welchen wir mit einem Laser draufzeigen. Dieser Spiegel lässt sich mit C++ ansteuern. Das Manuel befindet sich am Ende (ich hab leider keine bessere Möglichkeit gesehen als es hier rein zu koieren).

    Leider sind unsere C Kentnisse sehr dürftig. Wie müsste ein Programm ausschauen? Wir können es uns nicht vorstellen was da im Endeeffekt alles noch reingeschrieben werden müsste. Zuerst einmal das Ganze include, import, define ... oder? Und dann ins Programm nach dem main nur mehr die danach beschriebenen Befehle? Vielen Dank

    Manual:
    5.2. CI USB Library
    The CI USB Library is implemented as an object that conforms to Microsoft's Component Object Model (COM). A COM object is an instance of a COM class. Clients interact with a COM object only through its interfaces.
    Object Registration and Instance Creation
    You can use the Regsvr32 tool (Regsvr32.exe) to register and unregister COM objects such as CIUsbLib.dll that are self-registerable. Regsvr32.exe is included with Microsoft Internet Explorer 3.0 and later versions, Windows 95 OEM Service Release 2 (OSR2) or later versions, and Windows NT 4.0 Service Pack 5 (SP5) and later versions. Regsvr32.exe is installed in the System (Windows Me/Windows 98/Windows 95) or System32 (Windows NT/Windows XP/Windows Vista) folder. To create an instance of the COM object in a C++ program, include the following lines of code in your program: #include "..\CIUsbLib\CIUsbLib.h" #import "..\CIUsbLib\_CIUsbLib.tlb" no_namespace using namespace std; CComPtr<IHostDrv> m_pIHostDrv; HRESULT hr = CoCreateInstance(__uuidof(CHostDrv), NULL, CLSCTX_INPROC, __uuidof(IHostDrv), (LPVOID ) &m_pIHostDrv);
    Definitions
    #define MAX_USB_DEVICES 32 // maximum number of devcs supported #define NUM_ACTUATORS 160 // words sent in 128/140 modes #define USB_BYTES_PER_FRAME (NUM_ACTUATORS
    2) // Error codes from CIUSBLib interface methods #define H_DEVICE_STATUS_OK 0 // No Errors #define H_DEVICE_NOT_FOUND -1 // USB Device was not found #define H_DEVICE_NO_COMM -2 // USB communication was lost #define H_DEVICE_CMD_ERR -3 // Unknown command #define H_DEVICE_TIMEOUT -4 // USB transfer time out // USB Message callback definitions #define CIUsb_MESSAGE_USBDEVICE 0 // USB PNP Message #define CIUsb_MSG_USBDEV_REMOVAL 0 // USB PNP Message: removal #define CIUsb_MSG_USBDEV_ARRIVAL 1 // USB PNP Message: arrival // Used in CIUSBLib CIUsb_GetStatus() #define CIUsb_STATUS_DEVICENAME 0 // Get Device Name #define CIUsb_STATUS_VID 1 // Get Device Vendor ID #define CIUsb_STATUS_PID 2 // Get Device Product ID #define CIUsb_STATUS_FRAME_ERROR 3 // Get value of FRAME_ERROR bit #define CIUsb_STATUS_PD_HVA_E 4 // Get value of PD_HVA_E bit #define CIUsb_STATUS_CABLE_OK 5 // Get value of CABLE_OK bit // Used in CIUSBLib CIUsb_SetControl() #define CIUsb_CONTROL_ASSERT_FRAME_SYNC 0 // Set FRAME_SYC = 1 #define CIUsb_CONTROL_DEASSERT_FRAME_SYNC 1 // Set FRAME_SYC = 0 #define CIUsb_CONTROL_ASSERT_FRESET 2 // Set FRESET = 1 #define CIUsb_CONTROL_DEASSERT_FRESET 3 // Set FRESET = 0 #define CIUsb_CONTROL_ASSERT_HV_ENAB 4 // Set HV_ENAB = 1 #define CIUsb_CONTROL_DEASSERT_HV_ENAB 5 // Set HV_ENAB = 0
    Boston Micromachines Corporation | Copyright 2009
    CIUsb_GetAvailableDevices
    HRESULT CIUsb_GetAvailableDevices ([out] LONG *pDeviceIds, [in] LONG nSizeBuff, LONG * p_nStatus); CIUsb_GetAvailableDevices() returns an array of device IDs that can be used in later calls as the nDevId parameter. nSizeBuff in the size in LONG words of the array. p_nStatus points to the return status word. This method should be called after each notification of USB device removal or USB device arrival.
    CIUsb_SetNotify
    HRESULT CIUsb_SetNotify ([in] HWND hWindow, [in] UINT uMessageId); CIUsb_SetNotify() specifies a window handle and message for notification of USB device removal and arrival events. When a device is inserted or removed, the message uMessageId is sent to hWindow. Upon receiving the message, the handler can check lParam for CIUsb_MESSAGE_USBDEVICE and wParam for either CIUsb_MSG_USBDEV_REMOVAL or CIUsb_MSG_USBDEV_ARRIVAL. The method CIUsb_GetAvailableDevices() should be called in either case to update the application’s view of available devices.
    CIUsb_GetStatus
    HRESULT CIUsb_GetStatus ([in] LONG nDevId, [in] LONG nStatId, [out] LONG* p_nStatus); CIUsb_GetStatus() returns requested status from device index nDevId. The status requested is specified by nStatId. The status is returned using the p_nStatus pointer. The status requests that are currently supported are: CIUsb_STATUS_DEVICENAME (char ) Device “FriendlyName” CIUsb_STATUS_VID (long ) Device Unique Vendor ID CIUsb_STATUS_PID (long ) Device Unique Product ID CIUsb_STATUS_FRAME_ERROR (long ) Device Framing Error Status CIUsb_STATUS_PD_HVA_E (long ) Device High Voltage Status CIUsb_STATUS_CABLE_OK (long ) Device Cable Status
    CIUsb_SetControl
    HRESULT CIUsb_SetControl ([in] LONG nDevId, [in] LONG nCntlId, [out] LONG
    p_nStatus); CIUsb_SetControl() commands control bits on device index nDevId. The control function is specified by nCntlId. The control functions that are currently supported are: CIUsb_CONTROL_ASSERT_FRAME_SYNC Set FRAME_SYC = 1 CIUsb_CONTROL_DEASSERT_FRAME_SYNC Set FRAME_SYC = 0 CIUsb_CONTROL_ASSERT_FRESET Set FRESET = 1 CIUsb_CONTROL_DEASSERT_FRESET Set FRESET = 0 CIUsb_CONTROL_ASSERT_HV_ENAB Set HV_ENAB = 1 CIUsb_CONTROL_DEASSERT_HV_ENAB Set HV_ENAB = 0
    CIUsb_SendFrameData
    HRESULT CIUsb_SendFrameData ([in] LONG nDevId, [in] BYTE
    pFrameData, [in] LONG nBuffSize, [out] LONG
    p_nStatus); The CIUsb_SendFrameData() method is identical to and has been replaced by CIUsb_StepFrameData(). See section 4.9.
    Boston Micromachines Corporation | Copyright 2009
    CIUsb_StreamFrameData
    HRESULT CIUsb_StreamFrameData ([in] LONG nDevId, [in] BYTE
    pFrameData, [in] LONG nBuffSize, [out] LONG
    p_nStatus); CIUsb_StreamFrameData() sends a frame of actuator data to the device index nDevId. The pFrameData parameter points to the actuator data and the nBuffSize parameter specifies the size of the data buffer in bytes. When using this method, frame data is buffered to maximize throughput at the expense of data latency. There will be some delay between calling this method and the frame data arriving at the target.
    CIUsb_StepFrameData
    HRESULT CIUsb_StepFrameData ([in] LONG nDevId, [in] BYTE
    pFrameData, [in] LONG nBuffSize, [out] LONG* p_nStatus); CIUsb_StepFrameData() sends a frame of actuator data to the device index nDevId. The pFrameData parameter points to the actuator data and the nBuffSize parameter specifies the size of the data buffer in bytes. When using this method, frame data is not buffered to minimize latency at the expense of throughput. Each call to this method will result in data arriving at the target with minimal latency. The overall frame rate will be limited as compared to the CIUsb_StreamFrameData() method.
    CIUsb_FlushStream
    HRESULT CIUsb_FlushStream ([in] LONG nDevId, [out] LONG* p_nStatus); CIUsb_FlushStream() terminates a frame stream to the device index nDevId. When using the CIUsb_StreamFrameData() method, CIUsb_FlushStream() should be called at the end of streaming operations to properly terminate. Some frames may be lost (and not sent to the target) as the stream buffers are cleared.



  • Absoluter Beginner schrieb:

    Wir können es uns nicht vorstellen was da im Endeeffekt alles noch reingeschrieben werden müsste.

    Ein Programmierer wüsste es. Besorgt euch einen Programmierer.

    Wir können es uns nicht vorstellen was da im Endeeffekt alles noch reingeschrieben werden müsste. Zuerst einmal das Ganze include, import, define ... oder? Und dann ins Programm nach dem main nur mehr die danach beschriebenen Befehle?

    Ist das ein Aprilscherz?



  • Im Zweifelsfalle gehst Du mit Deinem Spiegel auf den nächstbesten Polterabend. Das bringt dem Brautpaar zwar nach Hörensagen Pech, aber dafür bist Du das Teil los.

    PS: Achso, ja, deformiert ist er dann auch so richtig schön.

    Insofern: Einen schönen 1.4.


Anmelden zum Antworten