
Rod1 (Customer) asked a question.
#include <P1AM.h>
#include <SimpleTimer.h>
const char configData[2] = {0x40, 0x03};
float elongation;
float load;
SimpleTimer timer;
void flushBuffer()
{
Serial.flush(); // flush serial buffer (may not always flush?)
while (Serial.available()) // manually empty as well, read as long as bytes in there
Serial.read();
}
void read1(){
flushBuffer();
elongation = P1.readAnalog(1, 1); //Reads analog data from slot 1 channel 1 of the analog input module
Serial.print("!O elongation= ");
Serial.println(elongation);
load = P1.readAnalog(1, 2); //Reads analog data from slot 1 channel 2 of the analog input module
Serial.print("!O load= ");
Serial.println(load);
}
void graph(){
Serial.print(elongation);
Serial.print(",");
Serial.println(load);
}
void setup(){ // the setup routine runs once:
Serial.begin(9600); //initialize serial communication at 9600 bits per second
while (!P1.init()){
; //Wait for Modules to Sign on
}
P1.configureModule(configData, 1);
timer.setInterval(1000L, read1);
timer.setInterval(1000L, graph);
}
void loop(){ // the loop routine runs over and over again forever:
timer.run();
}
Have you tried running the AnalogInput example program so see if you get a value? Understand some code won't apply if applying your input voltage.
Do you have 24Vdc applied to the module? What is the reading you are seeing for voltage on analog input with your tester?
I have tried the AnalogInput example with no luck. I have a P1-01AC power supply connected to the P1AM on the left side, which I assume is also supplying 24V to the input module, unless I need another external power supply for the input module?
I'm reading between 0.5-1.5 volts from the sensor.
Yes you will need another 24Vdc supply to be applied to the 24V & 0V terminals on the front of the module.
In addition, you will want to jumper unused inputs to common.
Thank you. I was not sure if I needed the extra power supply since all the modules and the controller were connected together. I have noticed that the controller would not recognized the module until I had the power supply pugged in, even plugged the controller recognizes the module, but the module does not see the voltage.
Thanks again.