24vac pulse - detect and record timestamp - Page 1
Forum section: electronics / beginners

author: papapaul
author_rank: Newbie
timestamp: October 01, 2014, 08:06:13 pm
content: I'm a total electronics novice, looking for some direction.At my coin operated businesses I need to track exactly when coins are dropped into the equipment - what I want to do is to record the date and time (accurate to the second) when each coin is dropped.I'm hoping there are off-the-shelf components that I can bolt together to do this, but I'm not even sure what to search for! If not off the shelf, I'm hoping its not too complex for me to handle. If any of you would be so kind as to point me in the right direction to get me started I'd be very grateful.My equipment does send a 24 VAC pulse (up to about 10 per second I think) for each coin, so I figure I can tap into this and "simply" write a timestamp each time a pulse is received. I'd also need to incorporate a timer of some sort so that I'd get an accurate timestamp. I'd like to be able to store about 20,000 timestamps at a time, then retrieve them for long term storage and reset it. (more storage would be better.) Manual retrieval is OK - an SD card or flash memory seems easiest to me, but am seeking suggestions.I have no experience with electronics. Yet. I can program in C, I could learn to program a PLC in a few days if that is an option, & I'm not intimidated by learning whatever I need to. I just started reading about arduino boards - that's something I think I could handle if it will work.I'm a DIY guy, I might end up paying somebody to do this for me but I get a lot of enjoyment out of doing it myself so thats my first hope.Thanks for any assistance/ guidance you can offer, & fire away with questions if I haven't offered enough information.

author: Rick Law
author_rank: Super Contributor
timestamp: October 01, 2014, 08:39:49 pm
content: Quote from: papapaul on October 01, 2014, 08:06:13 pmAn Arduino plus SD card plus RTC (DS3231) could do the job for you...Your Arduino will need some kind of power brick (7-9V). The DS3231 could provide the time. The on-board digital input (over 10 digital input available) with voltage divider and diode bridge can detect the 24VAC pulse (if it is a long enough pulse) and log it to the SD card with time stamp. Some DS3231 breakout boards has 4K EEPROM, but you need 2 bytes per entry (for date/time) so 4K is not big enough - you need the SD. (I am assuming the 24VAC is 60Hz range which could be smoothed by a capacitor so AC is no problem. Otherwise, the cyclic nature of VAC may give you a false multiple count.)DS3231 is the "more accurate" kind (compare to other kinds like DS1307), but if you really want second accuracy, you may need weekly adjustment. You can work out at 86400 seconds a day, one per million accuracy would lost/gain a second in less than 2 weeks and DS3231 is not in the 1 to 2 ppm range. But I really think the DS3231 would be good enough. You wont be able to sync your watch with the DS3231 with 100ppm accuracy anyhow.In this solution, the pulse width is going to be the driving factor. 10 pulse per second means the max pulse cycle is going to be 100milli-second. You need to detect it going high and returning to low, so 50 milli-second pulse high with 50 milli second low is ideal, but you don't know the pulse width (you should look into it) - how long does it stay high?You need two digitalRead() reading high then low per coin - with pulse lasting long enough to read and with enough time to read the clock and write the SD card. You need to work out the timing there (or use interrupt). You may want/need to do some trade off (save and log later) because the SD card is going to be too slow to log on the fly with merely 100 milli-seconds between coins. You would also need to work out power-lost data-lost trade offs.Or, you can of course add additional electronics to latch, and/or to do the counting... Of course, you can do dual boards with one managing the SD writing...Good luck,Rick

author: papapaul
author_rank: Newbie
timestamp: October 02, 2014, 01:23:54 pm
content: thats exactly the type of feedback I was hoping for, thank you Rick

author: papapaul
author_rank: Newbie
timestamp: October 06, 2014, 02:10:10 pm
content: And after a weekend of self-education, it appears that I got good advice, fast. Thanks again. I'm sure I'll have challenges getting it perfected, but I'm well on my way.I'm still doing preliminary research, but at the moment I'm planning to use an arduino Uno (perhaps mega) with an adafruit assembled data logging shield.I now understand the voltage divider + capacitor + diode bridge to detect the pulses. I *think* my pulses are between 16 & 200 ms with a minimum 16ms pause between pulses, but I'll probably do some field testing to confirm.I've traced through assorted C code samples, although my coding skills are quite rusty I think I can handle the necessary coding for all of this without undue pain.I can also handle the write latency issues, I'll probably add some FeRAM and a second controller after I get the basics working.Thinking out loud, I think my next challenge is to learn how to calculate which diodes/resistors/etc I actually need to buy. And how to power the Uno from a 24vac source.Anyhow, just thought I'd let you know you got me on the right track quickly, thanks.

author: Rick Law
author_rank: Super Contributor
timestamp: October 06, 2014, 06:50:15 pm
content: Goodie. I am rather new myself, so I shared what I know to help others as others helped me. Good you are on the right track.You need diode bridge to rectify the 24V AC before anything else, then the divider + capacitor (or capacitor + divider).Also, 16ms before next pulse is rather short. Test that well. I know that just an lcd.print() may be longer than 16ms depending on what you print. With such short duration, you may need to do interrupt instead of polling.You can of course do that by timing: if 116ms ago, it was HI, it is still HI, so it must be new pulse. I personally would prefer to detect a LOW before HI (or LOW after HI) to ensure it is a new pulse instead of possibly getting the "left over" from the last pulse and get a false HI.To detect LO you need to make sure your capacitor discharges within at the very most 8ms (1/2 of 16) so you have a LO to detect. The quicker discharge the better so you have a longer LOW, but enough capacitor to smooth the rectified AC for detection (ie: min during on is > approx 3V so it is detected as HI). You may want to parallel your cap with a resistor to discharge it quicker. Size them so that while it stays HI as long as pulse is ON but drop really quick when pulse is off.Good luck, that sound fun to do.RickAlternative is, if the thing is still HI 100ms second later, pretend it must be a new pulse.Good luckRick