View previous topic :: View next topic |
Author |
Message |
natanj
Joined: 10 Jan 2012 Posts: 7
|
ADC Problem in 33FJ12GP202 |
Posted: Tue Jan 10, 2012 4:35 pm |
|
|
Hello, I have a problem with adc conversion. This is my code
Code: |
#include <33FJ12GP202.h>
#device adc = 12
#fuses HS,PR,NOWDT
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_B6,rcv=PIN_B7,bits=8)
void main() {
int16 adcvalue;
setup_adc_ports(sAN0|VSS_VDD);
setup_adc( ADC_CLOCK_INTERNAL );
delay_ms(100);
while (true){
set_adc_channel(0);
adcvalue = read_adc();
printf("%lu\n", adcvalue) ;
}
}
|
and these are the messages in Proteus:
Quote: |
the SSRC<2:0>, SIMSAM and ASM bits, should not be not be written to while ADON=1
The ADC module needs to be disabled before the AD12B bit is modified
VOltage references for ADC conversion yield a 0V range (V+ =0,V-=0); |
Somebody help me!!! |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
Proteus |
Posted: Fri Jan 13, 2012 8:34 am |
|
|
Listen to the guys on this forum.
Throw Proteus away.
Work with real hardware, send your ADC values etc to a PC via RS232 to check that it's working.
Mike |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Fri Jan 13, 2012 3:17 pm |
|
|
Your code looks OK to me. I don't know much about Proteus, but the line about references makes we wonder if your PIC is wired correctly. Is your setup_adc_ports line in agreement with what Proteus thinks your hardware is?
I have never used Proteus in 20+ years working with PICs. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
natanj
Joined: 10 Jan 2012 Posts: 7
|
|
Posted: Fri Jan 13, 2012 7:12 pm |
|
|
you never use Proteus or some similar program?
and i believe i have a mistake with sentence
I've never used dsPIC for program only PIC so my questions is
is different channel analog in dsPIC that in PIC then no call equal in code.
AN0!=sAN0
I'm sorry for my english I'm from Venezuela.
thanks for response |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Fri Jan 13, 2012 7:55 pm |
|
|
Please, get RID of Proteus !!! Send it to the recycle bin then permanently DELETE it from your computer !!
The only 'error' I can see in the program is that you should include 'errors' in the use rs232(....) options when using the internal hardware UART.
Like others here, 20+ years of PICs,40+ in mini and micro computers and I've NEVER,EVER found a 'simulator' that was worth anything. Proteus is FULL of bugs, errors, faulty DRCs....even the 'schematics' are WRONG !!
If I had a penny or peso for every Proteus error I've seen, I could retire.Really , it's that bad.
Do yourself a HUGE favour, get some real PICs, parts, a white breadboard and build real projects.You will LEARN a LOT more and understand it better. |
|
|
natanj
Joined: 10 Jan 2012 Posts: 7
|
|
Posted: Fri Jan 13, 2012 8:01 pm |
|
|
Thanks for your comment but in my country do not get the parts as cheap as in your country so simepre is simulated before obtaining a final prototype only you can afford the luxury of building and then discard it works but my question remains
What is the difference between analog configuration code of DSPIC and PIC? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Fri Jan 13, 2012 9:45 pm |
|
|
While PICs may be expensive your gasoline sure is cheap !!! I pay over $5 / US gallon here.
The real problem with Proteus is that IF you believe what it tells you, when you build your real circuit , the chances are very good it will NOT work and you'll spend a great many hours trying to figure out where you went wrong when really it was the simulator's fault.
I still use PICs that are 15+ years old,mostly 16F84 and 16F877s. I do not use the DSPIC series. No project that I've done has needed the 'special' stuff inside the DSPICs. |
|
|
natanj
Joined: 10 Jan 2012 Posts: 7
|
What is the difference between analog configuration code of |
Posted: Sat Jan 14, 2012 8:38 am |
|
|
you are right I fill the tank with 3bsf something like $ 0.75 but is not the case.
Proteus is a tool like many others that are useful and sometimes not because any error should be discarded both large and small should simulate We start to save cost but is not the case because my question is not whether they like or proteus simulator I recommend
What is the difference between analog configuration code of DSPIC and PIC?
and your 15 years you should not schedule anything you require as a PID control or a system that requires you to use a 18F in my case I need to use a dsPIC for the analog channel 12-Bit PIC 16F are beginners and have no resources to achieve a good project but again not my problem but know or can not answer my question really do not want to read your response
What is the difference between analog configuration code of DSPIC and PIC? |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
Translation problem. |
Posted: Sun Jan 15, 2012 4:59 pm |
|
|
Quote: |
you are right I fill the tank with 3bsf something like $ 0.75 but is not the case.
Proteus is a tool like many others that are useful and sometimes not because any error should be discarded both large and small should simulate We start to save cost but is not the case because my question is not whether they like or proteus simulator I recommend
What is the difference between analog configuration code of DSPIC and PIC?
and your 15 years you should not schedule anything you require as a PID control or a system that requires you to use a 18F in my case I need to use a dsPIC for the analog channel 12-Bit PIC 16F are beginners and have no resources to achieve a good project but again not my problem but know or can not answer my question really do not want to read your response
|
I am very confused by the above quote.
I do not want there to be a misunderstanding as a result of a language translation problem.
I will try to keep things simple by using short sentences.
I will try to express only one idea in each sentence.
The other guys and I are saying that ALL simulators are flawed, with no exceptions.
We are finding it difficult to understand why you need to use a dsPIC.
Tell us a little more about what you are trying to do. Then we may be able to help.
I can accept that you have difficulty obtaining PIC's and other parts.
I use a white breadboard (or something similar such as PICDEM 2 PLUS) for the early stages of most projects.
The idea of a white breadboard is that I can build a REAL working circuit early in the project.
I can use leaded parts (NOT surface mount).
I can easily change the circuit when I discover errors.
When I get to the prototype board stage I can recover almost all of the parts.
I can then use MOST of the parts again.
Very FEW parts are wasted or thrown away.
It's a low cost, effective way of doing things.
Are you really saying that you will not read our responses if we do not say what you want to hear?
Mike |
|
|
natanj
Joined: 10 Jan 2012 Posts: 7
|
Re: Translation problem. |
Posted: Mon Jan 16, 2012 8:35 am |
|
|
Thanks for ask me and thanks for using short sentence.
I apologize to everyone for the misunderstanding.
I accepted that simulation can cause errors but i do not understand why they say that should be discarded.
But no matter if anything I learned in my 10 years of programming and 30 years live in my country is to respect the opinions of others.
With that conclusion can be discarded or MPLAB programs like matlab or many other software that help generate load.
But that's their opinions and respect them.
I just want to know what is the difference in syntax ccs in the ADC conversion?
I program in asm because it is always easy to find the datasheets with a gigantic amount of information and code examples.
But wanted to do in ccs DSPIC but I'm not sure the PIC in CCS syntax is the same as in DSPIC.
So I ask you whats difference??
I do not want to tell me the price of oil, or that Proteus does not work if I could answer the question I would appreciate much. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Mon Jan 16, 2012 10:24 am |
|
|
The problem with Proteus(any simulator) is that we cannot 'fix' the simulator to properly emulate the dsPIC. You would have to go the designer of it and get them to fix it.
The odds are it's not setting up the ADC registers correctly, something that would require you to dump the listings and check with the datasheet section on the ADC configuration.
That's why it's nice to use real hardware, you get to see your program execute and make changes as required.
Question...does your program compile under MPLAB and CCS C compiler ?
I don't use the dsPIC series, quite happy with the 16F and 18F series. I get 10KHz response from a 16F877 PID controller, more than required for the task it was designed for 15 years ago.
The dsPICs don't seem to be popular,perhaps due to lack of 'tools' or the fact almost everyone can get the job done with the more common PICs.
Another question. What is so special about using the dsPIC? Do you really need 12bit ADC ? Perhaps 10 could be enough? Overall speed ? There may be another solution to your application if we knew more about it. |
|
|
natanj
Joined: 10 Jan 2012 Posts: 7
|
|
Posted: Mon Jan 16, 2012 11:25 am |
|
|
hello
I agree with what they say I have also Proteus errors but disposal is not a good decision for me at least.
I am currently designing the hardware for debugging. with Proteus ARES tool for me the best.
Although I understand you do not believe me maybe it's because I do not speak good English.
I work with MPLAB asm and c with ccs.
The dsPIC are very popular in dealing with FFT filter design signals may not know them because only things in programs this family of PIC 16F for me it has many resources 18F I like more but those are your design needs and you respect them.
I'm doing a project that will have a filter an analog signal processing and communication by MiWi dsPIC so take this with you I do not have language or compiler that work so if you decided to work with hardware and simulators (PROTEUS).
What worries me is not whether or dsPIC pic bar program is different in ccs.
I ask again why perhaps I can respond without alaguien many rodeo.
What is the difference in syntax between the adc converter DSPIC and PIC? |
|
|
yerpa
Joined: 19 Feb 2004 Posts: 58 Location: Wisconsin
|
|
Posted: Mon Jan 16, 2012 2:55 pm |
|
|
The syntax is very similar between PCD and PCH compilers. I would download the latest PCD reference manual from CCS, and look at the ADC examples. Start with Functional Overview - ADC. There are links to example code.
One warning - the dsPIC ADC is noisy, it is very hard (impossible?) to get 12 good bits of data.
Good luck! |
|
|
natanj
Joined: 10 Jan 2012 Posts: 7
|
|
Posted: Mon Jan 16, 2012 3:41 pm |
|
|
Thanks friends.
I'm gonna read this manual. |
|
|
|