Welcome, Guest
Username: Password: Remember me

TOPIC: Arduino problem in 5.6

Arduino problem in 5.6 3 years 11 months ago #10560

  • brunad
  • brunad's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 247
  • Thank you received: 48
  • Karma: 11
Hi Bill,

Your problem is maybe the result of a bad signal.
In industrial environment there are a lot of electomagnetic disturbances. This is the reason why symetrical bus link with terminal resistors is widely used for sensors (RS485 for Foundation fieldbus, Modbus and Profibus for instance). Recently a new fieldbus named IO-Link was introduced. This bus uses asymetrical 24V signal (one wire is asymetrical 3V), I just tested it and ... it's very bad, even with short links (few meters), It's very incompatible with inverters's electromagenetics interferences (mainly by conduction mode).
You have to use shielded twisted pair with the shield connected to the ground at one extremity (to avoid parasitic currents's circulation). If you can, take a look to the signal with an oscilloscope.

I found this
pdfserv.maximintegrated.com/en/an/AN148.pdf
www.maximintegrated.com/en/design/techni...pp-notes/6/6208.html
And this
networkencyclopedia.com/electromagnetic-interference-emi/
networkencyclopedia.com/drain-wire/

I hope it will help you a bit. :)

/Bruno
Last Edit: 3 years 11 months ago by brunad.
The administrator has disabled public write access.
The following user(s) said Thank You: brew

Arduino problem in 5.6 3 years 11 months ago #10561

  • brew
  • brew's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 108
  • Karma: 0
Hello Bruno,

Your links are very useful and interesting. I should put an oscilloscope on the signal sometime soon. I use CAT5 cable, which is unshielded .
There could be problems with the CAT5.

BUT, the 600ms - .6 second-- delay is without anything connected to the arduinos.
So there is something delaying the processes in software. Most likely DallasTempurature.
Since no hardware is hooked up to the arduino when i run the tests.

When i hook up all the wiring, the delay increases to 1.6 seconds .
I am going to try and get the software fixed first, then go after the hardware setup.

Thanks again!!
bill
The administrator has disabled public write access.

Arduino problem in 5.6 3 years 2 months ago #10882

  • brew
  • brew's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 108
  • Karma: 0
Hello Marc, Claes, Bruno, and All,

I am back to this problem ... my setup is doing the time stretch once again--
it worked fine for 3 months, now is back to time errors
What i have done so far--
Replaced all the wires with new 100%copper cat5 wiring
Replaced all the OneWire Temp sensors
Upgraded the Arduino Library to the newest versions of OneWire and DallasTempurature

I am still getting errors due to timing -- like before...

I have been doing some research on OneWire Temp Sensor problems, and people say a few things that may help

1--tell all devices on the bus to convert simultaneously, rather than separately... with the SKIP ROM and Convert T commands

2-- there is no timing { DELAY } Code in the sketch-- most people are putting in 750ms or 1000ms ... do i need to modify the sketch with a fixed DELAY in the code?

I am NOT a good coder, so i am leery of touching anything without you guys help/ guidance. It also seems the Code on the proview Arduino Sketch is pretty advanced, and i don't understand what is going on in general, and may SCREW THINGS UP BIGTIME by changing things...

Any ideas on how to process 25 OneWire DallasTemp sensors faster?

Thanks!!!!

here are some websites with notes on this subject

===========
playground.arduino.cc/Learning/OneWire/

This length of this conversion process varies depending on the resolution and is listed in the device datasheet. a DS18B20 takes from 94 (9-bit resolution) to 750ms (12-bit resolution) to convert temperature (c.f. DS18B20 Datasheet). While the conversion is taking place, the device may be polled, e.g. using in the ds.read() command in OneWire, to see if it has successfully performed a conversion.
www.cupidcontrols.com/2014/10/moteino-ar...your-read-for-speed/

Now, we can also separate conversion commands and reading the data back. If you have multiple sensors, you actually want to use the Skip ROM and Convert T commands to tell all devices on the bus to convert simultaneously, but that’s another topic. In the meantime while conversion is taking place, we can do other stuff.
www.sparkfun.com/products/245

you dont need to do nothing in those 750ms, you can come back later and read the data.
For example you can call the function every second and toggle between start convert and read temperature. If you have multiple devices, you can make them all convert at the same time (SKIP ROM command), so you dont need to wait 750ms for each of them.
Also if you lower the precision of them, they convert much faster, if you can do with .5C readouts they only need 100ms

www.makerguides.com/ds18b20-arduino-tutorial/

The administrator has disabled public write access.

Arduino problem in 5.6 3 years 2 months ago #10883

  • brew
  • brew's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 108
  • Karma: 0
here is my proview arduino sketch

also attached at bottom
//
// Proview
// Copyright (C) 2010 SSAB Oxelösund AB.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 2 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with the program, if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// Description:
// Sketch for Arduino USB board to communicate with Proview I/O
// object OtherIO:Arduino_Uno.
//

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

DeviceAddress oneThermometer = { 0x28, 0x1E, 0x4D, 0x12, 0x1A, 0x19, 0x01, 0x4C };
DeviceAddress twoThermometer = { 0x28, 0x5A, 0x0B, 0x15, 0x1A, 0x19, 0x01, 0x16 };
DeviceAddress threeThermometer = { 0x28, 0xFC, 0x95, 0x6C, 0x1C, 0x19, 0x01, 0x07 };
DeviceAddress fourThermometer = { 0x28, 0x19, 0x7D, 0x26, 0x1A, 0x19, 0x01, 0x0B };
DeviceAddress fiveThermometer = { 0x28, 0x9B, 0xB8, 0x16, 0x1A, 0x19, 0x01, 0x37 };
DeviceAddress sixThermometer = { 0x28, 0x3C, 0xB9, 0x1F, 0x1A, 0x19, 0x01, 0xB0 };
DeviceAddress sevenThermometer = { 0x28, 0x89, 0x67, 0x07, 0x38, 0x19, 0x01, 0x5F };
DeviceAddress eightThermometer = { 0x28, 0x44, 0x43, 0x56, 0xB5, 0x01, 0x3C, 0x91 };
DeviceAddress nineThermometer = { 0x28, 0x71, 0x03, 0x1D, 0x1A, 0x19, 0x01, 0x7A };
DeviceAddress tenThermometer = { 0x28, 0xEE, 0x7A, 0x1D, 0x1A, 0x19, 0x01, 0x71 };
DeviceAddress elevenThermometer = { 0x28, 0x89, 0xCB, 0x31, 0x38, 0x19, 0x01, 0x0C };
DeviceAddress twelveThermometer = { 0x28, 0xB7, 0x98, 0x56, 0xB5, 0x01, 0x3C, 0x94 };
DeviceAddress thirteenThermometer = { 0x28, 0x6F, 0xCE, 0x4A, 0x38, 0x19, 0x01, 0x79 };
DeviceAddress fourteenThermometer = { 0x28, 0xF9, 0x87, 0x40, 0x38, 0x19, 0x01, 0x7B };
DeviceAddress fifteenThermometer = { 0x28, 0xA1, 0xE4, 0xF7, 0x2D, 0x19, 0x01, 0xC3 };
DeviceAddress sixteenThermometer = { 0x28, 0xDB, 0x02, 0x3D, 0x38, 0x19, 0x01, 0x8F };
DeviceAddress seventeenThermometer = { 0x28, 0x6D, 0x9C, 0x56, 0xB5, 0x01, 0x3C, 0x80 };
DeviceAddress eighteenThermometer = { 0x28, 0xFF, 0x52, 0xF4, 0x64, 0x15, 0x02, 0xB5 };
DeviceAddress nineteenThermometer = { 0x28, 0x40, 0x53, 0x68, 0x1C, 0x19, 0x01, 0xCD };
DeviceAddress twentyThermometer = { 0x28, 0xFF, 0x66, 0xE4, 0x64, 0x15, 0x01, 0xF4 };
DeviceAddress twentyoneThermometer = { 0x28, 0x36, 0xAD, 0x56, 0xB5, 0x01, 0x3C, 0x1F };
DeviceAddress twentytwoThermometer = { 0x28, 0x07, 0x98, 0x5F, 0x1C, 0x19, 0x01, 0xA1 };
DeviceAddress twentythreeThermometer = { 0x28, 0xFF, 0xD2, 0xDB, 0x64, 0x15, 0x02, 0x94 };
DeviceAddress twentyfourThermometer = { 0x28, 0xD1, 0x50, 0x2E, 0x38, 0x19, 0x01, 0xE6 };

byte firmware[20] = "Proview V2.0.0-2";
byte version_major = 2;
byte version_minor = 0;
byte msg = 0;
byte sts;
int val = 0;
byte amsg[68];
byte smsg[10];
byte diSize = 0;
byte doSize = 0;
byte aiSize = 0;
byte aoSize = 0;
byte diMask[10];
byte doMask[10];
byte aiMask[4];
byte aoMask[4];
int watchdogTime = 5000;
int status;
int i;
int j;
int aiList[32];
int aiCnt;
int aoList[32];
int aoCnt;
byte msgType;
byte msgId;
byte msgSize;
byte msgData[128];
byte rmsg[40];
int sizeErrorCnt = 0;
int noMessageCnt = 0;
const int delayTime = 1;
const int debug = 0;

const int MSG_TYPE_DOWRITE = 1;
const int MSG_TYPE_DIREAD = 2;
const int MSG_TYPE_AIREAD = 3;
const int MSG_TYPE_AOWRITE = 4;
const int MSG_TYPE_CONFIGURE = 5;
const int MSG_TYPE_STATUS = 6;
const int MSG_TYPE_DEBUG = 7;
const int MSG_TYPE_WRITEALL = 8;
const int MSG_TYPE_READALL = 9;
const int MSG_TYPE_CONNECTREQ = 10;
const int MSG_TYPE_CONNECTRES = 11;

const int ARD__SUCCESS = 1;
const int ARD__DICONFIG = 2;
const int ARD__DOCONFIG = 4;
const int ARD__AICONFIG = 6;
const int ARD__AOCONFIG = 8;
const int ARD__COMMERROR = 10;
const int ARD__MSGSIZE = 12;
const int ARD__NOMSG = 14;
const int ARD__CHECKSUM = 16;

void sendDebug( byte sts)
{
rmsg[0] = 4;
rmsg[1] = 0;
rmsg[2] = MSG_TYPE_DEBUG;
rmsg[3] = sts;
add_checksum( rmsg);
Serial.write( rmsg, rmsg[0]);
}

void add_checksum( byte *buf)
{
int i;
byte sum = 0;

buf[0]++;
for ( i = 0; i < buf[0] - 1; i++)
sum ^= buf;

buf[buf[0]-1] = sum;
}

int check_checksum( byte size, byte id, byte type, byte *buf)
{
int i;
byte sum = 0;

sum ^= size;
sum ^= id;
sum ^= type;
for ( i = 0; i < size - 4; i++)
sum ^= buf;

if ( buf[size-4] == sum)
return 1;
return 0;
}

//
// Reset all outputs when communication communication is down
//
void resetOutput()
{
for ( i = 0; i < doSize; i++) {
for ( j = 0; j < 8; j++) {
if ( ((1 << j) & doMask) != 0)
digitalWrite( i * 8 + j, LOW);
}
}
for ( i = 0; i < aoCnt; i++)
analogWrite( aoList, 0);
}

//
// Read a message from the serial port
//
int serialRead()
{
int num;
int csum;

num = Serial.available();
if ( num == 0)
return ARD__NOMSG;

msgSize = Serial.peek();
if ( num < msgSize)
return ARD__MSGSIZE;

msgSize = Serial.read();

msgId = Serial.read();
msgType = Serial.read();
msgSize -= 3;

for ( int i = 0; i < msgSize; i++) {
if ( i >= 128)
break;
msgData = Serial.read();
}
csum = check_checksum( msgSize + 3, msgId, msgType, msgData);

if ( debug) {
rmsg[0] = msgSize + 3 - 1;
rmsg[1] = msgId;
rmsg[2] = MSG_TYPE_DEBUG;
for ( int j = 0; j < msgSize-1; j++)
rmsg[j+3] = msgData[j];
add_checksum( rmsg);
Serial.write( rmsg, rmsg[0]);
}
msgSize--;

if ( !csum)
return ARD__CHECKSUM;

return ARD__SUCCESS;
}

void setup()
{
// Start serial port at the configured baud rate
Serial.begin(2400);
Serial.flush();

// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(oneThermometer, 10);
sensors.setResolution(twoThermometer, 10);
sensors.setResolution(threeThermometer, 10);
sensors.setResolution(fourThermometer, 10);
sensors.setResolution(fiveThermometer, 10);
sensors.setResolution(sixThermometer, 10);
sensors.setResolution(sevenThermometer, 10);
sensors.setResolution(eightThermometer, 10);
sensors.setResolution(nineThermometer, 10);
sensors.setResolution(tenThermometer, 10);
sensors.setResolution(elevenThermometer, 10);
sensors.setResolution(twelveThermometer, 10);
sensors.setResolution(thirteenThermometer, 10);
sensors.setResolution(fourteenThermometer, 10);
sensors.setResolution(fifteenThermometer, 10);
sensors.setResolution(sixteenThermometer, 10);
sensors.setResolution(seventeenThermometer, 10);
sensors.setResolution(eighteenThermometer, 10);
sensors.setResolution(nineteenThermometer, 10);
sensors.setResolution(twentyThermometer, 10);
sensors.setResolution(twentyoneThermometer, 10);
sensors.setResolution(twentytwoThermometer, 10);
sensors.setResolution(twentythreeThermometer, 10);
sensors.setResolution(twentyfourThermometer, 10);
}

void loop()
{

status = serialRead();
if ( status == ARD__NOMSG) {
if ( watchdogTime != 0) {
// Increment watchdog counter
noMessageCnt++;
if ( noMessageCnt * delayTime > watchdogTime)
resetOutput();
}
}
else if ( status == ARD__MSGSIZE) {
sizeErrorCnt++;
if ( sizeErrorCnt > 50) {
Serial.flush();
sizeErrorCnt = 0;
}
}
else if ( (status & 1) != 0) {
// A message is received
sizeErrorCnt = 0;
noMessageCnt = 0;

if ( msgType == MSG_TYPE_DOWRITE) {
// Write digital outputs

if ( msgSize == doSize) {
for ( i = 0; i < doSize; i++) {
for ( j = 0; j < 8; j++) {
if ( ((1 << j) & doMask) != 0) {
if ( ((1 << j) & msgData) != 0)
digitalWrite( i * 8 + j, HIGH);
else
digitalWrite( i * 8 + j, LOW);
}
}
}
sts = ARD__SUCCESS;
}
else {
sts = ARD__COMMERROR;
}
}
else if ( msgType == MSG_TYPE_AOWRITE) {
// Write analog outputs

if ( msgSize == aoCnt) {
for ( i = 0; i < aoCnt; i++)
analogWrite( aoList, msgData);

sts = ARD__SUCCESS;
}
else {
sts = ARD__COMMERROR;
}
}
else if ( msgType == MSG_TYPE_WRITEALL) {
// Write digital outputs

if ( msgSize == doSize + aoCnt) {
for ( i = 0; i < doSize; i++) {
for ( j = 0; j < 8; j++) {
if ( ((1 << j) & doMask) != 0) {
if ( ((1 << j) & msgData) != 0)
digitalWrite( i * 8 + j, HIGH);
else
digitalWrite( i * 8 + j, LOW);
}
}
}

for ( i = 0; i < aoCnt; i++)
analogWrite( aoList, msgData[doSize + i]);

sts = ARD__SUCCESS;
}
else {
sts = ARD__COMMERROR;
}
}
else if ( msgType == MSG_TYPE_DIREAD) {
// Read Digital inputs
smsg[0] = diSize + 3;
smsg[1] = msgId;
smsg[2] = MSG_TYPE_DIREAD;
for ( i = 0; i < diSize; i++) {
smsg = 0;
for ( j = 0; j < 8; j++) {
if ( ((1 << j) & diMask) != 0) {
val = digitalRead( i * 8 + j);
if ( val == HIGH)
smsg |= 1 << j;
}
}
}
add_checksum( smsg);
Serial.write( smsg, smsg[0]);
}
else if ( msgType == MSG_TYPE_AIREAD) {
// Read analog inputs
amsg[0] = aiCnt * 2 + 3;
amsg[1] = msgId;
amsg[2] = MSG_TYPE_AIREAD;
sensors.requestTemperatures(); // Send the command to get temperatures
for ( i = 0; i < aiCnt; i++) {
switch ( i) {
case 0:
val = sensors.getTempC(oneThermometer) * 10; // Temperature values instead of aiRead()
break;
case 1:
val = sensors.getTempC(twoThermometer) * 10; // Temperature values instead of aiRead()
break;
case 2:
val = sensors.getTempC(threeThermometer) * 10; // Temperature values instead of aiRead()
break;
case 3:
val = sensors.getTempC(fourThermometer) * 10; // Temperature values instead of aiRead()
break;
case 4:
val = sensors.getTempC(fiveThermometer) * 10; // Temperature values instead of aiRead()
break;
case 5:
val = sensors.getTempC(sixThermometer) * 10; // Temperature values instead of aiRead()
break;
case 6:
val = sensors.getTempC(sevenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 7:
val = sensors.getTempC(eightThermometer) * 10; // Temperature values instead of aiRead()
break;
case 8:
val = sensors.getTempC(nineThermometer) * 10; // Temperature values instead of aiRead()
break;
case 9:
val = sensors.getTempC(tenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 10:
val = sensors.getTempC(elevenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 11:
val = sensors.getTempC(twelveThermometer) * 10; // Temperature values instead of aiRead()
break;
case 12:
val = sensors.getTempC(thirteenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 13:
val = sensors.getTempC(fourteenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 14:
val = sensors.getTempC(fifteenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 15:
val = sensors.getTempC(sixteenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 16:
val = sensors.getTempC(seventeenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 17:
val = sensors.getTempC(eighteenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 18:
val = sensors.getTempC(nineteenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 19:
val = sensors.getTempC(twentyThermometer) * 10; // Temperature values instead of aiRead()
break;
case 20:
val = sensors.getTempC(twentyoneThermometer) * 10; // Temperature values instead of aiRead()
break;
case 21:
val = sensors.getTempC(twentytwoThermometer) * 10; // Temperature values instead of aiRead()
break;
case 22:
val = sensors.getTempC(twentythreeThermometer) * 10; // Temperature values instead of aiRead()
break;
case 23:
val = sensors.getTempC(twentyfourThermometer) * 10; // Temperature values instead of aiRead()
break;
default:
val = 0;
}
amsg[i*2 + 3] = val >> 8;
amsg[i*2 + 1 + 3] = val & 0xFF;
}
add_checksum( amsg);
Serial.write( amsg, amsg[0]);
}
else if ( msgType == MSG_TYPE_READALL) {
// Read Digital inputs
amsg[0] = diSize + aiCnt * 2 + 3;
amsg[1] = msgId;
amsg[2] = MSG_TYPE_READALL;
for ( i = 0; i < diSize; i++) {
amsg = 0;
for ( j = 0; j < 8; j++) {
if ( ((1 << j) & diMask) != 0) {
val = digitalRead( i * 8 + j);
if ( val == HIGH)
amsg |= 1 << j;
}
}
}

sensors.requestTemperatures(); // Send the command to get temperatures
for ( i = 0; i < aiCnt; i++) {
switch ( i) {
case 0:
val = sensors.getTempC(oneThermometer) * 10; // Temperature values instead of aiRead()
break;
case 1:
val = sensors.getTempC(twoThermometer) * 10; // Temperature values instead of aiRead()
break;
case 2:
val = sensors.getTempC(threeThermometer) * 10; // Temperature values instead of aiRead()
break;
case 3:
val = sensors.getTempC(fourThermometer) * 10; // Temperature values instead of aiRead()
break;
case 4:
val = sensors.getTempC(fiveThermometer) * 10; // Temperature values instead of aiRead()
break;
case 5:
val = sensors.getTempC(sixThermometer) * 10; // Temperature values instead of aiRead()
break;
case 6:
val = sensors.getTempC(sevenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 7:
val = sensors.getTempC(eightThermometer) * 10; // Temperature values instead of aiRead()
break;
case 8:
val = sensors.getTempC(nineThermometer) * 10; // Temperature values instead of aiRead()
break;
case 9:
val = sensors.getTempC(tenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 10:
val = sensors.getTempC(elevenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 11:
val = sensors.getTempC(twelveThermometer) * 10; // Temperature values instead of aiRead()
break;
case 12:
val = sensors.getTempC(thirteenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 13:
val = sensors.getTempC(fourteenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 14:
val = sensors.getTempC(fifteenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 15:
val = sensors.getTempC(sixteenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 16:
val = sensors.getTempC(seventeenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 17:
val = sensors.getTempC(eighteenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 18:
val = sensors.getTempC(nineteenThermometer) * 10; // Temperature values instead of aiRead()
break;
case 19:
val = sensors.getTempC(twentyThermometer) * 10; // Temperature values instead of aiRead()
break;
case 20:
val = sensors.getTempC(twentyoneThermometer) * 10; // Temperature values instead of aiRead()
break;
case 21:
val = sensors.getTempC(twentytwoThermometer) * 10; // Temperature values instead of aiRead()
break;
case 22:
val = sensors.getTempC(twentythreeThermometer) * 10; // Temperature values instead of aiRead()
break;
case 23:
val = sensors.getTempC(twentyfourThermometer) * 10; // Temperature values instead of aiRead()
break;
default:
val = 0;
}
amsg[diSize + i*2 + 3] = val >> 8;
amsg[diSize + i*2 + 1 + 3] = val & 0xFF;
}
add_checksum( amsg);
Serial.write( amsg, amsg[0]);
}
else if ( msgType == MSG_TYPE_CONFIGURE) {
// Configure message
int offs = 0;
sts = ARD__SUCCESS;

if ( debug) {
smsg[0] = msgSize + 3;
smsg[1] = msgId;
smsg[2] = MSG_TYPE_DEBUG;
for ( int j = 0; j < msgSize; j++)
smsg[j+3] = msgData[j];
add_checksum( smsg);
Serial.write( smsg, smsg[0]);
}

watchdogTime = msgData[offs++] * 100;

diSize = msgData[offs++];
if ( diSize > 10) {
diSize = 10;
sts = ARD__DICONFIG;
}
if ( sts & 1 != 0) {
for ( i = 0; i < diSize; i++)
diMask = msgData[offs++];
}

if ( sts & 1 != 0) {
doSize = msgData[offs++];
if ( doSize > 10) {
doSize = 10;
sts = ARD__DOCONFIG;
}
}
if ( sts & 1 != 0) {
for ( i = 0; i < doSize; i++)
doMask = msgData[offs++];
}

if ( sts & 1 != 0) {
aiSize = msgData[offs++];
if ( aiSize > 4) {
aiSize = 4;
sts = ARD__AICONFIG;
}
}

if ( sts & 1 != 0) {
for ( i = 0; i < aiSize; i++)
aiMask = msgData[offs++];
}

if ( sts & 1 != 0) {
aoSize = msgData[offs++];
if ( aoSize > 4) {
aoSize = 4;
sts = ARD__AOCONFIG;
}
}

if ( sts & 1 != 0) {
for ( i = 0; i < aoSize; i++)
aoMask = msgData[offs++];
}

if ( sts & 1 != 0) {
// Set Di pinmode
for ( i = 0; i < diSize; i++) {
for ( j = 0; j < 8; j++) {
if ( ((1 << j) & diMask) != 0)
pinMode( i * 8 + j, INPUT);
}
}

// Set Do pinmode
for ( i = 0; i < doSize; i++) {
for ( j = 0; j < 8; j++) {
if ( ((1 << j) & doMask) != 0)
pinMode( i * 8 + j, OUTPUT);
}
}

// Create list of configured Ai
aiCnt = 0;
for ( i = 0; i < aiSize; i++) {
for ( j = 0; j < 8; j++) {
if ( ((1 << j) & aiMask) != 0) {
aiList[aiCnt] = i * 8 + j;
aiCnt++;
}
}
}

// Create list of configured Ao
aoCnt = 0;
for ( i = 0; i < aoSize; i++) {
for ( j = 0; j < 8; j++) {
if ( ((1 << j) & aoMask) != 0) {
aoList[aoCnt] = i * 8 + j;
aoCnt++;
}
}
}
}

// Send configuration status
smsg[0] = 4;
smsg[1] = msgId;
smsg[2] = MSG_TYPE_STATUS;
smsg[3] = sts;
add_checksum( smsg);
Serial.write(smsg, smsg[0]);

}
else if ( msgType == MSG_TYPE_CONNECTREQ) {
// Connect reqeust
amsg[0] = 23 + 3;
amsg[1] = msgId;
amsg[2] = MSG_TYPE_CONNECTRES;
amsg[3] = ARD__SUCCESS;
amsg[4] = version_major;
amsg[5] = version_minor;
for ( i = 0; i < 20; i++)
amsg[i+6] = firmware;
add_checksum( amsg);
Serial.write( amsg, amsg[0]);
}
}
else {
// Return error status
smsg[0] = 4;
smsg[1] = msgId;
smsg[2] = MSG_TYPE_STATUS;
smsg[3] = status;
add_checksum( smsg);
Serial.write(smsg, smsg[0]);

}

delay(delayTime);
}
The administrator has disabled public write access.

Arduino problem in 5.6 3 years 2 months ago #10884

  • marc
  • marc's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 710
  • Thank you received: 70
  • Karma: 24
Hi Bill,

No matter what breaking is on the MSM, the worst thing what can happen in this world is a brewery on it's knees because of a technical problem.
Period.

I started to read your posts from the last 6 years.
This is not easy to solve as an outsider.
I am busy, have my job, taking care of a MS based industrial production environment and at the moment an alarm clock at 2:30 AM. But next week I have a couple of days off.

First I want to know:

- How do you power the DS18B20's ?
- Did you try a stronger pull up resistor then 4.7 kOhm?
- I am not worried about the voltage drop on your cat5 cables but how long are they?

/Marc
Please, use the Wiki if you succeeded your project or solved your problem. Share your work, so we can learn from each other.
The administrator has disabled public write access.

Arduino problem in 5.6 3 years 2 months ago #10885

  • brew
  • brew's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 108
  • Karma: 0
marc wrote:
Hi Bill,

No matter what breaking is on the MSM, the worst thing what can happen in this world is a brewery on it's knees because of a technical problem.
Period.

First I want to know:

- How do you power the DS18B20's ?
- Did you try a stronger pull up resistor then 4.7 kOhm?
- I am not worried about the voltage drop on your cat5 cables but how long are they?

/Marc

Hahaha-- yes, a brewery that is not making beer is a horrible thing!
BUT, proview is working currently... i just increased the timing to 1.6 secs (1600ms) and it works ... just a little slowly...

the power for the DS18B20's is 5V

the pullup resistor is a 1K , not 4.7K most people use-- 1K fixed the problems with low signal strength...

The Cat5 cables (~30Meters) do not seem to be the problem... the temp readings work correctly, and the
Delay is the same with the cables hooked up, and without the cables hooked up-- it is always around 800ms
see screenshot
so i can disconnect the cables and still get a 800ms delay

The delay is clearly inside the arduino, in the code ...

Many people on Arduino forums complain about the OneWire and DallasTemperature slow processing

I was trying to figure out how to speed it up--

1-- get a faster arduino? one of the more modern ones that runs the arduino code, just at a faster speed...{teensy 3.6?}

2-- Modify the code to make the temp conversions go faster?

right now I am not stranded, without beer...

But it would be better to make it work faster than 1 and a half secs!

Thanks Marc!

yours in brewing,
Bill


new.png
The administrator has disabled public write access.
Time to create page: 8.400 seconds