Current Sensor value jumping by approx 10

Legacy support with Phidget21
Hannamja
Phidgetsian
Posts: 11
Joined: Tue Oct 02, 2012 2:13 am
Contact:

Current Sensor value jumping by approx 10

Postby Hannamja » Fri Oct 19, 2012 2:19 pm

Hi guys,

Right now I have phidgets interfacing with Flash. I need to get a animation done as shown in the attached video. However, the values that the sensor sends to Flash increases/decreases by a value of approximately 10, 500>510>520, resulting in a awkward animation. I need the sensor to be more precise to have a smoother animation.

Anyone has any solution to this? Here is a section of my code

function onSensorChange(evt:PhidgetDataEvent):void{
trace(evt);
tf_sensors[evt.Index].text = evt.Data;

current = phid.getSensorValue(1)/13.2 - 37.8787;
voltage = (phid.getSensorValue(0)+10)/13.2 - 37.8787; // to negate the effect of Ratiomatric
power = current*voltage;
myText.border=true;
myText.text =power.toString();
donut.rotation = power*1.8;

}
}
I use a mask to make the animation

Regards,
Benjamin

Thanks a lot!

P.S. Tried to embed the video but seems like the forums does not allow that, so I will attach the file instead. Here is the link to the video: http://www.youtube.com/watch?v=GaIZth-G9TI

erik
King of the Lab
Posts: 476
Joined: Fri Mar 06, 2009 12:42 pm
Location: Calgary, Canada
Contact:

Re: Current Sensor value jumping by approx 10

Postby erik » Mon Oct 22, 2012 7:51 am

This is because the Sensitivity of the board is set to 10, which means that an event will only occur when the SensorValue changes by 10. Try setting it to 0 (for constant data events, even when there is no change in data) or to 1 (events when the SensorValue changes by 1).

You only need to set the Sensitivity once, and this can be done after the device is opened, such as in the AttachEvent handler.

User avatar
burley
Human-Cyborg Relations
Posts: 441
Joined: Tue Sep 27, 2011 2:37 pm
Location: Calgary
Contact:

Re: Current Sensor value jumping by approx 10

Postby burley » Mon Oct 22, 2012 7:52 am

You can change the change threshold of the sensor to adjust the minimum change size. The default is 10, as you are noticing but you can set it to 0 or 1 to get a smoother gradient. Check the API for more information.

*Edit* Erik beat me to it
Brian Burley
403-282-7335 ext. 6003
support@phidgets.com

Hannamja
Phidgetsian
Posts: 11
Joined: Tue Oct 02, 2012 2:13 am
Contact:

Re: Current Sensor value jumping by approx 10

Postby Hannamja » Tue Oct 23, 2012 2:41 am

Thanks for the reply, but I don't think that was the problem. I tried rearranging the code to:

stage.addEventListener(Event.ENTER_FRAME, adjustRotation);

function adjustRotation(evt:Event):void
{
//myText.border=true;

//power = 50;
current = phid.getSensorValue(1)/13.2 - 37.8787;
voltage = (phid.getSensorValue(0)+10)/13.2 - 37.8787;
power = current*voltage;}

So the value should refresh at every frame. However, I think that the problem is with the value of phid.getSensorValue(1). It always increases by approx 10, which will make my current and power increase/decrease by a more or less fixed value. Please view the video attached and you will get what I mean. The value being displayed is phid.getSensorvalue(1).

I would like to make it such that the video being captured by phid.getSensorValue(1) is sensitive to the point where it will increase by a value of "1". That means that the phid.getSensorValue(1) should be increasing and decreasing by a value of "1", 501>502>503>504.... instead of jumping from 501 to 510.

If the problem lies with the sensitivity, is it possible to please tell me the code required to change the sensitivity of the sensor using Actionscript 3.0? I tried changing the slider bar from the Phidgets Manager but the sensitivity does not save.

Thanks for your help in advance!

Link to short video: http://www.youtube.com/watch?v=xHsXCVdrhFA

User avatar
burley
Human-Cyborg Relations
Posts: 441
Joined: Tue Sep 27, 2011 2:37 pm
Location: Calgary
Contact:

Re: Current Sensor value jumping by approx 10

Postby burley » Tue Oct 23, 2012 7:53 am

I can almost guarantee that this is caused by the sensitivity being set to 10. You need the adjust the sensor change threshold.

setSensorChangeTrigger

public function setSensorChangeTrigger( index: int, val: int ):void
Sets the change trigger for a sensor.

Parameters
index sensor index
val change trigger


You can find all information about the language you are using in the API for your language.

http://www.phidgets.com/documentation/w ... w-txt.html
Brian Burley
403-282-7335 ext. 6003
support@phidgets.com

Hannamja
Phidgetsian
Posts: 11
Joined: Tue Oct 02, 2012 2:13 am
Contact:

Re: Current Sensor value jumping by approx 10

Postby Hannamja » Tue Oct 23, 2012 8:38 am

So can I say that phid.setSensorChangeTrigger(0,1) will change the sensitivity for sensor0 to 1?

User avatar
burley
Human-Cyborg Relations
Posts: 441
Joined: Tue Sep 27, 2011 2:37 pm
Location: Calgary
Contact:

Re: Current Sensor value jumping by approx 10

Postby burley » Tue Oct 23, 2012 8:39 am

That is the gist of it yes.
Brian Burley
403-282-7335 ext. 6003
support@phidgets.com


Return to “ActionScript 3.0 - Flash CS3 / Flex / AIR”

Who is online

Users browsing this forum: No registered users and 1 guest