Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow Can Bus issue #2

Open
joeji073 opened this issue Dec 26, 2020 · 0 comments
Open

Slow Can Bus issue #2

joeji073 opened this issue Dec 26, 2020 · 0 comments

Comments

@joeji073
Copy link

Hello, I'm running GD23ZUTX on a teensy and I'm using a Can Bus transceiver that is reading data off my car's ECU.

The issue I'm having is that if I set the ECU to send data at anything more than 10HZ, the data I'm seeing on the serial monitor is really laggy, like 5 seond delay. I can switch it to 10hz and it will run alright but 10HZ produces a choppiness with the gauge command. I'd like to be able to run at least 20HZ or faster.

I've narrowed down the issues to the Gameduino part of my code. If I run just the Can Bus code and output it to the serial monitor, the data is received at even 50HZ. Once I introduce a command, for example just the number command to display a reading on the screen, the lag comes back.

I added some code using millis() to determine the loop rate and I'm getting about 55 loops a second so I'm not sure where the incoming data is being backed up.

Below is a sample of my code.

`#include <GD23ZUTX.h>
#include <FlexCAN.h>

static CAN_message_t rxmsg;

FlexCAN CANbus(500000);

float CTPS, TPS;

void setup() {

CANbus.begin();
GD.begin();

}

void loop() {

if ( CANbus.read(rxmsg) ) {
switch (rxmsg.id) { // Using IDs from 1512 as Megasquirt CAN broadcast frames for Simplified Dash Broadcasting.
  // EAch frame represents a data group http://www.msextra.com/doc/pdf/Megasquirt_CAN_Broadcast.pdf
  case 1523:
    CTPS = (float)(word(rxmsg.buf[0], rxmsg.buf[1]));  //AFR...no division
  break;
}

}

TPS = CTPS/10;

Serial.println(TPS);

GD.Clear();

GD.ColorRGB(0xffffff);

GD.printNfloat(390, 450, TPS, 0, 30);

GD.swap();

GD.finish();

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant