element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Upcycle It
  • Challenges & Projects
  • Design Challenges
  • Upcycle It
  • More
  • Cancel
Upcycle It
Blog [Upcycle It] Interactive Race Car Driver - We have the technology to rebuild him
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Workshopshed
  • Date Created: 2 Jun 2017 11:32 AM Date Created
  • Views 761 views
  • Likes 4 likes
  • Comments 4 comments
  • upcycled_interactiveracecardriver
Related
Recommended

[Upcycle It] Interactive Race Car Driver - We have the technology to rebuild him

Workshopshed
Workshopshed
2 Jun 2017

After the various modifications, repairs and tests it was time to put the Furby back together. The speaker wires were soldered in place and all the cables hot glued to act as a basic strain relief. A hole was made through the battery box to route the wires through to the Edison (via the level shifters). The power cables were extended and a couple of damaged links on the board were replaced. Once that was done the case could be re-assembled.

image

Power

As mentioned previously the Edison needs 7v to be able to power the board and USB correctly. To support this a boost regulator was added to the circuit based on the popular XL6009 chip. I initially planned to keep the 5v regulator from the origional battery box but that was not working when I tried it. Instead, I added a switch so that the battery can be switched between charging and powering. This can also be used as an off switch. I used the 100Ω high power resistor from the LED downlighter to load the board whilst I adjusted the output to 7v. I also checked that it stayed at 7v when the load was off.

imageimage

Level Shifters

I tested the level shifters with a dual power supply and a multimeter. Three worked as expected but one did not. Rather than 7v / 0v, there was around 2v on the output. So I swapped out the FRB590 with a BC549 and it tested ok.

imageimage

H-Bridge

The H-Bridge has been wired up and tested with the Furby's motor.

Update 4/6

I nearly forgot to include the H-Bridge but luckily there was a bit of space under the Edison.

image

Edison

Thanks to gpolder and the pinout he found, soldering up the connections to the breakout board was straight forward.

image

Update 4/6

 

Perhaps not as simple as I first thought as when I checked it again today one of the pins was in the wrong place, VBat vs Pin19. So I resoldered those.

 

My MCU code needed to be updated to reflect the new pins selected. I believe I have these correct but need to test them.

 

    gpio_setup(183, 0);  /* set GPIO 183 DIG9 as input*/

    gpio_register_interrupt(183, 1, IRQpulse);

    gpio_setup(49, 0);  /* set GPIO 49 DIG8 as input*/

    gpio_register_interrupt(49, 1, IRQreset);

 

Software

For the software side, the Furby needs to respond the events happening on the car. By subscribing to the same message queue as the car we can use pretty much the same code as for the car but just have different actions.

The previously developed MCU app communicates to the motor controller via the host control API and a bidirectional (or duplex) stream.

image

The duplex stream has "on" events for when data is recieved and a write method to send data.

var stream = require('stream');
var util = require('util');
var fileduplex = require('file-duplex');

var mcu = new fileduplex('/dev/ttymcu0');

mcu.on('data', function(data) {
    console.log('Data %s',data);
});

mcu.on('error', function(error) {  
    console.log('Error %s', error);
});

mcu.write("M"); //Request max value
mcu.write("C"); //Request counter value
//mcu.write("U"); //Count up
//mcu.write("D"); //Count down

 

Putting that together with the MRAA code from previous, we get the motor controller class for the Furby.

var mraa = require('mraa');

    var Motor = function (D1Pin, D2Pin, SpeedPin, HomePin, SensePin, mcuStream) {
    var self = this;

    self.MotorPin1 = new mraa.Gpio(D1Pin);
    self.MotorPin1.dir(mraa.DIR_OUT);
    self.MotorPin2 = new mraa.Gpio(D2Pin);
    self.MotorPin2.dir(mraa.DIR_OUT);
    self.MotorPinSpeed = new mraa.Pwm(SpeedPin);  //PWM available on default swizzler positions. (3,5,6,9)
    self.MotorPinSpeed.period_us(700);
    self.MotorPinSpeed.enable(true);
    self.mcu = mcuStream;
    self.positionDelta = 10;  //How many counter positions is close enough?
    self.counter = 0;
    self.max = 0;
    self.target = -1;    //What counter position to goto
    self.mcu.write("M"); //Ask the MCU to get the maximum value

    self.mcu.on('data', function(data) {
    switch (data.substring(0,1)) {
        case "C": {
            self.counter = data.substring(1);
            if (self.InPosition()) {
                console.log("Position found at %d", self.counter);
                self.Stop();
                self.target = -1;  
            }
            setTimeout(function() {self.mcu.write("C") },10);
            break;
        }
        case "M": {
            self.max = data.substring(1);
            break;
        }
        default:  
            console.log("Unexpected data recieved %s",data);
    }
    });

    self.mcu.on('error', function(error) {  
        console.log('Motor MCU error occurred %s', error);
    });

    self.Reset = function() {
        //Set the motor running for long enough to trigger a reset then stop
        var timeForOneRev = 1000;
        self.Forward();
        setTimeout(function() { self.Stop() },timeForOneRev);
        setTimeout(function() { self.mcu.write("C") },timeForOneRev);
    }

    self.Forward = function() {
        self.mcu.write("U");
        self.MotorPin1.write(1);
        self.MotorPin2.write(0);
    }

    self.Reverse = function() {
        self.mcu.write("D");
        self.MotorPin1.write(0);
        self.MotorPin2.write(1);
    }

    self.Stop = function() {
        self.target=-1;
        self.MotorPin1.write(0);
        self.MotorPin2.write(0);
    }

    self.Speed = function(percent) {
        self.MotorPinSpeed.write(percent);
    }

    self.Position = function() {
        return self.counter;
    }

    self.Max = function() {
        return self.max;
    }

    self.Distance = function(newPosition) {
        //What is the distance from the current position to the new position
        var p = self.Position();
        var m = self.Max();
        var D1 = newPosition - p;
        var D2 = (m - p) + newPosition;
        if (Math.abs(D1) < Math.abs(D2))
            return D1;
        else
            return D2;
    }

      self.Direction = function(newPosition) {
            return Math.sign(self.Distance(newPosition))
      }

      self.InPosition = function() {
          if (self.target == -1) return false; //Not going to a position
          return ((self.Distance() * self.Direction()) < self.positionDelta);
      }

      self.Goto = function(newPosition) {
            self.target = newPosition;
            if (self.InPosition()) {
                self.target=-1;
                return;
            }
            if (self.Direction(newPosition) > 0) {
                self.Forward();
            }
            else {
                self.Reverse();
            }
      }
};

    module.exports = Motor;

 

There's still a bit to be done with the software but I hope to have enough for a demo this weekend.

 

Reference

XL6009 DC-DC Converter Datasheet

How to create duplex streams with Node.js - a Nodejs programming tutorial for web developers | CodeWinds

https://nodejs.org/api/stream.html

https://www.npmjs.com/package/file-duplex

 

Previous Posts

Upcycle It Blogs tagged with upcycled_interactiveracecardriver

  • Sign in to reply

Top Comments

  • jasonwier92
    jasonwier92 over 8 years ago +1
    Nice write up. At this point, keep it simple and get it finished. Then add in bells and whistles, you are getting so close. I cannot wait for the demo!
  • Workshopshed
    Workshopshed over 8 years ago in reply to jasonwier92 +1
    At this point, keep it simple and get it finished. Indeed. There's still quite a check list but the items are getting checked off. I did think about making the car and driver communicate via BlueTooth…
  • DAB
    DAB over 8 years ago +1
    Great update Andy. Getting everything back together is a good step. Now you just need to put the fur back to hide all of the seams and you are good to go. DAB
Parents
  • jasonwier92
    jasonwier92 over 8 years ago

    Nice write up.  At this point, keep it simple and get it finished.  Then add in bells and whistles, you are getting so close. I cannot wait for the demo!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 8 years ago in reply to jasonwier92

    At this point, keep it simple and get it finished.

    Indeed. There's still quite a check list but the items are getting checked off. I did think about making the car and driver communicate via BlueTooth but I realised this morning that I can use MQTT over wifi, two things I've already setup and configured.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • Workshopshed
    Workshopshed over 8 years ago in reply to jasonwier92

    At this point, keep it simple and get it finished.

    Indeed. There's still quite a check list but the items are getting checked off. I did think about making the car and driver communicate via BlueTooth but I realised this morning that I can use MQTT over wifi, two things I've already setup and configured.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • jasonwier92
    jasonwier92 over 8 years ago in reply to Workshopshed

    Agree, Mqtt will work fine over wifi.

     

    I'd also like to play with Bluetooth, but time is not on my side.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube