OzGrant 22 Posted February 9, 2014 Share Posted February 9, 2014 G Quote Link to post Share on other sites
chicken 630 Posted February 9, 2014 Share Posted February 9, 2014 I don't think the internal reference will provide 2.5V when VDD drops below that value. You will probably have to go with 1.5V as reference. Quote Link to post Share on other sites
chicken 630 Posted February 9, 2014 Share Posted February 9, 2014 As for the map function, I would approach it like this: Simplify (and avoid divisions) by choosing a divider that converts a voltage like 5.12 to VREF. E.g. - with VREF 1.5V, the voltage divider would require a factor of approximately 3.4 (5.12V / 1.5V), this represents an ADC10 reading of 1024 - for 3.6V you'll get an ADC10 reading of approx. 723. ADC36 = (1024 / 1.5V) * (3.6V / 3.4) - for 1.8V you'll get an ADC10 reading of approx. 361. ADC18 = (1024 / 1.5V) * (1.8V / 3.4) - conveniently, ADC36-ADC18 is 362, which is close enough to 2 * 180 for our purpose To get this into your 8bit scale with 1 step per 0.01V, subtract ADC18 from your actual reading and divide by two: byteout = (ADC - ADC18) / 2 Quote Link to post Share on other sites
energia 484 Posted February 9, 2014 Share Posted February 9, 2014 the MSP430 minimal voltage supply is 1.8v. Most power supplies are +/- 10% over temperature and needs to be taken into account. If the voltage drops below 1.8v you might see unexpected behavior. Quote Link to post Share on other sites
grahamf72 169 Posted February 9, 2014 Share Posted February 9, 2014 According to the msp430g2553's data sheet, it needs 2.2v for the 1.5v reference and 2.9v for the 2.5v reference. The minimum Vcc for the ADC is also 2.2v, so to accurately measure voltage below 2.2v you will need an external ADC. If you are happy to measure in the range of 2.2v to 3.6v, ADC channel 11 is Vcc/2, so you can get the voltage with analogRead(11). Set your reference voltage to 1.5v first and do a read. If the result is 1023 (2^10 - 1), you know Vcc is above 3v so the 2.5v reference is valid. Set the reference to 2.5v and read it again. For 10mV per bit and 8 bit output, we simply choose an offset, let's say 2v since we can only measure down to 2.2v, then use map. If we used the 1.5v reference, 2v Vcc would give us a reading of 683 (1/1.5*1024), if we could read that low. A 3v reading would yield 1023, and we would want an output of 100 meaning 2v + 1v, so we would use map(reading,683,1023,0,100). If we took our reading from the 2.5v reference our physically impossible but theoretical reading for 2v would be 409 (1/2.5*1024), 3.6v would yield 737 (1.8v/2.5v * 1024), and we would want a value of 160 to represent 3.6v, so our map function would be map(reading,409, 737,0,160). Sent from my iPad using Tapatalk energia and OzGrant 2 Quote Link to post Share on other sites
OzGrant 22 Posted February 9, 2014 Author Share Posted February 9, 2014 G'day, Thanks for the detailed feedback. As I'm using a LFePO4 battery (3.2v), in reality only need a maximum range of one volt. So will give Graham's solution a shot today. Grant. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.