[)roi(]
Regarding Option 1, Arduino's are slow they make use of a 16Mhz Crystal to clock an ATMEL Chip
If I had to format messages into JSON, I will actually make it a whole lot worse because I would be giving it a task to send more data via Serial. Maybe I'm missing your point but I don't see retrieving Arrays using JSON be any faster than using VB's String.Split function. the issue is not with the CAN-BUS Data, the company called SEEED Studio did a very good Job at retrieving CAN-BUS Messages , All I have to do is send it to the PC via Serial.
Option 2, Thats actually a great idea! never thought about that, I will put some thought into that, The way I see it the less information travel from the Arduino to the PC the better.
Option3 is what I'm actually doing in the example.
What GKM is saying, is the ultimate problem, and will be present in all above mentioned options.
A Layman example.
Machine A is sending Lucky Packet contents on a conveyor belt to Machine B in a factory.
1 Toy, 1 small packet of sweets and 1 lollipop makes a Lucky Packet and represents a CAN-BUS Message.
The conveyor belt represents the Serial Connection between th Arduino (Machine A) and the PC (Machine B)
Machine A Spits out, 1 Random toy, a pack of sweets and a random flavored Lollipop.
and it all travels to Machine B.
We have a worker in between Machine A and Machine B that Analyzes the the toys, sweets and Lollipops for defects running on the Conveyor Belt.
But the problem is the factory worker can only see 1 item at a time.
So if the worker does his job well he will always see Toy,Sweet,Lolipop,Toy,Sweet,Lolipop,Toy,Sweet,Lolipop.
But if you had to draw his attention onto something else, he will see, Sweet,Lollipop,Toy or Lolipop, Toy, Sweet when he focuses back on the convener, Simply because the Conveyer does not have a stop button.
Because my Previous Worker was a slow Piece of #%$# (HP H440p Laptop) it wasnt doing a good Job, But my newer worker Elite Desk 850 with a i7 4790K CPU is much better at doing the Job and lucky
By the way, currently I'm not making use of CAN-BUS data, I'm simply generating a stream of messages to emulate it. Otherwise i have to test it on my Jeep all the ime, which will be a huge pain.
Below is the Arduino Code.
The Emulator.
The Code to be used with the CAN-BUS shield.
Regarding Option 1, Arduino's are slow they make use of a 16Mhz Crystal to clock an ATMEL Chip
If I had to format messages into JSON, I will actually make it a whole lot worse because I would be giving it a task to send more data via Serial. Maybe I'm missing your point but I don't see retrieving Arrays using JSON be any faster than using VB's String.Split function. the issue is not with the CAN-BUS Data, the company called SEEED Studio did a very good Job at retrieving CAN-BUS Messages , All I have to do is send it to the PC via Serial.
Option 2, Thats actually a great idea! never thought about that, I will put some thought into that, The way I see it the less information travel from the Arduino to the PC the better.
Option3 is what I'm actually doing in the example.
What GKM is saying, is the ultimate problem, and will be present in all above mentioned options.
A Layman example.
Machine A is sending Lucky Packet contents on a conveyor belt to Machine B in a factory.
1 Toy, 1 small packet of sweets and 1 lollipop makes a Lucky Packet and represents a CAN-BUS Message.
The conveyor belt represents the Serial Connection between th Arduino (Machine A) and the PC (Machine B)
Machine A Spits out, 1 Random toy, a pack of sweets and a random flavored Lollipop.
and it all travels to Machine B.
We have a worker in between Machine A and Machine B that Analyzes the the toys, sweets and Lollipops for defects running on the Conveyor Belt.
But the problem is the factory worker can only see 1 item at a time.
So if the worker does his job well he will always see Toy,Sweet,Lolipop,Toy,Sweet,Lolipop,Toy,Sweet,Lolipop.
But if you had to draw his attention onto something else, he will see, Sweet,Lollipop,Toy or Lolipop, Toy, Sweet when he focuses back on the convener, Simply because the Conveyer does not have a stop button.
Because my Previous Worker was a slow Piece of #%$# (HP H440p Laptop) it wasnt doing a good Job, But my newer worker Elite Desk 850 with a i7 4790K CPU is much better at doing the Job and lucky
By the way, currently I'm not making use of CAN-BUS data, I'm simply generating a stream of messages to emulate it. Otherwise i have to test it on my Jeep all the ime, which will be a huge pain.
Below is the Arduino Code.
The Emulator.
Code:
char incomingByte = 0; // for incoming serial data
String BuildString = "";
int BuildingStatus = 0; //0=Not Building 1=Building 2=Done Building
String inBITS[9];
String PID;
String BIT1;
String BIT2;
String BIT3;
String BIT4;
String BIT5;
String BIT6;
String BIT7;
String BIT8;
String MyRND;
int RandomPID=0;
int led = 13;
// the setup routine runs once when you press reset:
void setup()
{
Serial.begin(38400);
}
// the loop routine runs over and over again forever:
void loop()
{
//PID="10438040";
PID="1028";
BIT1="100";
BIT2="167";
BIT3="10";
BIT4="255";
BIT5="255";
BIT6="255";
BIT7="255";
BIT8="255";
//Overwrite PID with a random val
PID=random(1000, 1040);
MyRND = random(1,100);
if (MyRND=="6")
{
BIT1=random(100,130);
BIT2=random(100,130);
BIT3=random(100,130);
BIT4=random(100,130);
BIT5=random(100,130);
BIT6=random(100,130);
BIT7=random(100,130);
BIT8=random(100,130);
}
Serial.println(PID + "," + BIT1 + "," + BIT2 + "," + BIT3 + "," + BIT4 + "," + BIT5 + "," + BIT6 + + "," + BIT7 + + "," + BIT8 );
delay(10);
}
The Code to be used with the CAN-BUS shield.
Code:
//This Arduino UNO Sketch requires the Seeed CAN-BUS Shield Libraries
//https://github.com/yexiaobo-seeedstudio/CAN_BUS_Shield
#include <SPI.h>
#include "mcp_can.h"
INT32U canId = 0x000;
unsigned char len = 0;
unsigned char buf[8];
char str[20];
void setup()
{
Serial.begin(38400);
START_INIT:
if(CAN_OK == CAN.begin(CAN_125KBPS))
{
Serial.println("CAN BUS Shield init ok!");
}
else
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
}
void loop()
{
if(CAN_MSGAVAIL == CAN.checkReceive())
{
CAN.readMsgBuf(&len, buf);
canId = CAN.getCanId();
Serial.print("<");Serial.print(canId);Serial.print(",");
for(int i = 0; i<len; i++)
{
Serial.print(buf[i]);Serial.print(",");
}
Serial.print(">");
Serial.println();
}
}
Last edited: