Products for USB Sensing and Control
It is currently Sun May 19, 2013 11:47 pm

All times are UTC - 7 hours [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Tue Mar 27, 2012 7:14 pm 
Offline
Phidgetsian

Joined: Tue Mar 27, 2012 7:07 pm
Posts: 7
Hi, I am using phidget 0/16/16 to read GPIO outputs. It does not refresh upon change of the input. If it is set to 1 in the beginning and changed to 0 later, that is captured by the Phidget.
If I unplug the USB of the Phidget and plug it back, it shows me the current active inputs correctly.

How can I refresh phidget data without manually unplugging it?

Note:
I am using 3V GPIO outputs


Top
 Profile Send private message  
 
PostPosted: Wed Mar 28, 2012 8:36 am 
Offline
King of the Lab

Joined: Fri Mar 06, 2009 12:42 pm
Posts: 443
Location: Calgary, Canada
I suspect that you may not have the grounds of the 0/16/16 and the device that is outputting 3V tied together. There needs to be a common ground between them in order for the 0/16/16 to trigger correctly.


Top
 Profile Send private message  
 
PostPosted: Wed Mar 28, 2012 11:42 am 
Offline
Phidgetsian

Joined: Tue Mar 27, 2012 7:07 pm
Posts: 7
I have connected the grounds of the phidget to the ground of the GPIO chips. The phidget does not refresh the inputs : It shows once if I detach the USB and plug it back again..


Top
 Profile Send private message  
 
PostPosted: Wed Mar 28, 2012 2:52 pm 
Offline
King of the Lab

Joined: Fri Mar 06, 2009 12:42 pm
Posts: 443
Location: Calgary, Canada
Are you seeing this behaviour in our sample examples or in a custom program?


Top
 Profile Send private message  
 
PostPosted: Wed Mar 28, 2012 3:02 pm 
Offline
Phidgetsian

Joined: Tue Mar 27, 2012 7:07 pm
Posts: 7
Its my custom Phidget program, but it is using code from your InterfaceKit example.


Top
 Profile Send private message  
 
PostPosted: Wed Mar 28, 2012 3:14 pm 
Offline
King of the Lab

Joined: Fri Mar 06, 2009 12:42 pm
Posts: 443
Location: Calgary, Canada
Are you using the InputChangeEvents or are you polling their status? There may be an issue with how the InputChangeEvent handlers are set-up or used.

Does the issue still persist if the sample program is used?

If you could post some code of the initialization and the InputChangeEvent handlers, it would be helpful for us to debug.


Top
 Profile Send private message  
 
PostPosted: Wed Mar 28, 2012 3:17 pm 
Offline
Phidgetsian

Joined: Tue Mar 27, 2012 7:07 pm
Posts: 7
Code:
def __init__(self,serial=-1):
      try:
         self.interfaceKit = InterfaceKit()   
         self.interfaceKit.setOnAttachHandler(self.interfaceKitAttached)
         self.interfaceKit.setOnDetachHandler(self.interfaceKitDetached)
         self.interfaceKit.setOnErrorhandler(self.interfaceKitError)
         self.interfaceKit.setOnInputChangeHandler(self.interfaceKitInputChanged)
         self.interfaceKit.setOnOutputChangeHandler(self.interfaceKitOutputChanged)
         self.getSwitchHandle(serial)
         self.interfaceKit.enableLogging(PhidgetLogLevel.PHIDGET_LOG_VERBOSE,"log.txt")
      except PhidgetException as e:
         if (e.code == 12 or e.code == 13 or e.code==5) and serial != -1 :
            self.getSwitchHandle(-1) #find any PhidgetSwitch
         else:
            print("Phidget Exception %i: %s" % (e.code, e.details))
            raise PhidgetException(e.code)
   
   def interfaceKitAttached(self, event):
      attached = event.device
      print("-InterfaceKit %i Attached!" % (attached.getSerialNum()))
      
   def interfaceKitDetached(self, event):
      detached = event.device
      print("-InterfaceKit %i Detached!" % (detached.getSerialNum()))
   
   def interfaceKitError(self, event):
      source = event.device
      print("-InterfaceKit %i: Phidget Error %i: %s" % (source.getSerialNum(), event.eCode, event.description))
      
   def interfaceKitInputChanged(self, event):
      source = event.device
      print("-InterfaceKit %i: Input %i: %s" % (source.getSerialNum(), event.index, event.state))
      self.getInput();


Top
 Profile Send private message  
 
PostPosted: Wed Mar 28, 2012 4:55 pm 
Offline
Phidgetsian

Joined: Tue Mar 27, 2012 7:07 pm
Posts: 7
I am trying to read inputs from the Phidget but it does not update once the inputs change.
For example:
If the current state is pin1 = 1 and pin 2 = 1
It might register a change of Pin1=0
But if the current state is Pin1=0
It does not read if Pin1 is set to 1 after that.


Top
 Profile Send private message  
 
PostPosted: Wed Mar 28, 2012 5:11 pm 
Offline
Phidgetsian

Joined: Tue Mar 27, 2012 7:07 pm
Posts: 7
Please see the attached log if it helps, also I would like to add :

When the input pin is Active, it gives a voltage of 3V
and when it low, it gives a voltage of 0-.5 V.


But still this cannot explain, why does it not read a change in input when the input goes from low to high.


Attachments:
log.txt [1.45 KiB]
Downloaded 32 times
Top
 Profile Send private message  
 
PostPosted: Thu Mar 29, 2012 9:01 am 
Offline
Human-Cyborg Relations
User avatar

Joined: Tue Sep 27, 2011 2:37 pm
Posts: 314
Location: Calgary
What you are experiencing is actually to be expected. The turn-on voltage of the digital inputs on the 1012 is 4V. What this means is the input actually switches on around 3.5-3.75V. The input will switch OFF at about 1.25-1.5V. The zone in between is known as the hysteresis and in this zone unpredictable behaviour abounds. I did a few tests just now and I was able to replicate what you are seeing by using a 3V output and even as low as 1.7V.

In order to fix this you need to bring the voltage of your device up to a recommended minimum of 4V (although 3.75 would PROBABLY be good enough I won't guarantee it).

_________________
Brian Burley
403-282-7335 ext. 6003
support@phidgets.com


Top
 Profile Send private message  
 
PostPosted: Thu Mar 29, 2012 2:37 pm 
Offline
Phidgetsian

Joined: Tue Mar 27, 2012 7:07 pm
Posts: 7
Hi Brian,

Thanks a lot for the info. How ever I am still stuck. Is there a way to change the voltage that triggers the Phidget??


Top
 Profile Send private message  
 
PostPosted: Fri Mar 30, 2012 7:30 am 
Offline
Human-Cyborg Relations
User avatar

Joined: Tue Sep 27, 2011 2:37 pm
Posts: 314
Location: Calgary
No, the input range is 4-30V and that is not something you can change. You will need to increase the voltage you are feeding into the terminals. One thing you could do is use the output of your device on the gate of a transistor which switches a power supply like a 9V battery to the input on the 1012.

_________________
Brian Burley
403-282-7335 ext. 6003
support@phidgets.com


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

All times are UTC - 7 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


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