Asking about a timer project - Page 1
Forum section: electronics / beginners

author: ChemroukO
author_rank: Newbie
timestamp: March 25, 2018, 10:46:52 am
content: hello everyone.I am quite new to electronics and I want to make my very first project, I have an idea but not sure how to realize it.I am trying to make a square wave generator with the ability to change the frequency & the duty cycle with a display which shows both of them.How can I achieve that? I want it to as precise & reliable as possible (Highest frequency needed is about 1 kHz)Thank you.

author: RyanT
author_rank: Contributor
timestamp: March 25, 2018, 11:04:09 am
content: The tried and true old 555 timer (LM555, NE555, etc.) will do the job for you, and if you're just starting out, they're very useful to learn. Best advice, start with thedatasheetand give it a good read and try to emulate the circuits shown therein; that should get you quite close to what you want.For adjusting the frequency, you vary the value of the capacitor and one of the resistors. The duty cycle can be adjusted via the ratio between the two resistors. Once you've banged out a simple prototype, you can use digital potentiometers ("pots") to vary the resistance values via your display. (Or just use trimmer pots and keep it analog, if you prefer.) Hope this helps.

author: sokoloff
author_rank: Super Contributor
timestamp: March 25, 2018, 11:39:57 am
content: This screams digital micro controller to me.Set aside “as precise as possible” for the first version and just make it work.Get an Arduino and an LCD shield. Get v0.01 working and then decide if it’s good enough or not. At the low frequency you’re talking about, it probably will be.

author: ChemroukO
author_rank: Newbie
timestamp: March 25, 2018, 03:36:27 pm
content: Can you give a hint about how the code will be?

author: sokoloff
author_rank: Super Contributor
timestamp: March 25, 2018, 04:12:21 pm
content: loop(){// TOO: Do something with the buttons (read the buttons to change freq or duty cycle; if they change, update the LCD)// Now do the high part of the wave:digital_write(PIN, HIGH)// TODO: Then sleep for the appropriate amount of time that the signal should be high// Now do the low part of the wave:digital_write(PIN, LOW)// TODO: Then sleep for the appropriate amount of time that the signal should be low}

author: sokoloff
author_rank: Super Contributor
timestamp: March 25, 2018, 04:14:35 pm
content: Or google "arduino adjustable duty cycle square wave" or "arduino adjustable digital pulse generator" or similar keywords.

author: sokoloff
author_rank: Super Contributor
timestamp: March 25, 2018, 04:21:41 pm
content: Please get something working using the above method first.Then consider whether the programmable PWM timers can be used to accomplish what you want. (I know they can do the duty cycle adjustment, but I'm not sure how low a frequency they can be programmed to go down to.)The reason to do the simple thing as above is to get the Arduino development process down. Treat is as a little more complicated than a hello world.For the second mechanism, have a look here:https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM

author: ChemroukO
author_rank: Newbie
timestamp: March 25, 2018, 06:59:22 pm
content: But the display part, how can I do it?

author: sokoloff
author_rank: Super Contributor
timestamp: March 25, 2018, 07:04:55 pm
content: Quote from: ChemroukO on March 25, 2018, 06:59:22 pmWhat have you googled? What part of the google results was confusing?What have you tried that didn’t work?

author: paulca
author_rank: Super Contributor
timestamp: March 26, 2018, 08:50:18 am
content: Quote from: ChemroukO on March 25, 2018, 06:59:22 pmFor an actual text display the simpliest option is probably a 16x2 LCD. Just google Arduino 16x2LCD.Usually there is a library, you down load it, call it's functions to display text, clear the display, move the cursor etc.

author: tpowell1830
author_rank: Frequent Contributor
timestamp: March 26, 2018, 09:46:57 pm
content: Quote from: ChemroukO on March 25, 2018, 06:59:22 pm