1045 Phidget Temperature Sensor IR

Supporting Visual Studio on Windows
mse_uk
Phidgetsian
Posts: 5
Joined: Mon May 08, 2017 9:21 am
Contact:

1045 Phidget Temperature Sensor IR

Postby mse_uk » Mon Nov 19, 2018 8:18 am

Hi Phidgets,

I hope you are OK with me posting here. We use Rad Studio (Delphi) as a
programming language but connect to the phidgets.NET.dll as we are uplifting
our code to Phidget22. We are currently on version 1.1.0.30 but have also
tested on 1.1.0.32. The 1045 Temperature phidget is plugged directly into
a pc

I'm having difficulty getting the on change event for the 1045. When we set
everything up we get one on change event fired off but no changes thereafter.
I've put an iteration count on the form as well as breakpoints inside the
event handler but still only the one initial event.

Our minimum reproduceable code is:-

Code: Select all

procedure TForm1.btnTempClick(Sender: TObject);
begin
  Try
    //Zero the iteration count
   iter:=0;

   //Create and connect our 1045 object
   phTemp:=TTemperatureSensor.Create();
   phTemp.TemperatureChange:=Self.phTempTemperatureChange;
   phTemp.Attach:=Self.phTemperatureAttach;
   phTemp.DeviceSerialNumber:=424905;
   phTemp.IsLocal:=True;
   phTemp.IsRemote:=False;

   phTemp.Open(250);

   if phTemp.Attached = True then
    lblAttach.Caption:='Attached';

  Except
   On e:Exception do
    ShowMessage(e.Message);
  End; {Try}

end; {btnTempClick}

{*}

procedure TForm1.phTemperatureAttach(sender: IClrBaseObject;  e: IAttachEventArgs);
begin
   //Enable our timer to update the display
   tTemp.Enabled:=True;
   phTemp.TemperatureChangeTrigger:=0;
   phTemp.DataInterval:=phTemp.MinDataInterval;

end;

procedure TForm1.phTempTemperatureChange(sender: IClrBaseObject; e: ITemperatureSensorTemperatureChangeEventArgs);

begin
  Try
   //Set our variable depending on the channel
   If (Sender as TTemperatureSensor).Channel = 1 Then
    Self.dAmbient:=(Sender as TTemperatureSensor).Temperature
   Else
    Self.dIRTemp:=(Sender as TTemperatureSensor).Temperature;

   //Increment count so we can see how many change events happened
   inc(iter);
  Except
   On e:Exception do
    Begin
     ShowMessage(e.Message);
     tTemp.Enabled:=False;
   End;
  End; {Try}

end; {phTempTemperatureChange]

{*}

procedure TForm1.tTempTimer(Sender: TObject);
begin
  tTemp.Enabled:=False;
  lbl1.Caption:='Direct: ' + FloatToStr(self.dIRTemp);
  lbl2.Caption:='Ambient: ' + FloatToStr(self.dAmbient);

  lblIteration.Caption:='Iterations: ' + IntToStr(iter);
  tTemp.Enabled:=True;

end; {tTempTimer}


For the one reading we do get, the value is in line with the readings from the Phidget22 control panel. We are communicating correctly to a 1002, Vint Hub and VCP1000_0 Voltage Input. Can you guys see anything amiss at all please?

Many thanks,

Mark.

fraser
Engineering
Posts: 238
Joined: Thu Nov 19, 2009 4:41 pm
Contact:

Re: 1045 Phidget Temperature Sensor IR

Postby fraser » Mon Nov 19, 2018 10:26 am

The first problem I see is that you are trying to access channels 0 and 1 through a single object. In order to get each temperature (ambient and temperature) you need to make two objects and set their .Channel = 0 and .Channel = 1 prior to calling open on each one.

But that wouldn't cause the problem you're seeing. By default it will open Channel 0 so you should at least be getting Channel 0 values no problem. for now, try calling Open() instead of Open(250), and see what happens.

dgbaxter
Fresh meat
Posts: 2
Joined: Thu Jan 03, 2019 10:22 pm
Contact:

Re: 1045 Phidget Temperature Sensor IR

Postby dgbaxter » Thu Jan 03, 2019 10:35 pm

Are you willing to share how are using the .NET dll with Delphi? I am really upset that the Phidget folks left us Delphi shops hanging out to dry with this latest version. I've many users of my software and I trying to scramble to keep them running. Thank you!

mse_uk
Phidgetsian
Posts: 5
Joined: Mon May 08, 2017 9:21 am
Contact:

Re: 1045 Phidget Temperature Sensor IR

Postby mse_uk » Mon Jan 07, 2019 2:34 am

We use the CrystalNet runtime library so we can use .NET assemblies. https://www.crystalnet-tech.com/ For what we need it works very well. The only issue is that the assemblies are versioned so we have to be careful. We use Rad Studio 2010 but have evaluated Crystalnet with an evaluation copy of Tokyo both 32bit and 64bit successfully.

Hope this helps.

dgbaxter
Fresh meat
Posts: 2
Joined: Thu Jan 03, 2019 10:22 pm
Contact:

Re: 1045 Phidget Temperature Sensor IR

Postby dgbaxter » Wed Jan 16, 2019 9:43 am

Thank you. It seems users in our industry - theater/performing arts - are more likely now to have DMX, Open Sound Control, or network controlled power devices, so we are moving our development away from Phidgets. The changes they made accelerated that transition. Good luck with your projects.


Return to “C#.NET”

Who is online

Users browsing this forum: No registered users and 2 guests