Jump to content

StefanWxx

Members
  • Content Count

    34
  • Joined

  • Last visited

About StefanWxx

  • Rank
    Advanced Member
  • Birthday 01/20/1975

Profile Information

  • Gender
    Male
  • Location
    Germany - Pforzheim Baden W
  1. StefanWxx

    IR Led and IR photo transistor

    Hi, I would do it other than with analogread(),...simply work with the IRSend and IRrecv Examples. Take a tsop31238 to receive.
  2. StefanWxx

    Is this 38KHz PWM ?

    Unfortunately I have no osciloscope , is this PWM OK to use it for an IR-Signal? #include <msp430g2553.h> void main(void) { int counter = 26; // Is this correct? WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1DIR |= BIT6; // Set P1.6 to output direction P1OUT &= ~BIT6; // Set the green LED off P1SEL |= BIT6; // Green LED controlled by PWM TA0CCR0 = counter; // Count limit (16 bit) TA0CCR1 = counter/2; // 50% duty cycle TA0CCTL0 = 0x10; // Enable Timer A0 interrupts, bit 4=1 TA0CCTL1 = OUTMOD_7; TA0CTL = TASSEL_2 + MC_1; // Timer A0 with ACLK, count UP _BIS_SR(LPM0_bits + GIE); // LPM0 (low power mode) interrupts enabled } #pragma vector=TIMER1_A0_VECTOR // Timer1 A0 interrupt service routine __interrupt void Timer1_A0 (void) { // NOOP }
  3. StefanWxx

    Simple LPM4 serial demo ... does not work

    Thanks for the instructions, i have changed the code , now I 'm going to measure the current int test; void setup() { test=0; Serial.begin(9600); delay(3000); Serial.println("..running!"); Serial.println(); pinMode(P1_3, INPUT_PULLUP); attachInterrupt(P1_3, awake, FALLING); } void loop() { if (test == 1) { Serial.println("Button pressed"); delay(1000); Serial.println("doing some special stuff"); delay(1000); Serial.println("doing NOOP"); delay(1000); test = 0; } Serial.println("...suspending"); Serial.flush(); suspend(); // start in ultra low power mode, all work is done in the ISR routines } void awake(void) { wakeup(); test = 1; }
  4. Hi, the debug capability of energia via serial interface was for me a very nice feature for testing serial communication. Does the Code Composer Studio 6.0.1 also has a possibility to use the UART back channel over the USB? I think the com port is blocked by CCS already, but maybe I'm wrong.
  5. StefanWxx

    Serial.println(String) prints empty line

    Thanks for your reply, My app has just sent to many commands when a slider is moved, so i get corrupt data. Disabling btSerial has helped. In the meantime I have changed my sketch, the bluetooth receiver is now connected to the hardwareserial ports, Pin3&4 . Although I can not debug, but .... it works now as it should and in this case i had to comment out the disable Serial command in processCommand() but don't know why.
  6. Hello again, my actual project is a windowsphone app. With this app i want to control some led lights over bluetooth -> means that a command string comes over softwareserial I have already solved a lot myself, but now I need support. First Problem is that these 2 Lines only prints an empty row on the serial console, but not the word TEST. In a simple sketch this is working good! But not in my program, an i don't know why. look at the simple example at the bottom String pointer5 = "TEST"; Serial.println(pointer5); Second, this has not worked: if (pointer[5] == "True" { } . . Is there a solution? #include <WS2811Driver.h> #include <SoftwareSerial.h> const int TX_BT = 13; const int RX_BT = 12; const int PIN_RED = 2; const int PIN_GREEN = 14; const int PIN_YELLOW = 7; const int PIN_PROXIMITY_SENSOR = 5; SoftwareSerial btSerial(TX_BT, RX_BT); byte leds0[30]; WS2811Driver ledStrip; const char* color = ""; #define SOP '<' #define EOP '>' bool started = false; bool ended = false; int commandSize = 0; int commandPos = 0; char command[40]; char *pointer[6]; void processCommand(char* command) { btSerial.end(); char *p = command; char *str; int i =0; while ((str = strtok_r(p, ",", &p)) != NULL) // delimiter is comma { pointer[i] = str; i++; } Serial.println("NEW COMMAND"); Serial.println(pointer[0]); Serial.println(pointer[1]); Serial.println(pointer[2]); Serial.println(pointer[3]); Serial.println(pointer[4]); Serial.println(pointer[5]); String pointer5 = "TEST"; Serial.println(pointer5); //This Line is printing an empty row, not TEST btSerial.begin(9600); } //Setup MSP430 function void setup() { Serial.begin(9600); //Serial.println("USB Connected"); btSerial.begin(9600); pinMode(PIN_RED, OUTPUT); pinMode(PIN_GREEN, OUTPUT); pinMode(PIN_YELLOW, OUTPUT); pinMode(PIN_PROXIMITY_SENSOR, INPUT_PULLUP); ledStrip.setLEDCount(10); // setup for 4 leds on a strip ledStrip.begin(); } //Loop MSP430 function void loop() { if(btSerial.available()) { commandSize = (int)btSerial.read(); commandPos = 0; while(commandPos < commandSize) { if(btSerial.available()) { char buffer = btSerial.read(); if(buffer == SOP) { commandPos = 0; command[commandPos] = '\0'; started = true; ended = false; } else if(buffer == EOP){ ended = true; break; } else { command[commandPos] = buffer; commandPos++; command[commandPos] = '\0'; } } } //end while } if(started && ended) { // The end of packet marker arrived. Process the packet processCommand(command); // Reset for the next packet started = false; ended = false; commandPos = 0; command[commandPos] = '\0'; } } //this is the end This is the console output: NEW COMMAND 126 141 F53900 True True True <- here in this line should be: TEST NEW COMMAND 126 141 F53900 False True True NEW COMMAND 126 141 F53900 True True True Update: if I do not turn on software serial, the output of the strings works again here's some simpler code which shows the strange behavior: #include <SoftwareSerial.h> String text = "blablabla"; SoftwareSerial btSerial(P1_4, P1_3); char command[40]; void setup() { // put your setup code here, to run once: Serial.begin(9600); //btSerial.begin(9600); // if you uncomment this line, the String text is not printed: } void processCommand(char* command) { btSerial.end(); Serial.println("HELLO"); Serial.println(text); //works only with btSerial.begin(9600) commentet above } void loop() { processCommand(command); delay(500); }
  7. StefanWxx

    strtok_r Problem

    Hi, a simple program and also a simple problem, but I can not find a solution. someone has a tip for me? char text[] = "Value1, 1000, Value2,100,Value3,1.414,end"; void setup() { Serial.begin(9600); } void loop(){ char *p = text; char *str; while ((str = strtok_r(p, ",", &p)) != NULL) // delimiter is comma { Serial.println(str); delay(500); } } The output ist not as expected: Value1 1000 Value2 100 Value3 1.414 end Value1 Value1 Value1 Value1 Value1 Value1 Value1 . . . . . I want this: Value1 1000 Value2 100 Value3 1.414 end Value1 1000 Value2 100 Value3 1.414 end Value1 1000 Value2 100 Value3 1.414 end . . .
  8. Thank you, it works beautifully :-)
  9. Okay, just another Question about this.. How can ich make this with a loop: void loop() { const char* color = "34acef"; //GGRRBB unsigned long a = strtoul (color, NULL, 16); // want to do this in a loop: leds0[0] = (a >> 16) & 0xFF; leds0[1] = (a >> 8) & 0xFF; leds0[2] = a & 0xFF; leds0[3] = (a >> 16) & 0xFF; leds0[4] = (a >> 8) & 0xFF; leds0[5] = a & 0xFF; leds0[6] = (a >> 16) & 0xFF; leds0[7] = (a >> 8) & 0xFF; leds0[8] = a & 0xFF; leds0[9] = (a >> 16) & 0xFF; leds0[10] = (a >> 8) & 0xFF; leds0[11] = a & 0xFF; leds0[12] = (a >> 16) & 0xFF; leds0[13] = (a >> 8) & 0xFF; leds0[14] = a & 0xFF; leds0[15] = (a >> 16) & 0xFF; leds0[16] = (a >> 8) & 0xFF; leds0[17] = a & 0xFF; ledStrip.write(leds0); delay(5000); }
  10. Hi, in my code i want so set the color for a rgb led stripe. I use the WS2811Driver library. I tried this but it doesn't work: // blink_strip - ws2811 led strip blink example // 11-15-2012 Initial Version 0.1 #include <WS2811Driver.h> byte leds0[30]; byte leds1[30]; // 24 bits of color data stored GGRRBB //const uint8_t leds0[] = { 0x00,0xff,0x00, 0xff,0x00,0x00, 0x00,0x00,0xff, 0xff,0xff,0xff }; // R,G,B,W //const uint8_t leds1[] = { 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00 }; // 0,0,0,0, WS2811Driver ledStrip; // uses P1_7 as datapin connect to DIN on strip void setup(void) { ledStrip.setLEDCount(10); // setup for 4 leds on a strip ledStrip.begin(); // configure P1.7 for output } void loop() { //ledStrip.write(leds0); // set leds to red,green,blue,white //delay(500); //ledStrip.write(leds1,sizeof(leds1)); // turn off all 4 leds //delay(500); String color = "0000FF"; for(byte x = 0; x < 30 ; x++){ leds0[x] = byte('F'); //leds0[x+1] = byte(color.substring(2,3)); //leds0[x+2] = byte(color.substring(4,5)); } ledStrip.write(leds0); delay(5000); for(byte x = 0; x < 30 ; x++){ leds1[x] = 0x00; //leds0[x+1] = byte(color.substring(2,3)); //leds0[x+2] = byte(color.substring(4,5)); } ledStrip.write(leds1); delay(5000); } How can I convert the string to 3 bytes?
  11. StefanWxx

    How to wake up on keypad press ? [IR-Remote Project]

    @@Thorvard,@@SixSixSevenSeven in fact, I can now read the correct keys with the code, after I have added 'HIGH' to the Row Ports, before the keypad library takes over. #include <Keypad.h> #include <IRremote.h> const byte ROWS = 6; //four rows const byte COLS = 5; //four columns //define the cymbols on the buttons of the keypads char hexaKeys[ROWS][COLS] = { //b1-b6 = blank ones, not connected {'0','1','2','3','w'}, {'b1','4','5','6','.'}, {'7','8','9','-','C'}, {'%','m','b2','+','R'}, {'=','M','/','*','b3'}, {'b4','O','o','b5','b6'} }; byte rowPins[ROWS] = {P1_3, P1_4, P2_1, P1_5, P2_0, P2_2}; //connect to the row pinouts of the keypad byte colPins[COLS] = {P1_0, P2_4, P2_5, P1_6, P1_7}; //connect to the column pinouts of the keypad //initialize an instance of class NewKeypad //Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); //IRsend irsend; void setup() { Serial.begin(9600); delay(5000); Serial.println("..running!"); Serial.println(); pinsetup(); } void pinsetup(){ //.. so that the pins are interrupt capable disableWatchDog(); // disable timer keeper to use less power pinMode(P1_3, INPUT_PULLUP); pinMode(P1_4, INPUT_PULLUP); pinMode(P2_1, INPUT_PULLUP); pinMode(P1_5, INPUT_PULLUP); pinMode(P2_0, INPUT_PULLUP); pinMode(P2_2, INPUT_PULLUP); pinMode(P1_0,OUTPUT); pinMode(P2_4,OUTPUT); pinMode(P2_5,OUTPUT); pinMode(P1_6,OUTPUT); pinMode(P1_7,OUTPUT); digitalWrite(P1_0, LOW); digitalWrite(P2_4, LOW); digitalWrite(P2_5, LOW); digitalWrite(P1_6, LOW); digitalWrite(P1_7, LOW); attachInterrupt(P1_3, awake, FALLING); //row Pins = INPUT_PULLUP attachInterrupt(P1_4, awake, FALLING); attachInterrupt(P2_1, awake, FALLING); attachInterrupt(P1_5, awake, FALLING); attachInterrupt(P2_0, awake, FALLING); attachInterrupt(P2_2, awake, FALLING); } void loop() { Serial.println("preLPM4"); //__bis_status_register(LPM4_bits + GIE); LPM4; // start in ultra low power mode, all work is done in the ISR routines Serial.println("postLPM4"); } void awake(void) { detachInterrupt(P1_3); detachInterrupt(P1_4); detachInterrupt(P2_1); detachInterrupt(P1_5); detachInterrupt(P2_0); detachInterrupt(P2_2); digitalWrite(P1_0, HIGH); digitalWrite(P2_4, HIGH); digitalWrite(P2_5, HIGH); digitalWrite(P1_6, HIGH); digitalWrite(P1_7, HIGH); enableWatchDog(); delay(100); Serial.println(); Serial.println("Awake!"); //delay(500); Keypad keypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS ); char key = keypad.getKey(); Serial.println(key); delay(200); pinsetup(); } the first key stroke wakes up an the awake function is running, but after that he will not go back to sleep mode. ??? EDIT: I had it last compiled on another PC (i used a different energia installation) The difference was in the WInterrupts.c file, i forgot to add the line: _BIC_SR_IRQ(LPM4_bits); to the last 2 functions.. but now the output works as expected: ...running! preLPM4 Awake! 5 postLPM4 preLPM4 Awake! 8 postLPM4 preLPM4 Awake! 9 postLPM4 preLPM4 Awake! % postLPM4 preLPM4 Awake! / postLPM4 preLPM4 Awake! * postLPM4 preLPM4 Awake! / postLPM4 preLPM4 Awake! * postLPM4 preLPM4 Awake! - postLPM4 preLPM4 Awake! + postLPM4 preLPM4 Awake! O postLPM4 preLPM4 Awake! C postLPM4 preLPM4 Awake! R postLPM4 preLPM4 Awake! m postLPM4 preLPM4 Awake! M postLPM4 preLPM4 Awake! o postLPM4 preLPM4 Awake! 4 postLPM4 preLPM4 Now i think its solved! Many thanks
  12. StefanWxx

    How to wake up on keypad press ? [IR-Remote Project]

    thank you for the advice my paradigm leads to that I can not read the correct keys: #include <Keypad.h> #include <IRremote.h> const byte ROWS = 6; //four rows const byte COLS = 5; //four columns //define the cymbols on the buttons of the keypads char hexaKeys[ROWS][COLS] = { //b1-b6 = blank ones, not connected {'0','1','2','3','w'}, {'b1','4','5','6','.'}, {'7','8','9','-','C'}, {'%','m','b2','+','R'}, {'=','M','/','*','b3'}, {'b4','O','o','b5','b6'} }; byte rowPins[ROWS] = {P1_3, P1_4, P2_1, P1_5, P2_0, P2_2}; //connect to the row pinouts of the keypad byte colPins[COLS] = {P1_0, P2_4, P2_5, P1_6, P1_7}; //connect to the column pinouts of the keypad //initialize an instance of class NewKeypad //Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); //IRsend irsend; void setup() { Serial.begin(9600); delay(5000); Serial.println("..running!"); Serial.println(); pinsetup(); } void pinsetup(){ //.. so that the pins are interrupt capable disableWatchDog(); // disable timer keeper to use less power pinMode(P1_3, INPUT_PULLUP); pinMode(P1_4, INPUT_PULLUP); pinMode(P2_1, INPUT_PULLUP); pinMode(P1_5, INPUT_PULLUP); pinMode(P2_0, INPUT_PULLUP); pinMode(P2_2, INPUT_PULLUP); pinMode(P1_0,OUTPUT); pinMode(P2_4,OUTPUT); pinMode(P2_5,OUTPUT); pinMode(P1_6,OUTPUT); pinMode(P1_7,OUTPUT); digitalWrite(P1_0, LOW); digitalWrite(P2_4, LOW); digitalWrite(P2_5, LOW); digitalWrite(P1_6, LOW); digitalWrite(P1_7, LOW); attachInterrupt(P1_3, awake, FALLING); //row Pins = INPUT_PULLUP attachInterrupt(P1_4, awake, FALLING); attachInterrupt(P2_1, awake, FALLING); attachInterrupt(P1_5, awake, FALLING); attachInterrupt(P2_0, awake, FALLING); attachInterrupt(P2_2, awake, FALLING); } void loop() { Serial.println("preLPM4"); //__bis_status_register(LPM4_bits + GIE); LPM4; // start in ultra low power mode, all work is done in the ISR routines Serial.println("postLPM4"); } void awake(void) { detachInterrupt(P1_3); detachInterrupt(P1_4); detachInterrupt(P2_1); detachInterrupt(P1_5); detachInterrupt(P2_0); detachInterrupt(P2_2); enableWatchDog(); delay(100); Serial.println(); Serial.println("Awake!"); //delay(500); Keypad keypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS ); char key = keypad.getKey(); Serial.println(key); delay(200); pinsetup(); }
  13. StefanWxx

    How to wake up on keypad press ? [IR-Remote Project]

    no, i call: IRsend irsend; to initialize the IR object Without LPM4 addition, this code works.
  14. Hello, I'm still working on my Project -> C2RC -> Calculator2Remote Conversion The circuit and the IR codes now work after I adjusted the pulse timings. But now I wonder how I can put the MSP430G2553 in sleep mode.. I've followed the suggestion of energia http://forum.43oh.com/topic/2904-is-there-a-way-in-energia-to-access-the-lpms/ But I must be doing something fundamentally wrong, because I think that would be too easy: /* @file CustomKeypad.pde || @version 1.0 || @author Alexander Brevig || @contact alexanderbrevig@gmail.com || || @description || | Demonstrates changing the keypad size and key values. || # */ #include <Keypad.h> #include <IRremote.h> const byte ROWS = 6; //four rows const byte COLS = 5; //four columns //define the cymbols on the buttons of the keypads char hexaKeys[ROWS][COLS] = { {'0','1','2','3','w'}, {'b1','4','5','6','.'}, {'7','8','9','-','C'}, {'%','m','b2','+','R'}, {'=','M','/','*','b3'}, {'b4','O','o','b5','b6'} }; byte rowPins[ROWS] = {P1_3, P1_4, P2_1, P1_5, P2_0, P2_2}; //connect to the row pinouts of the keypad byte colPins[COLS] = {P1_0, P2_4, P2_5, P1_6, P1_7}; //connect to the column pinouts of the keypad //initialize an instance of class NewKeypad Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); IRsend irsend; void setup(){ Serial.begin(9600); //LPM disableWatchDog(); attachInterrupt(P1_3, awake, FALLING); //row Pins = INPUT_PULLUP attachInterrupt(P1_4, awake, FALLING); attachInterrupt(P2_1, awake, FALLING); attachInterrupt(P1_5, awake, FALLING); attachInterrupt(P2_0, awake, FALLING); attachInterrupt(P2_2, awake, FALLING); } void loop() { __bis_status_register(LPM4_bits + GIE); /* Code after this will never be reached */ } void awake(){ char customKey = customKeypad.getKey(); switch (customKey) { case 'o': irsend.sendSamsung(0xe0e040bf, 32); break; default: //irsend.sendSamsung(0xe0e040bf, 32); break; } } The IR-LED is always OFF. Where is my mistake?
×