Jump to content

StefanWxx

Members
  • Content Count

    34
  • Joined

  • Last visited

Everything posted by StefanWxx

  1. Hi, I would do it other than with analogread(),...simply work with the IRSend and IRrecv Examples. Take a tsop31238 to receive.
  2. 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. 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. 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. 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. 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); }
  9. 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?
  10. @@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
  11. 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(); }
  12. no, i call: IRsend irsend; to initialize the IR object Without LPM4 addition, this code works.
  13. 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?
  14. after 3 days of breeding, the egg is layed! use this pulse parameters #define SAMSUNG_BITS 32 #define SAMSUNG_HDR_MARK 4500 #define SAMSUNG_HDR_SPACE 4250 #define SAMSUNG_BIT_MARK 600 #define SAMSUNG_ONE_SPACE 1400 #define SAMSUNG_ZERO_SPACE 450 now it works, easter may come
  15. i send the IR Code, but after sending, the IR LED stays on.. until the next irsend command, but i don't know why sometimes after sending it is on, sometimes off Whether the code is right or wrong, the red LED from the TV is not even blinking, thus, it not receives the signal
  16. Thank you bluehash, hmm, samsung tvs are apparently problematic... I have no other solution for the Samsung IR Codes adaptation of the library, I've commented out the two lines in the IRremote.cpp, Does it make sense to continue to experiment in the IRremoteInt.h? // defines for Timer_A (16 bits) // NOTE: Using A1 instead of A0 because A0 is used by Serial #if defined(IR_USE_TIMERA) #define TIMER_RESET #define TIMER_ENABLE_PWM (TA1CTL = TASSEL_2 + MC_1) // SMCLK, Up mode #define TIMER_DISABLE_PWM (TA1CTL = TASSEL_2 + MC_0) // SMCLK, Stop mode #define TIMER_ENABLE_INTR ({ /*TA1CTL |= TAIE;*/ TA1CCTL0 |= CCIE;}) // SH 071112 #define TIMER_DISABLE_INTR ({TA1CTL &= ~TAIE; TA1CCTL0 &= ~CCIE;}) #define TIMER_INTR_NAME TIMER1_A0_VECTOR #define TIMER_CONFIG_KHZ(val) ({ \ TA1CCTL0 |= OUTMOD_4; \ TA1CCR0 = FOSC/val/2; \ }) // TODO: update TIMER_CONFIG_NORMAL // need to alter the math? // TA1CCR0 = SYSCLOCK * USECPERTICK / 1000000; #define TIMER_CONFIG_NORMAL() ({ \ TA1CTL = TASSEL_2 + MC_1 ; \ TA1CCTL0 |= OUTMOD_4; \ TA1CCR0 = SYSCLOCK * USECPERTICK / 1000000; \ TA1R = 0; \ }) #endif
  17. I'm really frustrated, doing the same with a Yamaha AV-Receiver, no Problems. recorded IR Signals sent as RAW works!!! So, no errors in the wiring! I add the Samsung Codes in the library and attached it here, with that I can decode signals -> E0E040BF = Power On/OFF in 32-bit When i send: irsend.sendSamsung(0xE0E040BF, 32); no reaction of the TV!! as same as with the RAW codes... I have 2 Samsung TVs,with remote control: AA59-00582A Where the dog is buried?
  18. Hello, I have studied these two manuals for the arduino and I have tried to implement this with the msp430g2533. http://as3breeze.com/arduino-sending-samsung-ir-codes/ http://arduinostuff.blogspot.de/2011/06/samsung-remote-ir-codes.html I have similar codes dumped with irrecvdump demo. In IRremote.cpp i commented this out: //pinMode(TIMER_PWM_PIN, OUTPUT); //digitalWrite(TIMER_PWM_PIN, LOW); // When not sending PWM, we want it low IR-LED PIN ist connected to P2_3 and GND. /* * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend * An IR LED must be connected to Arduino PWM pin 3. * Version 0.1 July, 2009 * Copyright 2009 Ken Shirriff * http://arcfn.com */ #include <IRremote.h> unsigned int powerOn[68] = {4500, 4500, 600, 1600, 600, 1650, 600, 500, 650, 500, 550, 550, 600, 500, 600, 1650, 600, 500, 600, 1650, 600, 1650, 600, 500, 600, 500, 600, 1650, 600, 500, 600, 1650, 600, 500, 600, 1650, 600, 500, 600, 550, 550, 550, 600, 500, 600, 550, 600, 500, 600, 500, 600, 550, 600, 1600, 600, 1650, 550, 1650, 600, 1650, 600, 1650, 550, 1650, 650, 1600, 600}; IRsend irsend; void setup() { Serial.begin(9600); } void loop() { irsend.sendRaw(powerOn,68,38); digitalWrite(11, LOW); //sometimes IR LED stays on?? delay(4000); // irsend.sendRaw(powerOn,68,38); } The IR LED is flashing but it is not recognized by the TV, What is going wrong? Has anyone got a hint? Edit: Added Datasheet for IR-LED LD217 How should this be wired correctly? Do i need a transistor? 184365-da-01-ml-IR_S_DIODE_LD271___LD271L_de_en.pdf IRremote.zip
  19. Hi, theoretically it would have to go directly or with an old mobile phone data cable. (I don't know the exact output level your rfid reader) Otherwise, I can recommend to look at the software serial examples . generally for the pc <-> mc connection I always take an old mobile phone cable (with max232 chip)
  20. @@Fred Next time I will describe it in more detail, The heli is quite difficult to control manually, a msp could do it certainly better, especially with openkinect
  21. @@pabigot Thanky you very much for your hints, but I am overwhelmed with the very detailed timer.h file. Can you please direct me to a concrete example?
  22. Hi, No, I wanted not send data over the serial port, but this is certainly possible but i cannot exclude timing problems of which I know nothing at the moment. I want to control directly a L298N Dual H Bridge DC Stepper Motor Drive Board. With the remote i want to drive a toy car, little project for my son and learning purposes.
  23. @@Philipp cool 1D pinball, thx
×
×
  • Create New...