Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Pic18f4550 adc

Status
Not open for further replies.
Hi ericgibbs,
Attached is the .asm file of this program. I have included comments to the coding.

Thanks alot for your help.

hi,
Downloaded OK, will post when ready.

EDIT:
Still looking thru it.
Noticed that you are using the REF Reg in the ADC delay.
ACQ_DELAY
movlw REF
movwf REG1


This the REF Reg that you are also using for the Inc/Dec push button counter.??
 
Last edited:
Thanks for the correction.

I changed the delay coding as below:

Code:
ACQ_DELAY
MOVLW .30
MOVWF REG1
ACQ1
DECFSZ REG1
BRA ACQ1
RETURN

...but unfortunately the problem is still there.
 
hi,
This now works, its very difficult to relate whats on the ADC Vinp and the PORTD display.

The main problems were, sharing Reg REF with inc/dec and the ADC delay.

Kept the REF for the adc delay and created REGF that holds the inc/dec compare value.

You were also loading 'movlw REGF' instead of 'movf REGF, W.

Lets know how it runs..
 
OHH finally it worked :D the problem was with the movlw instruction. When i changed it to movf, as you said, it worked.

Thank you so much for your help ericgibbs, really appreciate it :)
 
Hi,
The ADC is missing codes (from 50 its jumping to 64). What can be causing this please? by the way, the ref voltages of the ADC are set from 0.5V to 4.5V.

And another question. I want to display the respective temperature to an LCD display. Is it difficult to do that in assembly? do i have to refer to every binary value as a character? OR is it better to chance to C language for this part of the program?

Thanks in advance
 
Hi,
The ADC is missing codes (from 50 its jumping to 64). What can be causing this please? by the way, the ref voltages of the ADC are set from 0.5V to 4.5V.

And another question. I want to display the respective temperature to an LCD display. Is it difficult to do that in assembly? do i have to refer to every binary value as a character? OR is it better to chance to C language for this part of the program?

Thanks in advance

hi,
Are you saying as you increase the adc input voltage that the PORTD value is jumping from 50d to 64d,, as you decrease the input does it jump from 64d to 50d.??

Ref the LCD what type is it, how many lines etc.

You do have to convert the hex value of the ADC to ASCII in order to display in decimal.

EDIT:
Using Oshonsoft I have stepped thru all the combinations from 0 to 127 and I see no jumping of the codes up or down, the problem is elsewhere, have you changed the code, if so please post it.
 
Last edited:
Hi,

Thanks for your reply.

Are you saying as you increase the adc input voltage that the PORTD value is jumping from 50d to 64d??

Yes

as you decrease the input does it jump from 64d to 50d.??

Im not sure about this, but i will check that.

Using Oshonsoft I have stepped thru all the combinations from 0 to 127 and I see no jumping of the codes up or down, the problem is elsewhere, have you changed the code, if so please post it.

But were the ADC (of the pic) set to 0.5V to 4.5V ? because i notice that when the -Vref was set to 0v it worked fine, but for my project i want to set -Vref to 0.5V. By the way, the coding was not changed.
I think this is a common problem as i found it on google. The problem is that i cannot clearly understand what can cause this:
https://www.google.com.mt/search?hl...urce=og&sa=N&tab=wi&ei=vs8WT_SIHtGN4gSb_pSZBA

Ref the LCD what type is it, how many lines etc.
The LCD to be used is the one below:
**broken link removed**

I think to display temperature using asm would be a long and difficult task, am i right?

Thanks
 
Last edited:
hi,
The LCD is a standard type, not too difficult to program in asm or C.

Are you going to use a 4 or 8 wire Data connection to the LCD and/or use the R/W line on the LCD.?

I will try the -0.5Vref and +4.5Vref
 
Hi, i replaced the pic and its still the same, but when i set the ref voltage was set from 0V to 5V it works fine. Can the left justified (to set it to 7 bit) affect it?
 
Hi, i replaced the pic and its still the same, but when i set the ref voltage was set from 0V to 5V it works fine. Can the left justified (to set it to 7 bit) affect it?

hi,
I you could try to right justify the ADC and then right shift ADRSH and ADRESL say 3 times, then AND ADRESL with 01111111, that may avoid the jump problem
 
OK the circuit is working fine if i set the ref voltage from 0 to 5v. Another problem solved :) now the next task: displaying the temperature on the LCD.

Thanks
 
OK the circuit is working fine if i set the ref voltage from 0 to 5v. Another problem solved :) now the next task: displaying the temperature on the LCD.

Thanks

hi,
Let us know which PORT and which pins are connected to the LCD, we could post code fragments to get you started.

You could look at links near my signature on this post, I know they are 16F, but they cover the LCD programming.

BTW: did reading the ADRESH and ADRESL and shifting, fix the missing ADC codes.???
 
Last edited:
Hi ericgibbs,

The LCD will be connected as below:

Pin 1: GND
Pin 2: Vdd
Pin 3: Pot
Pin 4: RE0
Pin 5: RE1
Pin 6: RE2
Pin 7: NC
Pin 8: NC
Pin 9: NC
Pin 10: NC
Pin 11: RD4
Pin 12: RD5
Pin 13: RD6
Pin 14: RD7
Pin 15: BACK-LIGHT (5V)


BTW: did reading the ADRESH and ADRESL and shifting, fix the missing ADC codes.???

I haven't tried that, but with Vref set from 0V to 5V it worked fine.

Thanks for your help.
 
ok,
Did you look at this link.?
You could look at links near my signature on this post, I know they are 16F, but they cover the LCD programming.

There are examples for 4bit LCD
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top