nd help in writing the following program...

Status
Not open for further replies.

zak4546

New Member
my 10k pot has a range between 3 to 5 v to control a motor.. i want to compare the analogue values wif the a/d converted results and display it on leds. since i m doin 8 speed, i have divided accordingly and did the 10 bit digital conversion.so this are the expected digital outputs at which i want the respective LEDs to light up:

2.9v - 1001010001
3.2v - 1010001110
3.5v - 1011001100
3.8v - 1100001001
4.1v - 1101000110
4.4v - 1110000100
4.7v - 1111000001
5v - 1111111111

how do i go abt writing the program for this area..pls help! i m using
pic16F876a..
 
Mostly motors are controlling using PWM anyway!

Its better if you use 8bit conversion rather than 10bit.Otherwise you have to write a lot.8 bit is ok in your case to light up 8 led's.

Just read the AD value & compare with your reference values if it is equal just set a bit.This is the bit you sending to display.Don't clear that bit until you get the newer value.
 
Last edited:
how do i convert the values to 8 bit...do i juz read the values from the adreshl (right justified) or is there a calculation for for 8 bit conversionit? btw i would be greatful if u could juz show me a sample code. thx a lot for your reply.really meant a lot..
 
Just configure it justified as 8 bit, there's nothing complicated, if you only want 8 bits you just use the top eight bits, and the PIC is cunningly designed to make that trivial to do.
 
thanx for the help guys.i will write the program and then update u... i am new to this and i really hopes this works...
 
This is the program i wrote.but it doesn't seem to work...i really nd you guys to guide mr thro this...btw its a 8 speed dc motor controller.Any solutions?


 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…