Help with Phidget 1047-1 Encoder & Digital Inputs in C++

Comments & issues
Supporting Windows 8 or newer
alemarketing
Fresh meat
Posts: 1
Joined: Mon Nov 17, 2025 3:55 am

Help with Phidget 1047-1 Encoder & Digital Inputs in C++

Post by alemarketing »

Hi everyone,

I’m working on a project using the Phidget 1047-1 Highspeed 4-input encoder with 2 draw wire sensors and a rotary encoder. I’m coding in C++ in Visual Studio and trying to handle both encoders and digital inputs using the Phidget22 library.

The code compiles fine, but I’m running into runtime issues and errors that all seem to point to line 1, which makes it hard to debug. I suspect it might be something with how I’m including the header or initializing the devices.

Here’s roughly what I’m doing:
  • Creating multiple PhidgetEncoder and PhidgetDigitalInput handles
  • Setting serial numbers and channels for each device
  • Assigning event handlers (onPositionChange and onStateChange)
  • Opening each device with Phidget_openWaitForAttachment
I want to log the position changes from the encoders and the state changes from the digital inputs, but the output isn’t coming as expected.

Has anyone successfully used multiple 1047-1 encoders and digital inputs in C++? Any tips on:

Proper header/library includes

Correct event handler setup

Common pitfalls when opening multiple devices simultaneously

Thanks in advance for any help or example snippets!
jdecoux
Engineering
Posts: 188
Joined: Mon Nov 13, 2017 10:20 am

Re: Help with Phidget 1047-1 Encoder & Digital Inputs in C++

Post by jdecoux »

You can use the code sample generator on the 1047 product page to generate specific code for the particular channels you are using. Simply select C as your language, and check off which channels you need.