ADC0831 C code
Rsadeika
Posts: 3,837
in Propeller 1
As mentioned in my other post, I also purchased an ADC0831 chip. I guess the first thing to address is, how do you hook this thing up to the FLiP chip. I looked in the Learn forum, and did not find any sources. I also noticed that the only code available is blocklyprop. I still cannot get my head around the idea of using blocklyprop.
Does anybody have a diagram for connecting the ADC0831 to a FLiP module? I guess I have to get the thing hooked up before I can proceed with developing some C code. Again, I am using SimpleIDE; I looked for a driver in the Libs folder, but not sure if the one that is in there is for accessing the ADC0831 chip.
Thanks
Ray
Does anybody have a diagram for connecting the ADC0831 to a FLiP module? I guess I have to get the thing hooked up before I can proceed with developing some C code. Again, I am using SimpleIDE; I looked for a driver in the Libs folder, but not sure if the one that is in there is for accessing the ADC0831 chip.
Thanks
Ray
Comments
Try writing a short blockly program, then you can do a couple of things. Clicking "code" will show you the C code. You can check that to get the library name.
You can also export the blockly to SimpleIDE.
Tom
I looked at the JonnyMac diagram, but I am not sure what to make of it.
pin on the ADC0831:
1 - CS, gets connected to pin 22 on the FLiP module.
2 - ?
3 - ?
4 - GND, gets connected to the ground on the FLiP module.
5 - VREF, ?? gets connected to the 5V on the FLiP module.
6 - DO, gets connected to pin 21 on the FLiP module.
7 - CLK, gets connected to pin 20 on the FLiP module.
8 - ?
I have a voltage divider breakout board which has an output pin for ground, and output pin for the new voltage. So, which pins on the ADC0831 get the input from the voltage divider breakout board? Can some point me in the right direction.
I basically got spoiled using the Activity Board ADC setup, plug one wire into the GND and the other wire into the ADC socket, and mission accomplished.
Ray
2 - Connects to the voltage out from the breakout board you want to measure
3 -Connects to the ground on the breakout board.
4 - GND, gets connected to the ground on the FLiP module.
5 - VREF, ?? gets connected to the 5V on the FLiP module.
6 - DO, gets connected to pin 21 on the FLiP module.
7 - CLK, gets connected to pin 20 on the FLiP module.
8 - Either connects to the +5V USB supply from the Flip board or an external +5V supply.
Now, the value that is being printed out, 184, in this case, is what? I have a voltage source of 8V. Should the value that is being shown really be 1.84, that would make sense seeing that it is being run through a voltage divider. Does anybody know if the 184 value is really a true voltage value that has to be manipulated, or is it something else.
Ray
199*5/256=3.8867, not sure how this figures.
What I did do, for a test, is ((199*.01)*4.0201). The 4.0201=(8/1.99). Not sure if I am making the numbers fit the solution, or I am completely wet on this one.
Ray
Ray
The problem with this formula is that it is not taking the voltage divider into account so that is the voltage out from the divider going in to the ADC. It also assumes that Vref is 5.00 volts, which is rarely the case when using a power supply as the reference. If you added in the voltage divider calculation (3.8867 * R1/(R1 + R2) and replaced the "5" in the initial calculation with the actual power supply voltage you would get a much more accurate result.
No, you are all dry on this one. Some variation of this method is what I have used to calibrate instruments for more years than I care to mention. Inputting a known accurate reference voltage is the best way to calibrate an ADC and any front end circuitry. Best to verify it using 3 to 5 voltages over the full range to verify linearity.
Only suggestion I have is to do the calculations using integer math. That would result in 199 * 40201 = 7999999. Add 5000 to that for rounding and you get 8004999. Divide that by 1,000,000 and the result is 8.004999. Drop the last 4 digits to get 8.00 volts.
An alternative would be to convert the 8004999 to ascii text, remove the last 4 digits, and insert the decimal point between the 8 and 0. Probably faster this way.
Ray