Notifications
Clear all

Problem with digitalWrite extending interrupt count

37 Posts
7 Users
13 Likes
2,712 Views
ron bentley
(@ronbentley1)
Member
Joined: 2 years ago
Posts: 385
 

@inst-tech 

👍

It could be a none smooth pulse curve, causing two momentary rise/falls which the triggers the interrupt?

This is what happens when coding switches to deal with switch debounce.

I shall think on.

Yes, thanks, you too, have a great day.

Ron B

Ron Bentley
Creativity is an input to innovation and change is the output from innovation. Braden Kelley
A computer is a machine for constructing mappings from input to output. Michael Kirby
Through great input you get great output. RZA
Gauss is great but Euler rocks!!


   
Inst-Tech reacted
ReplyQuote
Inst-Tech
(@inst-tech)
Member
Joined: 2 years ago
Posts: 554
 
Posted by: @ronbentley1

@inst-tech 

👍

It could be a none smooth pulse curve, causing two momentary rise/falls which the triggers the interrupt?

This is what happens when coding switches to deal with switch debounce.

I shall think on.

Yes, thanks, you too, have a great day.

Ron B

I have been using an oscilloscope to monitor the wave form.. and its a clean square wave from the signal generator to the interrupt input( pin 2).. nothing suggest any abnormalities in pulse duration or wave signature, and frequency is +/- 1 hz , not enough frequency shift to cause this phenomenon. 

The fact that it is repeatable every time, no matter what frequency is inputted, is what is puzzling..

I'm wondering if because the serial port shares communication with the interrupt pins, the first pass thru it is just out of sync, and then next clock cycle syncs up?  That kinda makes since to me, but still doesn't tell me why it is so..

eventually, the solution will come...lol

Hang in there, we're getting closer now...

regards,

LouisR

 

LouisR


   
ReplyQuote
ron bentley
(@ronbentley1)
Member
Joined: 2 years ago
Posts: 385
 

@inst-tech 

I have neither a signal gen or oscilloscope so my comments are purely grey matter driven, unfortunately.

Here's an approach - gather stats over a period of time and then report using serial print functions.  You should then be able to rule in or out any interference?

However , I struggle to see if there may be any such inference as external interrupt pins on uno are 2 and 3, whilst the serial functions use pins 0 and 1, I believe.

Worth a try?

Ron Bentley
Creativity is an input to innovation and change is the output from innovation. Braden Kelley
A computer is a machine for constructing mappings from input to output. Michael Kirby
Through great input you get great output. RZA
Gauss is great but Euler rocks!!


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6960
 

@ronbentley1 @inst-tech I have been watching this thread for a while and keep hoping the OP will change pins. Check pinout diagrams and try a pin with NO other function, maybe try many, if they all act the same then we really have a great mystery, but my 'gut' is screaming that this is pin related. If I had the kit I would already be doing that but I don't so can't.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
ron bentley
(@ronbentley1)
Member
Joined: 2 years ago
Posts: 385
 

@inst-tech 

Hi Louis,

I put together a short C++ sketch to perform the function of a square wave signal generator, configured for 1 htz cycles. 

I uploaded the sketch to a MEGA (just what I have around) and connected this to the signal input interrupt port of your sketch  (pin 2), which I loaded to an UNO - I did modify the sketch a little to take out the battery check function call (also, this has a delay of 2 secs in it which affects the count reporting if left in).

Anyway, I found that your sketch works as expected, with the interrupt routine correctly clocking the pulses.  So, notwithstanding any specific errors in the author's original post and reported issues, the process works as expected.

I can post the sketches if that would be instructive.  

Cheers

Ron B

PS I did also test the arrangement and config for other frequencies, ie 2 htz, and worked fine.

Ron Bentley
Creativity is an input to innovation and change is the output from innovation. Braden Kelley
A computer is a machine for constructing mappings from input to output. Michael Kirby
Through great input you get great output. RZA
Gauss is great but Euler rocks!!


   
Inst-Tech reacted
ReplyQuote
Inst-Tech
(@inst-tech)
Member
Joined: 2 years ago
Posts: 554
 
Posted by: @ronbentley1

@inst-tech 

Hi Louis,

I put together a short C++ sketch to perform the function of a square wave signal generator, configured for 1 htz cycles. 

I uploaded the sketch to a MEGA (just what I have around) and connected this to the signal input interrupt port of your sketch  (pin 2), which I loaded to an UNO - I did modify the sketch a little to take out the battery check function call (also, this has a delay of 2 secs in it which affects the count reporting if left in).

Anyway, I found that your sketch works as expected, with the interrupt routine correctly clocking the pulses.  So, notwithstanding any specific errors in the author's original post and reported issues, the process works as expected.

I can post the sketches if that would be instructive.  

Cheers

Ron B

PS I did also test the arrangement and config for other frequencies, ie 2 htz, and worked fine.

Good Work Ron Bentley!...Yes, I have concluded that the sketch works fine and as expected..all that's left now is to find out why the timing starts in the sketch in the middle of the first pulse..I haven't found anything as yet, but haven't given up.. someone, somewhere, has encountered this phenomenon, and can explain it!..lol  as far as making it work goes, we've accomplished that goal, now to move on to other more pressing problems. 

Thanks again for confirming my test results..

Regards,

LouisR

 

LouisR


   
ron bentley reacted
ReplyQuote
ron bentley
(@ronbentley1)
Member
Joined: 2 years ago
Posts: 385
 

@inst-tech 

Louis

Could this be the feature being experienced:

When a pin is configured as an INPUT with pinMode() , and read with digitalRead() , the Arduino (ATmega) will report HIGH if: a voltage greater than 3.0V is present at the pin (5V boards) a voltage greater than 2.0V is present at the pin (3.3V boards)26 Jun 2021

The interrupt will fire/trigger as soon as the  threshold is reached and thetefore before fully high if you are detecting this phenomenon on the oscilloscope

 

Cheers

Ron b

 

Ron Bentley
Creativity is an input to innovation and change is the output from innovation. Braden Kelley
A computer is a machine for constructing mappings from input to output. Michael Kirby
Through great input you get great output. RZA
Gauss is great but Euler rocks!!


   
Inst-Tech reacted
ReplyQuote
Page 3 / 3