gobee
I have a P1-04RTD module, but I don't see a P1AM library module to support this device in the latest version of OpenPLC v4. There is a P1_04AD library module. How do I proceed? Can I use the P1_04AD somehow? Or, do I need to do something else?
 
Thanks!
Reply 0 0
gobee
I know this is bad form to answer my own question, but I spent a couple of hours with Claude and found the solution. In case anybody else runs into this problem here's what I did.
 
1) Create a new Function Block (P1_04RTD) with the C/C++ language. (The AI tools kept referring to this as an Ardunio Extension.)
2) Declare the variables in the OpenPLC editor. e.g. Name = rtd_slot, Class = input, Type = INT. I used 'slot', but this collided with something internal. No need to declare these variables again in the code.
3) Key points: include P1AM.h, use P1.init() in void setup() - see code in attached file. I also have a P1AM_INIT block inserted in my main program, which was/is required for the other 16 port I/O module in use.
4) Read Temp using:
float v1 = P1.readTemperature(rtd_slot,1);
5) Convert temp float to int as output. (I don't know if using INT for outputs is a best practice. I suppose the outputs could be 'real'. I didn't want to loose the 'tenths' place data.)
6) Serial.println statements go to /dev/ttyACM0 or whatever serial port you are using to upload the firmware. The print statements can be removed.
 
Now, you can drag the new function block into the main program and hook it up as needed. Debug works. The temp value is displayed.
 
So... I think this issue is closed. Hope this helps somebody else.
Reply 1 0
Reply