Any strange behaviour, crashing issues etc, post them here! Problems compiling the firmware should go in the General support section rather than here
By hello
#41266
hi everyone;
I just did some testing on 2560 and it didn't look too good for some things, ........................
I didn't look at speeduino code too close and maybe there are some nuansses(sp), but if it uses interupts.........
cut and paste code if interested
place wire between 7 and desired interupt
need arduino ide, open monitor

cheers!



void setup() {
// put your setup code here, to run once:
//2, 3, 18, 19, 20, 21 mega2560
//ON PIN 18,falling, goes to blink, on 19,RISING&FALLING, it oscillates between blink&help
//2, 3 seem more stable
//20 seems more stable than 21, 21 oscillates between blink&help

pinMode(20,INPUT);//HALL1
pinMode(21,INPUT);//HALL2

attachInterrupt(digitalPinToInterrupt(20), blink, FALLING);
attachInterrupt(digitalPinToInterrupt(21), help, FALLING);

pinMode(7,OUTPUT);

//CHANGE FREQUENCY PWM
int myEraser = 7; // this is 111 in binary and is used as an eraser.....4B IS PORT4, relates to pin 6,7,8
TCCR4B &= ~myEraser; // this operation (AND plus NOT), set the three bits in TCCR4B to 0
int myPrescaler = 5; // this could be a number in [1 , 6]. In this case, 3 corresponds in binary to 011.
TCCR4B |= myPrescaler; //this operation (OR), replaces the last three bits in TCCR2B with our new value 011
Serial.begin(9600); // open the serial port at 9600 bps:

//conclusion pins 2,3 may be suitable for external interupts
//
}

void loop() {
// put your main code here, to run repeatedly:
analogWrite(7, 127);

}

void blink() {
Serial.println("BLINK");
}

void help() {
Serial.println("help");
}
By noisymime
#41268
What are you actually trying to achieve here?

You're using the PWM output from pin 7 to trigger the external interrupts (Which work completely fine on any of the external enabled pins) and then printing something out. The obvious problem I see with this is that you're going to fill the serial buffer very quickly and then the calls to Serial.println are going to start blocking.

What frequency are you setting the PWM to?
By hello
#41277
trying to see how the board behaves.
they may work fine under certain circumstances but under these conditions they behave irradically.
some pins behave one way-others in another but they are both suppose to be the same.

1rpm=0.017 hz 8500rpm, redline 141.7hz
By JHolland
#41279
I'm not sure that I understand your set up, can you post a circuit diagram? If you are generating interrupts at 141Hz(7.1ms) then you don't have enough time between interrupts to output the data. At 9600baud then "blink" is going to take a minimum of 5*2*10 *(1/9600) = 10.4ms
By NickZ
#41314
as you have been told, your test method doesn't work correctly. the ATMEGA2560 is and does run perfectly fine.
there is no issue.
By hello
#41472
ha!, ha!, ha!, I wish that were true would have saved me alot of time.
there great boards have a lot of functionality, but ya have to know how to use em.
By noisymime
#41473
OK, run this sketch
Code: Select all
volatile unsigned long input1Time1;
volatile unsigned long input1Time2;
volatile unsigned long input2Time1;
volatile unsigned long input2Time2;

void setup() {
// put your setup code here, to run once:
//2, 3, 18, 19, 20, 21 mega2560
//ON PIN 18,falling, goes to blink, on 19,RISING&FALLING, it oscillates between blink&help
//2, 3 seem more stable
//20 seems more stable than 21, 21 oscillates between blink&help

pinMode(20,INPUT);//HALL1
pinMode(21,INPUT);//HALL2

attachInterrupt(digitalPinToInterrupt(20), blink, FALLING);
attachInterrupt(digitalPinToInterrupt(21), help, FALLING);

pinMode(7,OUTPUT);



//CHANGE FREQUENCY PWM
int myEraser = 7; // this is 111 in binary and is used as an eraser.....4B IS PORT4, relates to pin 6,7,8
TCCR4B &= ~myEraser; // this operation (AND plus NOT), set the three bits in TCCR4B to 0
int myPrescaler = 5; // this could be a number in [1 , 6]. In this case, 3 corresponds in binary to 011.
TCCR4B |= myPrescaler; //this operation (OR), replaces the last three bits in TCCR2B with our new value 011
Serial.begin(9600); // open the serial port at 9600 bps:

//conclusion pins 2,3 may be suitable for external interupts
//
}

void loop() {
// put your main code here, to run repeatedly:
analogWrite(7, 127);

Serial.print("Input 1 period: ");
Serial.println((input1Time2-input1Time1));
Serial.print("Input 2 period: ");
Serial.println((input2Time2-input2Time1));

}

void blink() {
//Serial.println("BLINK");
input1Time1 = input1Time2;
input1Time2 = micros();
}

void help() {
//Serial.println("help");
input2Time1 = input2Time2;
input2Time2 = micros();
}
It functions EXACTLY as I'd expect it to. The value output is 32640 uS, which is matched exactly with what I'm seeing on the scope.
By hello
#41480
its not about time though
..................
if during program run, and it will run...................on & on..............
.................
change the wire from one interrupt to another
monitor output should change consistently
if you disconnect wire completely does it give an output?
if it does, is the board defective?

The IRLB3034 may work better? https://www.infine[…]

MX5/Miata PNP on 1.8 issues

@D0nny94 As for the tachometer. If you do ne[…]

Thanks Eric for pointing me to that one, basical[…]

... Thanks for picking this up - some good wo[…]

Still can't find what you're looking for?