• Announcements

    • bluehash

      Forum Upgrade   03/11/2017

      Hello Everyone, Thanks for being patient while the forums were being fixed and upgraded. Please see details and report issues in this thread. Thanks!


  • Content count

  • Joined

  • Last visited

Everything posted by Taggsladder

  1. Hello I don't know if this is quite the right place to post this or if my title is describing this correct and maybe this is more of a general C questions, but I hope its OK to post it here. It is on a MSP430 Launchpad anyway. The code is simplified, there is more parameters passed to the function etc. // I have a function like this. void foo (char* bar) { if (!bar) Serial.print("bar is NULL"); // I want to check when NULL is passed on but this doesn't work? // Also tried (bar == NULL) and (bar[0] == NULL)... else Serial.print("bar is not NULL"); } // Usually I call it like this. foo("Normally text passed here"); // But I would like to call it like this also. foo(NULL); Looking forward to any reply. Best regards
  2. Thank you for your input. I think you are right, I looked at some other of my projects and found that I use similar code there that works. I need to dig into it
  3. [sOLVED] > QUICK AND DIRTY I got it working now. Not the best way but it does the job. Just a personal project so no worries. Running the initializing function two times with a delay did the trick for me. // Include LCD library. #include "LCD_5110.h" LCD_5110 myScreen; void setup() { myScreen.begin(); // Start LCD communication. delay(1000); myScreen.begin(); // Start LCD communication. myScreen.clear(); // Clear LCD. myScreen.setFont(0); // Set "small" font. myScreen.text(4, 2, "TEST"); // Display on LCD. } void loop() { } Have a nice day!
  4. Major bump I have the same problem. It works perfect except I need to reset the mcu after every powercycle or else the lcd stays completly blank. I could live with it but its just bugs the h*** out of me. Just basic sketch. In the code below I used a IO pin for powering the LCD but also tried powering from VCC with no luck. // Include LCD library. #include "LCD_5110.h" LCD_5110 myScreen; const int lcdVdd = P1_4; void setup() { pinMode(lcdVdd, OUTPUT); digitalWrite(lcdVdd, HIGH); myScreen.begin(); // Start LCD communication. myScreen.clear(); // Clear LCD. myScreen.setFont(0); // Set "small" font. myScreen.text(4, 2, "TEST"); // Display on LCD. } void loop() { } Tried it with the Tried with and with out this. No difference. Tried the library as is and tried changing the myScreen.begin(); function to something similiar: void LCD_5110::begin() { pinMode(_pinChipSelect, OUTPUT); pinMode(_pinReset, OUTPUT); pinMode(_pinDataCommand, OUTPUT); pinMode(_pinSerialData, OUTPUT); pinMode(_pinSerialClock, OUTPUT); pinMode(_pinBacklight, OUTPUT); pinMode(_pinPushButton, INPUT_PULLUP); delay(500); digitalWrite(_pinReset, HIGH); digitalWrite(_pinDataCommand, LOW); write(_commandLCD, 0x21); // chip is active, horizontal addressing, use extended instruction set write(_commandLCD, 0xc8); // write VOP to register: 0xC8 for 3V
  5. Hello I want to measure the battery voltage (ballpark measurement) in a car so I thought I do that with a voltage divider connected to a msp430 ADC pin, but I wanted to add overvoltage protection with a zener as in the schematics in the link below. I am using 100k / 10k in the voltage divider and a BZX79C2V7 zener. If I leave the zener disconnected I get the divider to work as expected in a linear fashion, but when I connect the zener I get the correct reading when the input voltage is 10V but if for example I double the input voltage to 20V I get a lower reading compared to when the zener is disconnected and the voltage divider is no longer linear. Measurements without zener: 10V in, 0.9V to mcu pin 15V in, 1.35V to mcu pin 20V in, 1.78V to mcu pin Measurements with zener: 10V in, 0.9V to mcu pin 15V in, 1.25V to mcu pin 20V in, 1.46V to mcu pin Why is this so? http://www.re-innovation.co.uk/web12/index.php/en/information/electronics-information/accurate-voltage-measurement Thanks Kind regards Andreas
  6. Hello I am working on a curcuit that need to switch two loads max 200mA. One load gets feed ground and the other load gets feed positive. VCC will be in a span of 6-30VDC. The curciut works as intended when VCC is 6VDC, but at the max span VCC 30VDC all (Q1, Q2, Q4) transistors and the FET breaks when the pin from the MCU goes HIGH. This will happen even if the connector is unconnected. Q1, Q2 http://www.farnell.com/datasheets/699988.pdf Q4 http://www.farnell.com/datasheets/1885683.pdf From what stupid me can read from the datasheet Q1 and Q2 should be able to handle 45V between collector-emitter. But I think that I can understand why Q4 fails becouse it can handle 20V max between gate-source. Am I right? Thanks Best regards, Andreas
  7. Thanks for the reply @@enl! Ok, I understand. The reverse breakdown of D5 is 200V. D5 http://www.farnell.com/datasheets/162697.pdf Though I think that I will go with the original plan of just using a DPDT signal relay switched by a transistor, find it is easier when you know exactly whats gonna be switched. Would have been neat to use them magic FET's but clearly I have some learning todo This forum is such a great place, thanks again! Kind regards, Andreas
  8. I played around with that too but since the device will power from the cars battery I want as low consumption as possible.
  9. I was thinking about some sort of lookup table as you say Thanks for the help, much appreciated. Have a nice day! Sent from my SM-G900F using Tapatalk
  10. Thanks for the reply! TBT, just the word opamp scares me a little, hehe. How comes the zener is used in the link and the title is "Accurate Voltage Measurement". Is there a way to calculate this offset in software or would it be to messy? I am not looking for a accurate reading, +- 0.5V in a 10-25V span would do fine. Best regards
  11. Hello Cannot get the Nokia 5110 LCD to work with my launchpad and the G2553. First thing I noticed is that when the library example sketch (LCD_5110_main.ino) is uploaded and the LCD is disconnected the backlight pin is floating. Also there is nothing happening when pushing the Launchpad push button 2 that should enable/disable the backlight. I am using this library: https://github.com/energia/Energia/tree/master/examples/07.Display/LCD_5110 As I said with the example sketch uploaded the backlight pin (P2.1) is floating with the line below either true or false. No errors or similiar in Energia when uploading the sketch. Also tried just to put the pin high or low with other code and no problem so it is not a hardware issue i believe. "boolean backlight = false;" What am I missing here? Kind regards, Andreas
  12. Strange. Changed computer and used a new Launchpad and it worked straight ahead. Well well. Goofed something up I used another library this time though. Don't know if it was the problem. Used this library from here instead, don't know the difference. https://github.com/pasky/Energia/tree/master/examples/7.Display/LCD_5110_430 Thanks anyway, sorry to bothering Kind regards Andreas
  13. Hello guys and gals Another newbie question I have a device that I want to communicate with over UART using the good old MSP430G2553. The device will have a supply voltage of about 4V and has an absolute max voltage rating of 3.1V on any input pin including the UART, typical 2.8V. Min. 2.4V for HIGH. First of all, from what I can read from the datasheet the MSP430 will have a UART logic high of Vcc - 0.3V and I am thinking that since the MSP430 supply voltage range is 1.8-3.6V, would it be "good practice" just to power the MSP430 with let's say 2.8V and thus have compatible UART levels with the other device or should I opt for a logic level converter? Pros cons? Also in the MSP430 datasheet I noted that there is a relation between supply voltage and system frequency. So will the mcu not run at full speed if I power it at 2.8V? It looks like it would be around 12MHz at that voltage. Thanks Kind regards Andreas
  14. Thanks! Sound good. Also found this https://www.sparkfun.com/products/12009 that looks quite nice. I will play around and see whats works best for my project. Have a nice day Best regards Andreas
  15. Hello I have a large sketch with lots of quite long Serial.print() and I have read somewhere about Arduino that to save SRAM you can use the F() macro like "Serial.print(F("lala"))". But When I try to use this in Energia I get no errors but the Serial.print don't display anything. Why is this? Thanks! Best regards Andreas
  16. Thanks for the reply! Have a great day. Kind regards Andreas
  17. Hello friends Hope you are all doing great! I need advice on an external temperature sensor for a MSP430G2553 project. I just need to read the "outside" temperature like a span of -30 to +80 celcius. I "just" ([emoji16]) want to know what the best/easiest/most common sensor would be. Of course I am a quite a newbie to this. I have looked at some sensor like the lm35 but I read somewhere that it couldn't run at mcu voltage. Also looked at DS18B20 but its just a jungle for me and I don't know what to look for. Requirements (not any particular order): Low price Can run at mcu voltage Under 1 celcius accuracy Nice to have some Energia examples to look at The fewer pins the better, but not that important. I have loads of free pins. Conclusion: A newbie friendly sensor to start out with Sorry if the English is a little off, I have troubles sometimes finding the right words. Best regards, Andreas
  18. Thanks guys! I ordered lm61, ds18b20 and the tmp100. Will play with them and see what suits my needs best. Have a nice day! Best regards, Andreas
  19. Hello I am working on a MSP430G2553 project and a strange thing is happening when I am converting two chars to integer. If I only convert one value like this: char a[2] = {data[9], data[10]}; // Put in a array + terminating NULL byte. int i_a = (int) atoi(a); // Convert to a integer. It converts the "a" correctly to a integer, but when I do like this: char a[2] = {data[9], data[10]}; // Put in a array + terminating NULL byte. int i_a = (int) atoi(a); // Convert to a integer. char b[2] = {data[12], data[13]}; // Put in a array + terminating NULL byte. int i_b = (int) atoi(; // Convert to a integer. It converts both "a" and "b" to integer but it adds 1 at the end, for example if "a"="30" after the conversion the "i_a"=301? So this just happens when I convert both "a" and "b". If I remove one of the conversion code it converts the other value correctly... BUT... If I manually add a terminating NULL byte on both "a" and "b" like this: char a[2] = {data[9], data[10]}; // Put in a array + terminating NULL byte. a[2] = NULL; int i_a = (int) atoi(a); // Convert to a integer. char b[2] = {data[12], data[13]}; // Put in a array + terminating NULL byte. b[2] = NULL; int i_b = (int) atoi(; // Convert to a integer. it works as intended. Why is this? Shouldn't declaring like "char a[2] = {data[9], data[10]};" autoadd the terminating NULL byte at the end? As you might suspect I am a newbie to this so what is the correct way of doing this? Hope I am clear enough and you understand. Looking forward to a reply. Best regards Andreas
  20. Thanks for everybodys input! Since it is working perfect and errorfree now I will stay with my setup until I have to move up if I need to incorporate new functions. Thanks again, really appreciate it! This is a great forum with nice people. Best regards Andreas
  21. Thanks for your reply! I looked at the map file and I was overwhelmed with data, didn't get much of that I have quite a lot of nested function calls but not deeper than function A calling function B. Do I understand it right that all the global vars is allocated in the RAM from the beginning and the local vars is allocated when calling the function and reset when the function exits? So the remaing 218 bytes you estimated needs to be allocated by one function bigger that 218B to run out of RAM? I don't use any malloc or new. The most of the code is just very basic code, IF statements, loops etc. I did look at this thread: http://forum.43oh.com/topic/3682-flash-and-estimated-ram-usage/ This gave me the following: text data bss dec hex 12842 4 448 13294 33ee So this would mean I am using 452B (data+bss) out of 512B RAM? Feels dangerously close :/ How accurate is this? Kind regards Andreas
  22. Hello again Sorry for the delay in replying. I truly appreciate the help you guys give I have tried a bunch of things and I got it working now but I kept the original code and change the other part of the code a little that was giving me crashes. I download Ti's CCS and tried to debug with it but I didn't work it out how to do it. It did give me about 50 compile warnings (nothing major) that Energia didn't say anything about though. They are all fixed now. The code now works as intended and I have really tested it hard without any issues but it would be interesting to know what coused the crash since if I change some part of the code that was by itself working but caused errors on a remote random part of the code made me also suspect some kind of lack of memory issue maybe. Since I am a noob please bear with me. I always thought that Energia or whatever compiler/uploader would tell me if I have reached some kind of space/RAM limit in MCU. But that isn't true? I have about 1500 lines of code. The globals vars are as follows: 7 int 3 long About 250 chars And a hell of alot of local vars. Also I use the MspFlash.h to write some data to the flash memory. How can I calculate if I need a bigger MCU? Best regards Andreas
  23. Hello friends I see that this thread has spiraled out of what I could ever learn by the stretch of the imagination But I still have the problems when I convert char to integer. This part of the code works as intended and the original problem is solved by increasing the arraysize, but now the MCU crashes and reboots on a remote part of the code not even touching this side of the code! This is the actual code // Put on onftime hours/minutes in a array + terminating NULL byte. char onfTimerH[3] = {data[9], data[10]}; char onfTimerM[3] = {data[12], data[13]}; // Convert onftime hours/minutes to a integer. int i_onfTimerH = (int) atoi(onfTimerH); int i_onfTimerM = (int) atoi(onfTimerM); i_onfTimerMin = (i_onfTimerH*60) + i_onfTimerM; // Calculate onftime in minutes. As soon as I remove one of the char to int conversionlines like below everything is working! // Put on onftime hours/minutes in a array + terminating NULL byte. char onfTimerH[3] = {data[9], data[10]}; char onfTimerM[3] = {data[12], data[13]}; // Convert onftime hours/minutes to a integer. int i_onfTimerH = (int) atoi(onfTimerH); //int i_onfTimerM = (int) atoi(onfTimerM); i_onfTimerMin = (i_onfTimerH*60); // Calculate onftime in minutes. What am I doing wrong? BTW the reason that I need two char-to-int lines is couse I need to convert hours and minutes to total minutes. For example the data could hold: data[9] and data[10] is the hours, lets say 09 hours data[12] and data[13] is the minutes, lets say 99 minutes At the moment I convert both chars to int like the above code and then add them ((i_onfTimerH*60) + i_onfTimerM), but if someone can tell me a better way of converting theese chars to total minutes it removes the need for the two char-to-int lines. Please note that the hours and minutes both can range from 01-99. Looking forward to any replies. Best regards Andreas