Page 1 of 1

Controlling relays using thermocouple readings

Posted: Sat Apr 27, 2019 5:44 pm
by hlaps1990
TLDR: What's the easiest way of interacting with a Phidget from inside another Phidget's event handler?

Me again, still working on the injection molding machine. The stepper motors are working great now thanks to the help I got on a previous post.

I want to regulate the temperature of the extruder using a thermocouple and four 40W cartridge heaters. I'm going to try to keep it simple for now: when the thermocouple notices a temperature change event, it checks to see if its below or above a global target temperature variable. From there, I'd like to be able to turn the heaters on or off, but I'm not sure how I can command the heaters in the temperature change handler because they were defined in a different scope. I'd prefer not to have to connect to the heaters every time I want to change them inside of the event handler. I have tried changing a global "is_heating" variable to "True", which works, but then I have to poll that value throughout the code to achieve any kind of update speed. Is there a more effective way of doing this?

Re: Controlling relays using thermocouple readings

Posted: Mon Apr 29, 2019 9:25 am
by jdecoux
In Python, you can add a Phidget handle to another Phidget by assigning it as an attribute.

For details and an example, you can look at our page on Referencing Other Phidgets from Events.

Re: Controlling relays using thermocouple readings

Posted: Tue Apr 30, 2019 7:52 am
by hlaps1990
Awesome, that worked, thanks!