Go Back   EcoModder Forum > EcoModding > Instrumentation > OpenGauge / MPGuino FE computer
Register Now
 Register Now
 

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 08-14-2013, 05:51 AM   #1 (permalink)
EcoModding Apprentice
 
Join Date: Dec 2012
Location: Portugal
Posts: 197
Thanks: 93
Thanked 70 Times in 64 Posts
I need your help (MPGuino code change for Arduino mega 2560?)

In MPGuino V0.86 entries for the injector and VSS Pins are made ​​with these,
injector open D2 (int0)
injector closed D3 (int1)
speed C0 (pcint8)

I needed to change the code of these Pins, so that work in Arduino mega 2560, which has D2 as (int4) and D3 as (INT5) and C0 there is no pcint8.

What parts should I change the code and how should I do.

Thank you
José Rodrigues

  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 08-15-2013, 09:53 AM   #2 (permalink)
Scandinavian creature
 
Join Date: Jun 2012
Location: Finland
Posts: 146

Golf ball - '94 Volkswagen Golf III
90 day: 28.46 mpg (US)
Thanks: 4
Thanked 27 Times in 22 Posts
find:
#define RISING 3
#define FALLING 2
These into whatever interruptpins you are using.
find:
#define vssBit ( 1 << 0 )
0 into whatever analog pin you are using.
__________________

Brrrmm
Now selling preassembled MPGuino's!
http://www.mthtek.net/mpguino/
  Reply With Quote
The Following User Says Thank You to Quezacotl For This Useful Post:
josemapiro (08-17-2013)
Old 08-16-2013, 08:19 AM   #3 (permalink)
EcoModding Apprentice
 
Join Date: Dec 2012
Location: Portugal
Posts: 197
Thanks: 93
Thanked 70 Times in 64 Posts
Quote:
Originally Posted by Quezacotl View Post
find:
#define RISING 3
#define FALLING 2
These into whatever interruptpins you are using.
find:
#define vssBit ( 1 << 0 )
0 into whatever analog pin you are using.
I've done some changes but the result is still not expected.
Later I will post here the changes I made and a video with the result.

Thank you
José Rodrigues
  Reply With Quote
Old 08-16-2013, 03:55 PM   #4 (permalink)
EcoModding Apprentice
 
Join Date: Dec 2012
Location: Portugal
Posts: 197
Thanks: 93
Thanked 70 Times in 64 Posts
Not changed the (# define RISING 3) (# define FALLING 2), because I use the pin 2 and 3, which amends and the INT0 and INT1, which belongs to pins 20 and 21.

Part code of injectors.
Code:
        injectorSettleTime = injhold;
	//int0Func = processInjOpen;                                                  // original code
	int4Func = processInjOpen;                                                  // code changed
	//int1Func = processInjClosed;                                                // original code
        int5Func = processInjClosed;                                                // code changed

	//set up the external interrupts
	//EICRB = (EICRB & ~((1 << ISC00) | (1 << ISC01)))                            // original code
        EICRB = (EICRB & ~((1 << ISC40) | (1 << ISC41)))                            // code changed
			//| ((parms[injEdgeIdx] == 1 ? RISING : FALLING) << ISC00);   // original code
                        | ((parms[injEdgeIdx] == 1 ? RISING : FALLING) << ISC40);   // code changed
	//EIMSK |= (1 << INT0);                                                       // original code
	EIMSK |= (1 << INT4);                                                       // code changed
	//EICRB = (EICRB & ~((1 << ISC10) | (1 << ISC11)))                            // original code
	EICRB = (EICRB & ~((1 << ISC50) | (1 << ISC51)))                            // code changed
			//| ((parms[injEdgeIdx] == 1 ? FALLING : RISING) << ISC10);   // original code
			| ((parms[injEdgeIdx] == 1 ? FALLING : RISING) << ISC50);   // code changed
	//EIMSK |= (1 << INT1);                                                       // original code
	EIMSK |= (1 << INT5);
The value of "# define vssBit (1 << 0)" is not the bit value of the pin?
Or put the value of the pin?
The pin that I use is the "A8" which uses pin "62" on the arduino mega.

If you have something wrong, please correct me.

As shown in the video, the program starts fine, but then when I trigger any of the buttons does a reset type, do not know what causes it.



If I can help I thank
José Rodrigues
  Reply With Quote
Old 08-16-2013, 10:34 PM   #5 (permalink)
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Hungary
Posts: 1,808

iNXS - '10 Opel Zafira 111 Anniversary

Suzi - '02 Suzuki Swift GL
Thanks: 831
Thanked 709 Times in 457 Posts
Quote:
Originally Posted by josemapiro View Post
The value of "# define vssBit (1 << 0)" is not the bit value of the pin?
Or put the value of the pin?
Those lines should really read:

Code:
#define vssBit (1 << PINC0)
#define lbuttonBit (1 << PINC3)
#define mbuttonBit (1 << PINC4)
#define rbuttonBit (1 << PINC5)
Quote:
Originally Posted by josemapiro View Post
As shown in the video, the program starts fine, but then when I trigger any of the buttons does a reset type, do not know what causes it.
It sounds like you might have connected your buttons by mistake to the reset pin. Somebody who is more familiar with the Arduino Mega may be able to verify that.
  Reply With Quote
The Following User Says Thank You to t vago For This Useful Post:
josemapiro (08-17-2013)
Old 08-17-2013, 06:41 AM   #6 (permalink)
EcoModding Apprentice
 
Join Date: Dec 2012
Location: Portugal
Posts: 197
Thanks: 93
Thanked 70 Times in 64 Posts
Quote:
Originally Posted by t vago View Post
Those lines should really read:

Code:
#define vssBit (1 << PINC0)
#define lbuttonBit (1 << PINC3)
#define mbuttonBit (1 << PINC4)
#define rbuttonBit (1 << PINC5)
It sounds like you might have connected your buttons by mistake to the reset pin. Somebody who is more familiar with the Arduino Mega may be able to verify that.
If you set the pins as indicated, but for the mega pins gives error.

mpguino_alt3_ino:251: error: 'PINK11' was not declared in this scope
mpguino_alt3_ino:251: error: 'PINK12' was not declared in this scope
mpguino_alt3_ino:251: error: 'PINK13' was not declared in this scope
mpguino_alt3_ino.ino: In function 'void __vector_10()':
mpguino_alt3_ino:398: error: 'PINK8' was not declared in this scope
mpguino_alt3_ino.ino: In function 'void mainloop()':
mpguino_alt3_ino:577: error: 'PINK11' was not declared in this scope
mpguino_alt3_ino:577: error: 'PINK13' was not declared in this scope
mpguino_alt3_ino:584: error: 'PINK12' was not declared in this scope
mpguino_alt3_ino:608: error: 'PINK11' was not declared in this scope
mpguino_alt3_ino:608: error: 'PINK12' was not declared in this scope
mpguino_alt3_ino:608: error: 'PINK13' was not declared in this scope
mpguino_alt3_ino:613: error: 'PINK11' was not declared in this scope
mpguino_alt3_ino:613: error: 'PINK12' was not declared in this scope
mpguino_alt3_ino:613: error: 'PINK13' was not declared in this scope
mpguino_alt3_ino.ino: In function 'void editParm(byte)':
mpguino_alt3_ino:1368: error: 'PINK11' was not declared in this scope
mpguino_alt3_ino:1368: error: 'PINK13' was not declared in this scope
mpguino_alt3_ino:1379: error: 'PINK12' was not declared in this scope
mpguino_alt3_ino:1407: error: 'PINK11' was not declared in this scope
mpguino_alt3_ino:1407: error: 'PINK12' was not declared in this scope
mpguino_alt3_ino:1407: error: 'PINK13' was not declared in this scope
mpguino_alt3_ino:1412: error: 'PINK11' was not declared in this scope
mpguino_alt3_ino:1412: error: 'PINK12' was not declared in this scope
mpguino_alt3_ino:1412: error: 'PINK13' was not declared in this scope

Here is a picture to help with the mega pins.


Thank you
José Rodrigues

Last edited by josemapiro; 08-17-2013 at 09:53 AM..
  Reply With Quote
Old 08-17-2013, 07:09 AM   #7 (permalink)
Scandinavian creature
 
Join Date: Jun 2012
Location: Finland
Posts: 146

Golf ball - '94 Volkswagen Golf III
90 day: 28.46 mpg (US)
Thanks: 4
Thanked 27 Times in 22 Posts
PinK?
__________________

Brrrmm
Now selling preassembled MPGuino's!
http://www.mthtek.net/mpguino/
  Reply With Quote
Old 08-17-2013, 09:46 AM   #8 (permalink)
EcoModding Apprentice
 
Join Date: Dec 2012
Location: Portugal
Posts: 197
Thanks: 93
Thanked 70 Times in 64 Posts
Quote:
Originally Posted by Quezacotl View Post
PinK?
Yes the Analogue pins in arduino mega, are PF0-7 and PK0-7, the pin PC in Atmega 328 were Analogue, in arduino mega are digital, you can confirm the image.


Last edited by josemapiro; 08-17-2013 at 09:53 AM..
  Reply With Quote
Old 08-19-2013, 08:04 AM   #9 (permalink)
EcoModding Apprentice
 
Join Date: Dec 2012
Location: Portugal
Posts: 197
Thanks: 93
Thanked 70 Times in 64 Posts
The error above was my mistake, define, # define vssBit (1 << PINK8); # define lbuttonBit (1 << PINK11); # define mbuttonBit (1 << PINK12); # define rbuttonBit (1 << pink13), but these pins is not are the correct, the correct are# define vssBit (1 << PINK0); # define lbuttonBit (1 << pink3); # define mbuttonBit (1 << PINK4); # define rbuttonBit (1 << PINK5), the K Pins are 0 to 7.
I've been a bit sleep.
But even with these changes, the problem remains. Will be a registration on the changes I made, what needs to be changed too?
Any registration that points to a different Pin.

Thank you
José Rodrigues
  Reply With Quote
Old 08-19-2013, 01:11 PM   #10 (permalink)
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Hungary
Posts: 1,808

iNXS - '10 Opel Zafira 111 Anniversary

Suzi - '02 Suzuki Swift GL
Thanks: 831
Thanked 709 Times in 457 Posts
Can you give us a list of the interrupt vectors you're using? Such as -

Code:
ISR( TIMER2_OVF_vect ) { // system timer interrupt handler
ISR( INT0_vect ) { // fuel injector open event handler
ISR( INT1_vect ) { // fuel injector close event handler
ISR( PCINT1_vect ) { // button and VSS pin change vector
ISR( ADC_vect ) { // (freewheeling) A/D conversion completed vector
ISR( USART_UDRE_vect ) { // serial UART transmit data ready vector
I am asking because I had the hardest time trying to get my serial output routine to work as interrupt driven code. I'd write a change into the code, program my MPGuino, turn on serial output via parameter, then watch my MPGuino continually reset.

It turns out that the Arduino compiler would blindly accept anything placed within the "ISR()" parentheses. For my serial output ISR, I could have written:

Code:
ISR( this_is_not_defined_vect ) { // serial UART transmit data ready vector
And Arduino would have compiled it with no error.

The reason that is important is because if Arduino does not have the actual interrupt vector that is found in interrupts.h (mentioned near the beginning of the MPGuino code), then whatever is inside the ISR() parentheses will default to interrupt vector 0. That happens to be the processor reset vector.

  Reply With Quote
Reply  Post New Thread






Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com