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 #1451
Joined: Wed Apr 23 2008, 03:48AM
Location: Boulder, Co
Posts: 661
I've set up the PIC to monitor a voltage on four different capacitors and then stop charging when when the input goes to a certain level. Basically a comparator function. It was working great on low power tests, but when I changed the charging level to stop, nothing changed!!! Even though it should wait until the ADC gets to 04fh to turn off, it turns of at something around 0fh. This is with any value greater than 0fh. Did I set up the ADC wrong? Also, when I tried this code on my development board, I set it to turn on an LED when it reaches the value, and then turn it off when it goes bellow the value. Now, the LED comes on at about 3 different voltage levels! It never stays on like it should.
Registered Member #1451
Joined: Wed Apr 23 2008, 03:48AM
Location: Boulder, Co
Posts: 661
I did have a bunch of stuff commented out but removed it to post it. I think the issue is that it is partially damaged. I accidentally sent 12v into a pin and it never worked, but the rest of the device seemed to work fine. Could a value have been locked into the ADC results register by this?
Registered Member #1451
Joined: Wed Apr 23 2008, 03:48AM
Location: Boulder, Co
Posts: 661
ok new development...
Got new parts and still have the exact same problem...
I'm comparing the adc output to a constant. What is happening is that for the first 4 bits (1 through f) the program works as expected. But when I go into 8 bits, something strange happens! it seems that the 4 most significant bits are ignored! An example...
08h gives a voltage cutoff of 25v. 0fh gives one of 45v.
18h gives 25v! f8h gives 25v no matter what the farthest left digit is, only the right one is used!
The adc is a 10 bit one but i'm using it as an 8 bit (only using 8 most significant bits). Left justified i believe.
I'm using the constant in the following way... in the beginning of the code i load it into a register. Then i subtract the contents of the register with the adc output.
movfw VOLT subwf ADRESH,0
then check the carry bit to see which is bigger. Is this the right way?
Registered Member #27
Joined: Fri Feb 03 2006, 02:20AM
Location: Hyperborea
Posts: 2058
That will work fine for comparisons. I think you need to double check the alignment of the data from the A/D. It looks a bit like you are only using 4 bits.
I suggest you use errorlevel -305 and define W to be 0. then you write subwf ADRESH,W when you want the result in W. and subwf ADRESH when you want the result in the file.
It is easier to read that way and is more in line with what was the idea when the assembler was designed.
Registered Member #30
Joined: Fri Feb 03 2006, 10:52AM
Location: Glasgow, Scotland
Posts: 6706
Good point, check that the left/right justify thing in the ADC setup register is set properly.
If you're sensing multiple channels, there's a settling time for the multiplexer that you have to watch out for.
Also don't forget to clear the carry bit before you use it. bcf STATUS, C and so on. Some arithmetic instructions only set the carry and zero bits, they don't clear them if they were previously set. I can never remember which ones, so I always just clear the thing anyway.
Well, nowadays I use C and let the compiler worry about all of this
Registered Member #1451
Joined: Wed Apr 23 2008, 03:48AM
Location: Boulder, Co
Posts: 661
Figured it out!!!!
When I was saying test STATUS,1 i was testing the digit carry bit! In subwf the DC bit only reflects the results of the first four bits of what you're comparing!
Thanks for your suggestions, i wouldn't have figured it out without looking at the status reg.
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.