Welcome
Username or Email:

Password:


Missing Code




[ ]
[ ]
Online
  • Guests: 59
  • Members: 0
  • Newest Member: omjtest
  • Most ever online: 396
    Guests: 396, Members: 0 on 12 Jan : 12:51
Members Birthdays:
One birthday today, congrats!
mileswaldron (59)


Next birthdays
06/03 mileswaldron (59)
06/04 muze801 (33)
06/05 HVgeek (33)
Contact
If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.


Special Thanks To:
  • Aaron Holmes
  • Aaron Wheeler
  • Adam Horden
  • Alan Scrimgeour
  • Andre
  • Andrew Haynes
  • Anonymous000
  • asabase
  • Austin Weil
  • barney
  • Barry
  • Bert Hickman
  • Bill Kukowski
  • Blitzorn
  • Brandon Paradelas
  • Bruce Bowling
  • BubeeMike
  • Byong Park
  • Cesiumsponge
  • Chris F.
  • Chris Hooper
  • Corey Worthington
  • Derek Woodroffe
  • Dalus
  • Dan Strother
  • Daniel Davis
  • Daniel Uhrenholt
  • datasheetarchive
  • Dave Billington
  • Dave Marshall
  • David F.
  • Dennis Rogers
  • drelectrix
  • Dr. John Gudenas
  • Dr. Spark
  • E.TexasTesla
  • eastvoltresearch
  • Eirik Taylor
  • Erik Dyakov
  • Erlend^SE
  • Finn Hammer
  • Firebug24k
  • GalliumMan
  • Gary Peterson
  • George Slade
  • GhostNull
  • Gordon Mcknight
  • Graham Armitage
  • Grant
  • GreySoul
  • Henry H
  • IamSmooth
  • In memory of Leo Powning
  • Jacob Cash
  • James Howells
  • James Pawson
  • Jeff Greenfield
  • Jeff Thomas
  • Jesse Frost
  • Jim Mitchell
  • jlr134
  • Joe Mastroianni
  • John Forcina
  • John Oberg
  • John Willcutt
  • Jon Newcomb
  • klugesmith
  • Leslie Wright
  • Lutz Hoffman
  • Mads Barnkob
  • Martin King
  • Mats Karlsson
  • Matt Gibson
  • Matthew Guidry
  • mbd
  • Michael D'Angelo
  • Mikkel
  • mileswaldron
  • mister_rf
  • Neil Foster
  • Nick de Smith
  • Nick Soroka
  • nicklenorp
  • Nik
  • Norman Stanley
  • Patrick Coleman
  • Paul Brodie
  • Paul Jordan
  • Paul Montgomery
  • Ped
  • Peter Krogen
  • Peter Terren
  • PhilGood
  • Richard Feldman
  • Robert Bush
  • Royce Bailey
  • Scott Fusare
  • Scott Newman
  • smiffy
  • Stella
  • Steven Busic
  • Steve Conner
  • Steve Jones
  • Steve Ward
  • Sulaiman
  • Thomas Coyle
  • Thomas A. Wallace
  • Thomas W
  • Timo
  • Torch
  • Ulf Jonsson
  • vasil
  • Vaxian
  • vladi mazzilli
  • wastehl
  • Weston
  • William Kim
  • William N.
  • William Stehl
  • Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Forums
4hv.org :: Forums :: Computer Science
« Previous topic | Next topic »   

AVR -- Multi-function question

Move Thread LAN_403
Killa-X
Wed Dec 08 2010, 02:15AM Print
Killa-X Registered Member #1643 Joined: Mon Aug 18 2008, 06:10PM
Location:
Posts: 1039
I was thinking it would be kinda cool to take an AVR...And have buttons so i could step a frequency up/down by 1hz, or duty cycle up/down by 1%. I've already done this in the past...Having a PWM, variable duty, and variable frequency, limited it 1hz to 1Mhz.

But if I want to run 7-segments to display frequency and duty, how would I do this without screwing up the output frequency? To run up to 5 7-segments to display XXX frequency XX Duty, i would have to tell the AVR to go one by one. Meaning turn on segment 1, display a 1. Turn on segment 2, display a 5. etc etc, at a fast enough scan rate, that it will just read "155 50" meaning 155hz, 50% duty.

However, The time it takes for the chip to run that, will interfere with outputting 155hz wont it? Is there a way so i can have it range 1hz to 1Mhz, without slowing down how fast the refresh rate of the display is? Or will I have to get a 2nd chip, like ATTINY2313, dedicated to the segments?

Questions please ask...Hard to explain, I just remember last I tried a similar concept, when I told it to do 100hz, it made a 100hz tone, but the LCD was off during the time it was emitting that tone. It was fine at high frequency, but low frequency, it was annoying...Tips?

Thanks!
Back to top
Bjørn
Wed Dec 08 2010, 02:41AM
Bjørn Registered Member #27 Joined: Fri Feb 03 2006, 02:20AM
Location: Hyperborea
Posts: 2058
Most models have a PWM unit as part of the timer that generates a frequency with a given duty cycle, if not you will have the problem you describe.

You can only make frequencies with a period that is an integer multiple of the oscillator period. That means at high frequencies you can't control the frequency with high resolution. As an example, with a 1 MHz clock you can make a 1 MHz signal or a 500 kHz signal, nothing in between. If you want 1 Hz resolution at high frequencies you need to use an external chip or use direct digital synthesis (DDS) like this: Link2

Back to top
Killa-X
Wed Dec 08 2010, 04:31AM
Killa-X Registered Member #1643 Joined: Mon Aug 18 2008, 06:10PM
Location:
Posts: 1039
Yeah, kinda figured I might have to resort to having a seperate chip so one can control the 7-segment resolution, so I dont have and flickering, and keep one chip dedicated to just perform frequency. Will see what I can do, thanks for the tips/links, Bjorn.
Back to top
Turkey9
Wed Dec 08 2010, 06:20AM
Turkey9 Registered Member #1451 Joined: Wed Apr 23 2008, 03:48AM
Location: Boulder, Co
Posts: 661
The frequency output will not be affected by the code driving the display if you use a modern AVR. The frequency output is driven by the internal timer/counter and will run in the background so you can do what you want with the rest of the ports.
Back to top
Shrad
Wed Dec 08 2010, 10:26AM
Shrad Registered Member #3215 Joined: Sun Sept 19 2010, 08:42PM
Location:
Posts: 780
anyways, you may use the watchdog to count cycles and as it interrupts, you set your port high or low

once the watchdog has interrupted any operation will halt, you'll manipulate the output, then recalculate the cycle count for your frequency and duty cycle, put it in the watchdog counter, and after it is all done you're back in your main code which will only update the 7-segs and acquire your set point values

that's the most efficient way of generating a variable duty cycle variable frequency signal when you have a simple µC (even a 8-bit one will be accurate) but you have to be sure to have at least 20 times the desired frequency as a clock (eg. 20Mhz clock for 1Mhz output would be fine, leaving enough cycles to compute everything even at the highest output freq.)
Back to top

Moderator(s): Chris Russell, Noelle, Alex, Tesladownunder, Dave Marshall, Dave Billington, Bjørn, Steve Conner, Wolfram, Kizmo, Mads Barnkob

Go to:

Powered by e107 Forum System
 
Legal Information
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.