Jump to content
43oh

bobnova

Members
  • Content Count

    161
  • Joined

  • Last visited

  • Days Won

    6

Reputation Activity

  1. Like
    bobnova got a reaction from Rei Vilo in My first attempt TM4C129   
    I'll certainly try! I
    Never done anything on github but download, so I'll need to make an account and such.
    I'll see what I can do.
  2. Like
    bobnova got a reaction from abecedarian in My first attempt TM4C129   
    I don't know if you're still around or not, but I got a IoT launchpad a couple days ago and have been having similar issues with a webserver program based heavily on the demo/example program in Energia (BarometicPressureWebServer), which uses the same core code as in the original post of this thread.
     
    With possibly excessive use of Serial and LED debugging, I think I found the problem.
     
    If I'm correct, it's due to the while loop.
    It calls
    while (client.connected()) { if (client.available()) { and then goes on and does things.
     
    The break; statement that ends that while is inside the if (client.available). If the client never sends anything, or if the Launchpad misses it, client.available() never returns true, the IF never happens, and the break; statement never happens either. Leaving you stuck in the while loop for all eternity.
     
    I've been banging my head against this issue for a couple days, and finally figured out the above. I put in a timeout to kill the connection (call break; and let it trundle off to client.stop()) after 1000ms.
    void listenForEthernetClients() {   // listen for incoming clients   boolean activeConnection = false;   EthernetClient client = server.available();   if (client) {     Serial.println("Got a client");     // an http request ends with a blank line     boolean currentLineIsBlank = true;     char c;          while (client.connected()) {       if (!activeConnection){         connectionActiveTimer = millis();         activeConnection = true;       }              if (activeConnection && connectionActiveTimer + connectionTimeout < millis()){         break;       }                if (client.available()) { I've seen it hang in the while loop for a second and then reset and start working again, which leads me to believe that I've found and fixed the problem.
    Bug in the demo problem rather than a bug with Ethernet or the IoT.
     
     
     
    As a note, I'm absolutely loving the board and Energia support for it. Without Energia I'd be completely lost trying to do anything with this board.
  3. Like
    bobnova got a reaction from PTB in [Group Buy-11] [C] RGB LED Strips (with WS2811)   
    I'd go easy on these things on USB ports.
    I measured my 60LED strip at a bit over 2 amps of 5v (with a cheap multimeter) with all 60 at 255.
    Some USB port fuses are that size or less, and are one-time fuses. Don't want to kill your USB ports!  (USB2 ports are rated for 500ma. USB3 ports are rated at 1500ma)
    These are hungry little things.
     
     
    On the topic of another GB, I want two more meters, at least.
  4. Like
    bobnova got a reaction from sirri in Timing in Energia Code ?   
    The "BlinkWithoutDelay" example code that comes with energia (in the digital section) should get you going.
     
    It looks like that library might function in Energia if copied over. I didn't see any references to Arduino specific HW while glancing through it.
  5. Like
    bobnova got a reaction from bluehash in [Energia Library] WS2811Driver LED Controller Class   
    Got my strip and played with this a bit. It works great!
    Here's all 60 LEDs in my one meter strip with flowing colors. Max duty cycle is limited to 40, partly because these things are quite bright and partly because at full burn the strip eats ~1.2 amps and my regulator starts getting rather toasty. The LEDs are supplied with 5v (actually 4.5v after the LDO after coming out the USB3 port) from a seperate power board, the MSP430G2553 is on a standard Launchpad.
     

    #include <WS2811Driver.h> byte leds0[180]; WS2811Driver ledStrip; // uses P1_7 as datapin connect to DIN on strip void setup(void) { ledStrip.setLEDCount(60); // setup for 60 leds on a strip ledStrip.begin(); // configure P1.7 for output for (byte x = 0 ; x < 180 ; x++){ leds0[x] = 0; } } void loop() { for(byte x = 179; x >= 5 ; x--){ leds0[x] = leds0[x-3]; leds0[x-1] = leds0[x-4]; leds0[x-2] = leds0[x-5]; } leds0[0] = random(0,random(10,40)); leds0[1] = random(0,random(10,40)); leds0[2] = random(0,random(10,40)); ledStrip.write(leds0); // write to the LEDs delay(100); }
     
    Thanks for the library! It made this FAR easier!
  6. Like
    bobnova got a reaction from pivden in Simple one-button combination lock   
    Thanks!
    I tried the library, it refused to write anything but strings. All my attempts at telling it to write anything else resulted in 210 being stored. Never did figure out why! It may well have been operator error. Probably was, really.
    The flash reading and writing stuff is pulled out of the library (mspflash.cpp, to be specific) and changed slightly to suit my purposes.
  7. Like
    bobnova got a reaction from dacoffey in Simple one-button combination lock   
    One of my first MSP430 projects here, this is a (very) simple one-button combination lock. At the moment it's just using the launchpad's single button and the two LEDs for lock status. You'd need to figure out what you were locking or unlocking and add code for that obviously.
    It's all delay based, so it assumes you aren't doing anything overly crucial other than minding the button, or at least that the other tasks (if any) can be put on hold while the button is being used.
    I'm sure there are "better" ways to do it, but this seems to work so far!
     

    int counter; byte wiggleRoom = 25; //the amount + or - of the exact correct push length to pass a lock level, measured in 10ms steps. byte lockLevel = 1; //Stores what button press the lock is on boolean open = false; boolean buttonState; int test1 = 100; //Number of 10ms steps the button should be held down for the first time int test2 = 50; //Same, for press two. int test3 = 100; //And press 3. So for this setup, we press for 1s, let up, press for 0.5s, let up, press for 1s void setup(){ pinMode(P1_0, OUTPUT); pinMode(P1_6, OUTPUT); pinMode(P1_3, INPUT_PULLUP); } void loop(){ if (!open){ // normal state, red LED on, green LED off. digitalWrite(P1_0, HIGH); //In this section you would shut the lock, whatever it was. digitalWrite(P1_6, LOW); } else{ digitalWrite(P1_6, HIGH); //Open the lock digitalWrite(P1_0, LOW); delay(3000); //Wait a bit. lockLevel = 1; open = false; //Set the lock to close next pass through the code. //Might not be a bad idea to close the lock here too, really. //That would prevent the button being held down keeping the lock open. } buttonState = digitalRead(P1_3); if (!buttonState){ //Button is pushed counter = 0; //reset the counter, this is crucial. while (!buttonState){ //As long as the button is held down, this cycles. counter++; delay(10); //10ms per cycle, record the number of cycles. buttonState = digitalRead(P1_3); //We do need to get out eventually, when the button opens } switch (lockLevel){ //Now that we have a press duration, we need to find what level the lock is on case 1: //If it's the first press, we start here. if (counter >= test1 - wiggleRoom && counter <=test1 + wiggleRoom){ lockLevel = 2; //Adjust wiggleRoom to be the number of 10ms steps you want for wiggle room. counter = 0; //Right now we get +/- 250ms. digitalWrite(P1_6, HIGH); //Flash the green LED if the push was successful. Mostly for debugging. delay(50); digitalWrite(P1_6, LOW); } else{ lockLevel = 1; //If the push is the wrong length, start over. counter = 0; } break; case 2: if (counter >= test2 - wiggleRoom && counter <=test2 + wiggleRoom){ //Second push, same deal. lockLevel = 3; counter = 0; digitalWrite(P1_6, HIGH); delay(50); digitalWrite(P1_6, LOW); } else{ lockLevel = 1; //If the push is the wrong length, start over from push 1. counter = 0; } break; case 3: if (counter >= test3 - wiggleRoom && counter <=test3 + wiggleRoom){ open = true; //Third correct push opens the lock. counter = 0; } else{ lockLevel = 1; counter = 0; } break; } } }
    The next thing I'm inclined to work on is some learning, so that it remembers how long you hold the buttons down and adjusts the official "correct" number to match over time. The other thought is to time the delay between presses and use that as part of the combination, it would complicate the code fairly significantly but also increase security for a given time spent with the button.
    I got the idea while contemplating vehicle security, my thought was to re-use a dash button as the input button and control the fuel pump relay (that wouldn't turn off after three seconds!). That would give you totally invisible anti-theft in theory.
    I can't recommend it exactly, depending on how it's wired a dead MSP430 may render the vehicle suddenly stopped, not ideal!
     
    Thoughts?
  8. Like
    bobnova got a reaction from CodilX in Simple one-button combination lock   
    One of my first MSP430 projects here, this is a (very) simple one-button combination lock. At the moment it's just using the launchpad's single button and the two LEDs for lock status. You'd need to figure out what you were locking or unlocking and add code for that obviously.
    It's all delay based, so it assumes you aren't doing anything overly crucial other than minding the button, or at least that the other tasks (if any) can be put on hold while the button is being used.
    I'm sure there are "better" ways to do it, but this seems to work so far!
     

    int counter; byte wiggleRoom = 25; //the amount + or - of the exact correct push length to pass a lock level, measured in 10ms steps. byte lockLevel = 1; //Stores what button press the lock is on boolean open = false; boolean buttonState; int test1 = 100; //Number of 10ms steps the button should be held down for the first time int test2 = 50; //Same, for press two. int test3 = 100; //And press 3. So for this setup, we press for 1s, let up, press for 0.5s, let up, press for 1s void setup(){ pinMode(P1_0, OUTPUT); pinMode(P1_6, OUTPUT); pinMode(P1_3, INPUT_PULLUP); } void loop(){ if (!open){ // normal state, red LED on, green LED off. digitalWrite(P1_0, HIGH); //In this section you would shut the lock, whatever it was. digitalWrite(P1_6, LOW); } else{ digitalWrite(P1_6, HIGH); //Open the lock digitalWrite(P1_0, LOW); delay(3000); //Wait a bit. lockLevel = 1; open = false; //Set the lock to close next pass through the code. //Might not be a bad idea to close the lock here too, really. //That would prevent the button being held down keeping the lock open. } buttonState = digitalRead(P1_3); if (!buttonState){ //Button is pushed counter = 0; //reset the counter, this is crucial. while (!buttonState){ //As long as the button is held down, this cycles. counter++; delay(10); //10ms per cycle, record the number of cycles. buttonState = digitalRead(P1_3); //We do need to get out eventually, when the button opens } switch (lockLevel){ //Now that we have a press duration, we need to find what level the lock is on case 1: //If it's the first press, we start here. if (counter >= test1 - wiggleRoom && counter <=test1 + wiggleRoom){ lockLevel = 2; //Adjust wiggleRoom to be the number of 10ms steps you want for wiggle room. counter = 0; //Right now we get +/- 250ms. digitalWrite(P1_6, HIGH); //Flash the green LED if the push was successful. Mostly for debugging. delay(50); digitalWrite(P1_6, LOW); } else{ lockLevel = 1; //If the push is the wrong length, start over. counter = 0; } break; case 2: if (counter >= test2 - wiggleRoom && counter <=test2 + wiggleRoom){ //Second push, same deal. lockLevel = 3; counter = 0; digitalWrite(P1_6, HIGH); delay(50); digitalWrite(P1_6, LOW); } else{ lockLevel = 1; //If the push is the wrong length, start over from push 1. counter = 0; } break; case 3: if (counter >= test3 - wiggleRoom && counter <=test3 + wiggleRoom){ open = true; //Third correct push opens the lock. counter = 0; } else{ lockLevel = 1; counter = 0; } break; } } }
    The next thing I'm inclined to work on is some learning, so that it remembers how long you hold the buttons down and adjusts the official "correct" number to match over time. The other thought is to time the delay between presses and use that as part of the combination, it would complicate the code fairly significantly but also increase security for a given time spent with the button.
    I got the idea while contemplating vehicle security, my thought was to re-use a dash button as the input button and control the fuel pump relay (that wouldn't turn off after three seconds!). That would give you totally invisible anti-theft in theory.
    I can't recommend it exactly, depending on how it's wired a dead MSP430 may render the vehicle suddenly stopped, not ideal!
     
    Thoughts?
  9. Like
    bobnova got a reaction from jsolarski-backup in Simple one-button combination lock   
    One of my first MSP430 projects here, this is a (very) simple one-button combination lock. At the moment it's just using the launchpad's single button and the two LEDs for lock status. You'd need to figure out what you were locking or unlocking and add code for that obviously.
    It's all delay based, so it assumes you aren't doing anything overly crucial other than minding the button, or at least that the other tasks (if any) can be put on hold while the button is being used.
    I'm sure there are "better" ways to do it, but this seems to work so far!
     

    int counter; byte wiggleRoom = 25; //the amount + or - of the exact correct push length to pass a lock level, measured in 10ms steps. byte lockLevel = 1; //Stores what button press the lock is on boolean open = false; boolean buttonState; int test1 = 100; //Number of 10ms steps the button should be held down for the first time int test2 = 50; //Same, for press two. int test3 = 100; //And press 3. So for this setup, we press for 1s, let up, press for 0.5s, let up, press for 1s void setup(){ pinMode(P1_0, OUTPUT); pinMode(P1_6, OUTPUT); pinMode(P1_3, INPUT_PULLUP); } void loop(){ if (!open){ // normal state, red LED on, green LED off. digitalWrite(P1_0, HIGH); //In this section you would shut the lock, whatever it was. digitalWrite(P1_6, LOW); } else{ digitalWrite(P1_6, HIGH); //Open the lock digitalWrite(P1_0, LOW); delay(3000); //Wait a bit. lockLevel = 1; open = false; //Set the lock to close next pass through the code. //Might not be a bad idea to close the lock here too, really. //That would prevent the button being held down keeping the lock open. } buttonState = digitalRead(P1_3); if (!buttonState){ //Button is pushed counter = 0; //reset the counter, this is crucial. while (!buttonState){ //As long as the button is held down, this cycles. counter++; delay(10); //10ms per cycle, record the number of cycles. buttonState = digitalRead(P1_3); //We do need to get out eventually, when the button opens } switch (lockLevel){ //Now that we have a press duration, we need to find what level the lock is on case 1: //If it's the first press, we start here. if (counter >= test1 - wiggleRoom && counter <=test1 + wiggleRoom){ lockLevel = 2; //Adjust wiggleRoom to be the number of 10ms steps you want for wiggle room. counter = 0; //Right now we get +/- 250ms. digitalWrite(P1_6, HIGH); //Flash the green LED if the push was successful. Mostly for debugging. delay(50); digitalWrite(P1_6, LOW); } else{ lockLevel = 1; //If the push is the wrong length, start over. counter = 0; } break; case 2: if (counter >= test2 - wiggleRoom && counter <=test2 + wiggleRoom){ //Second push, same deal. lockLevel = 3; counter = 0; digitalWrite(P1_6, HIGH); delay(50); digitalWrite(P1_6, LOW); } else{ lockLevel = 1; //If the push is the wrong length, start over from push 1. counter = 0; } break; case 3: if (counter >= test3 - wiggleRoom && counter <=test3 + wiggleRoom){ open = true; //Third correct push opens the lock. counter = 0; } else{ lockLevel = 1; counter = 0; } break; } } }
    The next thing I'm inclined to work on is some learning, so that it remembers how long you hold the buttons down and adjusts the official "correct" number to match over time. The other thought is to time the delay between presses and use that as part of the combination, it would complicate the code fairly significantly but also increase security for a given time spent with the button.
    I got the idea while contemplating vehicle security, my thought was to re-use a dash button as the input button and control the fuel pump relay (that wouldn't turn off after three seconds!). That would give you totally invisible anti-theft in theory.
    I can't recommend it exactly, depending on how it's wired a dead MSP430 may render the vehicle suddenly stopped, not ideal!
     
    Thoughts?
  10. Like
    bobnova reacted to energia in Simple one-button combination lock   
    You could look into interrupt driven logic. This could be applied to the unlocking as well as the learning.
    I haven't given this much bought but for the unlocking you could use combination of attachInterrupt() and mills(). The msp430 unfortunately does not have state change interrupt so you will have to flip RISING/FALLING interrupt inside the ISR by detaching and then attaching on the opposite edge. The counter for how long the button was pressed can be updated using mills() inside the ISR...
    You could use the same logic for recording while in learning mode.
  11. Like
    bobnova got a reaction from energia in Simple one-button combination lock   
    One of my first MSP430 projects here, this is a (very) simple one-button combination lock. At the moment it's just using the launchpad's single button and the two LEDs for lock status. You'd need to figure out what you were locking or unlocking and add code for that obviously.
    It's all delay based, so it assumes you aren't doing anything overly crucial other than minding the button, or at least that the other tasks (if any) can be put on hold while the button is being used.
    I'm sure there are "better" ways to do it, but this seems to work so far!
     

    int counter; byte wiggleRoom = 25; //the amount + or - of the exact correct push length to pass a lock level, measured in 10ms steps. byte lockLevel = 1; //Stores what button press the lock is on boolean open = false; boolean buttonState; int test1 = 100; //Number of 10ms steps the button should be held down for the first time int test2 = 50; //Same, for press two. int test3 = 100; //And press 3. So for this setup, we press for 1s, let up, press for 0.5s, let up, press for 1s void setup(){ pinMode(P1_0, OUTPUT); pinMode(P1_6, OUTPUT); pinMode(P1_3, INPUT_PULLUP); } void loop(){ if (!open){ // normal state, red LED on, green LED off. digitalWrite(P1_0, HIGH); //In this section you would shut the lock, whatever it was. digitalWrite(P1_6, LOW); } else{ digitalWrite(P1_6, HIGH); //Open the lock digitalWrite(P1_0, LOW); delay(3000); //Wait a bit. lockLevel = 1; open = false; //Set the lock to close next pass through the code. //Might not be a bad idea to close the lock here too, really. //That would prevent the button being held down keeping the lock open. } buttonState = digitalRead(P1_3); if (!buttonState){ //Button is pushed counter = 0; //reset the counter, this is crucial. while (!buttonState){ //As long as the button is held down, this cycles. counter++; delay(10); //10ms per cycle, record the number of cycles. buttonState = digitalRead(P1_3); //We do need to get out eventually, when the button opens } switch (lockLevel){ //Now that we have a press duration, we need to find what level the lock is on case 1: //If it's the first press, we start here. if (counter >= test1 - wiggleRoom && counter <=test1 + wiggleRoom){ lockLevel = 2; //Adjust wiggleRoom to be the number of 10ms steps you want for wiggle room. counter = 0; //Right now we get +/- 250ms. digitalWrite(P1_6, HIGH); //Flash the green LED if the push was successful. Mostly for debugging. delay(50); digitalWrite(P1_6, LOW); } else{ lockLevel = 1; //If the push is the wrong length, start over. counter = 0; } break; case 2: if (counter >= test2 - wiggleRoom && counter <=test2 + wiggleRoom){ //Second push, same deal. lockLevel = 3; counter = 0; digitalWrite(P1_6, HIGH); delay(50); digitalWrite(P1_6, LOW); } else{ lockLevel = 1; //If the push is the wrong length, start over from push 1. counter = 0; } break; case 3: if (counter >= test3 - wiggleRoom && counter <=test3 + wiggleRoom){ open = true; //Third correct push opens the lock. counter = 0; } else{ lockLevel = 1; counter = 0; } break; } } }
    The next thing I'm inclined to work on is some learning, so that it remembers how long you hold the buttons down and adjusts the official "correct" number to match over time. The other thought is to time the delay between presses and use that as part of the combination, it would complicate the code fairly significantly but also increase security for a given time spent with the button.
    I got the idea while contemplating vehicle security, my thought was to re-use a dash button as the input button and control the fuel pump relay (that wouldn't turn off after three seconds!). That would give you totally invisible anti-theft in theory.
    I can't recommend it exactly, depending on how it's wired a dead MSP430 may render the vehicle suddenly stopped, not ideal!
     
    Thoughts?
×
×
  • Create New...