Absolute Beginner!!!!!!!!!!!

Comments & issues
The Gent
Fresh meat
Posts: 3
Joined: Wed Nov 21, 2012 9:59 am
Contact:

Absolute Beginner!!!!!!!!!!!

Postby The Gent » Wed Nov 21, 2012 10:13 am

Good day,

I have been tasked with using a digital input from a 1018 interface card to drive a motor via a 1062 phiddget stepper.

I have managed to get both handlers (from the example code) in the source file debugged and built the .exe however, getting the motor to turn based on an input is where I fall down.

As before If I wanted to turn a digital output on via the digital input I would use the below code:

printf("Digital Input: %d > State: %d\n", Index, State);
if (Index == 3 && State == PTRUE) {
CPhidgetInterfaceKit_setOutputState(IFK, 0, PTRUE);
}
else if (Index == 3 && State == PFALSE) {
CPhidgetInterfaceKit_setOutputState(IFK, 0, PFALSE);
}
return 0;
}

I thought if I wanted to turn a motor I would modify this accordingly

if (Index == 3 && State == PTRUE) {
CPhidgetStepper_setTargetPosition (stepper, 0, 200);
}
else if (Index == 3 && State == PFALSE) {
CPhidgetStepper_setTargetPosition (stepper, 0, 0);
}
return 0;

Unfortunately its not that easy (I guess that why I'm not a programmer)

Any help would be very much appreciated.

Regards

The Gent

User avatar
Patrick
Lead Developer
Posts: 3176
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Absolute Beginner!!!!!!!!!!!

Postby Patrick » Wed Nov 21, 2012 11:24 am

Make sure to set the motor enabled to true, or it won't start moving.

-Patrick

The Gent
Fresh meat
Posts: 3
Joined: Wed Nov 21, 2012 9:59 am
Contact:

Re: Absolute Beginner!!!!!!!!!!!

Postby The Gent » Wed Nov 21, 2012 11:35 am

Patrick Thanks,

I believe the motor is enabled as the example code initiates a sequence that sees the motor spinning in both directions.

My problem is trying to get the motor to spin based on a command from the 1018 interface kit

Cheers


Return to “General”

Who is online

Users browsing this forum: No registered users and 3 guests