barryjh

Member Since: March 2, 2012

Country: United States

Profile

Programming Languages: C, C++, Java, Linux shell scripts.

Web Site: www.miser-tech.com

Lessons in Algorithms

December 21, 2016

Learn techniques on how to use Finite Impulse Response (FIR) filters and other data-processing tools to turn data into information.
  • Cool experiment.

    After watching the video a few things come to mind about the speeding off and falling over. Assuming the speeding off is due to an error correction above some threshold. Could it be any of the following?

    1. The motor does not have a high enough top end speed to get the wheels back under itself.
    2. The motor does not have enough torque to create enough acceleration to overcome the falling acceleration and reverse it.
    3. The horizontal speed somehow effects the vertical acceleration reading making the algorithm think it has righted the ship and then it slows and falls over.
  • No, no, that is my caption, not a snide remark.

  • “OMG, we’re going to have a caption contest and only give away a tactile switch!!!”

  • Before starting this wire wrap job, I bought one of those fancy wrappers that held the spool of wire and stripped as it wrapped so I could just move pin to pin for the bus connections. Imagine the fun I had finding a loose wire in there.

  • Well, I don’t have a project from 15 years ago that I used a Sparkfun product on, but while we are looking back at the past I have a contrast between projects done 30 years in between. I contrasted an all wire wrap board with a PCB board I built using knowledge I gained on the Sparkfun website that enabled me to design my own board and do the surface mount soldering. When I saw how easy Nate made it look to do surface mount soldering I decided to take the plunge and haven’t looked back. Here is a photo of 1985 versus 2015.

    I found this 30+ year old gem in my garage while doing some rearranging. I just couldn’t throw it out every time I would think back about all the work that went into that wire wrapping. Here is a link to the full article.

  • How about “Bumble Bot”. Since it doesn’t have weapons its kind of like the Abominable Snowman that had all its teeth pulled in the Rudolph the Red Nose Reindeer movie. :)

  • Pete, I write a lot of code dealing with Endianess between processors and from your bit pattern graphic, it appears the SBUS data is little endian with channels packed in a structure with 11bit bit channel fields. If the micro you use is little endian which most seem to be you can use the following structure to decode the Futaba SBUS. Its not good practice to send bit field structures in communication messages, but since the controller already did it,why not use such a structure on the other side. This might make using SBUS data easier to understand. Just put this structure definition above your setup() function.

    struct FutabaSBUS
    {
      uint8_t  start;
      uint16_t channel1 : 11;
      uint16_t channel2 : 11;
      uint16_t channel3 : 11;
      uint16_t channel4 : 11;
      uint16_t channel5 : 11;
      uint16_t channel6 : 11;
      uint16_t channel7 : 11;
      uint16_t channel8 : 11;
      uint16_t channel9 : 11;
      uint16_t channel10 : 11;
      uint16_t channel11 : 11;
      uint16_t channel12 : 11;
      uint16_t channel13 : 11;
      uint16_t channel14 : 11;
      uint16_t channel15 : 11;
      uint16_t channel16 : 11;
      uint8_t  unused;
      uint8_t  stop;
    };
    

    You can simply overlay over the RX_array a reference variable of the structure type and then use it to decode the channels and flag fields. For example put this below your array definition:

    uint8_t RX_array[25];
    FutabaSBUS& sbus = *(FutabaSBUS*)RX_array;
    

    Then in your loop after reading data into the buffer you can simply do this:

    channel[1] = sbus.channel1;
    channel[2] = sbus.channel2;
    

    etc…

    Also you can just use the sbus fields directly in your code like this without copying into a channel array:

    //set up light mode on channel 7 
    if (sbus.channel6 < 0x00FF) mode = 0;
    else if ((sbus.channel6 > 0x00FF) && (sbus.channel6 < 0x0400)) mode = 1; 
    else if (sbus.channel6 > 0x0700) mode = 2; 
    

    If you port this code to big Endian just copy the bytes as they come in from the SBUS using index 24 down to 0 rather than 0 to 24, and reverse all the fields of the FutabaSBUS structure and it will decode big endian.

    I did run a test just poking a few data values into the array to verify output and all looks good and as you can see the structure is a size of 25 bytes. This verifies the Arduino compiler produces compatible code.

    RX_array[0] = 0xFF;
    RX_array[1] = 0x01; // Poke a 1 into channel 1 bits
    RX_array[2] = 0x10; // Poke a 2 into channel 2 bits
    RX_array[24] = 0x10;
    
    printf("Struct size = %d\n",sizeof(FutabaSBUS));
    printf("start = %d\n",sbus.start);
    printf("channel1 = %d\n",sbus.channel1);
    printf("channel2 = %d\n",sbus.channel2);
    printf("stop = %d\n",sbus.stop);
    

    The test code produced this output on little endian ESP8266 Thing Dev:

    Struct size = 25

    start = 255

    channel1 = 1

    channel2 = 2

    stop = 16

  • As you can tell I am clueless about Drone’s not having played around with one yet. I was thinking the guts of what’s in the RC controller that a uC or SBC could provide virtual steering, speed, etc data on the channels going up to the drone, however that would mean I would need a feed back with current positioning to fly to a location with virtual controls. I guess what your saying is that I would want custom flight controller on board as well so it would know where its at while flying to coordinates that it can receive via any wireless medium, like Xbee etc.

    I guess open source or hackable flight controllers may already exist for such a thing.

  • Very interesting. OK, I know you’re just getting started with grabbing channels off the drone’s bus, but I’m already thinking ahead. Do you have any plans to create a hack-able remote control piece to put custom stuff on those channels? I’ve been working on what I call “Avatar Framework” to allow local networked devices (sensors/control apps/actuators) to find one another and interact with very low latency. I’ve blogged in the early days of my endeavor that a very advanced actuator could be a drone. So naturally after watching this I’m seeing the possibility of the super mobile electronic watchdog. Perhaps the “ROVER” would be a fitting name :). Anyway a special remote controller with network connectivity could receive an actuator command to check out specific coordinates due to a motion sensor that went off in a particular area of the backyard and ROVER could be dispatched to that area to get video and what ever other surveillance deemed necessary. Even if it was only a Deer it scared off, it might have saved your vegetable garden. Perhaps that kind of operation could be worked into the AVC competition in the future as a super advanced mission. Anyway, just wondering if you had any plans on eventually hacking the other side of those channels.

  • I know it was intentional but I had to bitch anyway since the possible methods are numerous. I’ll be interested to see the method you went with and the reasons you selected the method. If it does include filtering sampled data I’ll be interested to see if you designed a FIR using TFilter :)

No public wish lists :(