EcoModder.com

EcoModder.com (https://ecomodder.com/forum/)
-   OpenGauge / MPGuino FE computer (https://ecomodder.com/forum/opengauge-mpguino-fe-computer.html)
-   -   I need your help (MPGuino code change for Arduino mega 2560?) (https://ecomodder.com/forum/showthread.php/i-need-your-help-mpguino-code-change-arduino-26674.html)

josemapiro 08-14-2013 04:51 AM

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

Quezacotl 08-15-2013 08:53 AM

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.

josemapiro 08-16-2013 07:19 AM

Quote:

Originally Posted by Quezacotl (Post 385332)
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

josemapiro 08-16-2013 02:55 PM

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.

https://www.youtube.com/watch?v=_oFHlihGZog

If I can help I thank
José Rodrigues

t vago 08-16-2013 09:34 PM

Quote:

Originally Posted by josemapiro (Post 385656)
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 (Post 385656)
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.

josemapiro 08-17-2013 05:41 AM

Quote:

Originally Posted by t vago (Post 385706)
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.
http://imageshack.us/a/img826/1596/l293.th.jpg

Thank you
José Rodrigues

Quezacotl 08-17-2013 06:09 AM

PinK? :)

josemapiro 08-17-2013 08:46 AM

Quote:

Originally Posted by Quezacotl (Post 385765)
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.

http://imageshack.us/a/img826/1596/l293.th.jpg

josemapiro 08-19-2013 07:04 AM

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

t vago 08-19-2013 12:11 PM

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.


All times are GMT -4. The time now is 03:24 AM.

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