Hi everyone,
I do not speak English very well, so I helped with google translator
I have two Arduino DUE with SN65HVD230 transceiver and this is a problem: when I send a value read from pin A0 with the first arduino board to the second arduino board, everything is ok, but when I send the second value read from pin A0 with the first arduino board to the second arduino board the value read remains the previous one.
this is the sent sketch:
#include "Arduino.h"
#include "variant.h"
#include "due_can.h"
#define ID 0x07
#define CAN_MSG_DUMMY_DATA 0x55AAEE22
// CAN frame max data length
#define MAX_CAN_FRAME_DATA_LEN 8
int val = 0;
CAN_FRAME output;
void setup()
{
Serial.begin(115200);
Can0.begin(CAN_BPS_125K);
}
void loop(){
int val = analogRead(A0);
Serial.print("value ");
Serial.println(val);
output.id = ID;
output.length = MAX_CAN_FRAME_DATA_LEN;
output.data.low = val;
output.data.high = CAN_MSG_DUMMY_DATA;
Can0.sendFrame(output);
Serial.println("message sent");
delay(2000);
}
this is receive sketch:
#include "Arduino.h"
#include "variant.h"
#include "due_can.h"
#define id 0x07
CAN_FRAME in;
void setup() {
Serial.begin(115200);
Can0.begin(CAN_BPS_125K);
Can0.watchFor(id);
}
void loop() {
Serial.println("waiting...");
if(Can0.available()){
Can0.read(in);
Serial.println("The value received is ");
Serial.println(in.data.low);
Serial.println("from ");
Serial.println(in.data.high, HEX);
delay(1000);
}
}
i use due_can library
I am attaching an image
Thanks for the helping
Now in italian
Ciao a tutti
Posseggo due Arduino DUE con due SN65HVD230 per la comunicazione CAN e ho questo problema: quando invio un valore letto dal pin A0 dalla prima scheda Arduino alla seconda scheda Arduino, la comunicazione del valore letto avviene correttamente, ma quando viene letto il secondo valore, sempre dalla prima scheda alla seconda, il valore ricevuto resta il primo. Esempio se il primo valore letto è 800 e questo valore viene trasmesso correttamente, il secondo valore letto ipotizziamo sia 600 il valore ricevuto resta 800, e così anche con la terza, quarta, quinta lettura resterà 800. L' unica soluzione è resettare entrambe le schede e non solo una, ma proprio tutte due.
Gli sketch che ho utilizzato sono sopra
la libreria usata è la due_can
vi lascio un immagine allegata
Grazie mille per l aiuto