Page 1 of 1

Reassigning MEGA Pins on a 043c to work with SimpleDyno

Posted: Fri Aug 05, 2022 12:57 am
by purplelightning
So this is a little out of scope of Speeduino firmware as such, but I figured I'd ask here in case someone can help. I have an inertia dyno and I'd like to use my 043c speeduino that I have to send data to SimpleDyno. In this case it's not performing any ECU functions.

SimpleDyno comes with a sketch for an Arduino Uno Sketch, but from what I can tell from the pin assignments will not work with how the MEGA is setup with the 043c board, so I need to reassign the pins. But I don't see any pin assignments detailed in the sketch.

Any thoughts on how I could make these inputs work with Simpledyno? Or where I might go to remap them?

Engine RPM
IAT
CLT
AFR
Dyno flywheel RPM (Could I use CPS for this)

Re: Reassigning MEGA Pins on a 043c to work with SimpleDyno

Posted: Fri Aug 05, 2022 7:24 am
by JHolland
The pin mapping is implicit. You need to change the code so instead of just looping through A0 to A5 it reads the correct channels in Speedy, something
like:
Code: Select all
// do first channel
              AnalogResult = analogRead(insert speedy channel);
             AllResult += ",";
              AllResult += AnalogResult;
// repeat for each channel
              .........................
For clarity you could #define the analogue inputs
Code: Select all
#define SpeedyIAT       0   // IAT is A0
then in the main code it becomes
Code: Select all
AnalogResult = analogRead(SpeedyIAT);
You may also need to change the definitions for the pin change interrupts to match the inputs that Speedy uses for cam and crank.
If you can't understand it then run through some of the Arduino tutorials to familiarize yourself with Arduino programming.

Re: Reassigning MEGA Pins on a 043c to work with SimpleDyno

Posted: Fri Aug 05, 2022 5:39 pm
by purplelightning
Thanks so much. I wondered if it was just looking at the pins in sequence but I was just guessing vs knowing.
Maybe I'll try and grab the crank signal to start and see how it goes....

.... So circling back on just getting RPM to work... I'm totally lost on how I can map that to D19 which is used for RPM on the MEGA... Looks like this might need to be explicitly defined too?
Code: Select all
  // Initialize interupts (Pin2 is interrupt 0 = RPM1, Pin3 in interrupt 1 = RPM2)
  attachInterrupt(0,channel1,FALLING);
  attachInterrupt(1,channel2,FALLING);
}
I'll continue thinking out loud in case it helps someone else. So these are not just digital channels, but interrupt ones. On the Uno the two pins being used are

D2 Digital Pin 2 INT0 Interrupt Pin 0
D3 Digital Pin 3INT1 Interrupt Pin 1

Looking to get a a concrete answer what the interrupt pins are on the 2560 board. Turns out the Crank and Cam pin mapping in the 043c board with a mega are interrupts. (This probably seems obvious to anyone with knowledge of arduino)

From https://www.circuitstoday.com/arduino-m ... schematics

Hardware Interrupt Pins :
Digital pin 18 – 21,2,3 hardware interrupt is used for interrupt services. Hardware interrupt must be enabled with global interrupt enable to get interrupt from other devices.

Going to poke around in init.ino for speeduino and see if I can figure something out.. Way above my head here.

Re: Reassigning MEGA Pins on a 043c to work with SimpleDyno

Posted: Fri Aug 05, 2022 7:37 pm
by JHolland
Looking at the schematic and the Mega documentation Speedy uses INT2 and INT3 so you need to change the code to:
Code: Select all
  attachInterrupt(2,channel1,FALLING);
  attachInterrupt(3,channel2,FALLING);
or RISING if thats what you need. I haven't tested that, the correct way to measure RPM is using Input Capture but Speedy doesn't support that.

Re: Reassigning MEGA Pins on a 043c to work with SimpleDyno

Posted: Sat Aug 06, 2022 1:34 am
by purplelightning
Thanks again, I updated the code with that and will try it shortly...

How were you able to ascertain that INT2 and INT3 were involved? When I looked at the schematic, the CPS and CKP signals were mapped to MCU-D19 and MCU-D18

Image

Which show as being Rx and Tx in the serial area of the Mega board. Clearly I'm not interpreting it correctly.
Image

Re: Reassigning MEGA Pins on a 043c to work with SimpleDyno

Posted: Sat Aug 06, 2022 1:39 pm
by JHolland
You need to look at the pin out diagram for the Mega:
Image

Re: Reassigning MEGA Pins on a 043c to work with SimpleDyno

Posted: Sat Aug 06, 2022 7:36 pm
by purplelightning
Gotya, I guess where I got confused is that those pins are in the "communication" area. Just my lack of understanding of Arduino I guess.

Re: Reassigning MEGA Pins on a 043c to work with SimpleDyno

Posted: Fri Jan 06, 2023 11:05 am
by jonbill
so hard to remember.

Re: Reassigning MEGA Pins on a 043c to work with SimpleDyno

Posted: Fri Jan 06, 2023 6:35 pm
by PSIG
jonbill wrote: Fri Jan 06, 2023 11:05 am so hard to remember.
:lol: ... both SPAM posts have been reported. Who is doing the SPAM cleanups these days?

Re: Reassigning MEGA Pins on a 043c to work with SimpleDyno

Posted: Fri Jan 06, 2023 6:41 pm
by jonbill
I think it's only Josh can do it.