Voor mijn project maak ik een kruispunt waarbij ik werk met lusdetectie.
Via een oscillator waarbij de frequentie veranderd wanneer er metaal over de spoel komt. Ik kan met arduino de frequentie meten om dan de verandering te zien en de lichten te laten veranderen. Maar nu is het probleem dat ik dit project liefst met de ATTiny85 moet doen en er geen genoeg timers zijn om dit programma te gebruiken. Iemand die weet hoe ik dit kan oplossen?
Zonder code en schema is er niet veel wat we kunnen doen.
Het is misschien beter om dit op het Engelstalige deel van het forum te plaatsen, zodat je meer kans hebt op iemand die ervaring heeft met dit soort projecten.
Afhankelijk van hoe hoog de resonantiefrequentie is, en hoeveel de ATtiny voor de rest moet doen, kan je eventueel in een loop het aantal pulsen tellen, zonder een hardware timer te gebruiken. Je hoeft niet continu te meten, eens om de 50 ms is waarschijnlijk meer dan genoeg.
For my project I need to use an ATTiny85 to control a miniature intersection and have now come to the realisation that my frequency counter for the loop detection only works on my arduino and not on the ATTiny85 because it only has 1 timer. I have an oscillator that changes the frequency when metal goes over my coil and I need to see that the frequency changes with my ATTiny85. Anyone knows how I can do this? I added my scheme and program in the attachments
The ATtiny85 has two timer/counter units but both are only 8bit timer/counter.
In your sketch you use all 3 timer/counter units of the ATmega328. Timer0 is used for the Arduino time keeping (millis() and the like) but if you don't need these functions you can reuse it. The bigger problem is that you're using the 16bit counter to count the pulses and the ATtiny85 doesn't offer a 16bit counter. You can overcome this with clever programming but only under special conditions.
Without additional information I would say: change your hardware as the ATtiny85 doesn't seem to fulfill your requirements.