ilde:
Hello!yes, i can imagine where is the bug in the Arduino OPC Server. Could you send me your sketch or al least the line where you create the OPC Item? AddItem(....
I am creating a new site for the Arduino OPC Server at:
so you could use the support forum for news, updates and bug fixes
All the best
ilde
Hi ilde
Please see my sketch below. Any suggestions are welcome.
Just to recap: when the piece of code " if(currentMillis - previousMillis > 2000)" executes every 2 seconds the OPC tag quality changes from good to bad and back to good.
It seems like every time the onewire device is accessed the OPC quality changes.
Looking forward to your response.
Regards
an3s
#include <OPC.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 10
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices
DallasTemperature Sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature.
DeviceAddress ThermometerAddr = { 0x28, 0x2C, 0x83, 0x04, 0x05, 0x00, 0x00, 0x6B }; // Assign the addresses of your 1-Wire temp sensors.
OPC aOPC; // Declaring the OPC object
int Analogue;
long previousMillis = 0;
int callback(const char *itemID, const opcOperation opcOP, const int value) // create a callback function for the OPCItem
{
return Analogue;
}
void setup() {
Serial.begin(9600);
Sensors.begin(); // Start up the library
Sensors.setResolution(ThermometerAddr, 12); // set the resolution to 12 bit
Sensors.requestTemperatures(); // Getting Temperatures
aOPC.setup(); // OPC Object initialization
aOPC.addItem("store",opc_read, opc_int, callback); // random OPCItem declaration
}
void loop() {
aOPC.processOPCCommands(); // OPC process commands
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > 2000) // Scan This peace of code only every 2 seconds
{
previousMillis = currentMillis;
Sensors.requestTemperatures(); // Getting Temperatures
Analogue = Sensors.getTempC(ThermometerAddr);
}
}
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.