CAN-BUS Polling Suspend

A forum for discussing the MegaSquirt related (but non-B&G) board development, assembly, installation, and testing.

Moderators: jsmcortina, muythaibxr

Post Reply
Aaargh74
MS/Extra Newbie
Posts: 4
Joined: Sun Mar 08, 2015 3:55 pm

CAN-BUS Polling Suspend

Post by Aaargh74 »

I've created a Dash board and additional I/O that uses CAN-BUS to talk to the Megasquirt 2. It uses an Arduino and CAN-BUS shield for the communications. The dash can supply data when polled by the Megasquirt and request data points when required.

The issue that I've run into is that the Megasquirt poll rate is a lot quicker than the Arduino can process so after a second or two the message requests from the Dash to the Megasquirt stop working. When the CAN-BUS polling from the Megasquirt is disabled the Dash receives data from the Megasquirt correctly each time so I am assuming it is a buffer issue.

The Question I would like answering is:
There is a polling suspend command in the Megasquirt CAN-BUS documentation. Is this implemented in the latest MS2 Extra Code. If so what should the Table and Offset be set too when generating the CAN-BUS message ID when sending this Extended CAN-BUS message to the Megasquirt.

I'm hoping that suspending the Megasquirt polling periodically will allow the Arduino to catch up and then restart the polling again.
jsmcortina
Site Admin
Posts: 39612
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN-BUS Polling Suspend

Post by jsmcortina »

That sounds like fixing the wrong problem. Why is your code so slow?

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
xrattiracer
Experienced MS/Extra'er
Posts: 301
Joined: Fri Aug 01, 2008 2:25 pm

Re: CAN-BUS Polling Suspend

Post by xrattiracer »

check out my other thread with the teensy gauge. the teensy is vastly more powerful that the arduino, but is arduino compatible so your code will run with little or no modification. i have no troubles processing hundreds (or probably thousands, i havent actually measured it) packets per second in both directions.
As James says, optimize your code. or upgrade the hardware.
Alfagta
Experienced MS/Extra'er
Posts: 239
Joined: Wed Aug 21, 2013 2:54 am

Re: CAN-BUS Polling Suspend

Post by Alfagta »

I also use CAN Bus with an MCP Chip and an Atmel. No Problems with Speed or something else.
Poste your Code here, and maybe we will see what's wrong.

Best Regards
Alfa 156 GTA
Alfa 75 Race Car MS III -- alway latest FW
Alfa 164 V6 Turbo
Alfa 155 2,5TD RIP
Test MS II --always latest FW
Tunerstudio V2.6.11 Registered
MegaLog Viewer V3.4.04 Registered
Aaargh74
MS/Extra Newbie
Posts: 4
Joined: Sun Mar 08, 2015 3:55 pm

Re: CAN-BUS Polling Suspend

Post by Aaargh74 »

I've managed to get my code working - I was passing too much DEBUG information to the serial port on the Arduino and this was slowing down the cycle time.
Also my program now executes different blocks of code each cycle to reduce the overall cycle time. The poor Arduino couldn't process everything in one hit and respond to all the data from the Megasquirt.

The code responds to requests for ADC 0-7 from Table 1,2 in the Arduino and also requests a few parameters from Table 6 in the Megasquirt for a temporary dashboard.
There is code for Digital Inputs on table 3 but I haven't tested this.

The CAN-BUS Suspend and Resume functions work if you should ever feel the need to stop/start the polling...

I'm not a programmer so feel free to have a look and suggest improvements

Regards
Paul.
Alfagta
Experienced MS/Extra'er
Posts: 239
Joined: Wed Aug 21, 2013 2:54 am

Re: CAN-BUS Polling Suspend

Post by Alfagta »

Hello,

where should we look for the code?
Alfa 156 GTA
Alfa 75 Race Car MS III -- alway latest FW
Alfa 164 V6 Turbo
Alfa 155 2,5TD RIP
Test MS II --always latest FW
Tunerstudio V2.6.11 Registered
MegaLog Viewer V3.4.04 Registered
Aaargh74
MS/Extra Newbie
Posts: 4
Joined: Sun Mar 08, 2015 3:55 pm

Re: CAN-BUS Polling Suspend

Post by Aaargh74 »

I'll try again to upload...
Arduino CAN-BUS attempt.txt
Post Reply