Jump to content


  • Content Count

  • Joined

  • Last visited

Reputation Activity

  1. Like
    ROFLhoff reacted to voodoofish in Multi-battery Voltmeter   
    Nice setup. Did you use the pins for the 32Khz crystal for anything or have any plans to? Had you considered a 5v switching regulator for the display(I had similar issues with the display not showing up very well on lower voltages). I think the transistor idea for the LCD panel enable/disable would be useful. If you don't use the pins for the crystal, you could also use those pins for for button actions(start/stop) or other things.
  2. Like
    ROFLhoff reacted to grahamf72 in Multi-battery Voltmeter   
    To protect the inputs I'd change them as follows:

    This provides protection against both over voltage and negative voltage. The resistor values are not critical. If you use a lower value for the input resistor, it increases the maximum current that can flow, hence reducing the voltage range that it can safely shunt. The tie down resistor has been increased to reduce the voltage divider effect. With a 1:1000 ratio the error from the voltage divider is negligible. Over voltage is clamped at 3.6v while negative voltage is clamped to approx -0.6v. With the 100 ohm input resistor, a typical 400mW Zener can protect against an over voltage of approx 15V. Dropping the input resistor to 50 ohm reduces the over-voltage tolerance to about 9V.
    Sent from my iPad using Tapatalk
  3. Like
    ROFLhoff reacted to link in Multi-battery Voltmeter   
    The 100R/100k may act as a voltage divider, but with low impact on the measurement. With higher values on the input resistances you may get problems, because the sample and hold capacitor may take longer to load.
    Enviado desde mi HTC Sensation Z710e mediante Tapatalk
  4. Like
    ROFLhoff got a reaction from bluehash in Multi-battery Voltmeter   
    Hey guys, thought I'd post something I made this month to learn about interrupts and state machine coding. This project just measures up to four sub-1.5V batteries and shuts down after four seconds. I chose to not have the project run off the batteries it tests. I had a ton of 18650 lithium cells, and used one. I had a little trouble thinking of a way to power the LCD as it really needed more than 3.6V to read any characters on it. Using a lithium cell is convenient as the screen is nice and legible throughout a big portion of the cell's working voltage. As of right now, the whole circuit consumes 8mA when displaying a measurement, and around 5mA when the screen is off. I'm pretty sure I can cut down more by switching the 595 and the LCD's power with a transistor when the G2231 enters LPM, at the expense of a slow (50ms) turn on time when taking a measurement.
    I ended up not using LPM in the delay and ADC measurement code, as that stuff happens in bursts.
    Do you guys suggest any other small improvements I can add to this? 

    And finally is there a decent way to safeguard against negative voltages on the ADC inputs? The only components I have on each input are pulldown resistors to remove floating ADC inputs.
    Code posted here:
    Version 2.c

  5. Like
    ROFLhoff reacted to NatureTM in Flashing the missing DCO calibration constants   
    EDIT: Here's another really nice DCO calibration program. It's part of TinyOS-msp430. http://code.google.com/p/tinyos-msp430/ It's the file called calibrate-dco. As gordon, who discovered it said, "[it] appears to be a quite beefed-up DCO calibration app, with goodies on the side (taking silicon errata into account for various devices when calibrating)." It looks like it's built to be solid and reliable. I skimmed over the code and didn't see anything for calculating SegA checksum, but that usually isn't an issue for most non-critical applications.
    EDIT: maxpenna shared another version of the DCO calibration program. This is the one to use if you need a correct SegmentA checksum. It uses the C calibration function. You can get it here http://www.43oh.com/forum/download/file.php?id=292
    WARNING: Some of the programs in this thread will erase Segment A and only put back the DCO calibrations. They should not be used with chips that have an ADC12, as this process will destroy the ADC12 calibrations. Some of the programs do not calculate the Segment A checksum, so the integrity of Segment A cannot be verified during runtime after calibration. Still, I've been using it without any problems.
    There's been a bit of a discussion in another thread about an idea simpleavr had for adding the dco calibration constants to flash for the Value Line series. I've cobbled together some pieces of TI code and have it working. It seems to work great. Here's how I did it with CCS. I think the people on linux should be able to reproduce the result with a little adaptation.
    This requires the TI DCO library I modified in another thread and an external LF crystal like the one with Launchpad.
    First, run this to calibrate the constants and write them to flash:
    EDIT: 43oh member zeke has made some changes to the code for finer tuning. Check page 2 for his code.

    //****************************************************************************** // MSP430F20xx Demo - DCO Calibration Constants Programmer // // NOTE: THIS CODE REPLACES THE TI FACTORY-PROGRAMMED DCO CALIBRATION // CONSTANTS LOCATED IN INFOA WITH NEW VALUES. USE ONLY IF THE ORIGINAL // CONSTANTS ACCIDENTALLY GOT CORRUPTED OR ERASED. // // Description: This code re-programs the F2xx DCO calibration constants. // A software FLL mechanism is used to set the DCO based on an external // 32kHz reference clock. After each calibration, the values from the // clock system are read out and stored in a temporary variable. The final // frequency the DCO is set to is 1MHz, and this frequency is also used // during Flash programming of the constants. The program end is indicated // by the blinking LED. // ACLK = LFXT1/8 = 32768/8, MCLK = SMCLK = target DCO // //* External watch crystal installed on XIN XOUT is required for ACLK *// // // MSP430F20xx // --------------- // /|\| XIN|- // | | | 32kHz // --|RST XOUT|- // | | // | P1.0|--> LED // | P1.4|--> SMLCK = target DCO // // A. Dannenberg // Texas Instruments Inc. // May 2007 // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A //****************************************************************************** #include "msp430x20x1.h" #include "DCO_Library.h" unsigned char CAL_DATA[8]; // Temp. storage for constants volatile unsigned int i; int j; char *Flash_ptrA; // Segment A pointer void Set_DCO(unsigned int setting); void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT for (i = 0; i < 0xfffe; i++); // Delay for XTAL stabilization P1OUT = 0x01; // Red LED on P1SEL = 0x10; // P1.4 SMCLK output P1DIR = 0x51; // P1.0,4,6 output j = 0; // Reset pointer Set_DCO(TI_DCO_16MHZ); // Set DCO and obtain constants CAL_DATA[j++] = DCOCTL; CAL_DATA[j++] = BCSCTL1; Set_DCO(TI_DCO_12MHZ); // Set DCO and obtain constants CAL_DATA[j++] = DCOCTL; CAL_DATA[j++] = BCSCTL1; Set_DCO(TI_DCO_8MHZ); // Set DCO and obtain constants CAL_DATA[j++] = DCOCTL; CAL_DATA[j++] = BCSCTL1; Set_DCO(TI_DCO_1MHZ); // Set DCO and obtain constants CAL_DATA[j++] = DCOCTL; CAL_DATA[j++] = BCSCTL1; Flash_ptrA = (char *)0x10C0; // Point to beginning of seg A FCTL2 = FWKEY + FSSEL0 + FN1; // MCLK/3 for Flash Timing Generator FCTL1 = FWKEY + ERASE; // Set Erase bit FCTL3 = FWKEY + LOCKA; // Clear LOCK & LOCKA bits *Flash_ptrA = 0x00; // Dummy write to erase Flash seg A FCTL1 = FWKEY + WRT; // Set WRT bit for write operation Flash_ptrA = (char *)0x10F8; // Point to beginning of cal consts for (j = 0; j < 8; j++) *Flash_ptrA++ = CAL_DATA[j]; // re-flash DCO calibration data FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY + LOCKA + LOCK; // Set LOCK & LOCKA bit P1OUT = 0; while (1) { P1OUT ^= BIT6; // Toggle green LED for (i = 0; i < 0x4000; i++); // SW Delay } } void Set_DCO(unsigned int setting){ volatile unsigned int I; // P1DIR |= BIT0; // P1.0 output BCSCTL1 &= ~XTS; // external source is LF; BCSCTL3 &= ~(LFXT1S0 + LFXT1S1); // watch crystal mode BCSCTL3 |= XCAP0 + XCAP1; // ~12.5 pf cap on the watch crystal as recommended for( I = 0; I < 0xFFFF; I++){} // delay for ACLK startup if(TI_SetDCO(setting) == TI_DCO_NO_ERROR) // if setting the clock was successful, P1OUT |= BIT0; // bring P1.0 high (Launchpad red LED) else while(1); // trap if setting the clock isn't successful }
    The green light should start blinking in a few seconds, indicating success. Now we need to modify some linker and header files so CCS knows about the new calibrations.
    I'm using the MSP430G2231, so I duplicated the file C:\Program Files (x86)\Texas Instruments\ccsv4\msp430\include\msp430g2231.cmd in that directory, and renamed the duplicate as msp430g2231_mod.cmd. Now I can edit it without affecting the original. Edit msp430g2231_mod.cmd and change the calibration section at the bottom to this:

    /************************************************************ * Calibration Data in Info Mem ************************************************************/ CALDCO_16MHZ = 0x10F8; CALBC1_16MHZ = 0x10F9; CALDCO_12MHZ = 0x10FA; CALBC1_12MHZ = 0x10FB; CALDCO_8MHZ = 0x10FC; CALBC1_8MHZ = 0x10FD; CALDCO_1MHZ = 0x10FE; CALBC1_1MHZ = 0x10FF;
    Now the linker knows we have calibration data in that section when we use the modified file.
    When we create a new project in CCS or modify an existing one, CCS will want to use the default linking file, and the default header. Here's an example about how to configure a project to use the new constants.
    First create a new project. Within the project, there should be a file called something like lnk_msp430g2231.cmd. The last line of that file should be something like -l msp430g2231.cmd. Open it, and change the last line to reflect the new linker file so it reads -l msp430g2231_mod.cmd.
    Next, add the appropriate header file to the project. Right-click the project folder in the left pane of CCS and click "Add files to project..." In this example, I'm using C:\Program Files (x86)\Texas Instruments\ccsv4\msp430\include\msp430g2231.h. Now we have a copy of the file in the project we can safely edit. Edit the file so the calibration section looks like this:

    /************************************************************ * Calibration Data in Info Mem ************************************************************/ #ifndef __DisableCalData SFR_8BIT(CALDCO_16MHZ); /* DCOCTL Calibration Data for 16MHz */ SFR_8BIT(CALBC1_16MHZ); /* BCSCTL1 Calibration Data for 16MHz */ SFR_8BIT(CALDCO_12MHZ); /* DCOCTL Calibration Data for 12MHz */ SFR_8BIT(CALBC1_12MHZ); /* BCSCTL1 Calibration Data for 12MHz */ SFR_8BIT(CALDCO_8MHZ); /* DCOCTL Calibration Data for 8MHz */ SFR_8BIT(CALBC1_8MHZ); /* BCSCTL1 Calibration Data for 8MHz */ SFR_8BIT(CALDCO_1MHZ); /* DCOCTL Calibration Data for 1MHz */ SFR_8BIT(CALBC1_1MHZ); /* BCSCTL1 Calibration Data for 1MHz */ #endif /* #ifndef __DisableCalData */
    Now you can begin using the new calibration data in your program. When you #include the msp430g2231.h file, put it in quotes instead of <> to ensure it's loading the modified header local to the project directory.
    I tested the constants with a cheap oscilloscope and they seemed correct. My scope doesn't have great accuracy at high frequencies so they might be a little off, but nothing I can detect. It works with my composite video prog, so that's a pretty good sign.
    EDIT: Oops! I had an incorrectly named file in these instructions. Corrected.
  6. Like
    ROFLhoff reacted to RobG in Color LCD Booster Pack   
    Here's some basic JD-T1800 code for testing purposes...
    ...and a short video


    #include #include "ST7735.h" #define JDT1800_WIDTH 128 #define JDT1800_HEIGHT 160 #define JDT1800_SCL_PIN BIT5 #define JDT1800_SDA_PIN BIT7 #define JDT1800_CS_PIN BIT2 #define JDT1800_RS_PIN BIT4 #define JDT1800_SELECT P1OUT &= ~JDT1800_CS_PIN #define JDT1800_DESELECT P1OUT |= JDT1800_CS_PIN #define JDT1800_SET_COMMAND P1OUT &= ~JDT1800_RS_PIN #define JDT1800_SET_DATA P1OUT |= JDT1800_RS_PIN #define JDT1800_COMMAND 0 #define JDT1800_DATA 1 void initLCD(); void delay(char x10ms); void write(char data, char registerSelect); void setAddr(char xStart, char yStart, char xEnd, char yEnd); void fillScreen(unsigned int color_16); void writeConfig(char command, char numberOfArgs, const char *args); void writeConfigWithDelay(char command, char x10ms); #define writeData(data) write(data, JDT1800_DATA); #define writeCommand(command) write(command, JDT1800_COMMAND); // convenience color table const int color[] = { ST7735_16_BLACK, ST7735_16_WHITE, ST7735_16_YELLOW, ST7735_16_RED, ST7735_16_MAGENTA, ST7735_16_BLUE, ST7735_16_CYAN, ST7735_16_GREEN }; void main(void) { WDTCTL = WDTPW + WDTHOLD; // disable WDT BCSCTL1 = CALBC1_16MHZ; // 16MHz clock DCOCTL = CALDCO_16MHZ; P1OUT |= JDT1800_CS_PIN + JDT1800_RS_PIN; P1DIR |= JDT1800_CS_PIN + JDT1800_RS_PIN; P1SEL |= JDT1800_SCL_PIN + JDT1800_SDA_PIN; P1SEL2 |= JDT1800_SCL_PIN + JDT1800_SDA_PIN; UCB0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master UCB0CTL1 |= UCSSEL_2; // SMCLK UCB0BR0 |= 0x01; // 1:1 UCB0BR1 = 0; UCB0CTL1 &= ~UCSWRST; // clear SW initLCD(); // clear screen fillScreen(ST7735_16_BLACK); // cycle through 8 colors char c = 0; while (c < 8) { _delay_cycles(1000000); fillScreen(color[c]); c++; } } void setAddr(char xStart, char yStart, char xEnd, char yEnd) { writeCommand(ST7735_CASET); writeData(0x00); writeData(xStart); writeData(0x00); writeData(xEnd); writeCommand(ST7735_RASET); writeData(0x00); writeData(yStart); writeData(0x00); writeData(yEnd); writeCommand(ST7735_RAMWR); // data to follow } void fillScreen(unsigned int color_16) { char colorHighByte = color_16 >> 8; char colorLowByte = color_16; char x = JDT1800_WIDTH; char y = JDT1800_HEIGHT; setAddr(0, 0, x - 1, y - 1); while (y-- > 0) { while (x-- > 0) { writeData(colorHighByte); writeData(colorLowByte); } } } void write(char data, char registerSelect) { registerSelect ? (JDT1800_SET_DATA) : (JDT1800_SET_COMMAND); JDT1800_SELECT; UCB0TXBUF = data; while (!(IFG2 & UCB0TXIFG)) ; JDT1800_DESELECT; } void writeConfig(char command, char numberOfArgs, const char *args) { writeCommand(command); while (numberOfArgs--) { writeData(*args++); } } void writeConfigWithDelay(char command, char x10ms) { writeCommand(command); delay(x10ms); } void delay(char x10ms) { while (x10ms > 0) { _delay_cycles(160000); x10ms--; } } // ************* // Config section // ************* const char frmctr[] = { 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D }; const char invctr[] = { 0x07 }; const char pwctr1[] = { 0xA2, 0x02, 0x84 }; const char pwctr2[] = { 0xC5 }; const char pwctr3[] = { 0x0A, 0x00 }; const char pwctr4[] = { 0x8A, 0x2A }; const char pwctr5[] = { 0x8A, 0xEE }; const char vmctr1[] = { 0x0E }; const char madctl[] = { 0xC8 }; const char colmod[] = { 0x05 }; // 16-bit color void initLCD() { writeConfigWithDelay(ST7735_SLPOUT, 50); // sleep out writeConfig(ST7735_FRMCTR1, 3, frmctr); // frame rate in normal mode writeConfig(ST7735_FRMCTR2, 3, frmctr); // frame rate in idle mode writeConfig(ST7735_FRMCTR3, 6, frmctr); // frame rate in partial mode writeConfig(ST7735_INVCTR, 1, invctr); // display inversion control writeConfig(ST7735_PWCTR1, 3, pwctr1); // power control settings writeConfig(ST7735_PWCTR2, 1, pwctr2); // power control settings writeConfig(ST7735_PWCTR3, 2, pwctr3); // power control settings writeConfig(ST7735_PWCTR4, 2, pwctr4); // power control settings writeConfig(ST7735_PWCTR5, 2, pwctr5); // power control settings writeConfig(ST7735_VMCTR1, 1, vmctr1); // power control settings writeConfig(ST7735_INVOFF, 0, 0); // display inversion off writeConfig(ST7735_MADCTL, 1, madctl); // memory data access control writeConfig(ST7735_COLMOD, 1, colmod); // color mode writeConfigWithDelay(ST7735_NORON, 1); // normal display on writeConfigWithDelay(ST7735_DISPON, 10); // display on }

    #ifndef ST7735_H_ #define ST7735_H_ #define ST7735_16_BLACK 0x0000 #define ST7735_16_BLUE 0x001F #define ST7735_16_RED 0xF800 #define ST7735_16_GREEN 0x07E0 #define ST7735_16_CYAN 0x07FF #define ST7735_16_MAGENTA 0xF81F #define ST7735_16_YELLOW 0xFFE0 #define ST7735_16_WHITE 0xFFFF #define ST7735_NOP 0x00 #define ST7735_SWRESET 0x01 #define ST7735_RDDID 0x04 #define ST7735_RDDST 0x09 #define ST7735_SLPIN 0x10 #define ST7735_SLPOUT 0x11 #define ST7735_PTLON 0x12 #define ST7735_NORON 0x13 #define ST7735_INVOFF 0x20 #define ST7735_INVON 0x21 #define ST7735_DISPOFF 0x28 #define ST7735_DISPON 0x29 #define ST7735_CASET 0x2A #define ST7735_RASET 0x2B #define ST7735_RAMWR 0x2C #define ST7735_RAMRD 0x2E #define ST7735_PTLAR 0x30 #define ST7735_COLMOD 0x3A #define ST7735_MADCTL 0x36 #define ST7735_FRMCTR1 0xB1 #define ST7735_FRMCTR2 0xB2 #define ST7735_FRMCTR3 0xB3 #define ST7735_INVCTR 0xB4 #define ST7735_DISSET5 0xB6 #define ST7735_PWCTR1 0xC0 #define ST7735_PWCTR2 0xC1 #define ST7735_PWCTR3 0xC2 #define ST7735_PWCTR4 0xC3 #define ST7735_PWCTR5 0xC4 #define ST7735_VMCTR1 0xC5 #define ST7735_RDID1 0xDA #define ST7735_RDID2 0xDB #define ST7735_RDID3 0xDC #define ST7735_RDID4 0xDD #define ST7735_GMCTRP1 0xE0 #define ST7735_GMCTRN1 0xE1 #define ST7735_PWCTR6 0xFC #endif /*ST7735_H_*/
  7. Like
    ROFLhoff reacted to RobG in Color LCD Booster Pack   
    150 mil SOIC
  8. Like
    ROFLhoff reacted to RobG in Color LCD Booster Pack   
    Hirose DF23C-10DS-0.5V(51) - socket needed for Nokia 6100 and Nokia 1600 (1600 was added on the latest version of the board.)
    Hirose DF23C-22DS-0.5V(53) - socket needed for Nokia 6101
    R1 - 47k 0805 (display reset resistor)
    R2 - 0ohm jumper (JD-T1800 current limiting 0805 resistor if needed)
    R3 & R4 - 220-300ohm 0805 (LED resistors)
    LED1 & LED2 - 0805 LEDs
    C1, C2, C3 - 1uF 0805 ceramic (charge pump caps, needed for Nokia displays only)
    C4 - 0.1uF 0805 (decoupling cap for memory chips, but it doesn't hurt to have one in any case)
    C5 - MIA
    C6 - 0.1uF 0805 (display reset cap)
    IC1 - TPS60403DBV (backlight charge pump for Nokia displays, can be TPS60400 to TPS60403, but might require larger caps)
    IC2 and IC4 - Microchip 23Kxxx (SRAM) or 25AAxxx (EEPROM) series memory. IC2's HOLD pin is controlled with P1.0
    IC3 - MIA
  9. Like
    ROFLhoff reacted to bluehash in PetiteFS FATfs SDCard USCI code   
    Edit: July 6th, 2014
    Please also note that Pabigot maintains BSP430 which has an example for the msp430. He also tracks any changes done to the ElmChan library with patches made to the example. Refer this post.
    First version. It's very untidy as I just got it to work. Works on USCI on the MSP430G2553. Supports Read/Listing. The monitor code does not have write yet. It works on the SDCard Boosterpack.

    I also used Rickta's serial code to reduce file size. I'll update to the next version once I have time and a clean it up to. Also need to add more features.

    Usage in screenshot.
    di : disk initialize
    fi : mount disk
    fl : list files
    fo filename: open file name.

    Latest Code:
    http://www.43oh.com/forum/viewtopic.php?f=10&t=1883&start=20#p18738'>Code Rev 0.2

    Member Contributed Code:
    Jazz_ys - http://forum.43oh.com/topic/1427-petitefs-fatfs-sdcard-usci-code/page__st__20#entry24449'>Link
  10. Like
    ROFLhoff reacted to RobG in 3V LaunchPad   
    Here is one way to temporarily lower LaunchPad's 3.6V supply down to 3V (or 3.3V)
    Attach 220k (240k) resistor in parallel to R8.
    The values are for LaunchPad v1.5.
    LP v1.4 divider's values are 10 times smaller, so adjust as necessary.
    Also, LP will not work below 3V.

  • Create New...