New PhidgetSBC Firmware Version 1.0.4

General PhidgetSBC Discussion.
User avatar
Patrick
Lead Developer
Posts: 3399
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: New PhidgetSBC Firmware Version 1.0.4

Post by Patrick »

Have you installed the 64-bit Visual studio compiler/libraries? These are not installed by default, so you'll have to select them specifically in the installer. If you are using the Express version of Visual Studio (the free version), then it doesn't support 64-bit compiling, but you can install the 64-bit compiler by installing the Windows SDK, which can be downloaded for free.

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

Re: New PhidgetSBC Firmware Version 1.0.4

Post by Patrick »

As for better Matlab support - we are definitely planning this. We hope to provide a more integrated solution, rather then just calling directly into the C library. Right now, Matlab support is more of a 'proof of concept' with some examples, then a fully supported language (with examples for every Phidget).

-Patrick
galileo

Re: New PhidgetSBC Firmware Version 1.0.4

Post by galileo »

Thank you for your quick response...
i have installed VS2008 professional edition that supports both 32-bit and 64-bit sytems...so what do i have to do now, to install also windows SDK????

And as far it concerns matlab's support, when we should be expecting it???
User avatar
Patrick
Lead Developer
Posts: 3399
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: New PhidgetSBC Firmware Version 1.0.4

Post by Patrick »

Have you explicitly selected the 64-bit C compiler in the Visual Studio installer?

No date on full Matlab support. It's a big project, and not yet started.

-Patrick
galileo

Re: New PhidgetSBC Firmware Version 1.0.4

Post by galileo »

i did reinstall the VS2008 with x64 compilers/libraries components, but now i get another error:

Code: Select all

Warning: Warnings messages were produced while parsing.  Check the functions you
intend to use for correctness.  Warning text can be viewed using:
[notfound,warnings]=loadlibrary(...) 
> In loadlibrary at 396
  In analogin at 4
Warning: The enumeration 'CPhidgetDictionary_keyChangeReason' already exists and will not be
created 
> In loadlibrary at 458
  In analogin at 4
Warning: The enumeration 'CPhidgetIR_Encoding' already exists and will not be created 
> In loadlibrary at 458
  In analogin at 4
Warning: The enumeration 'CPhidgetTemperatureSensor_ThermocoupleType' already exists and will
not be created 
> In loadlibrary at 458
  In analogin at 4
Warning: The enumeration 'CPhidgetLED_Voltage' already exists and will not be created 
> In loadlibrary at 458
  In analogin at 4
Warning: The enumeration 'CPhidget_DeviceID' already exists and will not be created 
> In loadlibrary at 458
  In analogin at 4
Warning: The enumeration 'CPhidgetLED_CurrentLimit' already exists and will not be created 
> In loadlibrary at 458
  In analogin at 4
Warning: The enumeration 'CPhidget_DeviceClass' already exists and will not be created 
> In loadlibrary at 458
  In analogin at 4
Warning: The enumeration 'CPhidgetLog_level' already exists and will not be created 
> In loadlibrary at 458
  In analogin at 4
Warning: The enumeration 'CPhidget_ServoType' already exists and will not be created 
> In loadlibrary at 458
  In analogin at 4
Warning: The enumeration 'CPhidgetIR_Length' already exists and will not be created 
> In loadlibrary at 458
  In analogin at 4
Warning: The structure type 's_CPhidget_Timestamp' already exists.
The existing type will be reused. 
> In loadlibrary at 458
  In analogin at 4
Warning: The structure type 's_CPhidgetIR_CodeInfo' already exists.
The existing type will be reused. 
> In loadlibrary at 458
  In analogin at 4
Warning: The structure type 's_CPhidgetSpatial_SpatialEventData' already exists.
The existing type will be reused. 
> In loadlibrary at 458
  In analogin at 4
Warning: The data type 'FcnPtr' used by function CPhidgetDictionary_set_OnKeyChange_Handler does
not exist. 
> In loadlibrary at 458
  In analogin at 4
Error loading library intermediate output follows.
The actual error is at the end of this output.
*********

Failed to parse type '...' original input ' ...'
Found on line 702 of input from line 701 of file C:\\Program Files\\MATLAB\\R2010b\\Mike_Matlab\\phidget21Matlab.h
Error parsing argument for function CPhidget_log function may be invalid.
*********
??? Error using ==> loaddefinedlibrary
The function call type stdcall is not supported

Error in ==> loadlibrary at 458
    loaddefinedlibrary(librarypath,fcns,classname,structs,enums, thunkfilename,
    LibraryTempDirectory);

Error in ==> analogin at 4
loadlibrary phidget21 phidget21Matlab.h ;
 
>> 
can you figure what is wrong???
User avatar
Patrick
Lead Developer
Posts: 3399
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: New PhidgetSBC Firmware Version 1.0.4

Post by Patrick »

That's odd, what version of Matlab are you using?

You can just delete the offending lines and try to continue. (lines 700-701 from phidget21matlab.h).

-Patrick
galileo

Re: New PhidgetSBC Firmware Version 1.0.4

Post by galileo »

erik wrote:The temperature sensor that you are using (the 1125) is simply an analog sensor. You cannot "connect" to it using the Open commands.

You need to access the port (index) of the InterfaceKit that you plugged the sensor into.

Code: Select all

int CPhidgetInterfaceKit_getSensorValue (CPhidgetInterfaceKitHandle phid, int index, int *sensorValue)
Then use the formula in the 1125 manual to convert the sensorValue into a temperature.

Hello again...Itried the function above but i am a little bit confused...Somewhere i must declare the CPhidgetInterfaceKitHandle phid of the function so as for the program to know where it should be searching...I'm sending the code:

Code: Select all

// - TemperatureSensor simple -
// This simple example simple opens a temperature sensor phidget and waits for one to be attached.  The program will then wait for
// user input to terminate.  While waiting it will display the data generated by the events, such as the temperature change event
// which will display the currently measured temperature without sensitivity modifications.
//
// Copyright 2008 Phidgets Inc.  All rights reserved.
// This work is licensed under the Creative Commons Attribution 2.5 Canada License.
// view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/ca/

// - InterfaceKit simple -
// This simple example simply creates an InterfaceKit handle, hooks the event handlers and opens it.  It then waits
// for an InterfaceKit to be attached and waits for events to be fired. We progress through three steps, 1. Normal settings, 
// 2. Setting analog sensor sensitivity to 100, 3. Toggling Ratiometric, waiting for user input to proceed to next step to allow 
// data to be read.
//
// Copyright 2008 Phidgets Inc.  All rights reserved.
// This work is licensed under the Creative Commons Attribution 2.5 Canada License. 
// view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/ca/


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

int AttachHandler(CPhidgetHandle IFK, void *userptr)
{
	int serialNo;
	const char *name;

	CPhidget_getDeviceName(IFK, &name);
	CPhidget_getSerialNumber(IFK, &serialNo);

	printf("%s %10d attached!\n", name, serialNo);

	return 0;
}

int DetachHandler(CPhidgetHandle IFK, void *userptr)
{
	int serialNo;
	const char *name;

	CPhidget_getDeviceName (IFK, &name);
	CPhidget_getSerialNumber(IFK, &serialNo);

	printf("%s %10d detached!\n", name, serialNo);

	return 0;
}

int ErrorHandler(CPhidgetHandle IFK, void *userptr, int ErrorCode, const char *unknown)
{
	printf("Error handled. %d - %s", ErrorCode, unknown);
	return 0;
}

//callback that will run if an input changes.
//Index - Index of the input that generated the event, State - boolean (0 or 1) representing the input state (on or off)
int InputChangeHandler(CPhidgetInterfaceKitHandle IFK, void *usrptr, int Index, int State)
{
	printf("Digital Input: %d > State: %d\n", Index, State);
	return 0;
}

//callback that will run if an output changes.
//Index - Index of the output that generated the event, State - boolean (0 or 1) representing the output state (on or off)
int OutputChangeHandler(CPhidgetInterfaceKitHandle IFK, void *usrptr, int Index, int State)
{
	printf("Digital Output: %d > State: %d\n", Index, State);
	return 0;
}

//callback that will run if the sensor value changes by more than the OnSensorChange trigger.
//Index - Index of the sensor that generated the event, Value - the sensor read value
int SensorChangeHandler(CPhidgetInterfaceKitHandle IFK, void *usrptr, int Index, int Value)
{
	printf("Sensor: %d > Value: %d\n", Index, Value);
	return 0;
}

//Display the properties of the attached phidget to the screen.  We will be displaying the name, serial number and version of the attached device.
//Will also display the number of inputs, outputs, and analog inputs on the interface kit as well as the state of the ratiometric flag
//and the current analog sensor sensitivity.
int display_properties(CPhidgetInterfaceKitHandle phid)
{
	int serialNo, version, numInputs, numOutputs, numSensors, triggerVal, ratiometric, i;
	const char* ptr;

	CPhidget_getDeviceType((CPhidgetHandle)phid, &ptr);
	CPhidget_getSerialNumber((CPhidgetHandle)phid, &serialNo);
	CPhidget_getDeviceVersion((CPhidgetHandle)phid, &version);

	CPhidgetInterfaceKit_getInputCount(phid, &numInputs);
	CPhidgetInterfaceKit_getOutputCount(phid, &numOutputs);
	CPhidgetInterfaceKit_getSensorCount(phid, &numSensors);
	CPhidgetInterfaceKit_getRatiometric(phid, &ratiometric);

	printf("%s\n", ptr);
	printf("Serial Number: %10d\nVersion: %8d\n", serialNo, version);
	printf("# Digital Inputs: %d\n# Digital Outputs: %d\n", numInputs, numOutputs);
	printf("# Sensors: %d\n", numSensors);
	printf("Ratiometric: %d\n", ratiometric);

	for(i = 0; i < numSensors; i++)
	{
		CPhidgetInterfaceKit_getSensorChangeTrigger (phid, i, &triggerVal);

		printf("Sensor#: %d > Sensitivity Trigger: %d\n", i, triggerVal);
	}

	return 0;
}

int AttachHandlerTemp(CPhidgetHandle TEMP, void *userptr)
{
	int serialNo;
	const char *name;

	CPhidget_getDeviceName (TEMP, &name);
	CPhidget_getSerialNumber(TEMP, &serialNo);
	printf("%s %10d attached!\n", name, serialNo);

	return 0;
}

int DetachHandlerTemp(CPhidgetHandle TEMP, void *userptr)
{
	int serialNo;
	const char *name;

	CPhidget_getDeviceName (TEMP, &name);
	CPhidget_getSerialNumber(TEMP, &serialNo);
	printf("%s %10d detached!\n", name, serialNo);

	return 0;
}

int ErrorHandlerTemp(CPhidgetHandle TEMP, void *userptr, int ErrorCode, const char *Description)
{
	printf("Error handled. %d - %s\n", ErrorCode, Description);
	return 0;
}

int TemperatureChangeHandler(CPhidgetTemperatureSensorHandle TEMP, void *usrptr, int Index, double Value)
{
	double ambient;
	CPhidgetTemperatureSensor_getAmbientTemperature(TEMP, &ambient);
	printf("Temperature sensor: %d > Temperature: %f (Ambient: %f)\n", Index, Value, ambient);
	return 0;
}

//Display the properties of the attached phidget to the screen.  We will be displaying the name, serial number and version of the attached device.
int display_properties(CPhidgetTemperatureSensorHandle phid)
{
	int serialNo, version, numInputs, i;
	double value;
	const char* ptr;

	double min, max;

	CPhidget_getDeviceType((CPhidgetHandle)phid, &ptr);
	CPhidget_getSerialNumber((CPhidgetHandle)phid, &serialNo);
	CPhidget_getDeviceVersion((CPhidgetHandle)phid, &version);

	CPhidgetTemperatureSensor_getTemperatureInputCount (phid, &numInputs);


	printf("%s\n", ptr);
	printf("Serial Number: %10d\nVersion: %8d\n", serialNo, version);
	printf("# Temperature Inputs: %d\n", numInputs);

	for(i = 0; i < numInputs; i++)
	{
		CPhidgetTemperatureSensor_getTemperatureChangeTrigger (phid, i, &value);
		CPhidgetTemperatureSensor_getTemperatureMax(phid, i, &max);
		CPhidgetTemperatureSensor_getTemperatureMin(phid, i, &min);
		printf("Temperature Input #: %d > sensitivity: %f Max: %0.0f, Min: %0.0f\n", i, value, max, min);
	}

	CPhidgetTemperatureSensor_getPotentialMax(phid, 0, &max);
	CPhidgetTemperatureSensor_getPotentialMin(phid, 0, &min);
	printf("Potential Max: %0.3f, Min: %0.3f\n", max, min);

	CPhidgetTemperatureSensor_getAmbientTemperatureMax(phid, &max);
	CPhidgetTemperatureSensor_getAmbientTemperatureMin(phid, &min);
	printf("Ambient Sensor Max: %0.0f, Min: %0.0f\n", max, min);

	return 0;
}
////////////////////////////////////////////////////////////////////////////////////
int tempsensor_simple(int *tempsensorValue)
{
	int result;
	const char *err;
	

	//Declare an temperature sensor handle
	CPhidgetTemperatureSensorHandle temp = 0;
	

	//create the temperature sensor object
	CPhidgetTemperatureSensor_create(&temp);
	

	printf("H timh ths temp einai %f",temp);

	//Set the handlers to be run when the device is plugged in or opened from software, unplugged or closed from software, or generates an error.
	CPhidget_set_OnAttach_Handler((CPhidgetHandle)temp, AttachHandler, NULL);
	CPhidget_set_OnDetach_Handler((CPhidgetHandle)temp, DetachHandler, NULL);
	CPhidget_set_OnError_Handler((CPhidgetHandle)temp, ErrorHandler, NULL);

	//Registers a callback that will run if the Temperature changes by more than the Temperature trigger.
	//Requires the handle for the Temperature Sensor, the function that will be called, and a arbitrary pointer that will be supplied to the callback function (may be NULL).
	CPhidgetTemperatureSensor_set_OnTemperatureChange_Handler(temp, TemperatureChangeHandler, NULL);

	//open the temperature sensor for device connections
	//CPhidget_open((CPhidgetHandle)temp, -1);

	CPhidgetInterfaceKit_getSensorValue ((CPhidgetInterfaceKitHandle)ifkit, 0, tempsensorValue);
    printf("AAA %f",*tempsensorValue);

	//get the program to wait for an temperature sensor device to be attached
	printf("Waiting for TemperatureSensor to be attached....");
	if((result = CPhidget_waitForAttachment((CPhidgetHandle)temp, 10000)))
	{
		CPhidget_getErrorDescription(result, &err);
		printf("Problem waiting for attachment: %s\n", err);
		return 0;
	}

	//Display the properties of the attached accelerometer device
	display_properties(temp);

	//read temperature sensor event data
	printf("Reading.....\n");
	//tempsensor_simple(tempsensorValue);

	//keep displaying temperature sensor event data until user input is read

	//modify the sensor sensitivity, index 1 is the thermocouple sensor, index 0 is the onboard or ambient sensor
	//printf("Setting sensitivity of the thermocouple to 2.00. Press any key to continue\n");
	//getchar();

	//CPhidgetTemperatureSensor_setTemperatureChangeTrigger (temp, 1, 2.00);

	printf("Press any key to end\n");
	getchar();

	//since user input has been read, this is a signal to terminate the program so we will close the phidget and delete the object we created
	printf("Closing...\n");
	CPhidget_close((CPhidgetHandle)temp);
	CPhidget_delete((CPhidgetHandle)temp);

	//all done, exit
	return 0;
}
//////////////////////////////////////////////////////////////////////////////////////////////////


int interfacekit_simple()
{
	int result, numSensors, i;
	const char *err;
	int tempsensorValue=0;

	//Declare an InterfaceKit handle
	CPhidgetInterfaceKitHandle ifKit = 0;

	//create the InterfaceKit object
	CPhidgetInterfaceKit_create(&ifKit);

	//Set the handlers to be run when the device is plugged in or opened from software, unplugged or closed from software, or generates an error.
	CPhidget_set_OnAttach_Handler((CPhidgetHandle)ifKit, AttachHandler, NULL);
	CPhidget_set_OnDetach_Handler((CPhidgetHandle)ifKit, DetachHandler, NULL);
	CPhidget_set_OnError_Handler((CPhidgetHandle)ifKit, ErrorHandler, NULL);

	//Registers a callback that will run if an input changes.
	//Requires the handle for the Phidget, the function that will be called, and an arbitrary pointer that will be supplied to the callback function (may be NULL).
	CPhidgetInterfaceKit_set_OnInputChange_Handler (ifKit, InputChangeHandler, NULL);

	//Registers a callback that will run if the sensor value changes by more than the OnSensorChange trig-ger.
	//Requires the handle for the IntefaceKit, the function that will be called, and an arbitrary pointer that will be supplied to the callback function (may be NULL).
	CPhidgetInterfaceKit_set_OnSensorChange_Handler (ifKit, SensorChangeHandler, NULL);

	//Registers a callback that will run if an output changes.
	//Requires the handle for the Phidget, the function that will be called, and an arbitrary pointer that will be supplied to the callback function (may be NULL).
	CPhidgetInterfaceKit_set_OnOutputChange_Handler (ifKit, OutputChangeHandler, NULL);

	//open the interfacekit for device connections
	//CPhidget_open((CPhidgetHandle)ifKit, -1);

	CPhidget_openRemote 	((CPhidgetHandle)ifKit, 111653,"phidgetsbc", 0);

	//get the program to wait for an interface kit device to be attached
	printf("Waiting for interface kit to be attached....");
	if((result = CPhidget_waitForAttachment((CPhidgetHandle)ifKit, 10000)))
	{
		CPhidget_getErrorDescription(result, &err);
		printf("Problem waiting for attachment: %s\n", err);
		return 0;
	}

	//Display the properties of the attached interface kit device
	display_properties(ifKit);

	//read interface kit event data
	printf("Reading.....\n");

	//keep displaying interface kit data until user input is read
	printf("Press any key to go to next step\n");
	getchar();

	printf("Modifying sensor sensitivity triggers....\n");

	//get the number of sensors available
	CPhidgetInterfaceKit_getSensorCount(ifKit, &numSensors);

	//Change the sensitivity trigger of the sensors
	for(i = 0; i < numSensors; i++)
	{
		CPhidgetInterfaceKit_setSensorChangeTrigger(ifKit, i, 100);  //we'll just use 10 for fun
	}

	//read interface kit event data
	printf("Reading.....\n");

	
	//keep displaying interface kit data until user input is read
	printf("Press any key to go to next step\n");
	getchar();

	printf("Toggling Ratiometric....\n");

	CPhidgetInterfaceKit_setRatiometric(ifKit, 0);

	//read interface kit event data
	printf("Reading.....\n");

	tempsensor_simple(&tempsensorValue);

	printf("H thermokrasia einai :%f (°C)",tempsensorValue  * 0.22222 - 61.11);

	//keep displaying interface kit data until user input is read
	//printf("Press any key to end\n");
	//getchar();

	//since user input has been read, this is a signal to terminate the program so we will close the phidget and delete the object we created
	//printf("Closing...\n");
	//CPhidget_close((CPhidgetHandle)ifKit);
	//CPhidget_delete((CPhidgetHandle)ifKit);

	//all done, exit
	return 0;
}



int main(int argc, char* argv[])
{
	interfacekit_simple();
	
	return 0;
}

can you tell me what should i do to make it work??what should i declare as CPhidgetInterfaceKitHandle phid because i put ifkit and correctly it says that is not defined, such it is below in the next function int interfacekit_simple()...
erik
King of the Lab
Posts: 476
Joined: Fri Mar 06, 2009 12:42 pm
Location: Calgary, Canada
Contact:

Re: New PhidgetSBC Firmware Version 1.0.4

Post by erik »

In interfacekit_simple() on the line where you have

Code: Select all

tempsensor_simple(&tempsensorValue);
replace with

Code: Select all

CPhidgetInterfaceKit_getSensorValue ((CPhidgetInterfaceKitHandle)ifkit, 0, tempsensorValue);
If you are using the 1125 Temperature/Humidity Sensor (http://www.phidgets.com/products.php?ca ... ct_id=1125), then you cannot use any of the code from TemperatureSensor-Simple.
TemperatureSensor-Simple is only used for 1051 PhidgetTemperatureSensor 1-Input (http://www.phidgets.com/products.php?ca ... ct_id=1051).
galileo

Re: New PhidgetSBC Firmware Version 1.0.4

Post by galileo »

erik wrote:In interfacekit_simple() on the line where you have

Code: Select all

tempsensor_simple(&tempsensorValue);
replace with

Code: Select all

CPhidgetInterfaceKit_getSensorValue ((CPhidgetInterfaceKitHandle)ifkit, 0, tempsensorValue);
If you are using the 1125 Temperature/Humidity Sensor (http://www.phidgets.com/products.php?ca ... ct_id=1125), then you cannot use any of the code from TemperatureSensor-Simple.
TemperatureSensor-Simple is only used for 1051 PhidgetTemperatureSensor 1-Input (http://www.phidgets.com/products.php?ca ... ct_id=1051).
a is that so??ok then.
and for my 1125 sensor what must i do???is any project to see how the program must be built???
AdamS

Re: New PhidgetSBC Firmware Version 1.0.4

Post by AdamS »

You would need to use a code sample for the PhidgetInterfaceKit. There should be a InterfaceKit-simple program in there, and to get the data for the temperature sensor you would need to poll the sensor value of the index in which the temperature sensor is plugged in, or use the sensor changed events.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests