maelli01

Members
  • Content count

    45
  • Joined

  • Last visited

  • Days Won

    12

maelli01 last won the day on April 23

maelli01 had the most liked content!

About maelli01

  • Rank
    Advanced Member
  1. exactly, and the second diode to make it fool-proof
  2. Did anybody been succesful in writing to the SD card on the FR5994? For me the out of the box demo does not work for SD-logging. When re-installing it, no idea whether it worked when originally came out of the box ;-( Is there a "hello world on SD card" example using the fr5994 around somewhere? update: yesterday it did not work and I did not know why today I got it working (the out of the box project) and I do not know why.... ;-)
  3. The example msp430fr5994x_lpm4-5_02.c is supposed to show how little current is used in this mode. In the file it says: // MSP430FR5x9x Demo - Entering and waking up from LPM4.5 via P1.3 interrupt // with SVS disabled // // Description: Download and run the program. When entered LPM4.5, no LEDs // should be on. Use a multimeter to measure current on JP1 and // compare to the datasheet. When a positive voltage is applied // to P1.3 the device should wake up from LPM4.5. This will enable // the LFXT oscillator and blink the LED (on P1.0). Even for a high-end multimeter this current is too low to be accurately measured. So I helped myself this way: - power the processor from the supercap - a 10k resistor with two antiparallel diodes act as a shunt, - connect the volt meter across the supercap, not across the processor 0.43mV over a 10k resistor gives 43 Nanoamps. (!) Yes, the datasheet (page 32) is right, typical value at 25°C is 45nA. A CR2032 (200mAh) cell would allow the processor to wait for an interrupt for 530 years.
  4. Weekend-project: Autoranging microvoltmeter based on the MSP430FR4133 launchpad. ADC used: MIcrochip MCP3422, an 18bit, 3.75 sample/second Sigma Delta with 2 differential inputs. I2C interface This nice little chip contains a programmable amplifier (x2,x4,x8) and a not-too-bad internal reference of 2.048V. Max input range is +/-2.048V, resolution (8x amplified) is 2uV. Hand-etched a single layer PCB which goes on top of Launchpad. Type K cable in hot water: 2.93mV, 73Kelvin temp difference to ambient compare with my Fluke 289, 0.06% (datasheet says 0.05% typical, 0.35% max) Not too shabby for a chip that costs 3 bucks. Current consumption: on average <40uA, the whole setup would run 5000hours from a CR2032 The ADC does 1 sample/second and sleeps the rest of the time, the MSP430 does what it likes the most: sleep in LPM3 Code is not a big deal, quick hack based on the FR4133 examples, for the LCD and for the I2C interface //microvolt meter with MCP3422 and MSP430FR413 //****************************************************************************** #include <msp430.h> #define LCDMEMW ((int*)LCDMEM) #define pos1 4 // Digit A1 - L4 #define pos2 6 // Digit A2 - L6 #define pos3 8 // Digit A3 - L8 #define pos4 10 // Digit A4 - L10 #define pos5 2 // Digit A5 - L2 #define pos6 18 // Digit A6 - L18 const char digit[10] ={ 0xFC, // "0" 0x60, // "1" 0xDB, // "2" 0xF3, // "3" 0x67, // "4" 0xB7, // "5" 0xBF, // "6" 0xE0, // "7" 0xFF, // "8" 0xF7 // "9" }; volatile long voltage; unsigned long dvoltage; unsigned char TXByteCtr; unsigned char TXData; unsigned char newgain,gain; void Clear_LCD(){ int i; for(i=5;i;i--) LCDMEMW[i]=0; LCDMEMW[9]=0; } int main( void ) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P1OUT = 0x00;P2OUT = 0x00;P3OUT = 0x00;P4OUT = 0x00; P5OUT = 0x00;P6OUT = 0x00;P7OUT = 0x00;P8OUT = 0x00; P1DIR = 0xFF;P2DIR = 0xFF;P3DIR = 0xFF;P4DIR = 0xFF; P5DIR = 0xFF;P6DIR = 0xFF;P7DIR = 0xFF;P8DIR = 0xFF; P5SEL0 |= BIT2 | BIT3; // I2C pins // Configure XT1 oscillator P4SEL0 |= BIT1 | BIT2; // P4.2~P4.1: crystal pins do { CSCTL7 &= ~(XT1OFFG | DCOFFG); // Clear XT1 and DCO fault flag SFRIFG1 &= ~OFIFG; } while (SFRIFG1 & OFIFG); // Test oscillator fault flag // Disable the GPIO power-on default high-impedance mode // to activate previously configured port settings PM5CTL0 &= ~LOCKLPM5; CSCTL4 = SELMS__DCOCLKDIV + SELA__XT1CLK; // MCLK=SMCLK=DCO; ACLK=XT1 // Configure RTC RTCCTL |= RTCSS__XT1CLK | RTCIE; // Initialize RTC to use XT1 and enable RTC interrupt RTCMOD = 16384; // Set RTC modulo to 16384 to trigger interrupt twice a second // Configure LCD pins SYSCFG2 |= LCDPCTL; // R13/R23/R33/LCDCAP0/LCDCAP1 pins selected LCDPCTL0 = 0xFFFF; LCDPCTL1 = 0x07FF; LCDPCTL2 = 0x00F0; // L0~L26 & L36~L39 pins selected LCDCTL0 = LCDSSEL_0 | LCDDIV_7; // flcd ref freq is xtclk // LCD Operation - Mode 3, internal 3.08v, charge pump 256Hz LCDVCTL = LCDCPEN | LCDREFEN | VLCD_5 | (LCDCPFSEL0 | LCDCPFSEL1 | LCDCPFSEL2 | LCDCPFSEL3); LCDMEMCTL |= LCDCLRM; // Clear LCD memory LCDCSSEL0 = 0x000F; // Configure COMs and SEGs LCDCSSEL1 = 0x0000; // L0, L1, L2, L3: COM pins LCDCSSEL2 = 0x0000; LCDM0 = 0x21; // L0 = COM0, L1 = COM1 LCDM1 = 0x84; // L2 = COM2, L3 = COM3 LCDCTL0 |= LCD4MUX | LCDON; // Turn on LCD, 4-mux selected (LCD4MUX also includes LCDSON) Clear_LCD(); // Configure USCI_B0 for I2C mode UCB0CTLW0 |= UCSWRST; // Software reset enabled UCB0CTLW0 |= UCMODE_3 | UCMST | UCSYNC; // I2C mode, Master mode, sync UCB0CTLW1 |= UCASTP_2; // Automatic stop generated // after UCB0TBCNT is reached UCB0BRW = 0x0008; // baudrate = SMCLK / 8 UCB0I2CSA = 0x0068; // Slave address UCB0CTL1 &= ~UCSWRST; UCB0IE |= UCRXIE | UCNACKIE | UCBCNTIE | UCTXIE0; while(1){ // P1OUT |= BIT0; TXByteCtr = 1; // Load TX byte counter TXData = 0x8C+gain; while (UCB0CTLW0 & UCTXSTP); // Ensure stop condition got sent UCB0CTLW0 |= UCTR | UCTXSTT; // I2C TX, start condition // P1OUT &= ~BIT0; __bis_SR_register(LPM3_bits | GIE); // timer will wake me up // P1OUT |= BIT0; UCB0TBCNT = 0x0003; // 3 bytes to be received voltage=0; UCB0CTLW0 &= ~UCTR; while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent UCB0CTL1 |= UCTXSTT; // I2C start condition __bis_SR_register(LPM3_bits | GIE); // I2C irq will wake me up voltage<<=8; // shift to left corner to do the sign correctly voltage/=32; // calibration is done here: 2048 in an ideal world if ((voltage<400000)&&(voltage>(-400000))){ // autoranging, downshift if (newgain<3) newgain++; } if ((voltage>1000000)||(voltage<-1000000)){ // autoranging, upshift if (newgain) newgain--; } voltage>>=gain; gain=newgain; if ((voltage<500000)&&(voltage>-500000)){ voltage*=10; //low range LCDMEM[11]&=~1; //adjust decimal point LCDMEM[9]|=1; } else{ //high range LCDMEM[9]&=~1; //adjust decimal point LCDMEM[11]|=1; } voltage*=25; voltage/=128; if (voltage<0) {dvoltage=-voltage; LCDMEM[5]|=4 ;} //negative else {dvoltage= voltage; LCDMEM[5]&=~4;} //positive LCDMEM[pos1] = digit[(dvoltage / 100000)%10]; LCDMEM[pos2] = digit[(dvoltage / 10000)%10]; LCDMEM[pos3] = digit[(dvoltage / 1000)%10]; LCDMEM[pos4] = digit[(dvoltage / 100)%10]; LCDMEM[pos5] = digit[(dvoltage / 10)%10]; LCDMEM[pos6] = digit[dvoltage % 10]; // P1OUT &= ~BIT0; __bis_SR_register(LPM3_bits | GIE); // timer will wake me up } } #pragma vector = RTC_VECTOR __interrupt void RTC_ISR(void){ switch(__even_in_range(RTCIV, RTCIV_RTCIF)){ case RTCIV_NONE: break; // No interrupt case RTCIV_RTCIF: // RTC Overflow __bic_SR_register_on_exit(LPM3_bits); break; default: break; } } #pragma vector = USCI_B0_VECTOR __interrupt void USCIB0_ISR(void){ switch(__even_in_range(UCB0IV, USCI_I2C_UCBIT9IFG)){ case USCI_NONE: break; // Vector 0: No interrupts case USCI_I2C_UCALIFG: break; // Vector 2: ALIFG case USCI_I2C_UCNACKIFG: // Vector 4: NACKIFG UCB0CTL1 |= UCTXSTT; // I2C start condition break; case USCI_I2C_UCSTTIFG: break; // Vector 6: STTIFG case USCI_I2C_UCSTPIFG: break; // Vector 8: STPIFG case USCI_I2C_UCRXIFG3: break; // Vector 10: RXIFG3 case USCI_I2C_UCTXIFG3: break; // Vector 14: TXIFG3 case USCI_I2C_UCRXIFG2: break; // Vector 16: RXIFG2 case USCI_I2C_UCTXIFG2: break; // Vector 18: TXIFG2 case USCI_I2C_UCRXIFG1: break; // Vector 20: RXIFG1 case USCI_I2C_UCTXIFG1: break; // Vector 22: TXIFG1 case USCI_I2C_UCRXIFG0: // Vector 24: RXIFG0 voltage=(voltage<<8)+UCB0RXBUF; break; case USCI_I2C_UCTXIFG0: // Vector 26: TXIFG0 if (TXByteCtr){ // Check TX byte counter UCB0TXBUF = TXData; // Load TX buffer TXByteCtr--; // Decrement TX byte counter } else{ UCB0CTLW0 |= UCTXSTP; // I2C stop condition UCB0IFG &= ~UCTXIFG; // Clear USCI_B0 TX int flag } break; case USCI_I2C_UCBCNTIFG: // Vector 28: BCNTIFG __bic_SR_register_on_exit(LPM3_bits); break; case USCI_I2C_UCCLTOIFG: break; // Vector 30: clock low timeout case USCI_I2C_UCBIT9IFG: break; // Vector 32: 9th bit default: break; } }
  5. Hioki multimeter MSP430F449 8:12
  6. had this thing now running 24/7 for more than a year. Each time the ethernet library crashed, watchdog would trigger, count up one and restart the board. It crashed 32 times in the last 12 months. ;-) not often, but often enough to be a useless bit of kit. Has the problem been solved in the meantime? I have not been looking around in the forum much, but I have the impression that I am/was not the only one with issues. Could it make sense to upgrade to the latest energia?
  7. In the Horowitz/Hill Art of Electronics, third edition, design practices with discrete 74HCxxx, FPGA and Microprocessor are compared and discussed. As an example, the ultimate gibberish machine is described, a circuit that sends out a succession of pseudorandom bytes, as standard RS232 serial data, with 2 selectable speeds, 9600 / 1200 baud. Independent of the processor type, the implementation with a small micro and program it in C looks like the clear winner here, smallest engineering effort, lowest hardware effort (have to admit that I do not have the faintest idea about FPGA.) The example in the book used some 8051ish device, so I was wondering on how this would look like on a MSP430/launchpad See my code below, based on the 8051 C code from the book, but adapted to run as low power as possible (LPM3) The power consuption of this thing is: 40uA at 9600baud, 6uA at 1200baud //MSP430G2553LP implementation of the ultimate gibberish machine //from the art of electronics, third edition, Chapter 11.3. //Produces a pseudorandom datastream at 9600/1200baud, 8n1 //P1.0 output, sync, processor busy //P1.2 output, serial pseudorandom data //P1.3 input, data rate select (button,at start) //32768Hz crystal is required //2016-10-23 maelli01 #include <msp430.h> unsigned char d,c,b,a=1; int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P1DIR = ~BIT3; P1REN=BIT3; P1OUT=BIT3; // all output, except button P1SEL = BIT2; P1SEL2=BIT2; // P1.2=TXD P2REN = 0x3F; // all unused pins resistor enable P3REN = 0xFF; // all unused pins resistor enable UCA0CTL1 |= UCSSEL_1; // CLK = ACLK if(P1IN&8){ // button not pressed: 9600 baud UCA0BR0 = 3; // 32768Hz/9600 = 3.41 UCA0MCTL = UCBRS1 + UCBRS0; // Modulation UCBRSx = 3 } else{ // button pressed: 1200 baud UCA0BR0 = 27; // 32768Hz/1200 = 27.3 UCA0MCTL = UCBRS1; // Modulation UCBRSx = 2 } UCA0BR1 = 0x00; UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** IE2 |= UCA0TXIE; // Enable USCI_A0 TX interrupt __bis_SR_register(LPM3_bits + GIE); // Enter LPM3 w/ int } #pragma vector=USCIAB0TX_VECTOR __interrupt void USCI0TX_ISR(void){ P1OUT |=1; UCA0TXBUF=((d<<1)|(c>>7))^c; // 32 bit pseudorandom generator d=c; c=b; b=a; a=UCA0TXBUF; P1OUT &=~1; }
  8. it is a long time ago since I hacked this together. For the LNK304 based 15V supply I more or less followed this: https://ac-dc.power.com/design-support/reference-designs/design-examples/der-231-132-w-power-supply/ Adapt R8 and R9 for different output voltage. The UF4007 is a cheap but rather fast diode, a normal 1N4007 will NOT work. I found this LNK chips very easy to use. But yes, these things handle high voltage without potential separation. I always use a separation transformer when experimenting and keep my hands im my pockets...
  9. sure you can power an MSP430 from 2 AA cells. The unequal power drain should be manageable for a hobby project. However, for a "product" it is probably not a too good idea: - what happens when inserting / removing batteries? - 2 cells discharged during months, 2 others not, might be o.k. for alkalines, but for long term using Nimh? I do not know. - The MSP can use the internal reference for battery voltage measurement. You have to check the datasheet whether the 1.5V reference works when 2 cells are at the end of life. - you might also check for wrong polarity. The german clever designers solved this issue mechanically. It does not give contact when in wrong direction.
  10. Last year my daughter (she was almost 7 back then) got interesting in soldering. So I let het solder stuff together, no function whatsoever. It did not last long, until she wanted to solder something that "does something". So I took the challenge and designed this christmas tree. - FR2 board, copper artwork by me, other side by my daughter. (cheap FR2 is better for using felt tip pens.. almost like paper) - G2553, all 16pins to simple LEDs, various colours - simple discrete regulator (another led+ transistor) for more or less 3V - powered by USB - mostly through-hole (soldered by a 7 year old), some SMD (where I helped) - programmed in Energia merry christmas!
  11. Bike light follow-up: reverse engineering time! here is my almost complete circuit diagram. IC1 is a voltage regulator: 2.5V, exact type I could not find out. Only the MSP runs on the regulated voltage, all the rest runs from the raw battery voltage. Voltage divider R2 1M / R3 330K measure the battery voltage (some microamps get lost here) LED2 and 3 are indicator (red/green) LED1 is the power led PWM is 20kHz, coming from pin 11 of the MSP. Main switch is a Si4562, N and P channel 20V 5A mosfet. Inductor is 100uH. Instead of using only the upper fet, they alternately switch on the upper / lower FET, avoiding one diode voltage drop, increasing effiency. The circuitry around IC3 (a weird CMOS 4572) creates a small dead time (less than a microsecond) to avoid cross-conduction. Note the resistors in the signal path ;-) They managed to regulate the LED current without a shunt resistor. Took me some time to find out how: The voltage across the inductor is low-pass filtered, R14 390k / C4 0.1u, then fed into the MSP. Of course the DC-part of the inductor voltage depends on the current flow. Pretty clever. The regulation is rather slow (ramp-up of current is so slow it is actually visible). The circuitry around Q8 and Q9 takes care of the battery charge turn on/off. Input is from a wall-wart adaptor which is 500mA constant current type. R10/R11 tell the MSP that external voltage is present.
  12. power an msp430 without power pins ;-) http://www.eevblog.com/2015/12/18/eevblog-831-power-a-micro-with-no-power-pin/
  13. Reading this discussion on e2e.ti.com does not give me a good feeling. Seems like nobody wants to solve the problem or even admit there is one :-( meanwhile I added a watchdog (4secs) into my code. I feed the dog after the client.print function calls. The watchdog triggers more often than not. I have the strong feeling that sometimes the client.print(xx); function gets stuck in nowhereland for ever. Not good. With the device resetting every now and then, I cannot log any data.
  14. It is was a Busch & M
  15. My high tech, German street legal, bicycle light failed. Corrosion on the battery contacts, one day it worked, the other not. So I cracked the damn thing open. Solid build quality, waterproof, but not built to be repairable. As far as I remember, I bought it back in 2006. So what is inside: An MSP430F1122, doing all the business: - Battery charge termination (four AA NIMH) - Two LED intensity levels PWM - 2 color status led (blink duty cycle would indicate remaining charge) - Pushbutton, long for on/off, short for low/high The electronics still works fine, but would need a lot of duct tape to make it a cycle light again :-(