Jump to content

p2baron

Members
  • Content Count

    31
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    p2baron reacted to Fred in 43oh wins TI Community Highlight Award   
    Too shy to tell us yourself, @@bluehash? Well, I'll have to do it then!
     
    It looks like 43oh has won TI's Community Highlight Award. Definitely well deserved. This place has always been a great source of help and inspiration. Probably the reason why I use TI stuff rather than anyone else's.
     
    Well done.
  2. Like
    p2baron got a reaction from tripwire in [SOLVED] Is this code blocking suspend()/lpm4?   
    I think I've found the culprit with the help of this article: http://www.elevendroids.com/2013/06/code-recipe-reading-msp430-power-supply-voltage-level/
     
    If I add "ADC10CTL0 &= ~ENC;" to wiring_analog.c the problem is solved.
     
    i.e. 
    #if defined(__MSP430_HAS_ADC10__) ADC10CTL0 &= ~ADC10ENC; // disable ADC ADC10CTL1 = ADC10SSEL_0 | ADC10DIV_4; // ADC10OSC as ADC10CLK (~5MHz) / 5 ADC10CTL0 = analog_reference | // set analog reference ADC10ON | ADC10SHT_3 | ADC10IE; // turn ADC ON; sample + hold @ 64
  3. Like
    p2baron got a reaction from Fmilburn in [SOLVED] Is this code blocking suspend()/lpm4?   
    I think I've found the culprit with the help of this article: http://www.elevendroids.com/2013/06/code-recipe-reading-msp430-power-supply-voltage-level/
     
    If I add "ADC10CTL0 &= ~ENC;" to wiring_analog.c the problem is solved.
     
    i.e. 
    #if defined(__MSP430_HAS_ADC10__) ADC10CTL0 &= ~ADC10ENC; // disable ADC ADC10CTL1 = ADC10SSEL_0 | ADC10DIV_4; // ADC10OSC as ADC10CLK (~5MHz) / 5 ADC10CTL0 = analog_reference | // set analog reference ADC10ON | ADC10SHT_3 | ADC10IE; // turn ADC ON; sample + hold @ 64
  4. Like
    p2baron got a reaction from spirilis in [SOLVED] Is this code blocking suspend()/lpm4?   
    I think I've found the culprit with the help of this article: http://www.elevendroids.com/2013/06/code-recipe-reading-msp430-power-supply-voltage-level/
     
    If I add "ADC10CTL0 &= ~ENC;" to wiring_analog.c the problem is solved.
     
    i.e. 
    #if defined(__MSP430_HAS_ADC10__) ADC10CTL0 &= ~ADC10ENC; // disable ADC ADC10CTL1 = ADC10SSEL_0 | ADC10DIV_4; // ADC10OSC as ADC10CLK (~5MHz) / 5 ADC10CTL0 = analog_reference | // set analog reference ADC10ON | ADC10SHT_3 | ADC10IE; // turn ADC ON; sample + hold @ 64
  5. Like
    p2baron reacted to Fmilburn in [SOLVED] Is this code blocking suspend()/lpm4?   
    Hi @@p2baron,
     
    I'm glad you found the article helpful.  I looked at your code quickly and while I didn't see the problem, I have two questions:
    Does everything in the code work as you expect other than it doesn't go into LPM4 when you call suspend()?  Have you tried using debug mode in CCS to step through and see what is happening - e.g. suspend() is called and the variables awake, newMail, etc. are what you expect?  Lately I have been using CCS Cloud with Energia when I need debug and find it more convenient than using CCS on the desktop if I don't need to view memory or registers.
  6. Like
    p2baron reacted to jscrane in Interrupted: a library for low-power, low-latency sketches   
    Hi guys,
    I've been working on this for a while and I've written about it here: http://programmablehardware.blogspot.ie/search/label/interrupted
     
    Github is here: https://github.com/jscrane/Interrupted
     
    It now runs on Energia with msp430g2553.
     
    Feedback welcome!
    Steve
  7. Like
    p2baron reacted to spirilis in New Energia release 0101E0013 - 09/05/2014   
    NEW FEATURE folks will want to be aware of!
     
    For msp430 and lm4f (Tiva/Stellaris), there are three new ways to pause or halt the CPU-
     
    void sleep(uint32_t milliseconds);
    void sleepSeconds(uint32_t seconds);
    void suspend();
     
    and a complementary function: wakeup()
     
    For the lm4f/tm4c platform, these are mostly just placeholders that do not consume any less power than usual; in the future I'd like to explore the ARM's low-power features to make them workable.
     
    For msp430 though, the first two use LPM3 modes, and the third enters LPM4.
    Energia tests XT1 osc. fault on reset to see if a 32.768KHz XTAL is present; if so, ACLK is set to that and it's noted that ACLK is being driven at 32.768KHz.  If not, VLOCLK is used and its nominal frequency is assumed to be its speed.
     
    When sleep() is called, the WDT is reworked to fire every ~1.9ms (varies XT1 vs VLO) using WDT_ADLY_1_9 while incrementing millis() and micros() as accurately as it can (which isn't always accurate... particularly with VLOCLK).  Alas, it does give you true LPM3 mode!
     
    sleepSeconds() uses WDT_ADLY_250, which is a much more coarse sleep interval but allows the chip to spend a whole lot more time asleep.
     
    suspend() just runs LPM4.
     
    The catch here is that normally IRQs firing won't wake up the chip permanently, and since Energia occupies the ISRs with its own routines, it's not possible for a user's ISR (registered via attachInterrupt() or similar) to run __bic_SR_register_on_exit to cancel the LPM mode.
     
    Enter wakeup().  The wakeup() function sets a volatile global flag which signals to the sleep(), sleepSeconds() or suspend() function that sleep mode should be aborted.  Moreover, many of the ISRs have been reworked to check for a change in this flag after it executes the user's ISR in order to determine if it should run __bic_SR_register_on_exit(LPM4_bits) itself.  This allows the user's ISR to cancel LPM mode.
     
    These functions (sleep(), sleepSeconds(), suspend() and wakeup()) also exist on the lm4f/tm4c platform, they just don't use any particularly low-power modes yet.  But still, the code should port over, and it does give you as a programmer a simple way to "halt" the CPU or pause with the option of aborting it early.
     
    Also note, LPM3/LPM4 will cause any Serial input to be corrupt, since the SMCLK isn't running for the UART module to correctly detect the bits.  This isn't the case for the Tiva/Stellaris yet, but will be once we implement true low power modes over there.
     
    The wakeup() handler has been added to the I2C ISR handler too, so it is (in theory) possible to configure the chip as an I2C slave with the Wire library and then suspend() to enter LPM4, then wakeup() upon receiving a request, since I2C is clocked externally.  (I haven't actually tested this yet...)
     
    I never got around to adding these functions to the cc3200 port, but will do so by the next release (or maybe offer a patch for it in between).
    (I just added the suspend() and wakeup() stuff, all props go to @@energia for the sleep/sleepSeconds/ACLK implementation )
  8. Like
    p2baron reacted to energia in New Energia release 0101E0013 - 09/05/2014   
    I am happy to announce that release 0101E0013 just went up on http://energia.nu. This release adds support for the awesome CC3200 WiFi LaunchPad and CC3100 BoosterPack for MSP430 and TivaC.
     
    I want to thank everybody for their support and contributions. Energia would not have been possible without such an awesome community!
     
    Details of the release can be found on http://energia.nu
  9. Like
    p2baron reacted to zormino in Problem with Capacitive Touch Library   
    The millis() thing should still work, but it wont report time in milliseconds anymore. I timed it, and for each second in real time, millis() had incremented by 25. If you were waiting for half a second banking on millis() incrementing by 500, it will actually take 20 seconds. Im assuming the CapTouch library changes the clock frequency for whatever clock millis() was using.
     
    I too had the issues with the oscillation, but it would start almost as soon as I had touched the sensor (im using the capacitive sliders on the 430BOOST-SHARP96 as buttons, with a G2553). I think this was partly because the isTouched function would eventually start reporting inverted values. (if it was touched it would send a 0, not a 1). The way I got around this was to go into CapTouch.cpp, and comment out from line 93 to line 95, (the if (delta < 0) stuff), and comment out the base--; on line 98. Then in the code I'm writing I set the threshold to 1000. I havn't tested this to see if it works over extended periods though.
     
     
    I was also wondering if there was a plan to port the CapTouch library over to working on the fr5969?
  10. Like
    p2baron reacted to spirilis in Building low power into Energia   
    Yep.
  11. Like
    p2baron reacted to spirilis in Building low power into Energia   
    Never use it in an interrupt.  Prefer to do the heavy lifting in the main loop(), and I'm not even sure that delay() would work either (?) in the interrupts...
  12. Like
    p2baron got a reaction from spirilis in Building low power into Energia   
    @@spirilis thanks. I will handle that in the main loop,
     
    I basically want to stay in LPM3/4 mode all of the time except when an interrupt occurs. Do I need to have sleepsecond(xxx) in the main loop?
  13. Like
    p2baron reacted to energia in Building low power into Energia   
    I took a while but I finally got around to spend a couple of days looking at low power modes using the awesome feedback in this thread. The key of course is to not break any existing API's. That led to the introduction of a sleep() API. It's not fully baked yet but I have some interesting numbers below.
     
    1: Empty loop: 5.3 mA
    2: loop with delay(10): 800 uA
     
    That's pretty low power already if your code spends most of it's time in delay(). The new sleep API improves the current consumption significantly. Right now it uses the 32k crystal only but the idea is to fall back on the VLO if there is no XTAL. This will basically be done by looking at the oscillator fault bit. Sleep goes down to LPM3. You might ask, why not put LPM3 mode in delay(). This was the plan initially but it would potentially break to many Sketches if the user would not be aware of the change in behavior.
     
    3: loop with sleep(10): 30 uA
    This set WDT to wakeup every 2 milliseconds and hence the resolution is 2 milliseconds.
    4: loop with sleepSeconds(1): 1.3 uA measured with a FLUKE multimeter so I am positive that this is pretty accurate.
    This sets WDT to wakeup every 1 second. 
     
    You can also call delay with > 1000. It will call sleepSeconds() for the whole seconds and the sleep() for the remainder. The full seconds will draw 1.3 uA and the remainder 30 uA.
     
    To give some color to what this means in terms of battery live. I have an Anaren 900MHz wireless BoosterPack transmitting sensor data every 10 sec. The time it takes to transmit and the current draw associated with it can be neglected vs the time spend in LMP3. To take worse case let's say we consume 2.5 uA on average. With a CR2032 coin cell battery with a capacity of 225mA the sensor node can operate for 63000 hours or 2625 days or roughly 7 years :-) The battery live was calculated using the "battery life calculator" up on the Digikey website. This calculator already takes in account external factors that can affect battery life by applying a 0.7 multiplication.
     
    There is still plenty of room for improvement but I think this is pretty interesting already.
    Once sleep is implemented for all boards I will look at attachInterrupt() as suggested in this thread.
     
    Thanks for all the help and feedback!
     
    Robert
  14. Like
    p2baron got a reaction from jpnorair in To stop drolling in front of those Arduino Yun web pages...   
    Please note that the precompiled Openwrt binaries contains ACM drivers that contain a bug. When your MSP430 spits out serial messages before you open the serial port (in python or bash) the driver crashes and no communication is possible. Wasted a couple of hours figuring that out. :-(
    This isn't a problem when the OpenWRT devices initiates communication. You can fix this by modifying the drivers and compiling OpenWRT yourself.
     
    Verstuurd vanaf mijn HTC One met Tapatalk
     
     
  15. Like
    p2baron got a reaction from pine in To stop drolling in front of those Arduino Yun web pages...   
    Please note that the precompiled Openwrt binaries contains ACM drivers that contain a bug. When your MSP430 spits out serial messages before you open the serial port (in python or bash) the driver crashes and no communication is possible. Wasted a couple of hours figuring that out. :-(
    This isn't a problem when the OpenWRT devices initiates communication. You can fix this by modifying the drivers and compiling OpenWRT yourself.
     
    Verstuurd vanaf mijn HTC One met Tapatalk
     
     
  16. Like
    p2baron got a reaction from cde in To stop drolling in front of those Arduino Yun web pages...   
    Please note that the precompiled Openwrt binaries contains ACM drivers that contain a bug. When your MSP430 spits out serial messages before you open the serial port (in python or bash) the driver crashes and no communication is possible. Wasted a couple of hours figuring that out. :-(
    This isn't a problem when the OpenWRT devices initiates communication. You can fix this by modifying the drivers and compiling OpenWRT yourself.
     
    Verstuurd vanaf mijn HTC One met Tapatalk
     
     
  17. Like
    p2baron reacted to energia in Problems with CapTouch library   
    @@p2baron I have had the test running for 3 days straight now and am not able to reproduce it. The LED is still blinking and the touching the button still turns the middle LED on and off. I remember that there were some CapTouch boosterpacks that showed strange behaviour. I believe that the one I have on there right now is a good one. I will dig up one of the none behaving ones and restart the test.
     
    Below is a test sketch that reads the raw values. I hope this will show what is going on when things stop working. Would you please be so kind to load this Sketch and log the output when it goes into the weeds? This will print a lot of data. Best is to close the Serial terminal while the test is running and then open it when it goes into the weeds to see what values are printed.
    /* CapTouchRaw CapTouch library example for the capacitive booster pack http://www.ti.com/tool/430boost-sense1 This example demonstrates how to get the raw, delta and base sensor count and print them in the Serial monitor. Created 2012 by Robert Wessels from http://energia.nu This example code is in the public domain. */ #include <CapTouch.h> #define LEFT_BUTTON 10 #define MIDDLE_LED P1_0 /* Create a CapTouch instance for the left sensor */ CapTouch left = CapTouch(LEFT_BUTTON, TOUCH_BUTTON); uint16_t measured, base; /* Delta can be negative */ int16_t delta; uint8_t state; void setup() { /* Use middle LED as indicator */ pinMode(MIDDLE_LED, OUTPUT); Serial.begin(9600); } void loop() { state = left.isTouched(); digitalWrite(MIDDLE_LED, state); measured = left.getMeasured(); base = left.getBaseline(); delta = left.getDelta(); Serial.print("State: "); Serial.print(state); Serial.print("\tBase: "); Serial.print(base); Serial.print("\tMeasured: "); Serial.print(measured); Serial.print("\tDelta: "); Serial.println(delta); }
  18. Like
    p2baron reacted to energia in Problems with CapTouch library   
    Wild guess that it's a counter overflow that is not being taken into account. I'll look into.
  19. Like
    p2baron reacted to energia in Problems with CapTouch library   
    This could be hard to reproduce as it takes 20 hours.
    To narrow it down, can you run the following Sketch?
    #include <CapTouch.h> #define LEFT_BUTTON 10 #define MIDDLE_LED P1_6 uint8_t state = false; CapTouch left = CapTouch(LEFT_BUTTON, TOUCH_BUTTON); void setup() { /* Use the middle LED to indicate touch */ pinMode(MIDDLE_LED, OUTPUT); pinMode(GREEN_LED, OUTPUT); } void loop() { /* State will be 1 if any of the buttons was touched, otherwise 0 */ state = left.isTouched(); /* Turn on the LED if any of the buttons was touched */ digitalWrite(MIDDLE_LED, state); digitalWrite(GREEN_LED, HIGH); delay(100); digitalWrite(GREEN_LED, LOW); delay(100); } This will blink the GREEN_LED constantly. If after 20 hours the GREEN_LED is still flashing but the CapTouch button is no longer responding then we know it's not hanging in the CapTouch library. If the GREEN_LED did stop blinking then the isTouched() api hangs or worse case, the MSP430 went into the weeds all together.
     
    Robert
  20. Like
    p2baron reacted to f4dtr in Energia Cheat Sheet   
    Hi,
     
    I created a cheat-sheet for Launchpad, based on  http://www.cheat-sheets.org/#Arduino'>
  21. Like
    p2baron 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.
  22. Like
    p2baron reacted to zlalanne in [Energia Library] HTTPClient   
    Below is a link to the port of the Arduino Library HTTPClient for Energia/MSP430. It works with the latest version of Energia with F5529LP + CC3000 BoosterPack. Simply download/clone the library into the hardware/msp430/libraries folder of Energia and the library will appear upon restart.
     
    The library makes it easy to interact with web servers using Energia/MSP430. The included example shows how to download a webpage (energia.nu), check http response codes and display the content of the downloaded webpage.
     
    GitHub Link:
    https://github.com/zlalanne/HttpClient
  23. Like
    p2baron reacted to vinietje in [Energia Library] Ported RemoteSwitch to Energia   
    Hey All,
     
    I've ported the RemoteSwitch library to Energia, For now i've only teste the receiving part, which works.
     
    I've used the MSP430G2452 in accordens with the CZS-3 SAW receiver, all works on 432.93mzh Or 433.
     
    It it can be used to controll Action, Blokker and Klik-aan-Klik uit devices like power sockets, and receive the remote control presses.
     
    So far the sending part and the optional RemoteSensor I haven't touched (yet).
     
    the code is hosted on Github: https://github.com/vinietje/RemoteSwitchEnergiaPort
    Please note that i've written/run this code using a current git-checkout of Energia, rather than the energia-0101E0009-macosx.dmg build. (which appear to have a bug regarding external interrupts (which this port basically is all about).
     
    Have fun using it, and keep in mind: all credit to the original authors!
     
    Cheers
  24. Like
    p2baron reacted to energia in [Energia Library] Capacitive Touch library   
    [Edit: New library attached with a bug fix for CapTouch on port 1 in combination with Serial]
    Attached CapTouch.zip is a capacitive touch library for the MSP430. All examples are written for the capacitive touch boosterpack (http://www.ti.com/tool/430boost-sense1). If you do not have one of these then it's fairly simple to create a capacitive sensor from a bare piece of PCB. Just solder a wire to it and hook it up to one of the pins. The library is based on the relaxing oscillator method. Each of the MSP430 pins can be connected to the internal relaxing oscillator peripheral called PinOsc. The PinOsc is a comparator based relaxing oscillator that changes frequency based on a change in capacitance. The idea is to "measure" the capacitance by counting the number of relaxing oscillator cycles during a fixed amount of time. The time during which we measure is called the gate time. So we need a counter to count the number of cycles and a timer to set the gate time during which we count. In this case the watchdog timer in interval mode is used as the gate timer and the capture compare feature of Timer0 is used as the counter. To trigger a measurement, the watchdog timer is set to a certain gate time, the counter start running and the MSP430 is put into LPM3. When the watchdog triggers, the MSP430 wakes up and triggers the capture of the Timer0 counter.
     
    There is a lot more to it than this though such as baseline tracking, threshold, etc. If you would like to get to the details then I recommend reading the following literature:
     
    http://en.wikipedia.org/wiki/Relaxation_oscillator
    http://www.ti.com/tool/430boost-sense1#technicaldocuments
     
    There are 4 examples included in the library to show how to use the API's. To install the library, unzip the attached and copy it to a folder called libraries in you Energia Sketch folder. 
     
    API:
    Include CapTouch.h in your Sketch.
     
    CapTouch(uint8_t pin, uint8_t sensorType);
     
    Description:
    Creates a CapTouch instance and calculates the baseline.
     
    Parameters:
    pin: The pin to use as a capacitive touch or proximity pin.
     
    sensorType: This is either TOUCH_PROXIMITY for a proximity sensor or TOUCH_BUTTON for a button.
     
    void setThreshold(uint16_t threshold);
     
    Description:
    Sets the threshold that needs to be exceeded for the button to be considered as touched. See isTouched() for more details.
     
    uint16_t getBaseline();
     
    Description:
    Returns the the current baseline value of the last measurement of the untouched sensor. Note that a call to this library does not trigger a measurment.
     
    uint16_t getMeasured();
     
    Description:
    Returns the measured value of the last measurement of the sensor. Not that a call to this library does not trigger a measurment.
     
    int16_t getDelta();
     
    Description:
    Returns the difference between the baseline value and the las measured value. Note that a call to this function does not trigger a measurement.
     
    uint8_t isTouched();
     
    Description:
    If the the difference between the baseline (untouched sensor) and the measured value exceeds the threshold then the button is considered to be touched.
    A call to this function triggers a measurement of the sensor.
     
    Returns 1 if the sensor is touched otherwise 0.
     
  25. Like
    p2baron got a reaction from bluehash in [Energia library] x10rf   
    I've used the cheap (3$) ebay module shown in below. With perhaps a little tweaking on the timing this library should also work voor 315Mhz version.  Haven't tried this.
     

     
    I still need to update the library. It would be nice to support receiving X10rf messages and the delay functions need to be replaced by non-block code.
    Currently I am using a RfxCom USB transceiver to receive X10 messages for home automation in Domoticz.
×
×
  • Create New...