Table Errors

Support forum for MegunoLink
Post Reply
shields
Posts: 10
Joined: Sat Jan 06, 2018 7:10 pm

Wed Oct 31, 2018 6:21 am

Hi Phil,

I'm getting some compile errors using the Arduino IDE. I am using the latest version of Megunolink 1.24.18261.918 with Arduino 1.8.5. I get these errors whether I'm compiling for the Arduino DUE or the ShieldBuddyTC275 which is a multicore processor.

What's curious is that I have compiled Megunolink for the DUE previously but I think either a Megunolink update or Arduino IDE update may have started this problem. Error message below.

-Joel

C:\Users\shields\Documents\Arduino\libraries\MegunoLink\utility\Table.cpp:3:70: error: default argument given for parameter 1 of 'Table::Table(const char*, Print&)' [-fpermissive]

Table::Table(const char *Channel = NULL, Print &rDestination = Serial)

^

In file included from C:\Users\shields\Documents\Arduino\libraries\MegunoLink\utility\Table.cpp:1:0:

C:\Users\shields\Documents\Arduino\libraries\MegunoLink\utility\Table.h:7:2: error: after previous specification in 'Table::Table(const char*, Print&)' [-fpermissive]

Table(const char *Channel = NULL, Print &rDestination = Serial);

^

C:\Users\shields\Documents\Arduino\libraries\MegunoLink\utility\Table.cpp:3:70: error: default argument given for parameter 2 of 'Table::Table(const char*, Print&)' [-fpermissive]

Table::Table(const char *Channel = NULL, Print &rDestination = Serial)

^

In file included from C:\Users\shields\Documents\Arduino\libraries\MegunoLink\utility\Table.cpp:1:0:

C:\Users\shields\Documents\Arduino\libraries\MegunoLink\utility\Table.h:7:2: error: after previous specification in 'Table::Table(const char*, Print&)' [-fpermissive]

Table(const char *Channel = NULL, Print &rDestination = Serial);

^

C:\Users\shields\Documents\Arduino\libraries\MegunoLink\utility\Table.cpp:8:78: error: default argument given for parameter 2 of 'Table::Table(const __FlashStringHelper*, Print&)' [-fpermissive]

Table::Table(const __FlashStringHelper *Channel, Print &rDestination = Serial)

^

In file included from C:\Users\shields\Documents\Arduino\libraries\MegunoLink\utility\Table.cpp:1:0:

C:\Users\shields\Documents\Arduino\libraries\MegunoLink\utility\Table.h:8:2: error: after previous specification in 'Table::Table(const __FlashStringHelper*, Print&)' [-fpermissive]

Table(const __FlashStringHelper *Channel, Print &rDestination = Serial);

^

exit status 1
Error compiling for board Arduino Due (Programming Port).
philr
Posts: 359
Joined: Mon May 26, 2014 10:58 am

Thu Nov 01, 2018 8:00 am

Hi Joel, sorry about that. I think a bug made it into the latest megunolink release. Can you try updating the arduino manually from github? Basically download the zip, unzip it and overwrite the files on your computer with the new ones.

You can download it here
https://github.com/Megunolink/MLP

Let me know if this fixes it.

Cheers
Phil
shields
Posts: 10
Joined: Sat Jan 06, 2018 7:10 pm

Thu Nov 01, 2018 4:23 pm

Hi Phil,

Seems to have worked. Thx,

-Joel
shields
Posts: 10
Joined: Sat Jan 06, 2018 7:10 pm

Fri Nov 02, 2018 6:12 am

Hi Phil,

Your library compiles on my Arduino Due but I've now moved to trying it with a shieldbuddy which is a three core 200 Mhz processor. The code compiles but I tried plotting a constant value using a TimePlot and I didn't see any messages in the serial monitor. One thing is that this processor uses commands like SerialASC.println("Hello \n") to send messages through the USB connector. I'm not sure this is compatible with your library. You seem to be using print commands to send data. I've attached my sketch below. Note there are three setup() and loop() functions in this sketch one for each core. I use the first core to send a time plot message.

-Joel

#include <MegunoLink.h>
#include <CommandHandler.h>
#include <TCPCommandHandler.h>
#include <ArduinoTimer.h>
#include <CircularBuffer.h>
//#include <EEPROMStore.h>
#include <Filter.h>

/*** Don't worry, the normal Arduino setup() and loop() are below this block! ***/
#include <SPI.h>
#include <SpiIf.h>

/* LMU uninitialised data */
StartOfUninitialised_LMURam_Variables
/* Put your LMU RAM fast access variables that have no initial values here e.g. uint32 LMU_var; */
EndOfUninitialised_LMURam_Variables

/* LMU uninitialised data */
StartOfInitialised_LMURam_Variables
/* Put your LMU RAM fast access variables that have an initial value here e.g. uint32 LMU_var_init = 1; */
EndOfInitialised_LMURam_Variables

/* If you do not care where variables end up, declare them here! */

# define Serial SerialASC
TimePlot MyPlot;

/*** Core 0 ***/

void setup() {
// put your setup code for core 0 here, to run once:
Serial.begin(115200);
}


void loop() {
// put your main code for core 0 here, to run repeatedly:
MyPlot.SendData("My Sensor", 4.7);
Serial.println("Test message from Core 0!!!!!! \n");
delay(500);
}


/*** Core 1 ***/

/* CPU1 Uninitialised Data */
StartOfUninitialised_CPU1_Variables
/* Put your CPU1 fast access variables that have no initial values here e.g. uint32 CPU1_var; */
EndOfUninitialised_CPU1_Variables

/* CPU1 Initialised Data */
StartOfInitialised_CPU1_Variables

/* Put your CPU1 fast access variables that have an initial value here e.g. uint32 CPU1_var_init = 1; */
// Thermistor parameters
float MAX_V = 5.0; // 3.3 Reference voltage for A2D channels
int MAX_A2D = 1023;
int analogPin0 = 0;
int analogPin1 = 1;
float THETA[3] = {3.33746911687670e+2,-3.83716062783759e+1,5.73463936130444e-2};
float MIN_RESISTANCE = 303.075;
float MAX_RESISTANCE = 367701.4;
float divider_resistance = 10000; // Ohms

int twelve_bit_A2D0_val = 0;
int twelve_bit_A2D1_val = 0;
float water_temperature_right = 0.0;
float water_temperature_left = 0.0;
float water_temperature_average = 0.0;

EndOfInitialised_CPU1_Variables

float convert_thermistor_voltage2temp(int);

void setup1() {
// put your setup code for core 1 here, to run once:
pinMode(2, OUTPUT);
Serial.begin(115200);
}


void loop1() {
// put your main code for core 1 here, to run repeatedly:
digitalWrite(2,HIGH);
delay(3);
digitalWrite(2,LOW);
delay(3);

twelve_bit_A2D0_val = analogRead(analogPin0); // read the input pin
twelve_bit_A2D1_val = analogRead(analogPin1); // read the input pin
water_temperature_right = convert_thermistor_voltage2temp(twelve_bit_A2D0_val);
water_temperature_left = convert_thermistor_voltage2temp(twelve_bit_A2D1_val);
water_temperature_average = (water_temperature_right + water_temperature_left)/2.0;

Serial.println(twelve_bit_A2D0_val, BIN);
Serial.println(twelve_bit_A2D1_val, BIN);
Serial.println(twelve_bit_A2D0_val, DEC);
Serial.println(twelve_bit_A2D1_val, DEC);
Serial.println("Analog Reads: Core 1 \n");
delay(500);
}

float convert_thermistor_voltage2temp(int A2D_val)
{
float A2D_voltage = 0.0;
float thermistor_resistance = 0.0;
float thermistor_temperature = 0.0;

A2D_voltage = (MAX_V/MAX_A2D)*(A2D_val);
if(A2D_voltage <= (MAX_V/MAX_A2D)*(1.0))
{
A2D_voltage = (MAX_V/MAX_A2D)*(1.0);
}
thermistor_resistance = divider_resistance*((MAX_V/A2D_voltage) - 1);
if(thermistor_resistance <= MIN_RESISTANCE)
{
thermistor_resistance = MIN_RESISTANCE;
}
thermistor_temperature = THETA[0] + THETA[1]*log(thermistor_resistance) + THETA[2]*(pow(log(thermistor_resistance),3));

return thermistor_temperature;
}

/*** Core 2 ***/

/* CPU2 Uninitialised Data */
StartOfUninitialised_CPU2_Variables
/* Put your CPU2 fast access variables that have no initial values here e.g. uint32 CPU2_var; */
EndOfUninitialised_CPU2_Variables

/* CPU2 Initialised Data */
StartOfInitialised_CPU2_Variables

/* Put your CPU2 fast access variables that have an initial value here e.g. uint32 CPU2_var_init = 1; */
// D2A MAX541 parameters
const int D2A1_CS = 9; /* D2A chip selects */
const int D2A2_CS = 10;
const float MAX_D2A_voltage = 5.0;
const float MIN_D2A_voltage = 0.0;
const unsigned short MAX_word = 65535; /* 2^16 - 1 = 65535 is maximum unsigned short */
const unsigned int D2A_SCK_RATE = 10000000; /* 10MHz */
float input_Vr = 2.0;
float input_Vl = 3.0;

EndOfInitialised_CPU2_Variables

void send_D2A_voltages(float *, float *);

SPISettings myD2ASettings(D2A_SCK_RATE, MSBFIRST, SPI_MODE0);

void setup2() {
// put your setup code for core 2 here, to run once:
pinMode (D2A1_CS, OUTPUT);
pinMode (D2A2_CS, OUTPUT);

digitalWrite(D2A1_CS,HIGH); // start out high
digitalWrite(D2A2_CS,HIGH); // start out high
}


void loop2() {

send_D2A_voltages(&input_Vr,&input_Vl); // control + idle voltages

// // put your main code for core 2 here, to run repeatedly:
// SPI.beginTransaction(myD2ASettings);
// digitalWrite(D2A1_CS,LOW);
// SPI.transfer(0x81); // 5A
// SPI.transfer(0x5A);
// digitalWrite(D2A1_CS,HIGH);
// SPI.endTransaction();

// SPI.beginTransaction(myD2ASettings);
// digitalWrite(D2A1_CS,LOW);
// SPI.transfer(0x5A);
// //SPI.transfer(0x5A);
// digitalWrite(D2A1_CS,HIGH);
// SPI.endTransaction();

delayMicroseconds(100);
}

void send_D2A_voltages(float *V_D2A1, float *V_D2A2)
{
unsigned short data1 = 0, data2 = 0; /* For Due short is 16 bits, int is 32 bits */
byte data1_highbyte, data1_lowbyte;
byte data2_highbyte, data2_lowbyte;

if (*V_D2A1 < MIN_D2A_voltage)
{
*V_D2A1 = MIN_D2A_voltage;
}
if (*V_D2A1 > MAX_D2A_voltage)
{
*V_D2A1 = MAX_D2A_voltage;
}

if (*V_D2A2 < MIN_D2A_voltage)
{
*V_D2A2 = MIN_D2A_voltage;
}
if (*V_D2A2 > MAX_D2A_voltage)
{
*V_D2A2 = MAX_D2A_voltage;
}

data1 = (unsigned short) (MAX_word/MAX_D2A_voltage)*(*V_D2A1);
data2 = (unsigned short) (MAX_word/MAX_D2A_voltage)*(*V_D2A2);

data1_highbyte = (byte) ((data1 & 0xFF00) >> 8);
data1_lowbyte = (byte) (data1 & 0x00FF);

data2_highbyte = (byte) ((data2 & 0xFF00) >> 8);
data2_lowbyte = (byte) (data2 & 0x00FF);

//SPI.beginTransaction(SPISettings(D2A_SCK_RATE, MSBFIRST, SPI_MODE0));
SPI.beginTransaction(myD2ASettings);
digitalWrite(D2A1_CS,LOW);
SPI.transfer(data1_highbyte);
SPI.transfer(data1_lowbyte);
digitalWrite(D2A1_CS,HIGH);
SPI.endTransaction();

//SPI.beginTransaction(SPISettings(D2A_SCK_RATE, MSBFIRST, SPI_MODE0));
SPI.beginTransaction(myD2ASettings);
digitalWrite(D2A2_CS,LOW);
SPI.transfer(data2_highbyte);
SPI.transfer(data2_lowbyte);
digitalWrite(D2A2_CS,HIGH);
SPI.endTransaction();
}
shields
Posts: 10
Joined: Sat Jan 06, 2018 7:10 pm

Sun Nov 04, 2018 4:40 am

Hi Phil,

Had some success using

# define Serial SerialASC

inside TimePlot.h. I am now seeing a message

{TIMEPLOT:Test Time Plot|DATA|My Sensor|T|4.7000}

in the Monitor stream. Not sure if this is the whole solution though.

-Joel
shields
Posts: 10
Joined: Sat Jan 06, 2018 7:10 pm

Mon Nov 05, 2018 12:18 am

How do I make the execution of the #define dependent on the board I select? The board I'm using shows up as a ShieldBuddy_TC275_Dx within the Tools>Board menu. Sorry not very familiar with the Arduino IDE environment.

-Joel
philr
Posts: 359
Joined: Mon May 26, 2014 10:58 am

Mon Nov 05, 2018 7:30 am

Hi Joel, sorry for the late reply.

Our plotting, and many of the other libraries allow you to specify an alternative source. For example the constructor for the plot object is
Plot::Plot( const __FlashStringHelper *Context, Print &rDestination )
: MegunoLinkProtocol(Context, rDestination)
{

}

So if you declared your plot like this
TimePlot MyPlot(F("Data"),&SerialASC);

It should then send it out of your new serial port.

I'm not sure about your latest question. Maybe this page is helpful
https://arduino.stackexchange.com/quest ... pe-in-code

Cheers
Phil
shields
Posts: 10
Joined: Sat Jan 06, 2018 7:10 pm

Tue Nov 06, 2018 5:18 am

Hi Phil,

FYI this worked …

TimePlot MyPlot("Test Time Plot",SerialASC);

but not this …

TimePlot MyPlot("Test Time Plot",&SerialASC);

Didn't seem to like the address operator.

-Joel
philr
Posts: 359
Joined: Mon May 26, 2014 10:58 am

Tue Nov 06, 2018 7:58 am

Ha nice catch!
Phil
Post Reply