Hello I was wondering if someone can better explain what is happening when using the '*/' command. I had posted some months ago asking for help in converting a 10 bit analog to digital number into a value of 0 to 5 to display it on an LCD. Here is the code that someone posted and it works perfectly fine.
I am performing A to D on analog channel 11 on a PIC16F690
READ_A_D_AN11: 'used for adjusting set pts
ADCON0 = %11101101 'right justified, using Vref, AD on Channel 11
PAUSEUS 50 ' wait 50 microsec
ADCIN 11, AD_AN11_VALUE ' read channel 11 to AD_AN11_VALUE
AD_AN11_VOLT = (AD_AN11_VALUE */ 5000) >> 2
RETURN
Code for displaying it on an LCD.
DISPLAY_SENSOR_VALUE:
GOSUB CLEAR_LCD
GOSUB READ_A_D_AN11
LCDOUT "Rotary Voltage"
LCDOUT $FE, $C0, "Sensor ", DEC (AD_AN11_volt/1000) ,".", DEC3 AD_AN11_VOLT ," VDC"
This works perfectly fine and displays a value of with 3 decimal places.
What I am attempting to do is use a potentiometer to act as a trigger for another part of a circuit. I can set the voltage points in software to act as trip points. What I would like to do is create a window in which the trigger will occur. I was simply going to have another routine that would be adjustable from 10 to 250, which I would like to represent 0.010V t0 0.250V. The problem is that I was going to just take the number 10 to 250 and subract that from my A to D conversion value but that does not give me the true representation of what I need to adjust my window by.
I would like to some how convert backwards from what I did to get my range from 0 to 5 V from the A to D value of 0 to 1023. I would like to take 0.01 to 0.250V and convert this to a proportional value to subtract from my A to D value.
If I have not confused everyone and someone has any ideas I would love to hear them. Thanks for your help.
Bookmarks