change datarate via control panel network server or javascript didn't work

Comments & issues
Supporting Windows 8 or newer
mindthegap
Phidgetsian
Posts: 5
Joined: Mon Sep 11, 2017 6:46 am

change datarate via control panel network server or javascript didn't work

Post by mindthegap »

I tried changing the data rate on a PhidgetSBC4 to which two Phidget ENC1000 quadrature encoders are connected. It doesn't work on the network server, in the control panel, or via programming.
javascript: encoder.setDataInterval(datainterval)

Where can I set this? What's wrong?

I have to Encoder, one with 10ms, the other with 250ms, and I can't change it to the same value! It's all inside a vue component, works great, without the dataInterval...

onMounted(async () => {

if (store.state.config.init1 === true || store.state.config.init2 === true) {
const conn = new phidget22.NetworkConnection(8080, store.state.config.drehradip );
try {
await conn.connect();
} catch (err) {
console.error('Error during connect', err);
process.exit(1);
}
}

if (store.state.config.init1 === true) {
const encoder1 = new phidget22.Encoder();

encoder1.setHubPort(store.state.config.port1);
encoder1.setDataInterval(store.state.config.datainterval);


// eslint-disable-next-line no-unused-vars
encoder1.onPositionChange = (positionChange, timeChange, indexTriggered) => {

if (positionChange > 0) {
props.externalfunction1();
// store.state.drill1 = store.state.drill1 + positionChange / store.state.config.drehradteiler;
store.state.drill1 = ((store.state.drill1 * (store.state.config.drehraddamping - 1)) + positionChange / store.state.config.drehradteiler) / store.state.config.drehraddamping;
// console.log("drill1", store.state.drill1);
}
};

encoder1.onAttach = () => {
console.log('Attach!');
};

encoder1.onDetach = () => {
console.log('Detach!');
};

encoder1.onError = (code, description) => {
console.log('Description: ' + description.toString());
console.log('----------');
};

try {
await encoder1.open(5000);
} catch (err) {
console.error('Error during open', err);
process.exit(1);
}
}

if (store.state.config.init2 === true) {
const encoder2 = new phidget22.Encoder();

encoder2.setHubPort(store.state.config.port2);
encoder2.setDataInterval(store.state.config.datainterval);

// eslint-disable-next-line no-unused-vars
encoder2.onPositionChange = (positionChange, timeChange, indexTriggered) => {


if (positionChange > 0) {
props.externalfunction2();
store.state.drill2 = ((store.state.drill2 * (store.state.config.drehraddamping - 1)) + positionChange / store.state.config.drehradteiler) / store.state.config.drehraddamping;
}
};

encoder2.onAttach = () => {
console.log('Attach!');
};

encoder2.onDetach = () => {
console.log('Detach!');
};

encoder2.onError = (code, description) => {
console.log('Description: ' + description.toString());
console.log('----------');
};

try {
await encoder2.open(5000);
} catch (err) {
console.error('Error during open', err);
process.exit(1);
}
}
});
User avatar
Patrick
Lead Developer
Posts: 675
Joined: Mon Jun 20, 2005 8:46 am
Location: Calgary

Re: change datarate via control panel network server or javascript didn't work

Post by Patrick »

Hi,

The Data Interval needs to be set after open has completed, or from inside the attach event.

-Patrick