Jump to content

Antscran

Members
  • Content Count

    47
  • Joined

  • Last visited

  • Days Won

    6

Antscran last won the day on July 19 2015

Antscran had the most liked content!

About Antscran

  • Rank
    Advanced Member

Contact Methods

  • Website URL
    http://www.coder-tronics.com

Profile Information

  • Gender
    Male
  • Location
    Denmark
  • Interests
    Technology, Microcontrollers, Fishing, Photography and the great outdoors as well as a few sports
  1. Antscran

    Interrupt Debounce

    I wrote some stuff on debouncing back in 2014, all the code is for the MSP430 and based on various sources as well as Jack Ganssle's. It might be of some use. http://coder-tronics.com/switch-debouncing-tutorial-pt1/ http://coder-tronics.com/switch-debouncing-tutorial-pt2/
  2. Antscran

    Interface MSP432 with MPU6050

    I have not worked that much with the MPU6050 or the MSP432, but usually use lower value pull-ups than 10k as you get a cleaner i2c signal. 4k7 down to 2k2 are usually safe values and it is possible to go lower on 3.3v but probably not necessary in most cases. If you can scope the signal that could be useful to see, as well as the code. Other obvious problems is the wrong address, but assuming you have checked this.
  3. Antscran

    Energy harvesting

    Hi Adnan, I have made a few energy harvesting circuits now and usually use Linear Technology IC's, they offer a good range of options. TI also do a range of devices as well as do other manufacturers, but I am less familiar with these. You need to use a boost or similar topology (Sepic) if you want to have the system running when the solar cell is below the loads running voltage. Unsure of the power output of your solar cell, but this will determine the charging speed of your supercapacitor at any given irradiance level and load requirements. I have not used the voltage range that you require, but the LTC3105 should fit your requirements. The circuit calculations are easy enough and the datasheet walks you through everything you need. Hope this is of some use, Ant
  4. Antscran

    Code composer Studion Graphing Tool Tutorial

    Cheers for the comments and glad it will prove useful. You can up the refresh rate a bit, also in the CCS preferences menu under debug is a further option for refreshing the the data (forget the exact setting as on my mobile) you can increase this to 100mS Max I believe. The G2553 wasn't up for that and the code I was running, as it proved unstable so set it to 1000mS, but tweaking the settings you can find a balance. I have found the watched expressions don't seem to work on local variables, if someone knows otherwise please let me know. This should work on MSP430 (tested), Tiva C (soon to test) and C2000 (tested).
  5. Hi all, Just made a tutorial both written and video on how to use the graphing tool built into Code Composer Studio. I meant to do this awhile back just not had the time until now, hope it proves of some use. http://coder-tronics.com/code-composer-studio-graphing-tool-tutorial/ https://youtu.be/-iGnh0_9YxE Cheers, Ant
  6. Antscran

    MSP430G Launchpad Frequency Counter

    oPossum, Thanks for the information this seems to tally-up with the my observations, I will look into the itoa function and also see if I can find alternatives. I was looking at your project, very nice and see you have solved the issue of measuring up to 16MHz despite using a 16Mhz clock is a simple but clever way.
  7. Antscran

    MSP430G Launchpad Frequency Counter

    I made some tweaks to the code as below but still have the issue as described char buffer[8]; unsigned long toLCD = Freq; //int counter = 0; int Base = 10; itoa(toLCD, buffer, Base); //char array[6] = { 0, }; setColor(COLOR_BLACK); drawString(17, 80, FONT_LG_BKG, "888888"); setColor(COLOR_ORANGE_RED); //int2ASCII(Freq, array, 0); drawString(5, 80, FONT_LG_BKG, buffer); Now the issue happens pretty much at 32760kHz (adjustment too course on the function generator to be accurate), which happens to be exactly half of what a 16bit integer can hold. Back to more testing, but any idea's would be appreciated :-) Cheers, Ant
  8. Antscran

    MSP430G Launchpad Frequency Counter

    Hi Greeeg, I missed that, obviously! I don't have a function generator at home so will take it down the University lab and test tomorrow. Cheers for your input, Ant
  9. Antscran

    MSP430G Launchpad Frequency Counter

    Hi all, After bit of help. I was inspired by this MSP430F550x frequency meter Jazz made and thought I would code one from scratch, different from the one I posted in the that original thread http://forum.43oh.com/topic/3317-msp430f550x-based-frequency-meter/ The one I made works fine but I am having an issue displaying above ~32kHz on the LCD, I know the variable Freq that holds the frequency is correct as viewed this in debug mode. So it must be my implementation of the itoa function or possibly a casting issue?....this is where my C skills are a bit sketchy! The video shows the frequency counter in operation and it uses an early iteration of RobG's EduKit BoosterPack. It doesn't show what happens above 30kHz, however a negative value is displayed or one which is completely incorrect. https://www.youtube.com/watch?v=Ene1dIvGBBo The itoa function is attached as well but I doubt this is at fault, not one I have coded but I have used it before successfully. #include "msp430.h" #include "edukit.h" #include "itoa.h" /*** Constants ***/ const int NumberSamples = 4; /*** Global variables ***/ volatile unsigned int CounterValue = 0; volatile unsigned int StoredCount = 0; volatile unsigned int Result = 0; unsigned int Freq = 0; unsigned int SampleTuneTime = 58950; /*** Function prototype ***/ void calc_freq(); void main(void) { /*** System Set-Up ***/ WDTCTL = WDTPW + WDTHOLD; // disable WDT initMSP430(); // init MSP430's clock BCSCTL3 |= LFXT1S_2; // VLO mode _delay_cycles(16000000); // wait for LCD to reset setUpSPIforLCD(SPI2, CA, DA); // set up LCD's SPI initLCD(); // init LCD clearScreen(COLOR_BLACK); /*** GPIO Set-Up ***/ P2DIR &= ~BIT0; // P2.0 set as input P2SEL |= BIT0; // P2.0 set to primary peripheral Timer1_A P1DIR |= BIT4; // Set P1.4 as output P1SEL |= BIT4; // Output SMCLK to P1.4 /*** Timer Set-Up ***/ TA0CCR0 = SampleTuneTime; // 2MHz = 500nS therefore 60000 = 30mS sample time TA0CCTL0 |= CCIE; // Interrupt enable TA0CTL |= TASSEL_2 + ID_3; // SMCLK, /8 TA1CCTL0 |= CCIE + CCIS_0 + CM_1 + CAP; // Interrupt enable, capture select CCIxA, Positive edge, capture mode TA1CTL |= TASSEL_2; // SMCLK /*** Set-up LCD text ***/ setColor(COLOR_GREEN); drawString(10, 5, FONT_LG_BKG, "Frequency"); drawString(25, 25, FONT_LG_BKG, "Counter"); setColor(COLOR_BLUE); drawString(110, 85, FONT_MD, "Hz"); _bis_SR_register(GIE); // Enter LPM0 w/ interrupt while (1) { TA1CTL |= MC1; // Start timer TA0CTL |= MC0; // Start timer while (CounterValue != NumberSamples); // Wait while CounterValue is not equal to 4 TA0CTL &= ~MC0; // Stop timer TA1CTL &= ~MC1; // Stop timer Result >>= 2; // Divide Result by 4 calc_freq(); unsigned char buffer[8]; int toLCD = Freq; //int counter = 0; int Base = 10; itoa(toLCD, buffer, Base); char array[8] = { 0, }; setColor(COLOR_BLACK); drawString(17, 80, FONT_LG_BKG, "888888"); setColor(COLOR_ORANGE_RED); //int2ASCII(Result, array, 0); drawString(5, 80, FONT_LG_BKG, buffer); _delay_cycles(1600000); // delay 100mS until next screen refresh Result = 0; // Zero Result CounterValue = 0; // Zero CounterValue StoredCount = 0; // Zero StoredCount TA0R = 0; // Zero Timer_A0 register TA1R = 0; // Zero Timer_A1 register } } //Timer_A0 TACCR0 Interrupt Vector Handler Routine #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer0_A0(void) { TA0CTL &= ~MC0; // Stop timer TA1CTL &= ~MC1; // Stop timer CounterValue++; // Increment CounterValue if (CounterValue >= (NumberSamples +1)) // Reset values if NumberSamples +1 is reached { CounterValue = 0; // Zero CountValue StoredCount = 0; // Zero StoredCount } Result += StoredCount; // Store accumulated count in Result StoredCount = 0; // Zero StoredCount TA1CTL |= MC1; // Start timer TA0CTL |= MC0; // Start timer } //Timer_A1 TACCR0 Interrupt Vector Handler Routine #pragma vector=TIMER1_A0_VECTOR __interrupt void Timer1_A0(void) { StoredCount++; // Increment StoredCount } void calc_freq() { float SampTime = 0.03; // 30mS sample time Freq = Result / SampTime; // Divide the averaged sampled result by the sample time to gain the frequency } Cheers, Ant
  10. Antscran

    MSP430F550x based frequency meter

    I was playing around with the timers in the MSP430G2553 as making a frequency counter test, I don't have a function generator at home so was trying to generate a PWM and then also capture and count it...still working on this and not sure it's possible! However I found this post useful and modified the code a little bit to run on the MSP430G2553, I have only tested it on a 1kHz test signal from my oscilloscope but seems to work and read 1009Hz consistently. Posted the code below so someone else might find it useful. #include <msp430g2553.h> /*** Global variables ***/ volatile unsigned int CounterValue = 0; volatile unsigned int StoredCount = 0; unsigned int Result = 0; int main(void) { /*** Watchdog timer and clock Set-Up ***/ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_8MHZ; // Set range DCOCTL = CALDCO_8MHZ; // Set DCO step + modulation /*** GPIO Set-Up ***/ P2DIR &= ~BIT0; // P2.0 set as input P2SEL |= BIT0; // P2.0 set to primary peripheral Timer1_A /*** Timer_A Set-Up ***/ TA0CCR0 = 20000; // 20000*400 = 8000000 or 8MHz TA0CCTL0 |= CCIE; // Interrupt enable TA0CTL |= TASSEL_2; // SMCLK TA1CCTL0 |= CCIE + CCIS_0 + CM_2 + CAP; // Interrupt enable, capture select CCIxA, Positive edge, capture mode TA1CTL |= TASSEL_2; // SMCLK _BIS_SR(GIE); // Enter LPM0 with interrupts enabled while(1) { TA0CTL |= MC0; // Start timer TA1CTL |= MC1; // Start timer while(CounterValue != 400); // Wait while CounterValue is not equal to 400 TA0CTL &= ~MC0; // Stop timer TA1CTL &= ~MC1; // Stop timer Result = StoredCount; // Store frequency in Result CounterValue = 0; // Zero CounterValue StoredCount = 0; // Zero StoredCount TA0R = 0; // Zero Timer_A0 register TA1R = 0; // Zero Timer_A1 register } } //Timer_A0 TACCR0 Interrupt Vector Handler Routine #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer0_A0(void) { CounterValue++; } //Timer_A1 TACCR0 Interrupt Vector Handler Routine #pragma vector=TIMER1_A0_VECTOR __interrupt void Timer1_A0(void) { StoredCount++; }
  11. @@Fred I have the DS1074Z great scope it definitely has the feature to be upgraded via software, so no doubt exploitable ;-). I am still in the trial time period so have the decoding and other features enabled. I have used the Saleae products though before and they are very good.
  12. Antscran

    Convert char to integer issue

    Hi all, Well my programming skills are not as good as most, but could you not use an itoa function to convert a char to an integer, by using a different base value. The itoa code I usually use is linked below by Lukas Chmela. So I guess this is more of a question than an answer, but by changing the int base value, would this not allow char to int conversion? http://www.jb.man.ac.uk/~slowe/cpp/itoa.html
  13. Antscran

    Alternate MSP430 RF boards?

    I should have one of these arriving soon, Bluetooth 4 http://www.anaren.com/sites/default/files/Part-Datasheets/A2541R24A_ADB1_Product_Brief.pdf
  14. Antscran

    Accelerometer reading problem

    Hi Pawnie, Firstly sorry to hear you had trouble with my code! I can see one thing I would change and this may help, but if not follow the further steps below. Move the last 4 statements in the Read_adc() function around as below, so the CPU is sent to sleep after the readings from the array are assigned to the variables X_Axis = adc[2]; // adc array 2 copied to the variable X_Axis Y_Axis = adc[1]; // adc array 1 copied to the variable Y_Axis Z_Axis = adc[0]; // adc array 0 copied to the variable Z_Axis __bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit The next things I would do is confirm the code is working correctly on the MSP430F2274. Your reading values as the adc[] array is initialised so those values are coming from somewhere, So what I propose is the following: 1) Connect the X ADC input reading to Gnd and you should get a 0 in CCS, then connect to 3.3V (I usually do this via a 1k resistor) to the ADC X input and you should then see something around 4095. You can repeat these steps for the Y and Z ADC connections. Assuming these read as expected pretty sure the code is working ok on the MSP430F2274. 2) What voltage ranges are you expecting from the Accelerometer? 3) Check the accelerometer voltage ranges by using a multimeter. If you are unsure of the range the datasheet should tell you, you can also note what the level values are then as well. 4) Also remember CCS updates the data at a slower rate than the microcontroller, it's default settings is every 500mS, you can reduce this to 100mS Pending on these test we can then see if we can solve this issue. Cheers, Ant
  15. Antscran

    Hello from UK

    Hi from Denmark, but I am a Brit
×