joanaconstantina
Newbie level 6
I need help in using multiplication and division operation using PIC18F4455 in assembly language.
So, my project is like this: I have a voltage divider circuit, with the input connected to a voltage reference of 5V and the output connected to the analog input of the PIC. I used the ADC feature of PIC to obtain the 10-bit voltage output. The project aims to determine the value of an unknown resistance given the other resistance is fixed at some value.
The problem begins with the actual manipulation of the ADC output. I can't figure out a way to perform operation on a 10-bit data, divided into two registers (ADRESH:ADRESL). My pseudocode is like this:
* Get the decimal equivalent of the ADC output: Vout=(Vin/1024)*analogvalue
* Solve for Runk = Rk[(Vout/Vin)-1] where Runk is the unknown resistance and Rk is the known resistance
However, I got stuck at the first step. How do I multiply analogvalue with (Vin/1024) considering the 2 most significant bits are in another register? Anyone got an idea on this? Or better yet, is there a better way to solve for the unknown resistance, without going through this process?
Thanks in advance.
So, my project is like this: I have a voltage divider circuit, with the input connected to a voltage reference of 5V and the output connected to the analog input of the PIC. I used the ADC feature of PIC to obtain the 10-bit voltage output. The project aims to determine the value of an unknown resistance given the other resistance is fixed at some value.
The problem begins with the actual manipulation of the ADC output. I can't figure out a way to perform operation on a 10-bit data, divided into two registers (ADRESH:ADRESL). My pseudocode is like this:
* Get the decimal equivalent of the ADC output: Vout=(Vin/1024)*analogvalue
* Solve for Runk = Rk[(Vout/Vin)-1] where Runk is the unknown resistance and Rk is the known resistance
However, I got stuck at the first step. How do I multiply analogvalue with (Vin/1024) considering the 2 most significant bits are in another register? Anyone got an idea on this? Or better yet, is there a better way to solve for the unknown resistance, without going through this process?
Thanks in advance.