Jump to content
43oh

sirri

Members
  • Content Count

    161
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    sirri reacted to xv4y in Real-Time Clock (RTC) Library for the MSP430/LaunchPad   
    Hi Graham,
     
    Sorry but I just came to read your message.
    I have been busy those last days working, and now it is New Year holidays and my two children are at home wanting me to spend some time with them.
    I will try to have a look at what you have done and then publish "our" library on my website.
    It could be in more than a week unfortunately but I will try to do it ASAP.
     
    I am currently writing a logger weather station.
    However I prefered to use an Arduino Nano with one DS1307 module because :
    - the ATMega328 as 1k EEPROM for saving measurements
    - it has 2ko RAM allowing me to use a cheap NC28J60 ethernet chipset for the web server
    - the DS1307 module is battery saved
     
    I use a MSP430G2452 for the remote sensor.
     
    You can have a look at the prototype (missing daily saving points for weekly and monthly trend statistics) here :
    http://cairang.radioclub.asia:8080
     
    Wishing you happy new year of the Snake.
    Regards,
    Yan.
  2. Like
    sirri reacted to mbeals in light alarm clock project using msp430   
    You are correct.
  3. Like
    sirri reacted to mbeals in light alarm clock project using msp430   
    Pull the RST jumper too.  There are hold up resistors on the RST line on both sides of the header.  So with VCC pulled, the RST line is still holding the emulation side's VCC rail high.
  4. Like
    sirri reacted to roadrunner84 in light alarm clock project using msp430   
    Let's de-goto this baby first:
    And get code indentation right:
    void buzzerbaslatma(void) { while(1){ buttonState33 = digitalRead(buttonPin3); /*if(buzzermode=!0) { tone(speakerOut, 600); } else { noTone(speakerOut); }*/ if ((buttonState33 != old33) &&(buttonState33==0)) { noTone(speakerOut); alarmonoff=0;snz=1; for (int jk=0;jk<150000;jk++) { int jk2=map(jk,0,150000,255,0); analogWrite(powerled1,jk2); if(jk2==1) { break; } } digitalWrite(powerled1,LOW); ledbrightness=0; return; } else { old33=buttonState33; } ledyazdir(16,1); //N ledyazdir(0,2); // 0 ledyazdir(0,3); // 0 ledyazdir(0,4); // 0 switch(buzzermode) { case 0: noTone(speakerOut); break; case 1: tone(speakerOut, 300,500); break; case 2: tone(speakerOut, 600,500); break; case 3: tone(speakerOut, 600,500); break; } //tone(speakerOut, 600); digitalWrite(powerled1,HIGH); } } You write "else { old33=buttonState33; }", why do you keep track of old33? If the condition is true, you will jump out of the function anyway, so you're guaranteed that old33 is 1, given that the loop is executed at least once.
     
    I totally forgot to ask? What is the problem you have with this code?
  5. Like
    sirri reacted to roadrunner84 in light alarm clock project using msp430   
    That's a huge slab of code!
     
    I have some questions (although I cannot read your comments)
    (((sayi%1000)%100)%10)%1) a number divisibe by 10 is also divisible by 100 or 1000 (as 100/10 is a round number, so is 1000/10), so you can drop de %1000 and %100 when doing %10 also. Any integer number is divisible by 1, so %1 will alwaysd result in the value 0.
    eskisayac1=millis(); eskisayac2=millis(); eskisayac3=millis(); eskisayac4=millis(); eskisayac5=millis(); why are you loading all variables with the result from the same function? In this case you'll execute the function five times, while one time would probably suffice
    eskisayac1=millis(); eskisayac2=eskisayac1; eskisayac3=eskisayac1; eskisayac4=eskisayac1; eskisayac5=eskisayac1; // or even more compact eskisayac1=eskisayac2=eskisayac3=eskisayac4=eskisayac5=millis(); You're dividing in comparison, but divisions are way more expensive than multiplications.
    t2>(a2+(2*(b2-a2)/3)) // instead of dividing by 3, multiply the other side by 3 (t2*3)>(a2*3+(2*(b2-a2))) // you're doing a certain amount of a2 minus anoter amount of a2 (t2*3) > (a2*3 + (2*b2 - 2*a2)) (t2*3) > (a2*3 + 2*b2 - 2*a2) // a2*3 - a2*2 = a2*1 (t2*3) > (a2 + 2*b2) // these should all five result in the same outcome, but the last saves you the most code space and the mose clockcycles. These kind of optimisations can save you a lot of code space, so you could maybe even fit it in a smaller chip or save more power.
    h
  6. Like
    sirri reacted to roadrunner84 in Real-Time Clock (RTC) Library for the MSP430/LaunchPad   
    I'f you're having a lot of local variables (those declared inside functions) you might run out of stack space, on IAR the stack is by default defined at 50 bytes, of which most function calls eat at 2 to 10, excluding local variables. so if you have a loop() calling function1() calling function2() calling delay() you have a call depth of 4, which means your functions cannot exceed 10 bytes of stack space on average or you'll run out of stack when an interrupt occurs. Your compiler or run time will not complain, but you might overwrite global variables without intention!
  7. Like
    sirri reacted to grahamf72 in Real-Time Clock (RTC) Library for the MSP430/LaunchPad   
    If you are using this RTC library, in most cases it will not be affected by delay().
     
    It is best practice to not have any code that calls delay() inside the Timer Interrupt Function. Short delays will work ok, but if the delay is long enough that the timer will trigger again before you have finished handling the previous interrupt, you will very quickly run out of RAM. If using my version of the RTC library and with #define RTCSUBSECONDS turned on, your interrupt routine must run in less than 3 milliseconds. This doesn't give scope for using delay() - your interrupt needs to just increment the clock counter & get out.
     
    If however you are using delay() in other sections of code outside the Timer Interrupt function it won't have any effect on the accuracy of the timer. The RTC library requires you to create an interrupt function, which is configured to trigger based on ACLK - either once per second or 256 times per second (depending on if you use #define RTCSUBSECONDS). Energia also sets up an interrupt based on the SMCLK that is called 31250 times per second. This interrupt is used to increment an internal counter that is used for the millis() function. When you call delay(), it simply starts a loop in LPM0 that waits until the specified number of millis() have elapsed. This loop doesn't stop the ACLK interrupt from running, so if the RTC's ACLK interrupt triggers whilst inside the delay() function, it will run and update the RTC as per normal.
     
    So for example the following code will work as per normal...
    #include <RTCplus.h> RealTimeClock rtc; setup(){ rtc.begin(); }; loop(){ delay(5000); // put code here to do something useful - eg print the value of the RTC. // this code will only run approximately once every 5 seconds // but when it does run, the RTC will be accurate. }; interrupt(TIMER1_A0_VECTOR) Timer(void) { rtc.Inc(); // While we can do some other things inside the interrupt other than just increment the // timer, care needs to be taken with how long the routines used here take to run. It is // best to just increment the timer and not do much else. };
    But the following code will crash - it will run out RAM because the Timer keeps getting called before it has finished running.
    #include <RTCplus.h> RealTimeClock rtc; void setup(){ rtc.begin(); }; void loop(){ }; interrupt(TIMER1_A0_VECTOR) Timer(void) { rtc.Inc(); delay(5000); // bad practice to call delay, or run any other code that will // take a long time to execute, inside the interrupt routine. // If the delay is still running when the interrupt next triggers // we will ultimately end up running out of RAM, because of all // the interrupt calls getting put on the stack. // other time consuming code here - bad. };
  8. Like
    sirri reacted to roadrunner84 in Real-Time Clock (RTC) Library for the MSP430/LaunchPad   
    If you say delay, you mean a delay_cycles or delay_ms type of wait routine?
     
    In that case, yes, it does affect your clock accuracy, as you could at best time the period between two executions of your loop. This means that, for example, you'd wait one second and then execute some clock display refresh routine that takes 1 millisecond. This means that every loop iteration will take 1.001 second. So after 3600 seconds (one hour) you'll be off by 3.6 seconds.
    This will be even worse if you use interrupts, as the delay routine will just continue where it was interrupted. So if you have an interrupt that takes 50 microseconds executed four times per second, it will enlongate your loop iteration by 4 * 0.05 = 0.2 milliceonds. The whole iteration will now be 1.0012 seconds, and you'll be off by 4.32 seconds.
    And the nack with interrupts is, you never exacly know when they'll happen, so you cannot compensate for them.
  9. Like
    sirri reacted to grahamf72 in Real-Time Clock (RTC) Library for the MSP430/LaunchPad   
    I'd just like to point out that Yan (xv4r) did all the hard work with the code, I just tracked down the cause of the timing bug in Energia 9, and tweaked it a little to make it more suited for a couple of uses that I have for it. I still consider it his library, not mine.
     
    Other than the attachment to the posts in this thread, I haven't set up webpage where it is available for download. Yan you are more than welcome to place it on your website, since it is 90% your work anyway. From experiments I've done with it, if dates are turned off, the resulting library compiles to be exactly the same size as your original library - which is proof that it is your work, not mine.
     
    Although I won't take much credit for the library, if people do find it useful I would love a PM with a brief rundown of your project.  At the moment I am using it in a clock connected to a 16x2 LCD, where it has run for a couple of weeks and is still within a second of my desktop computer.  I have two plans for projects that will implement this code. One is a logging weather station and the other is a "word clock" - the type that highlights different words to indicate the time.
  10. Like
    sirri reacted to pivden in Real-Time Clock (RTC) Library for the MSP430/LaunchPad   
    grahamf72, nice work!
    about code size: #include <RTCplus.h> RealTimeClock myClock; void setup() {  myClock.begin(); } void loop() {} interrupt(TIMER1_A0_VECTOR) Tic_Tac(void) {  //myClock++;    //Binary sketch size: 867 bytes (with RTCSUBSECONDS), 585 bytes (w/o RTCSUBSECONDS)  //++myClock;    //Binary sketch size: 593 bytes (with RTCSUBSECONDS), 563 bytes (w/o RTCSUBSECONDS)  //myClock.Inc(); //Binary sketch size: 579 bytes (with RTCSUBSECONDS), 549 bytes (w/o RTCSUBSECONDS) };  
    I optimised the LiquidCrystal library that is included with Energia for 4bit mode (minimal optimization -214 bytes). 
     
    P.S. grahamf72, You can post LIb into Energia Libraries
  11. Like
    sirri reacted to igendel in light alarm clock project using msp430   
    Nice! You should have turned on the room lights just for a minute, so we could see the hardware setup too :-)
  12. Like
    sirri reacted to simpleavr in light alarm clock project using msp430   
    it looks like your multiplexing is leaking and there are shadowing segments. they became recognizable when u turn the lights (room light) down. u may want to look at the sequence when u turn port pins / directions on and off.
  13. Like
    sirri got a reaction from bluehash in light alarm clock project using msp430   
    After many hours of working on displays,buttons, menu systems and so on, here is my result work.
    (The clock somehow lags significantly up to 5 minutes in about 6 hours) But i haven't try the new RTC library yet. Maybe that fixes this issue. I have to fix that and also i will make the PCB and external voltage supply for the launchpad etc. The system works as i want for now. I can set the clock (standalone), set the alarm time, set the light modes (i made three modes: light fades in 10 minutes earlier gradually, 20 minutes and 30 minutes earlier)
    buzzer works if you set it at just at the alarm time.. i made some modes but i wish i could use some melodies (but i am too tired of working at the same project for a long time now : ))
     
    it also shows current temperature and if it is out of your desires min and max. it says it is COLD or HOT on the main loop. You can set the min and max temperature values in the settings menu. It shows the alarm time as well on the main loop, if alarm is set ON.
     
    I have used three buttons for this project. up/down buttons and a set button. 
    One last note is that finished work will have three 1W power leds.
     
    Here is the video of my work,
    Sirri
     
    Critics are welcomed 
     

     
    edit: the setup photo is added
     
     
     

  14. Like
    sirri reacted to roadrunner84 in light alarm clock project using msp430   
    IS the display as hard to read in real life as it is on the video? Maybe you should up your refresh rate?
  15. Like
    sirri reacted to cde in light alarm clock project using msp430   
    Add in a vibration/shaker motor output for those who need that extra push in the morning.
  16. Like
    sirri reacted to grahamf72 in Real-Time Clock (RTC) Library for the MSP430/LaunchPad   
    I discovered I actually had the stray dot in my documentation - oops!! sorry.
     
    I haven't found as much difference in compilation size as you are getting. I am only finding 36 bytes difference between directly calling Clock.Inc_sec() and using Clock++ but given that every byte is precious, I have updated my library to create an inline function Inc() which calls Inc_sec() or Inc_chunk() depending on the tick size. I have left the ++ operators in so you can still use them if you wish - the compiler is smart enough that the ++ operators don't create any overhead if you don't use them.  
     
    Attached is the latest version of my RTCplus library, with the Inc function and corrected documentation. I have also removed the documentation from the .cpp file and put it all in the .h file, it makes it easier for me to not have to keep two sets of the same stuff synchronised.
     
    I am curious about this optimised LCD1602 4 bit library you mention. I have been using the LiquidCrystal library that is included with Energia. Where did you find this 4 bit optimised library?
    RTCplus.zip
  17. Like
    sirri got a reaction from jsolarski in humor: iran space program   
    look at the photo. do you think it is launchpad powered? : )
     
     

  18. Like
    sirri reacted to grahamf72 in Real-Time Clock (RTC) Library for the MSP430/LaunchPad   
    Attached is my modified version of Yannick's RTC library.
     
    The main changes I have made are that it also does dates, and allows either 1 second or 1/256 second resolution.  To avoid code bloat for features you don't need, these features are controlled by editing the header file to comment out / uncomment some #defines. Hopefully a future release of Energia will allow specifying -D defines that get passed to the compiler, avoiding the need to edit the header file.
     
    The features that I have are:
    #define RTCSUBSECONDS
    When RTCSUBSECONDS is defined, the library generates ticks every 1/256 of a second. This is the same timing that Yannick's library used. Useful if you need fractional second resolution.  If this is turned off, the library will tick once every second. 
     
    #define RTCWITHDATE
    Fairly self explanatory - this turns on date features in addition to the time.  Basic leap year detection is included, however it will get leap years wrong in century years, so in the unlikely event your project will still be around in 2100, this will not work correctly for you.  No effort is made to account for leap-seconds.
     
    Also changed from Yannick's code, the Inc_sec, Inc_min, Inc_hour etc functions have been made public. I use this to allow user adjusting of the values (press a button to increase the hour etc).
     
    For smallest code size, comment out the #define lines for RTCSUBSECONDS and RTCWITHDATE.  With RTCSUBSECONDS turned on, and RTCWITHDATE turned off, the code size is exactly the same as what I was getting with Yannick's library - reflecting the fact that the code is basically identical.  
     
    Full documentation of how to use the library is included in the header file. Please let me know if you find any bugs / problems etc or need any guidance in using the library.
    RTCplus.zip
  19. Like
    sirri reacted to yyrkoon in (error = 57) on Energia   
    sirri, another thing to consider. Whilst I was outside splitting wood, I remembered a problem I've had in the past with Windows 7 x64. If you suspend, or hibernate  then swap out USB devices between power downs. The OS sometimes Wont recognize the change and cause problems until you completely soft boot the system.
     
    No idea if you're using hibernate or suspend, but there you have it.
  20. Like
    sirri reacted to yyrkoon in (error = 57) on Energia   
    If you google "Could not find MSP-FET430UIF on specified COM port" you'll find many hits all over the TI e2e forums, with many replies from TI employees. Granted, it seems many or even all are concerning CCS, but should not be exclusive to CCS only in fixes.
     
    For example, one fix was to disable / kill various processes that were interfering with the USB port functionality. 
     
    EDIT: Also as grahamf72 hit on, various COM port related applications can interfere with programming the launchpad. Such as terminal apps like puTTY etc. But if you have changed anything recently on your system that you think could cause an issue, you may want to look in that direction first.
     
    Off the top of my head one thing you could try is disabling then   re-enabling the COM port from within device manager.
  21. Like
    sirri reacted to grahamf72 in (error = 57) on Energia   
    Do you have CCS running in the background? I've had this error if CCS was running. Beyond that, can't help sorry.
  22. Like
    sirri reacted to yyrkoon in (error = 57) on Energia   
    This is one reason why personally, I dedicate a whole machine to software development. Maybe different kinds of development on the same machine, but it reduces complications that can arise from conflicting applications. Granted, I understand not everyone can do this . . .
     
    But, if you do confirm that one of these applications is the cause you'll obviously have a choice to make. Perhaps one work around, would be to setup more than one user on the machine, and make it so the program only installs for that user only. I do not remember if adobe applications have this fine grained of a user install method or not, and I have no idea period of autodesk applications.
  23. Like
    sirri reacted to xv4y in Real-Time Clock (RTC) Library for the MSP430/LaunchPad   
    Yes, I have it declared in the library .cpp file and declared again in my main file of the programs...
  24. Like
    sirri reacted to xv4y in Real-Time Clock (RTC) Library for the MSP430/LaunchPad   
    Hi,
     
    I have tested to put everything in the begin() and it works.
    I will publish the corrected library tomorrow.
    Thanks!
     
    Yan.
  25. Like
    sirri reacted to energia in [Energia Library] MSTimer2   
    The example below is taken from Joe's blog here:http://joe.blog.freemansoft.com/2012/09/msp430-fading-and-other-long-running.html.
    void setup() { // open the hardware serial port Serial.begin(9600); pinMode(heartbeatPin, OUTPUT); TwoMsTimer::set(500, flash); // 500ms period TwoMsTimer::start(); } // interrupt handler passed to TwoMsTimer void flash(){ // log every time the handler is called should be every 500msec Serial.println("flash"); heartbeatPinOn = !heartbeatPinOn; digitalWrite(heartbeatPin,heartbeatPinOn); }
×
×
  • Create New...