Products for USB Sensing and Control
It is currently Sun May 26, 2013 3:14 am

All times are UTC - 7 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: 8/8/8 digital outputs
PostPosted: Thu Apr 07, 2011 9:16 am 
Offline
Phidgetsian

Joined: Thu Apr 07, 2011 8:41 am
Posts: 7
Hi,
I've adquired an 8/8/8 and I'm testing it, but I haven't any signal at the outputs. May it be 5V? I'm testing it with this simple C-code:

And I have on the screen:
The 0 output state is 0. Press a key to continue
The 0 output state is 0. Press a key to continue


Changing the order of PTRUE and PFALSE, I obtain:
The 0 output state is 0. Press a key to continue
The 0 output state is 1. Press a key to continue


Anyway, the voltage at the output is 0V. Any help?

Thanks in advanced.
Cherrs.


Top
 Profile Send private message  
 
PostPosted: Thu Apr 07, 2011 9:19 am 
Offline
Phidgetsian

Joined: Thu Apr 07, 2011 8:41 am
Posts: 7
Sorry, the code is:

#include <phidget21.h>
#include <stdio.h>

int state, index;

int main(int argc, char *argv[])
{
index=0;

CPhidgetInterfaceKitHandle magneto = 0;
CPhidgetInterfaceKit_create(&magneto);

CPhidget_open((CPhidgetHandle)magneto, -1);

CPhidgetInterfaceKit_setOutputState(magneto, index, PTRUE);
CPhidgetInterfaceKit_getOutputState(magneto, index, &state);
printf("The %d output state is %d. Press a key to continue\n", index, state);
getchar();

CPhidgetInterfaceKit_setOutputState(magneto, index, PFALSE);
CPhidgetInterfaceKit_getOutputState(magneto, index, &state);
printf("The %d output state is %d. Press a key to continue\n", index, state);
getchar();

printf("Closing...\n");
CPhidget_close((CPhidgetHandle)magneto);
CPhidget_delete((CPhidgetHandle)magneto);

return 0;
}


Top
 Profile Send private message  
 
PostPosted: Thu Apr 07, 2011 9:31 am 
Offline
Phidgetsian

Joined: Thu Apr 07, 2011 8:41 am
Posts: 7
I've forgotten another thing: I feed the computer only with the USB cable, but I've tried too with a power supply (12V at 1.25A) and it doesn't work neither.

Thank you very much.
Regards,
Xap.


Top
 Profile Send private message  
 
PostPosted: Thu Apr 07, 2011 11:21 am 
Offline
King of the Lab

Joined: Fri Mar 06, 2009 12:42 pm
Posts: 444
Location: Calgary, Canada
Have you tried running the InterfaceKit-full example we provide on the website, and are the digital outputs working in the example?

Looking at your code, you should add a CPhidget_waitForAttachment after CPhidget_open, since CPhidget_open returns immediately, but does not guarantee that the 8/8/8 is ready to be communicated with.

This is why when you have set PTRUE second, the output changes to 1, since getchar gives the 8/8/8 time to get ready for commands.


Top
 Profile Send private message  
 
PostPosted: Fri Apr 08, 2011 5:22 am 
Offline
Phidgetsian

Joined: Thu Apr 07, 2011 8:41 am
Posts: 7
Hi erik,

Yes, I tried the InterfaceKit-full example, and I obtained:

Waiting for interface kit to be attached....Phidget InterfaceKit 8/8/8 31643 attached!
Digital Input: 0>State:0
Digital Input: 1>State:0
Digital Input: 2>State:0
Digital Input: 3>State:0
Digital Input: 4>State:0
Digital Input: 5>State:0
Digital Input: 6>State:0
Digital Input: 7>State:0
Digital Output:0>State:0
Digital Output:1>State:0
Digital Output:2>State:0
Digital Output:3>State:0
Digital Output:4>State:0
Digital Output:5>State:0
Digital Output: 6 > State: 0
Digital Output: 7 > State: 0
Sensor: 0 > Value: 0
Sensor: 1 > Value: 1
Sensor: 2 > Value: 1
Sensor: 3 > Value: 0
Sensor: 4 > Value: 1
Sensor: 5 > Value: 0
Sensor: 6 > Value: 0
Sensor: 7 > Value: 0
PhidgetInterfaceKit
Serial Number: 31643
Version: 823
# Digital Inputs: 8
# Digital Outputs: 8
# Sensors: 8
Ratiometric: 1
Sensor#: 0 > Sensitivity Trigger: 10
Sensor#: 1 > Sensitivity Trigger: 10
Sensor#: 2 > Sensitivity Trigger: 10
Sensor#: 3 > Sensitivity Trigger: 10
Sensor#: 4 > Sensitivity Trigger: 10
Sensor#: 5 > Sensitivity Trigger: 10
Sensor#: 6 > Sensitivity Trigger: 10
Sensor#: 7 > Sensitivity Trigger: 10
Reading.....
Press any key to go to next step

Modifying sensor sensitivity triggers....
Reading.....
Press any key to go to next step

Toggling Ratiometric....
Reading.....
Press any key to end

Closing...


Now, I've inserted the code:

/******************************************/
CPhidgetInterfaceKit_setOutputState(ifKit, index, PTRUE); CPhidgetInterfaceKit_getOutputState(ifKit, index, &state); printf("The %d output state is %d. Press a key\n", index, state);
getchar();

CPhidgetInterfaceKit_setOutputState(ifKit, index, PFALSE);
CPhidgetInterfaceKit_getOutputState(ifKit, index, &state);
printf("The %d output state is %d. Press a key\n", index, state);
getchar();
/*******************************************/

and I've obtained:

The 5 output state is 0. Press a key
Digital Output: 5 > State: 1

The 5 output state is 1. Press a key
Digital Output: 5 > State: 0


But at the output the voltage is 0 in both cases. Anyway, these 1->0 and 0->1 at the output are so stranges, aren't they? Could the controller be crashed because I fed it some time with 12V@1.25A?

Thank you so much.


Top
 Profile Send private message  
 
PostPosted: Fri Apr 08, 2011 6:14 am 
Offline
Phidgetsian

Joined: Thu Apr 07, 2011 8:41 am
Posts: 7
Now it works right!

Thank you erik. Cheers,
Xap.


Top
 Profile Send private message  
 
PostPosted: Fri Apr 08, 2011 9:23 am 
Offline
King of the Lab

Joined: Fri Mar 06, 2009 12:42 pm
Posts: 444
Location: Calgary, Canada
State 1 just means that it is set to PTRUE, and state 0 means it is set to PFALSE, where State 1 == 5V and State 0 == 0V.

Where are you measuring the voltage on? It is weird that it is always 0V.

But if it works now, then maybe the measurement connection wasn't very secure.

Glad to hear!


Top
 Profile Send private message  
 
PostPosted: Fri Apr 08, 2011 2:17 pm 
Offline
Phidgetsian

Joined: Thu Apr 07, 2011 8:41 am
Posts: 7
Yes, I know that, because I'm an electronic physician hehe. But I didn't understand why the "state" variable on CPhidgetInterfaceKit_getOutputState(ifKit, index, &state); returns me The 5 output state is 0 and the Handler Digital Output: 5 > State: 1 and vice versa.

The problem was so simple: I did the measurement with a multimeter and the contact between it and the 8/8/8 wouldn't was so good. Then, I've thought that maybe it was the problem and I've connected a pair of wires into the outputs and... 5V. I've felt like a fool :)

Thanks for all, erik.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 7 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group