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.
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?
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:
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.
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.
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.)
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.