Now even though the code is working I was getting wrong values some of the time so I had another look at the data sheet but this was no help! So what was going on it works when it first starts up well I found out what is going on even though the data sheet says nothing about it you need to send the set up every time you want to measure the ports. So the sequence is > send the set up command eg use the internal reference, single ended, unipolar mode then send the instruction to tell it what port or ports to measure, next read the data back. It now works all the time and I am getting a steady 5 digits that do not vary, 3 digits better than I ever got from the AVRs ADC this may be due to two factors one is the 12bits I now have, the second may be that this ADC is not in there with the other bits of the AVR and is on a seperate board connected via onl 4 lines + & - power and the I2C buss so there is far less noise to deal with. Next I will build a function to call the ADC values keeping it in line with bascom its going to be Getmax1238() (use the internal reference, single ended, unipolar mode )
This is the calls to the subs I have been testing it with
[code:1:c833b328f0]
Call Max1239_setup
Call Max1239_write
Waitms 200
Call Max1239_read
Shift Max1239b , Left , 4
Shift Max1239b , Right , 4
Print "MAX>" ; Max1239b
Volt = Max1239b * 0.00097813
Print "VOLTS>" ; Fusing(volt , "##.####")
[/code:1:c833b328f0]
Regards Paul
↧