Phidgets for the Serious Hobbyist

Comments & issues
Post Reply
electronicsHobbyist
Fresh meat
Posts: 4
Joined: Tue Aug 20, 2024 12:26 am
Contact:

Phidgets for the Serious Hobbyist

Post by electronicsHobbyist »

I got into electronics around 1972 when I was a teenager.
I had been into arts, writing, photography, model making. But in electronics I saw a clear career path and a good intellectual challenge.
I worked as a technician for about 5 years before getting involved in my church. I worked with them for 26 years, then came back into electronics.

Phidgets were developed by Saul Greenberg around 2001. I think I found out about them about ten years later. I was learning about programming at a community college and developing my hobby in the direction of interactive art. I bought my first hub (1011 S/N 269016) back then, but was overwhelmed by the programming learning curve.

Meanwhile I found a new technician job at Schweitzer Engineering Labs (SEL) in Pullman Washington. This got me interested in industrial automation, as I was working in a factory that used a lot of automation technology.

At home I was working with a combination of hard-wired analog and CMOS ICs, and just getting into using the Arduino platform. I preferred to hard wire my projects, as all you had to do was turn them on. But having a programmed platform gave me a lot more flexibility in my designs. Arduino has had the limitation that it does not communicate well with PCs. So I wanted something that could take advantage of the computer's human interaction features more fully. And I remembered phidgets. I found a "new" 1019 hub on eBay (S/N 178287 / Ver 904) and was impressed that it seemed fully functional. So now I have two hubs to play with.

I started with the little hub and put together a little temperature sensor (based on the LM335Z), plugged it into an analog input port and, sure enough, could monitor its output using the Control Panel.

But I wanted to build out this idea into what I would call an HMI application (Human-Machine Interface). I started with Thonny (never used before) with tkinter. I wanted to start with a window that would simply show the temperature reading. I had to somehow combine the code for the phidget (using events) with the tk code for a window. I could find almost zero online help on how to do this. I finally got some code to work, though it exits problematically.

The next step up is HMI developement software. But most "pro" HMIs work with PLCs, SCADA and databases. I don't need any of that functionality, though I suspect that some of Phidget's more serious users might.

What I would like to put to the community (which I suspect includes Phidget's own engineers) is this:
Are industry-level HMIs an unexplored area for Phidget products?
What are the best solutions other users have come up with to provide graphical objects for users to interact with phidgets?
Does anyone have some perfectly working code to share for a very simple application like the one I described above?
User avatar
mparadis
Site Admin
Posts: 660
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Phidgets for the Serious Hobbyist

Post by mparadis »

I don't have any experience with HMIs but I doubt you'll find much compatibility between them and Phidgets. Phidgets are designed specifically to run on computers running Windows, MacOS, or Linux. Even if the HMI is running on Linux, I would think it's locked down and customized to the point where you can't easily install our drivers or run code in the languages supported by our API. I think your only chance would be of the HMI supports some kind of module that can call out to an external computer that controls the Phidgets.

If you're mainly looking for a way to get Phidgets working with a graphical interface, these are probably your best bets:

- Python GUIs like tkinter are good because python is free and the quickest language to start with. But python GUIs can be more difficult to work with since there's no graphical editor (as far as I'm aware)

- Visual Studio GUIs using C/C# are good because there are a lot of resources for help online because of it's long-standing popularity. The downside is you either have to buy Visual Studio, or make do with whichever limitations are imposed on the free version.

- LabVIEW and Max/MSP are both visual programming languages that provide GUIs natively, but the programming language itself is a graphical node-based endeavor which may or may not be your cup of tea. They're also both paid like Visual Studio.
maxdvdt
Phidgetsian
Posts: 7
Joined: Mon Aug 28, 2023 10:03 am
Contact:

Re: Phidgets for the Serious Hobbyist

Post by maxdvdt »

A few comments

Phidget WIFI hub would (could) work as "fieldIO" especially if it supported something like modbus - then any existing HMI's could control that - BUT - the HMI's are not cheap


GUI's for python - free and great software https://www.qt.io/qt-for-python

And Visual Studio Community Edition is freely available and the same as the paid for develepor version.
electronicsHobbyist
Fresh meat
Posts: 4
Joined: Tue Aug 20, 2024 12:26 am
Contact:

Re: Phidgets for the Serious Hobbyist

Post by electronicsHobbyist »

I will next look into using JavaScript with HTML files in a browser.

I have not used JavaScript much, but I have written a lot of HTML, often with PHP. I think I may be able to do what I want using the Server supplied by Phidgets and building custom pages. We'll see how it goes.
electronicsHobbyist
Fresh meat
Posts: 4
Joined: Tue Aug 20, 2024 12:26 am
Contact:

Re: Phidgets for the Serious Hobbyist

Post by electronicsHobbyist »

You guys have a TON of code examples on your website!
But the one I was using, which is under JavaScript examples, Multiple_ Channels.html, has some html tags in the wrong places.
It is missing a <head> tag and then closes the head with an </html> tag, then gives another script. After the script and before the body, there is another <html> tag.
After I fix these problems, including entering the correct serial number so that it will attach to my 1011 (which I can see that it does), it still fails to report the values on the two voltage inputs and has "Timed out" errors.
This is the framework I would like to use for my own simple panel (in a browser - I use Firefox on Windows) but so far it's not working for me.
Learning all the ins and outs of JavaScript has been a huge challenge for me, especially since you guys use JQuery and JStree in your Control Panel app. That app (browser version) DOES report voltage values, but all the tree code you use to make it versatile enough to work with your entire product line (no mean feat!) is too dense for me. I hope to work this out fairly soon, one way or another.
cvboucher
Phidgetsian
Posts: 14
Joined: Fri Oct 22, 2021 11:29 am
Contact:

Re: Phidgets for the Serious Hobbyist

Post by cvboucher »

We're using this HMI to connect to a USB VINT hub and sensors via their JavaScript libraries and a web application (.Net Blazor Webassembly PWA). It's working really well. I ran into issues connecting to their WiFi VINT hub because Chrome only likes SSL connections and the WebSocket connections to the hub aren't SSL enabled.

https://www.seeedstudio.com/reTerminal-DM-p-5616.html

I also created a proof of concept where I ran a Blazor Server application on this HMI and connected to it with Chrome using a localhost url. This also worked well and let me use the native .Net Phidget libraries. We didn't go this route because it's a lot easier to push out updates to a web application.
Last edited by cvboucher on Mon Sep 16, 2024 12:18 pm, edited 1 time in total.
electronicsHobbyist
Fresh meat
Posts: 4
Joined: Tue Aug 20, 2024 12:26 am
Contact:

Re: Phidgets for the Serious Hobbyist

Post by electronicsHobbyist »

After some serious struggle, I got a basic browser-based interface working in my browser (Firefox) using JavaScript. From this I should be able to move forward into further development using either my older little hub or my newer hub (the 1019).

I should make some comments regarding this for people (like myself) who do not have a lot of experience working with scripting languages like Python or, in particular, JS.

First, most people who develop in these languages, or give code examples in forums, work with fairly simple IDEs that include a "console" window. If they want to know what their script is doing, they just insert a console.log() line in the code and they can see the result in the console window. There is actually also a console window in most browsers, available through "Web Developer Tools" or something similar.

But when you are writing a browser app you want to know if your script works correctly in a browser. This requires either a more sophisticated IDE or the use of a browser viewing your HTML as served by (usually) a local server, such as the one provided by Phidgets. When I was writing PHP I worked this way.

Second, in modern JS, there are usually about four different ways to write the same code. Every developer has their preferred style. They don't tell you why they prefer it; it's just the one they use the most. There are all kinds of shortcuts that make scripts shorter but also more "opaque." For example the "arrow function (=>)" did not become available until ES6, and did not become widely supported until 2017.

Writing for HTML also requires different methods for including libraries. HTML requires <script src="URL" > tags. And there are a LOT of different libraries. JQuery is used a lot in Phidget code examples and is considered a basic library by many developers.

I also had to deal with the document.ready() problem. This is a JQuery feature that ensures a code block is not executed until the DOM (Document Object Model) is fully loaded into the browser. Thus, you can place such a script in the <head> without worrying that it will start running before the <body> loads. If you are writing a standalone script, this is not relevant.

Further, there are different ways of handling events in JavaScript. For events that should probably be handled asynchronously (doing something else while we wait for them to complete), we now have the older .addEventListener() method and the newer "Promise" and "asynch/await" methods.

This is a lot for beginners to keep track of, and if you are writing example code for newbies, it should be sufficiently annotated.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest