OUTOFMEMORYERROR- arduino processing DINO
in
Integration and Hardware
•
7 months ago
Hi to all,
I am a newbie, in fact I've started to use/learn Processing just yesterday. I my trying to build a hot-tub DINO- so an anrduino mega is sending serial data to my pc then processing is used for displaying gauages an so on. This is what is all about.
Here is the problem, I'm stuck with this OUTOFMEMORYERROR after some minutes.Tried to increase memory as suggested by processing. It took some more time to crash but it did it again. Data input seems to be high to handle.
Is there something I can do like flushing the old data while using the incoming so to keep it to a minimum?
Any help appreciated. I thinking of dumping all and use another language but processing seems to the one with simple graphical contents I need.
THANKS
below is the arduino code:
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 3// Data wire is plugged into pin 3 on the Arduino
// 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);
// Assign the addresses of your 1-Wire temp sensors.
DeviceAddress vThermometer1 = { 0x28, 0xB0, 0x41, 0xEA, 0x03, 0x00, 0x00, 0x8B };
DeviceAddress vThermometer2 = {
0x28, 0x2B, 0x17, 0xEA, 0x03, 0x00, 0x00, 0xCB };
void setup(void)
{
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit
sensors.setResolution(vThermometer1, 10);
sensors.setResolution(vThermometer2, 10);
}
void loop(void)
{
sensors.requestTemperatures();
float collector = printTemperature(vThermometer1);
float tank = printTemperature(vThermometer2);
Serial.print("G0");
Serial.print(tank);
Serial.println("\n");
Serial.print("G1");
Serial.print(collector);
Serial.println("\n");
delay(10);
}
float printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
//Serial.print("Error getting temperature");
}
else {
}
return tempC;
}
Below is processing code:
import processing.serial.*;
Serial myPort; // Create object from Serial class
PFont mono;
int gaugeangle=180;//gauge display angle
int gaugepositionx=250;//gauge position in form (x)
int gaugepositiony=250;//gauge position in form (y)
int gaugescalerange=180;//in degrees steps of 30 max 180
int gaugestartvalue=0;
int gaugeendvalue=50;
int gaugescale=50;
int gaugescalecolour=0;
int gaugepointercolourR=204;
int gaugepointercolourG=102;
int gaugepointercolourB=0;
float GaugeVariabileG0;
float GaugeVariabileG1;
void setup()
{
size(800, 800);
smooth();
String portName = "COM4";
myPort = new Serial(this, portName, 9600);
myPort.bufferUntil('\n');
}
void serialEvent(Serial myPort)
{
// read String from the serial port:
String inString = myPort.readString();
String xxx = inString.substring(0, 2); // returns type
if (xxx.equals("G0") == true )
{
GaugeVariabileG0=float(inString.substring(2));
}
if (xxx.equals("G1") == true )
{
GaugeVariabileG1=float(inString.substring(2));
}
}
void draw()
{
background(255);
pushMatrix();
translate( gaugepositionx, gaugepositiony);//gauge position
drawGauge( map( GaugeVariabileG0, gaugestartvalue, gaugeendvalue, 0, 1 )); //map GaugeVariabileG0
mono=loadFont("Digital-7Mono-48.vlw");
textFont(mono);
textAlign(CENTER);
text(nf(GaugeVariabileG0, 2, 2), -60, 48);
mono=loadFont("Tahoma-12.vlw");
textFont(mono);
textAlign(CENTER);
text("Tank Temperature", 0, 60);
popMatrix();
pushMatrix();
translate( gaugepositionx+250, gaugepositiony);//gauge position
drawGauge( map( GaugeVariabileG1, gaugestartvalue, gaugeendvalue, 0, 1 )); //map GaugeVariabileG0
mono=loadFont("Digital-7Mono-48.vlw");
textFont(mono);
textAlign(CENTER);
text(nf(GaugeVariabileG1, 2, 2), -60, 48);
mono=loadFont("Tahoma-12.vlw");
textFont(mono);
textAlign(CENTER);
text("Heat Exchanger Temperature Out", 0, 60);
popMatrix();
}
void drawGauge(float val)
{
stroke(gaugescalecolour);//scale colour
//draws scale
for ( int i=0; i<gaugescale+1; i++)
{//scale nos
float a = radians(gaugeangle + i * gaugescalerange / gaugescale);
float r1 = 110;//scale length
float r2 = 100;//scale lenght small div
r2 = i % 5 == 0 ? 85 : r2;
r2 = i % 10 == 0 ? 80 : r2;
line( r1*cos(a), r1*sin(a), r2*cos(a), r2*sin(a));//draws scale
}
//
//draws double circle around the gauge
//noFill();
//ellipse(0, 0, 270, 270);
// ellipse(0, 0, 290, 290);
//
stroke(gaugepointercolourR, gaugepointercolourG, gaugepointercolourB);//pointer border colour
fill(gaugepointercolourR, gaugepointercolourG, gaugepointercolourB);//pointer fill colour
float b = radians( gaugeangle + val * gaugescalerange );
ellipse(0, 0, 10, 10);//pointer dot itself
line( -10*cos(b), -10*sin(b), 100 * cos(b), 100 * sin(b));//pointer
}
1