Jump to content

yosh

Members
  • Content Count

    207
  • Joined

  • Last visited

  • Days Won

    14

Reputation Activity

  1. Like
    yosh reacted to grahamf72 in low power mode first sketch   
    A basic sketch could look something like the following:
    void setup() { pinMode(P1_3,INPUT_PULLUP); //Enable inputs on P1_3 (onboard button) pinMode(P1_0,OUTPUT); //Enable output on P1_0 (onboard red LED) attachInterrupt(P1_3,Interrupt, FALLING); //attach our interrupt routine to P1_3 } void loop() { LPM4; //whenever the loop runs, switch back into LPM4 //we could put code here that would run after every Interrupt - see warning in text. } void Interrupt(void) //Our interrupt routine { digitalWrite(P1_0,!digitalRead(P1_0)); //toggle the red LED };   The above code will toggle the onboard red LED everytime the button is pressed.
     
    The code goes through the normal setup routine, which is pretty self explanatory. When it goes into the loop the first thing it gets is the command to switch to Low Power Mode 4. The processor now goes into a deep sleep until an interrupt occurs.  When you press the button, the processor wakes up and executes the code in the Interrupt() function - in this case just toggling the red led.  After the interrupt finishes, the processor should go back into sleep, however Energia has a timer that handles things like millis() that also wakes up with the return from the interrupt. This timer calls an interrupt, which leaves the processor running when it finishes. The processor will continue to run from the next command after LPM4 in loop(). In the above example, there is no more code, so loop() will start again, it gets to the LPM4 instruction and goes to sleep.
     
     
    If you will be using low power modes, I recommend going into the Energia "cores" folder, finding the file WInterrupts.c, and adding the command "LPM4_EXIT;" to the end of each of the interrupt handlers in that file. This will guarantee that the processor will always be left in the "awake" state after an interrupt runs, and doesn't make it dependent on Energia's timer. Without this change, if for some reason Energia's timer was stopped when you go into LPM4, there is no way to leave the processor awake after an interrupt.
     
    To minimize current consumption, you should also configure any unused pins as INPUT_PULLDOWN.  From the tests I have done, configuring all pins to INPUT_PULLDOWN will reduce current to below 0.1uA (on my meter it flickers between 0 and 0.1). Configuring unused pins to INPUT_PULLUP or OUTPUT will result in the meter showing a consistent 0.1uA, while leaving the pins at their default (equivalent to INPUT) resulted in random current consumption in the 200-500uA range.
  2. Like
    yosh reacted to Druzyek in RPN Scientific Calculator   
    Overview
    This is a scientific calculator I built that uses RPN notation. Features:
    BCD number format with 1-255 places Internal accuracy configurable from 6 to 32 decimal places Two separate 200 level stacks Optional scientific notation Functions: (a)sin, (a)cos, (a)tan, y^x, x root y, e^x, ln, 10^x, log, mod 20x4 character LCD 42 buttons The source code is available on https://github.com/druzyek/RPN_Calculator.
     

     
    Software
    The interface shows 4 levels of the stack, similar to some HP calculators. While I was writing the code for BCD calculations, I used a console program to test the routines. You can download it from GitHub if you want to test out the functionality: rpnmain_pc.c It will compile for Windows if #WINDOWS is defined or for Linux with the ncurses library if #LINUX is defined.
    On Windows: gcc -o rpncalc.exe rpnmain_pc.c On Linux: gcc -lncurses -o rpncalc rpnmain_pc.c Numbers are stored in unpacked BCD format on an external SRAM chip. I wanted to access this memory using variables but there is no convenient way to do this since every variable requires a function to access it. A simple functions like:
    X+=Y*Z-Q; would become something like this (assuming we are passing pointers):
    RAM_Write(X,RAM_Read(X)+(RAM_Read(Y)*RAM_Read(Z)-RAM_Read(Q)); To simplify things, I wrote a preprocessor program that looks for any variables that need to be stored in external RAM and converts access to them to function calls. External variables are all stored as pointers, so the PC version will work exactly the same with or without the preprocessor. To mark variables as external, #pragma directives are used. These are usually ignored by the compiler if they are not recognized, so they are a convenient way to communicate with the preprocessor. Here is an example:
    //Before processing void puts(unsigned char *msg) { #pragma MM_VAR msg for (int i=0;msg[i];i++) putchar(msg[i]); } int main() { #pragma MM_OFFSET 200 #pragma MM_DECLARE unsigned char text1[30]; unsigned char text2[30]; #pragma MM_END text1[0]='A'; text1[1]=0; puts(text1); } //After processing void puts(unsigned char *msg) { #pragma MM_VAR msg for (int i=0;RAM_Read(msg+i);i++) putchar(RAM_Read(msg+i)); } int main() { #pragma MM_OFFSET 200 #pragma MM_DECLARE unsigned char *text1=(unsigned char*)200; unsigned char *text2=(unsigned char*)230; #pragma MM_END RAM_Write(text1+0,'A'); RAM_Write(text1+1,0); puts(text1); } The trig and log functions are computed using CORDIC routines. This is a very efficient way to compute these functions for processors that cannot multiply or divide quickly. Instead, a lookup table is used with adds and shifts, which are much faster. I was able to speed the shifting up even more by using another lookup table that let me right shift 4 digits at a time. One way to measure the accuracy of calculations is with the calculator forensic found here: http://www.rskey.org/~mwsebastian/miscprj/forensics.htm. After setting accuracy to 24 places arcsin(arccos(arctan(tan(cos(sin(9)))))) evaluates to this:

     
    The settings page allows the accuracy to be set from 6 to 32 decimal places. With the default of 12, trig functions calculate in about a second. With 32 decimal places calculations take 3-4 seconds. After setting the accuracy, the program finds the largest element in the CORDIC table that is still significant, so that no time is wasted on elements that have no effect on the answer. The settings page also shows the current battery charge.

     
    When I began this project I wasn't sure how much I could fit into 16kB of firmware space. In the end it grew bigger than this and I had to use two MSP430s to hold everything. Part of this is due to all of the functions used to access external memory. The interface code also added a lot more to the size than I expected but I was able to add checks for most of the functions and add some meaningful error messages.

     
    Hardware
    My design uses two MSP430G2553s connected over UART. One of them (the master) reads the keyboard matrix, updates the LCD, and manages the interface. The other is connected to the data lines of 128k of parallel SRAM and does all of the calculating. The address lines of the SRAM are driven by two 74HC595 shift registers controlled by the second MSP430. The 17th address pin is controlled by the first MSP430 and allows the program to switch between two separate stacks. Here is the schematic: 

     
    The keypad is formed from 42 tactile buttons arranged in a 6x7 matrix and read with a 74HC165 shift register by the master MSP430. The LCD and keyboard share the same pins since they are never used at the same time. Here is the layout of the keys.

     
    The LCD is an HD44780 compatible 20x4 character LCD. It is rated for 5v but the logic works fine at 3.6v. The contrast needs to be close to 5v for anything to show up on the screen, so I used a 555 timer and some diodes to supply around -1.2v to the contrast pin. The result is very solid and clear.
     
    The calculator runs on four AA batteries regulated by an LM1117 configured to supply around 3.5 volts. To run at 16MHz the MSP430s need at least 3.3 volts. The wiggle room between the two voltages will let me see when the batteries are starting to wear down. By the time the voltage gets down to 3.3v, the batteries will be down to 1.15v or so, which can be considered dead.
     
    The PCB is made from perfboard. The top of the board contains female headers so that the keyboard and LCD can be unplugged. Part of the board had to be cut away so that it will fit in the case with the batteries. Although it is quite small, I ended up using over three meters of wire.

     
    The case is soldered out of copper clad. I used a lot of solder on it and it feels very sturdy. I will give it a coat of paint tomorrow before assembling everything.

  3. Like
    yosh got a reaction from cubeberg in PCB Give Away   
    EDIT: All PCBs found a new home - thanks :-)
     
    Hi,
     
    I have some spare PCBs I would like to give away for free. I will send three kits (each containing six PCBs, see attached image) for free inside the European Union.
     
     
     
    The green PCBs are stackable, 45x45 mm. One PCB is for the MCU, and the other two are proto boards. You could power the board by a CR2032 battery or use a LDO voltage regulator (MCP1702-3302). The header rows left and right are for stacking the boards, the lower one is for a Nokia 5110 LCD breakout.
     
     
     
    The black PCBs in the middle (35x35 mm) are stackable too. The lower header is for the I2C SSD1306 OLED (http://imall.iteadstudio.com/display/graphic-lcm/im130625003.html)

  4. Like
    yosh got a reaction from simpleavr in PCB Give Away   
    EDIT: All PCBs found a new home - thanks :-)
     
    Hi,
     
    I have some spare PCBs I would like to give away for free. I will send three kits (each containing six PCBs, see attached image) for free inside the European Union.
     
     
     
    The green PCBs are stackable, 45x45 mm. One PCB is for the MCU, and the other two are proto boards. You could power the board by a CR2032 battery or use a LDO voltage regulator (MCP1702-3302). The header rows left and right are for stacking the boards, the lower one is for a Nokia 5110 LCD breakout.
     
     
     
    The black PCBs in the middle (35x35 mm) are stackable too. The lower header is for the I2C SSD1306 OLED (http://imall.iteadstudio.com/display/graphic-lcm/im130625003.html)

  5. Like
    yosh got a reaction from reaper7 in PCB Give Away   
    EDIT: All PCBs found a new home - thanks :-)
     
    Hi,
     
    I have some spare PCBs I would like to give away for free. I will send three kits (each containing six PCBs, see attached image) for free inside the European Union.
     
     
     
    The green PCBs are stackable, 45x45 mm. One PCB is for the MCU, and the other two are proto boards. You could power the board by a CR2032 battery or use a LDO voltage regulator (MCP1702-3302). The header rows left and right are for stacking the boards, the lower one is for a Nokia 5110 LCD breakout.
     
     
     
    The black PCBs in the middle (35x35 mm) are stackable too. The lower header is for the I2C SSD1306 OLED (http://imall.iteadstudio.com/display/graphic-lcm/im130625003.html)

  6. Like
    yosh reacted to simpleavr in M-Clock build, M for Minimalist, Multi-mode or Matrix   
    Are we voting for this round of POTM soon?
     
    Time to reveal my Easter Egg "game" for upvotes. 
     

     
    Source code now host on github. https://github.com/simpleavr/mclock
  7. Like
    yosh got a reaction from energia in Unable to retrieve complete NMEA string from serial communication   
    @@Samanvai
     
    Yes it's true that you have to take care of RAM, but I think that would only be a problem if you want to process a lot of GPGSV sentences (and store them temporary). My problem was the flash memory (Binary sketch size: 16.177 bytes (of a 16.384 byte maximum)), because I'm using a pretty large OLED driver lib.
     
    Back to GPS: if you only need LON and LAT, I would go with tinyGPS and parse GPGGA and/or GPRMC sentence - both sentences contain LON and LAT and they are already included in the tinyGPS lib. The only things I did on the tinyGPS lib was to delete functions I don't need and modifying the "cardinal"-function for my needs. As far as I can remember, the lib and the arduino sketch worked in Energia without any changes.
     
    Now some code:
    #include <TinyGPS.h> TinyGPS gps; void setup() { ... Serial.begin(9600); //Initial baud rate of GPS is 9600 //Serial.println("$PMTK251,57600*2C"); Serial.println("$PMTK251,115200*1F"); //set to 115200 for 10Hz update rate Serial.begin(115200); //switch to 115200 Serial.println("$PMTK314,0,1,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*2C"); //only GPGGA and GPRMC sentences, see MTK3329/3339 Data sheet Serial.println("$PMTK220,100*2F"); //10Hz update rate ... } Simple example for showing the speed:
    bool newData = false; void loop() { // Parsing data for (unsigned long start = millis(); millis() - start < 85;) //85ms is a good value for 10Hz update rate - may be do some tests to find the optimal timing { while (Serial.available()) { char c = Serial.read(); if (gps.encode(c)) { // newData gets "true" when you have a fix and valid data (see GPRMC validity in tinyGPS.cpp) newData = true; } } } if (newData) { oled.set_cursor(0, 3, XL_FONT); oled.write("%3i",(int) gps.f_speed_kmph()); //display speed on OLED - change this to your needs (Serial output / LCD / ...) } } You can get LON and LAT with:
    gps.get_position(&lat, &lon, &age); So I think most of the tinyGPS examples you will find around the web will work without changes.
     
    Links:
    MTK Command Set
    Online Checksum Calculator
    Adafruit Tutorial
     
    There is also an Adafruit GPS lib here
     
    Kind regards
    yosh
  8. Like
    yosh reacted to jazz in F5529 - Question regarding maximum system clock   
    No, there is no 25 MHz crystal on LP, or any other TI board. On MSP430F5529 LP XT2 is 4 MHz only (on FET and target device).
  9. Like
    yosh reacted to spirilis in F5529 - Question regarding maximum system clock   
    No you don't need XT2; the internal DCOCLK can ramp up that high.  What these MSP430F5xxx series chips have is an FLL circuit that takes a lower speed crystal -- such as the 32.768KHz XT1 -- and multiplies it by some factor and then uses it as a reference to auto-trim the DCO.  So you can tune it up to 25MHz using the FLL.
     
    For what it's worth, on another MSP430F5 series (MSP430F5172) I've used this technique to trim the DCO up to 56MHz ... It crashed consistently above that but I was able to get a simple LED blink loop working perfectly at 56MHz :-)
     
    Likewise, you could say the DCOCLK can physically go up to 130MHz I think (datasheet has the spec for that) ... but the rest of the system silicon won't be guaranteeingly "stable" above 25MHz.  So 25MHz is the maximum safe speed.
  10. Like
    yosh reacted to Rei Vilo in Help me port energia to msp430f2274   
    You need to define the pins of the MCU with a specific energy_pins.h file and adapt the core libraries.
  11. Like
    yosh got a reaction from alibaba in sensor interface with launchpad msp430 using energia   
    I made a circuit of 4 load cells using a INA129. I use 3.3V as excitation voltage and power for the G2452 - no problems. You can easily adjust the (maximum) output voltage of the INA129 by choosing an appropriate trim potentiometer as the gain resistor.
    What kind of load cell are you using?
     
    Edit: Added Image.
     
     

  12. Like
    yosh got a reaction from dubnet in Hello from Germany   
    Hi,
     
    after following this forum for quite a while, I think it





  13. Like
    yosh reacted to Thorvard in MSP-EXP430F5529LP Out-of-Box Demo for Energia?   
    Hi everyone,
    has anyone successfully ported the Out-of-Box Demo (emulStorageKeyboard) that came with the F5529 Launchpad to Energia?
     
    Especially the storage emulation part interests me, cause i intend to use the F5529 Launchpad with the CC3000 as an embedded Webserver and uploading images and html pages to the usb storage qould be quite comfortable.
     
    best regards,
    Nick
  14. Like
    yosh got a reaction from zeke in RTFM - Read The Fabulous Manual   
    May be some thoughts of a beginner in the field of MCUs / MSP430:
     
    I think for beginners it's sometimes very hard to get the piece of information you need out of a bunch of datasheets, family guides, erratas, google search results, forum entries ... often it is simply to much of everything, but the advice of an experienced developer could lead to the answer in seconds. But I think by now this is not only a problem in the field of embedded programming, but in all kinds of "sciences"...
     
    I also agree with roadrunner84 regarding asking questions. Beginners (like me) often formulate their questions too vague. John Skeet (don't know how much he is known outside the .net/Java/StackOverflow-World) made I nice post on "writing the perfect question" http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx. I think we as beginners should ask more precise, like: What is the Problem? / What have I done/tried/read so far? / Showing relevant(!) code / and so on ... I will try to follow that more when asking my next question ;-)
  15. Like
    yosh got a reaction from roadrunner84 in RTFM - Read The Fabulous Manual   
    May be some thoughts of a beginner in the field of MCUs / MSP430:
     
    I think for beginners it's sometimes very hard to get the piece of information you need out of a bunch of datasheets, family guides, erratas, google search results, forum entries ... often it is simply to much of everything, but the advice of an experienced developer could lead to the answer in seconds. But I think by now this is not only a problem in the field of embedded programming, but in all kinds of "sciences"...
     
    I also agree with roadrunner84 regarding asking questions. Beginners (like me) often formulate their questions too vague. John Skeet (don't know how much he is known outside the .net/Java/StackOverflow-World) made I nice post on "writing the perfect question" http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx. I think we as beginners should ask more precise, like: What is the Problem? / What have I done/tried/read so far? / Showing relevant(!) code / and so on ... I will try to follow that more when asking my next question ;-)
  16. Like
    yosh reacted to Rei Vilo in [Energia Library] I   
    I'm not using any capacitor for filtering. 
     
    I compared the results of the INA219 to those provided by my digital multimeter.
     
     
    To define and set the right parameters for a 1? shunt, use the excellent configuration tool provided by Texas Instruments at the INA219 product page.
     
    Link: INA219EVM Software (ZIP 3636 KB )   11 Sep 2008 - Windows only
     
    Once again, the http://www.ti.com/lit/gpn/ina219'>Zer
  17. Like
    yosh got a reaction from roadrunner84 in 400kHz I2C on G2553 with Energia?   
    Hi,
     
    unfortunately no - it seems that defining TWI_FREQ at the top of my sketch or in the OLED-library has no effect.
     
    Kind regards
    yosh
  18. Like
    yosh reacted to Rei Vilo in 400kHz I2C on G2553 with Energia?   
    As for Arduino http://forum.arduino.cc/index.php?topic=16793.msg122226#msg122226'>Faster I
×
×
  • Create New...