Hello,
I am in a class at my tafe that is supposedly a beginner Microcontrollers class but it turns out that everyone else in the class has a lot of experience already with programming and so the teacher has decided to pitch the content at a much higher level.
As I have done nothing as of yet myself I am really struggling. He has asked us to design and build a 0-10V voltmeter which can display on a screen (he has given us the nokia 5110) and having learnt no C up till now I'm hard pressed.
I have found RobG's library but I am having a hard time understanding the concepts of how to implement it, especially as I don't know if what I have written so far will work at all.
To scale the ten volts down to the safe input range of the 430 I have a voltage divider (5 to 1) to bring the reading down to 2V5 when the input is @10V.
In the code I am trying to scale the ADC10 output down to the right range before sending to the display but that is about as far as I have gotten.
Any help would be greatly appreciated.
//Voltmeter
#include <msp430g2553.h>#include "PCD8544.h"#define Run_value 1#define Scaling_value 85.25 /*as the ADC3v3 ref is equal to the 1023rd ADC valuethen the 2v5 highest value we should get in is equal to 852.5.Divide this by 85.25 to get to 2v5 being 10*/#define Scaled_value ADC10MEM/Scaling_valuevoid main(void){WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog Timer//Setup: ADCADC10CTL0 = (ADC10SHT_3 +ADC10ON);ADC10CTL1 = INCH_0; //A0 is input pin__delay_cycles(1000); // Wait for ADC Ref to settleADC10CTL0 |= ENC + ADC10SC; //Turn ADC on, enable conversions//Setup: Run Programif (Scaled_value <= 10.0){Run_Value = 1; //while this equals 1 the screen will display voltage reading}if (Scaled_value > 10.0){Run_Value = 0; //while this equals 0 the screen will display max voltage}while (Run_value = 1){// Show voltage readout on screen_while (Run_value = 0){//Show Max voltage on screen}}
ROBG's nokia5110 library:
PCD8544.h 4.79KB
3 downloads
Thanks,
Hooleygan