Author Topic: Asking about a timer project  (Read 1608 times)

0 Members and 1 Guest are viewing this topic.

Offline ChemroukOTopic starter

  • Newbie
  • Posts: 4
  • Country: dz
Asking about a timer project
« on: March 25, 2018, 10:46:52 am »
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.
 

Offline RyanT

  • Contributor
  • Posts: 31
  • Country: ca
Re: Asking about a timer project
« Reply #1 on: March 25, 2018, 11:04:09 am »
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 the datasheet and 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.
 
The following users thanked this post: ChemroukO

Offline sokoloff

  • Super Contributor
  • ***
  • Posts: 1799
  • Country: us
Re: Asking about a timer project
« Reply #2 on: March 25, 2018, 11:39:57 am »
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.
 
The following users thanked this post: ChemroukO

Offline ChemroukOTopic starter

  • Newbie
  • Posts: 4
  • Country: dz
Re: Asking about a timer project
« Reply #3 on: March 25, 2018, 03:36:27 pm »
Can you give a hint about how the code will be?
 

Offline sokoloff

  • Super Contributor
  • ***
  • Posts: 1799
  • Country: us
Re: Asking about a timer project
« Reply #4 on: March 25, 2018, 04:12:21 pm »
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
}
 

Offline sokoloff

  • Super Contributor
  • ***
  • Posts: 1799
  • Country: us
Re: Asking about a timer project
« Reply #5 on: March 25, 2018, 04:14:35 pm »


Or google "arduino adjustable duty cycle square wave" or "arduino adjustable digital pulse generator" or similar keywords.
 

Offline sokoloff

  • Super Contributor
  • ***
  • Posts: 1799
  • Country: us
Re: Asking about a timer project
« Reply #6 on: March 25, 2018, 04:21:41 pm »
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
 
The following users thanked this post: ChemroukO

Offline ChemroukOTopic starter

  • Newbie
  • Posts: 4
  • Country: dz
Re: Asking about a timer project
« Reply #7 on: March 25, 2018, 06:59:22 pm »
 But the display part, how can I do it?
 

Offline sokoloff

  • Super Contributor
  • ***
  • Posts: 1799
  • Country: us
Re: Asking about a timer project
« Reply #8 on: March 25, 2018, 07:04:55 pm »
But the display part, how can I do it?
What have you googled? What part of the google results was confusing?

What have you tried that didn’t work?
 

Offline paulca

  • Super Contributor
  • ***
  • Posts: 4068
  • Country: gb
Re: Asking about a timer project
« Reply #9 on: March 26, 2018, 08:50:18 am »
But the display part, how can I do it?

For 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.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 
The following users thanked this post: ChemroukO

Offline tpowell1830

  • Frequent Contributor
  • **
  • Posts: 863
  • Country: us
  • Peacefully retired from industry, active in life
Re: Asking about a timer project
« Reply #10 on: March 26, 2018, 09:46:57 pm »
But the display part, how can I do it?

PEACE===>T
 
The following users thanked this post: ChemroukO


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf