Greetings Arduino community! I am relatively new to this community however I have...how do you say...been a long time listener...first time caller....
I will come out with it immediately...I am more hardware than software and have been using this time under quarantine to dig deeper into the software perspective.
Description of device.....
I have a device that outputs a 5v+ DC error message as a pulse train....150ms on....150ms off for the first 5 rising edge pulses...indicating there is an error message coming....then upon the fifth rising edge when it falls it stays low for 1.1seconds....then followed by the error message which is 700ms on and 600ms off...consisting of 1-11 pulses to differentiate between the errors. Their are a few unknowns about the packet repetition etc...however I will be measuring everything to tailor the software. Yes I am using a pulldown etc My objective is to count the pulses until the pin is low for 'x' seconds
Description of my solution(s)....
From what I understand there are two fairly simple ways to accomplish this, digitalRead() pin state -OR- attach interrupt. I have been playing with the attach interrupt as to learn more about it's functioning and I can get it to count all the pulses...however...it counts and outputs them individually....what I am trying to do is count all the pulses that follow the first pulse so I have the total of pulses to work with. The counter also needs to reset to zero after every packet which this code effectively does. I don't know if I am individually overthinking this problem however when the software is counting pulses i want to make sure it grabs all the pulses so it would need to understand to stay low at least 2 seconds(until I can measure the time between error packet delivery etc) This is my starting code which focuses only on the interrupt. I guess I am not looking for someone to just answer me, I would like to understand the solution etc...thank you for your time.
sketch_apr24d.ino (634 Bytes)