Hi, I'd like to measure the amount of time a contact remains closed with no "bounce".
I have two powerful magnets, (conductors) that I want to measure the instant they make contact with each other, until the first loss of contact. No actual switch involved, just using the touch of the two magnet conductors as the start and stop triggers.
If they touch again, I do not want the timer to continue or reset. Reset would be done by an additional standard momentary contact switch.
For a visual... imagine having two magnets with a wire coming off each and attempting to press the repelling poles together to start the timer -- until such time that pressure cannot be maintained any longer and contact is broken.
I'd like to have the Arduino set to the highest time resolution... hundreds or thousands of a second to display the length of time of continuous contact. Seems doable, but outside of my expertise.
Say more. Contacts bounce, typically an interval is selected to variously ignore the phenomenon.
If you ignore contact bounce, you would measure a very tiny interval of contact, possibly smaller than you can accurately measure with a simple program.
On the other hand, if you consider contact bounce, the selected interval may be in excess of what you expect to measure: typical pushbuttons use times like 10 or 20 or 50 milliseconds.
Or is this all moog, and you did not say this contact is somehow bounceless?
This inexpensive unit is a true surprise, does what it says. You can pay twice as much or half as much, they all seem to come out of the same factory somewhere.
Software for analysis is here
and whike I wouldn't call it intuitive, it is manageable.
The two cheap logic analyzers I have also function well with a version of Saleae's software. I didn't notice any reason to pick one over the other, my uses of the logic analyzer are on the simple side and PulseView is sufficient.
How much time resolution do you think an UNO or NANO classic does NOT have?
A while back for fun I made a super simple code once that simply incremented a count by 1 on every loop cycle. Every 10 seconds I serial printed the average number of loop cycles per second. It showed around 289,000 loops per second. By default the Atmega 328 can measure time in micro seconds (.000001 seconds, or a millionth of a second). That seems like plenty of chances to record time.
AI is a super handy tool. But it only regurgitates what it finds in a search. That isn’t always good and sometimes it is downright wrong. I use it because it can search and return results far faster than I can. I don’t ask it to show me code or coding techniques much beyond my skill level or much beyond my level of understanding. It has helped me learn by showing and explaining things at just slightly above my skill level.
As a code develops and gets longer, AI can definitely write it faster than I can. BUT as the code grows AI starts to mess up quite a bit. I think it is super important that you need to be able to read and interpret the code AI provides you so you can diagnose problems or ask it more direct questions.
In other words, folks need to know how to code before asking AI to do it for them. Without some knowledge of coding or the project, you won’t know where to begin when it does not work.
If you would... what AI did you use? Claude, Grok, ChatGPT? Gemini
And for fun, did you just copy paste my description or did you have to enhance the prompt? Yes, copied and pasted.
When the test button is pressed, an instant value is printed, ranging from 28 to 80 us, consistent with measuring the first contact bounce, +/-.
Applying a bounce free input correctly measures the down time of a signal.
If you add a debounce interval, you won't be able to measure anything smaller in a meaningful way.
The title is for 1/100th of a second. I don't see how a simple program can hack this.
If you meant measure the interval in units of 0.01 seconds, that is straightforward. You would have to say how the bouncing shoukd enter into the timing - first contact to last? The stable period between the closing bounces and the opening bounces? Like that.
I have few other ideas but am currently out of the things one runs out of. Maybe I'll ask an AI for 10 ms of its thinking.
In the meantime,
PukseView and the Saleae software both run on the Mac…