Hi all!
We are doing a project to display voltage & current values which are input from a 10k potentiometer into a PIC18f452 and outputting them into readable data on a LCD. We have been told that the chip can only detect and convert the voltage values but not the current's. Does anyone have any suggestions on how to find the current values?![]()
Last edited by ericgibbs; 5th September 2008 at 07:08 AM.
Eric " Good enough is Perfect "
I will NOT answer PM's requesting technical help, please use the Forum
"Nigels Asm tutorials:" www.winpicprog.co.uk/
"Ian Rogers 'C' conversion of Nigels Asm tutorials:" http://www.electro-tech-online.com/c...torials-c.html
Thanks for the reply Eric! Actually what our project does is acting like a multimeter. We do not have external measuring devices to measure voltage, current or resistor values, just the chip itself. Is there any way that the chip could calculate the voltage and current values just by programming the pic18 to read the data inputs from the pot?![]()
hi,
The resistor/current method is the way many modern DMM's work.
I assume you are using a PIC with ADC inputs.?
The PIC cant measure/read a pots resistance value directly, it has to be done measuring the voltage between the pot wiper and 0V.
Can you give us an example on how you want the PIC to measure the current.?
Eric " Good enough is Perfect "
I will NOT answer PM's requesting technical help, please use the Forum
"Nigels Asm tutorials:" www.winpicprog.co.uk/
"Ian Rogers 'C' conversion of Nigels Asm tutorials:" http://www.electro-tech-online.com/c...torials-c.html
Ya we're using microchip's pic18F452 with A/D inputs. And yes we have exactly no idea how we're going to measure the current with no external measuring equipments. Thus our post here. Except that we know we're not supposed to use any external measuring equipments, other than for testing purposes to find out whether our circuit is accurate. Here's a schematic drawing:
[/URL][/IMG]
Also, can you explain what u meant by "it has to be done measuring the voltage between the pot wiper and 0V."? Do you mean measuring using a multimeter? I'm sorry for all the trouble coz all our teammates have no idea what's going on except for a bit of the programming.![]()
hi,We are doing a project to display voltage & current values which are input from a 10k potentiometer into a PIC18f452 and outputting them into readable data on a LCD. We have been told that the chip can only detect and convert the voltage values but not the current's. Does anyone have any suggestions on how to find the current values?
Looking at your diagram.
You show two 10K0 variable resistors connected between +5V and 0V, with the slider/wiper of the pots going to a ADC inputs.
Which current are you trying to measure.?
The current thru each pot is I = V/R = 5/10000 = 0.5mA [ 500ľA].
The current into the PIC's ADC is very very small and could be considered as zero.
Answer: current into the ADC input = 0.0
Last edited by ericgibbs; 6th September 2008 at 07:46 AM.
Eric " Good enough is Perfect "
I will NOT answer PM's requesting technical help, please use the Forum
"Nigels Asm tutorials:" www.winpicprog.co.uk/
"Ian Rogers 'C' conversion of Nigels Asm tutorials:" http://www.electro-tech-online.com/c...torials-c.html
Thanks for the reply Eric. We're trying to measure the current running through each pot. Actually when the resistance of the pot is varied via the wiper/swiper, the current and voltage changes too right? Therefore all the changes must be concurrently displayed via our LCD. We are gonna try connecting: pin1 of the pot to ground, pin2 to PORTA aka the ADC input, and pin3 to 5V. I'll let you know the results once we've tried it out, about 2 days later. =)
hi,
As the 10K0 pot is a fixed value and the input resistance of the ADC is very high the current will NOT change
as you vary the position of the pot.
The current thru the pot will always be 5V/10000 = 500uAmps.!
I would recheck the assignment details, I think you must have misread it.
EDIT: please attach your images to the post by using the 'Manage Attachments' button
Last edited by ericgibbs; 6th September 2008 at 04:29 PM.
Eric " Good enough is Perfect "
I will NOT answer PM's requesting technical help, please use the Forum
"Nigels Asm tutorials:" www.winpicprog.co.uk/
"Ian Rogers 'C' conversion of Nigels Asm tutorials:" http://www.electro-tech-online.com/c...torials-c.html
Hi. We've jumped to the programming part of our project as we've not much time left, and the programming usually takes a lot more time (for us). Any help with the programming would be appreciated. We're using pic18F452 with the picdem 2 plus demo board. Our input would be that from the circuit with the pot mentioned above but right now we're using the pot connected via RA0.
Code :#include <p18xxxx.h> #include <delays.h> #include "lcd.h" #include <string.h> #define LCD_RS PORTAbits.RA3 #define LCD_EN PORTAbits.RA1 #define LCD_WR PORTAbits.RA2 #define set_dd_line1_pos1 0x80 #define set_dd_line2_pos1 0x80 char value1 [ ] = "0V"; char value2 [ ] = "5V"; void lcd_write_cmd(unsigned char cmd) { unsigned char temp2; LCD_RS = 0; Delay10TCYx(4); temp2 = cmd; temp2 = temp2 >> 4; PORTD = temp2 & 0x0F; Delay1KTCYx(1); lcd_strobe(); Delay1KTCYx(1); temp2 = cmd; PORTD = temp2 & 0x0F; Delay1KTCYx(1); lcd_strobe(); Delay1KTCYx(1); } void lcd_clear(void) { lcd_write_cmd(0x01); Delay1KTCYx(2); } void lcd_write_data(char data) { char temp1; LCD_RS = 1; Delay10TCYx(4); temp1 = data; temp1 = temp1 >> 4; PORTD = temp1 & 0x0F; Delay1KTCYx(1); lcd_strobe(); Delay1KTCYx(1); temp1 = data; PORTD = temp1 & 0x0F; Delay1KTCYx(1); lcd_strobe(); Delay1KTCYx(1); } void lcd_goto(unsigned char LCD_POS) { lcd_write_cmd(LCD_POS); Delay1KTCYx(2); } void lcd_strobe(void) { LCD_EN = 1; Delay10TCYx(4); LCD_EN = 0; Delay10TCYx(4); } void lcd_init(void) { LCD_RS = 0; LCD_WR = 0; Delay1KTCYx(250); Delay1KTCYx(250); Delay1KTCYx(250); Delay1KTCYx(250); PORTD = 0x03; lcd_strobe(); Delay1KTCYx(250); PORTD = 0x03; lcd_strobe(); Delay1KTCYx(250); PORTD = 0x03; lcd_strobe(); Delay1KTCYx(250); PORTD = 0x02; lcd_strobe(); Delay1KTCYx(250); Delay1KTCYx(250); lcd_write_cmd(0x28) lcd_write_cmd(0x01); Delay1KTCYx(20); Delay1KTCYx(20); lcd_write_cmd(0x0F); Delay1KTCYx(20); lcd_write_cmd(0x06); Delay1KTCYx(20); } main(void) { char outchar; unsigned char Sizevalue1, Sizevalue2, Sizevalue3; unsigned char index; #define constant [B]0x01[/B] #define constant2 [B]0x05[/B] TRISA = 0x00; TRISD = 0x00; PORTD = 0x00; ADCON0 = 0b11000001; ADCON1 = 0b00001110; for(;;) { ADCON0bits.GO = 1; (PIR1bits.ADIF == 0); PORTD = ADRESH; if(ADRESH < constant) { Sizevalue1 = strlen(value1); // get size of array LCD_EN = 0; LCD_RS = 0; LCD_WR = 0; lcd_init(); LCD_RS = 1; lcd_goto(set_dd_line1_pos1); for (index = 0; index < Sizevalue1; index++) { outchar = value1[index]; lcd_write_data(outchar); } Delay1KTCYx(250); Delay1KTCYx(250); Delay1KTCYx(250); lcd_goto(set_dd_line1_pos1); PIR1bits.ADIF = 0; lcd_clear(); } if(ADRESH > constant2) { Sizevalue2 = strlen(value2); LCD_EN = 0; LCD_RS = 0; LCD_WR = 0; lcd_init(); LCD_RS = 1; lcd_goto(set_dd_line1_pos1); for (index = 0; index < Sizevalue1; index++) { outchar = value2[index]; lcd_write_data(outchar); } Delay1KTCYx(250); Delay1KTCYx(250); Delay1KTCYx(250); lcd_goto(set_dd_line1_pos1); PIR1bits.ADIF = 0; lcd_clear(); } } }
I've managed to display 0V and 5V on the lcd when i turn the wiper of the pot CCW or CW completely. Now I'm trying to detect 1V when I'm adjusting the wiper but there are 2 problems. Firstly, As you can see from my programming, my constant values are 0x01 and 0x05, which I assume should read analog inputs of lower than 1V and higher than 5V. (Am I right?) It works on the program but still would like to double check it. My second problem is designing a subroutine to detect the 1V. How should I go about it?
Last edited by Cheng; 12th September 2008 at 04:15 AM.
hi.... im using mplab ide
im intersted with you code. how can i alter ur code to fit into mplab software?
| Tags |
| Similar Threads | ||||
| Thread | Starter | Forum | Replies | Last Post |
| Monitoring Current Using hall effect and help displaying it | chrisblack | Electronic Projects Design/Ideas/Reviews | 2 | 17th October 2006, 01:19 PM |
| Displaying voltage with LED Bars | dinofx | Electronic Projects Design/Ideas/Reviews | 18 | 2nd February 2006, 04:35 PM |
| voltage and current | VISHOK | General Electronics Chat | 0 | 25th September 2004, 08:01 PM |
| Current vs. Voltage | nyeboy2000 | General Electronics Chat | 13 | 28th February 2003, 03:49 PM |
| voltage/current | JEBB | General Electronics Chat | 1 | 17th February 2003, 08:27 AM |