Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. slarti
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by slarti

    • RE: [contest] Yet another servo blind control project

      My ethernet gateway died and I made another one on a Raspberry Pi so I updated all of my sensors from 1.4 libraries to 2.2. Here's the updated sketch for these servo blind control nodes:

      // A sketch to control a servo with a button and MySensors messages
      //#define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      #include <SPI.h>
      #include <MySensors.h>
      
      #include <Servo.h>
      #include <Button.h>        	//https://github.com/JChristensen/Button
      
      #define BUTTON_PIN 4       	//Connect a tactile button switch (or something similar)
                                  //from Arduino pin 4 to ground.
      #define PULLUP true        	//To keep things simple, we use the Arduino's internal pullup resistor.
      #define INVERT true        	//Since the pullup resistor will keep the pin high unless the
                                 	//switch is closed, this is negative logic, i.e. a high state
                                 	//means the button is NOT pressed. (Assuming a normally open switch.)
      #define DEBOUNCE_MS 20     	//A debounce time of 20 milliseconds usually works well for tactile button switches.
      #define LONG_PRESS_PERIOD 700   //How long to keep button pressed until sweeping starts
      
      #define MAX_DEGREES 180         //Servo limits. Whatever works for you.     
      #define MIN_DEGREES 0
      
      #define CHILD_ID 3
      
      Button myBtn(BUTTON_PIN, PULLUP, INVERT, DEBOUNCE_MS);    //Declare the button
      
      Servo myservo;
      enum {DECREASING, INCREASING};      //On a servo mounted on the left, with outer slat edge down as closed,
                                          // closing is going toward 180, opening toward 0 (on my fake futaba s3003's)
      
      boolean invertConversions = true;   // false if opening toward 180
      boolean servoDirection = INCREASING;     //A variable that keeps the current servo direction
      int servoPin = 3;                  
      int servoPosition;
      int servoSpeed = 1;                 // The bigger, the faster. 1=slow 5=fast
      
      
      MyMessage msg(CHILD_ID, V_PERCENTAGE);
      
      
      
      void setup(void)
      {
        
      }
      
      void presentation()  {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Servo", "1.3");
      
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID, S_COVER);
      }
      
      void loop(void)
      {
          myBtn.read();                    		//Read the button
      
          if (myBtn.wasReleased()){                   //If the button was pressed once sweep to end of current direction
              SweepToDirectionEnd();
              send(msg.set(ConvertDegToPercent(servoPosition)));
          }
          if (myBtn.pressedFor(LONG_PRESS_PERIOD)){   //If the button is held down the servo will start to sweep
              SweepUntilStop();
              send(msg.set(ConvertDegToPercent(servoPosition)));
          }
      }
      
      
      int ConvertPercentToDeg(int percent)
      {
          int degree;
          if (invertConversions)
              degree = map(percent, 0, 100, MAX_DEGREES, MIN_DEGREES);
          if (!invertConversions)
              degree = map(percent, 0, 100, MIN_DEGREES, MAX_DEGREES);
          return degree;
      }
      
      
      int ConvertDegToPercent(int degree)
      {
          int percent;
          if (invertConversions)
              percent = map(degree, MAX_DEGREES, MIN_DEGREES, 0, 100);
          if (!invertConversions)
              percent = map(degree, MIN_DEGREES, MAX_DEGREES, 0, 100);
          return percent;
      }
      
      void receive(const MyMessage &message) {
          myservo.attach(servoPin);
          if (message.type==V_PERCENTAGE) {
              int val = message.getInt();
              SweepToPosition(ConvertPercentToDeg(val)); //In this case the value has to be inverted because 0 = open
              send(msg.set(val));
          }
          else if (message.type==V_STATUS) {
              if (message.getInt() == 1){
              SweepToPosition(ConvertPercentToDeg(100));
              send(msg.set(100));
            }
              else if(message.getInt() == 0) {
              SweepToPosition(ConvertPercentToDeg(0));
              send(msg.set(0));
            }
          }
          else
              myservo.detach();
      }
      
      
      
      
      void ServoMoveUp()
      {
          if ((myservo.attached()) && servoPosition < MAX_DEGREES){
              servoDirection = INCREASING;
              servoPosition += servoSpeed;
              myservo.write(servoPosition);
              delay(10);
              Serial.print("Servo Position: ");
              Serial.println(servoPosition);
          }
          if (!myservo.attached()){      
              Serial.println("Servo stopped while moving toward MAX, direction unchanged");
              delay(100 * servoSpeed);
          }    
          if (servoPosition >= MAX_DEGREES){
              Serial.println("MAX reached, changing direction toward MIN");
              servoDirection = DECREASING;
              delay(100 * servoSpeed);			// Wait for the last movement to finish
          }
      }
      
      
      void ServoMoveDown()
      {
          if ((myservo.attached()) && servoPosition > MIN_DEGREES){
              servoDirection = DECREASING;
              servoPosition -= servoSpeed;
              delay(10);
              myservo.write(servoPosition);
              Serial.print("Servo Position: ");
              Serial.println(servoPosition);
          }
          if (!myservo.attached()){
              Serial.println("Servo stopped while moving toward MIN, direction unchanged");
              delay(100 * servoSpeed);
          }    
          if (servoPosition == MIN_DEGREES){
              Serial.println("MIN reached, changing direction toward MAX");
              servoDirection = INCREASING;
              delay(100 * servoSpeed);
          }
      }
      
      
      void SweepToDirectionEnd()
      {
          myservo.attach(servoPin);
          if (servoDirection == INCREASING){
              Serial.println("Going to MAX and stopping there");
              while (servoPosition < MAX_DEGREES){
                  ServoMoveUp();
              }
              delay(20 * servoSpeed);
              myservo.detach();
          }
          else if (servoDirection == DECREASING){
              Serial.println("Going to MIN and stopping there");
              while (servoPosition > MIN_DEGREES){
                  ServoMoveDown();
              }
              delay(20 * servoSpeed);
              myservo.detach();
          }
      }
      
      
      void SweepUntilStop()
      {
          myservo.attach(servoPin);
          while (myBtn.isPressed()){
              myBtn.read();
              if (myBtn.isReleased())
                  myservo.detach();
              if (servoDirection == INCREASING)
                  ServoMoveUp();
              if (servoDirection == DECREASING)
                  ServoMoveDown();
          }
      }
      
      
      void SweepToPosition(int destination)
      {
          if (abs(destination - servoPosition) >= servoSpeed)    //Don't move if destination is close to position
              myservo.attach(servoPin);
          if (destination > servoPosition && myservo.attached()){
              Serial.print("Going to ");
              Serial.print(destination);
              Serial.println(" and stopping there");
              while (servoPosition < destination){
                  ServoMoveUp();
              }
              delay(20 * servoSpeed);
              myservo.detach();
          }
          if (destination < servoPosition && myservo.attached()){
              Serial.print("Going to ");
              Serial.print(destination);
              Serial.println(" and stopping there");
              while (servoPosition > destination){
                  ServoMoveDown();
              }
              delay(20 * servoSpeed);
              myservo.detach();
          }
      }```
      posted in My Project
      slarti
      slarti
    • RE: [contest] Yet another servo blind control project

      @Nuubi Yes, I've been happy with them but MySensoring the rest of them is on hold. I've been extremely busy with a new job for a long time and I was supposed to do a few more improvements and tweaks before doing the rest of them. Also, my tinkering space (the kitchen table) is always under heavy pressure from other activities. Maybe I can get some time during the winter.

      TL;DR I've been lazy

      posted in My Project
      slarti
      slarti
    • RE: [contest] Yet another servo blind control project

      @Nuubi Can you show your connections?

      posted in My Project
      slarti
      slarti
    • RE: [contest] Yet another servo blind control project

      @exosteph I would think so since these are just MySensors actuator nodes.

      The sketches are made using MySensors 1.4 libraries so they might not work with 1.5. I've been really busy lately and haven't had any time for this stuff 😢

      I did make some helper boards earlier to make it easier to solder these sensors (nevermind the horrible soldering)

      IMG_20150314_195847.jpg
      IMG_20150319_173009.jpg IMG_20150319_172532.jpg IMG_20150319_173020.jpg

      posted in My Project
      slarti
      slarti
    • RE: Step-up / Boost regulator PCBs

      @bjornhallberg Good to know, thanks! Seems we had the same problems.

      posted in Hardware
      slarti
      slarti
    • RE: Step-up / Boost regulator PCBs

      Oh, yeah. Did you get a .gml file (milling)? If I included one of those every viewer went nuts and DirtyPCB wouldn't accept the file. When I left it out, everything was fine except for the problem described above.

      posted in Hardware
      slarti
      slarti
    • RE: Step-up / Boost regulator PCBs

      @bjornhallberg No, I only have the outline in the .gko file. It shows up fine in the picture generated by the panelizer but not in (almost) any viewer I've tried. Well, I sent the files in already so I guess we'll see what happens... 😉

      posted in Hardware
      slarti
      slarti
    • RE: Step-up / Boost regulator PCBs

      @bjornhallberg I'm trying to make some boards with the panelizer as well but I can't get the slots in the middle to show up in most gerber viewers. Did you have this problem? If so, how did you resolve it?

      Example:

      sfgfdsf.PNG

      The slots ARE in the .gko file but won't show up.

      posted in Hardware
      slarti
      slarti
    • RE: Windows GUI/Controller for MySensors

      Hi and thanks for a cool piece of software!

      I finally got around to soldering an ethernet gateway and decided to give this a spin. It worked like a charm for a while but now I get this error everytime any message goes through the gateway to Vera:

      myscontroller error.PNG

      OS is 32-bit Windows 7

      I can only get rid of this behaviour if I delete the configuration settings file and start over. It seems it only happens if I have logging enabled and exit the program and restart it.

      I'll have to start playing with the bootloader soon to get the OTA capabilities.

      posted in Controllers
      slarti
      slarti
    • RE: Servo issues - Weird things happening!!

      Sorry, no idea. I think your servo is faulty somehow.

      Here's my current sketch I use with my fake futaba 3003's which works fine with them. I got some TowerPro MG996R's but they don't move the whole 180 degrees for some reason. Went with the futabas and modified the TowerPros to continuous rotation.

      https://codebender.cc/sketch:79845

      posted in Troubleshooting
      slarti
      slarti
    • RE: [contest] Yet another servo blind control project

      Ok, I'm calling this one finished. I got all the wiring done and my sketch is working well enough (I'll update the first post). The result doesn't look too bad, either.

      I don't know if the little charger doesn't have enough power for the four arduinos and servos at once or if the radio network gets clogged up when Vera tries to control them all at the same time, but they work well as a group when I add a 500ms delay between each command. Here's the lua script I've put in a scene:

      local SSID = "urn:upnp-org:serviceId:Dimming1" 
      local value = luup.variable_get(SSID, "LoadLevelStatus", 59)
      windows = {59, 58, 54, 61}
      if (value == "0") then
        for i=1,4 do
          luup.call_action(SSID, "SetLoadLevelTarget", {newLoadlevelTarget = "100"}, windows[i])
          luup.sleep(500)
        end 
      else
        for i=1,4 do
          luup.call_action(SSID, "SetLoadLevelTarget", {newLoadlevelTarget = "0"}, windows[i])
          luup.sleep(500)
        end
      end
      

      It just looks up the status of the first window and then changes all positions to the exact opposite of that single window.

      I'll update the first post with a video of them being controlled with a zwave fibaro switch that controls another hidden fibaro switch which triggers the lua script in Vera (that's not complicated at all 😉 ).

      All in all, this ended up costing almost as much as a commercial solution if you count all the stuff I ordered from ebay and the tools I had to buy. On the other hand I now own the tools and I have a ton of leftover material for several more windows and sensors and now I know some C++, lua and even eagle CAD! Very happy with the end result. Thanks to the MySensors team for making it possible! 👍

      Here's the parts list (price/window):

      • Servo extension cables (2pcs 0.88€)

      • Servos (1pc 2.78€)

      • Bobbins (1pc 0.09€)

      • Buttons (1pc 0.70€)

      • Heat shrink tube (maybe 0.10€ worth)

      • Cat6 cable (solid core) (maybe 0.10€ worth)

      • Protoboard (1pc 0.20€)

      • Project box (1pc 1.44€)

      • Cable raceway (about 1€)

      • 3.3V regulators (1pc 0.12€)

      • 4,7 uF capacitors (1pc 0.16€)

      • various bits and pieces I can't think of now (can't think of a price, either)

      • 5v Arduino Pro Mini clone (1pc 2€)

      • NRF24L01+ -radio (1pc 0.70€)

      Grand total/window : 10.27€

      posted in My Project
      slarti
      slarti
    • RE: [contest] Yet another servo blind control project

      After soldering three ratsnests like the one in the previous post, I decided there has to be a simpler way to do things. So after a day of watching eagle cad tutorials and messing about with the software I came up with a board of my own.

      top_osh.png
      bot_osh.png

      I didn't want to add any stuff I didn't need except for a pin header for raw input, A0-breakout and a choice of 5V/3.3V output for A0 and D4 with a jumper. I also don't want to solder every pin on the pro mini so I can use them possibly elsewhere.

      Am I shooting a fly with a cannon? Do I need something else on the board? DirtyPCB and other chinese manufacturers are closed at the moment but are there alternatives besides OSHPARK?

      BTW, three arduinos and servos seem to be the maximum simultaneous capacity for the little Nokia charger. They all work but get a bit flaky after a few tests. We'll see what happens when I add the fourth 😉

      posted in My Project
      slarti
      slarti
    • RE: [contest] Yet another servo blind control project

      First finished sensor!:
      IMG_8136.jpg
      IMG_8135.jpg
      IMG_8134.jpg

      Obvious flaw:
      IMG_8137.jpg

      Whole window
      IMG_8139.jpg

      What is the best way to disable the power LED? Desolder it?

      posted in My Project
      slarti
      slarti
    • RE: [contest] Yet another servo blind control project

      A little bit of progress. Got some functional radios today and I've been trying to fit everything in the control boxes. I think I have an ok design but once I started soldering I realised that the protoboard I was using wasn't dot matrix like it said on the box but copper tracks 😡

      Oh well, I'll have to get something else tomorrow...

      Some mock up pics:

      IMG_8119.jpg
      IMG_8120.jpg
      IMG_8121.jpg
      IMG_8122.jpg

      posted in My Project
      slarti
      slarti
    • RE: Radio setup give: "check wires"

      @olaeke Thanks, made it easy to test the new radios I got today.

      If someone in Europe needs to get radios fast, try this guy in Finland. He advertises the radios as NRF24L01, but they are in fact NRF24L01+.

      posted in Troubleshooting
      slarti
      slarti
    • RE: Radio setup give: "check wires"

      We'll know tomorrow or the day after as I found a Finnish guy with some radios that should be either the real thing or the SI24R1 -clone that should work.

      posted in Troubleshooting
      slarti
      slarti
    • RE: Radio setup give: "check wires"

      @axillent Yes, the pingpong sketch from @olaeke works after I import the MySensors library to the sketch and comment out
      //#include "nRF24L01.h" //#include "RF24.h"
      and
      #define MINIMAL from RF24_config.h

      None of the "normal" examples work or give anything over serial.

      posted in Troubleshooting
      slarti
      slarti
    • RE: Radio setup give: "check wires"

      @axillent That's the funny thing, they were recognized as NRF24L01+ but still refuse to work. I don't get "check wires". I just don't get anything.

      posted in Troubleshooting
      slarti
      slarti
    • RE: Radio setup give: "check wires"

      @axillent I tried it and it worked with the modules but none of the MySensors example sketches work with them. Thread about it.

      posted in Troubleshooting
      slarti
      slarti
    • RE: Radio setup give: "check wires"

      @m26872 Didn't work for me. Please tell me how you do.

      posted in Troubleshooting
      slarti
      slarti
    • RE: Servo issues - Weird things happening!!

      @Mouridsen Try this sketch I use to test servolimits. Just enter the position (percentage) you want in serial monitor. This will probably tell you if there's something wrong with your servo or if there's a problem with the sketch. I can't test the mysensors example with my TowerPro because my radios still haven't arrived.

      link text

      If this works as expected there's something in the example sketch that doesn't agree with your servo. But try this first.

      posted in Troubleshooting
      slarti
      slarti
    • RE: No debug data from sensors or gateway. Bad radios?

      @olaeke Yeah, thanks, I've already done that a week ago but the waiting is really frustrating on a weekend when I have time for this stuff. I think I need to hunt down an european supplier for mission critical stuff like the radios.

      posted in Troubleshooting
      slarti
      slarti
    • RE: No debug data from sensors or gateway. Bad radios?

      @hek OK, so it would be possible to get these things to work by tweaking the code but I assume it's not worth the trouble.

      Just out of curiousity: why would they work with the pingpong sketch? Does it initialize the radio differently?

      posted in Troubleshooting
      slarti
      slarti
    • No debug data from sensors or gateway. Bad radios?

      Hello all

      I bought some suspicious NRF24L01+ -radios from ebay and I wonder if they're the source of my troubles.

      This is what they look like:

      IMG_8093.jpg

      Now I know they don't look like the regular ones but when I tried the pingpong sketch they reported themselves as NRF24L01+ and worked!

      But. When I use them on any example sketch for a node the node doesn't print anything on the serial console. (Yes, I've enabled debugging in MyConfig.h (well, it's enabled by default)).

      A serial gateway on vera seems to work but doesn't include any nodes (the inclusion process starts and stops as expected). I don't know how to verify if the radio works. The only thing the gateway prints on serial when connected to a PC is 0;0;3;0;14;Gateway startup complete.. Nothing else.

      Weirdly, I tried MySensors version 1.3 and did manage to get something on serial from the nodes:

      Started sensor. Open ping reading pipe: 255 Tx: fr=255,to=255,la=255,ne=255,ci=255,mt=4,ty=9,cr=184: No relay nodes was found. Trying again in 10 seconds.

      ...and from the serial gateway:

      0;0;4;11;Arduino startup complete.

      nothing else.

      I'm using arduino IDE 1.0.6 and Mysensors 1.4.1 and I've read and tried every troubleshooting trick including checking the wiring ten times, adding decoupling capacitors and trying different arduinos (uno, nano, pro mini)

      Anyone with any clues?

      posted in Troubleshooting
      slarti
      slarti
    • RE: [contest] Yet another servo blind control project

      @hek Indeed, as is cable raceway. I think I've bought a kilometer of the stuff and it's never enough. Improves the WAF, though.

      I'm surprised how well the little Nokia charger can handle the 4 servos and arduinos, although I haven't tried running all servos at once. I have a bigger 5v power supply in reserve but I haven't needed it yet while testing.

      I'm really frustrated with the radios I have because they seem like the real thing, but I'll post about them in troubleshooting.

      posted in My Project
      slarti
      slarti
    • RE: [contest] Yet another servo blind control project

      Thanks!

      I guess the blinds are the same in the nordic countries.

      I'm really pissed off waiting for the radios, can't really do anything without them... 😞

      ... except for the extremely innovative 5v rail.

      IMG_8100.jpg

      posted in My Project
      slarti
      slarti
    • [contest] Yet another servo blind control project

      Hello all.

      POST UPDATED 13.2.2015

      UPDATE 2: Noticed there's a competition going on and as I think this project qualifies, I'm entering it. So there.

      I've been following this site for a while now and finally decided to register and share my little project.

      I've had a Vera for ages which I've been using for my zwave lights. I really wanted to be able to control my curtains and blinds with it as well, but since it's next to impossible to get moderately priced motors for home automation here in Finland, I started exploring DIY solutions.

      I actually thought I had an original idea about using an Arduino and a servo to tilt my blinds but it turned out I'm late to the party.

      Anyways, here's my project so far and why it isn't finished: (edit: It is now...)

      First of all, blinds in Finland are almost always what the Americans call mini-blinds because we put them between the outer and inner windows and they are almost identical everywhere. This means my solution should work for most Finns... 😉

      THE MECHANICAL PART:

      The blinds are adjusted with a rod directly linked to the shaft that tilts the slats.

      IMG_8043.jpg

      This is removed. (Nevermind the dirt.)

      IMG_8044.jpg

      The little connecting springrod needs to removed as well.

      IMG_8050.jpg

      The D-shaft in the middle is the thing the servo needs to move.

      IMG_8049.jpg

      So we need some way to connect the servo spline to the shaft. There are shaft couplers available for servos but they cost about three times as much as the servos! So I swiped an idea from the guys making sail winch servos. Bobbins!

      IMG_8054.jpg
      IMG_8056.jpg

      Needs a little persuasion.

      IMG_8057.jpg
      IMG_8058.jpg
      IMG_8060.jpg
      IMG_8061.jpg

      Cut the coupler with the little set screw from the little springrod.

      IMG_8062.jpg
      IMG_8064.jpg

      I was going to glue this together but I couldn't find any, so I soldered it. Don't know how well that is going to hold.

      IMG_8065.jpg

      I installed the coupler to the opposite side so that the servo won't interfere with the strings used to pull up the blinds. The D-shaft slides with little force.

      IMG_8067.jpg

      I adjusted the slats to where I think they are closed (slat outer edge down). Some people have different views about the matter but they're just wrong 🙂 I didn't attach the servo just yet.

      IMG_8074.jpg

      The servo lined up perfectly in the housing and with the D-shaft after I de-tabbed it.

      IMG_8069.jpg
      IMG_8070.jpg

      After this, I gently disconnected the wires from the servo extension cable connector so I could thread it back through the rod hole. (The string goes through the lower hole in a spring tunnel)

      IMG_8075.jpg
      IMG_8077.jpg
      IMG_8078.jpg

      I put the connector back on the other side.

      IMG_8087.jpg

      ELECTRICAL PART

      UPDATE The finished sensor

      I really wanted to have a physical button to adjust the blinds so I put one in this temporary box along with a 5v pro mini.

      IMG_8032.jpg
      IMG_8031.jpg
      IMG_8034.jpg

      I spliced in to another servo extension cable 5v from a phone charger. (Note to self: don't cut the wires so damn close to the connector!)

      IMG_8035.jpg

      This makes it easy to connect the button box with the servo cable and both are powered.

      IMG_8040.jpg

      The final version will have a DC socket at the junction so I can just run an easily disconnectable plug to every window. The holes are always on the hinge side so the window can be opened even without unplugging. I'll also wrap everything nicely in white heat shrink tubing and the box will be nicer, too.

      THE CODE PART

      This one was/is the most difficult for me because I had exactly zero experience with C++. Or any C. I've used a bit of python and some simple shell scripts but this was new. Anyways, I managed to write this:

      **UPDATE:**This is just test code for use without the Mysensors stuff. Scroll down for working code.

      link text

      Why this is bit complicated is because I wanted the button to do two things:

      • Press once; toggle open/close

      • Keep pressing the button; sweep back and forth until button is released and stop there.

      At the moment it does just that.

      I connected the servo to the shaft once I figured out with the button which way was closed and which way was open. 180 degrees was exactly the difference between open and closed.

      Now some of you may be thinking, "what the hell has this got to do with mysensors?" That's why the title is tagged [WIP]. I've been waiting for my NRF24L01+ -modules to arrive for a month and finally today they arrived.

      And they're not NRF24L01+ -modules.

      BUY YOUR RADIOS FROM THE MYSENSORS EBAY STORE LINK

      IMG_8093.jpg

      They were sold as NRF24L01+'s but they definitely are not. So now I have to wait again.

      Meanwhile, could someone tell me if they see something horribly wrong with this sketch I've been planning to use once I do get the radios? I can't really test it. (This works well now)

      UPDATE: Code is VERY much refactored and improved (works well)
      link text

      Oh yeah, some video:

      link text

      link text

      Sorry for the long post.

      posted in My Project
      slarti
      slarti