collapse

Welcome!



Welcome to Robot Rebels, an online robot maker community.

Register today to post your projects, ask questions, share knowledge and meet like-minded people from around the world.


The RobotRebel.org Community

Author Topic: 1B1 -- RAN Stack  (Read 660 times)

Ladvien

  • Alabtu-ian Refugee
  • Member
  • *
  • Posts: 57
1B1 -- RAN Stack
« on: April 14, 2018, 05:23:25 AM »
Ladvien's Lab -- 1b1

Not too long ago there was a post on Hackaday about a little four-wheeled bot made with a Raspberry Pi and some eBay motor drivers.



Raspberry Pi Zero Drives Tiny RC Truck

I really liked the little chassis, ordered one, and was happy to find it was delivered with the motors already mounted.  (As I become an aged hacker, it's the little time savers which are genuinely appreciated.)

On buying the chassis I'd already decided to use one of my Raspberry Pi Zero W's (rp0w) to control the bot.  I really like Arch Linux on the rp0w.  It's light weight and the packages are well curated.  Again, it's the little time savers.  I liked the combination even more since I found a way to set the rp0w headlessly, which meant I could go from SD card to SSH'ing into little Linux board.

Headless Arch Linux on Raspberry Pi Zero W

Coincidentally, I purchased several DRV8830 modules from eBay.  This is a sad story -- I've played with the DRV8830 chip a long time ago:

Kobold

 Because Sparkfun did a great job of documenting the IC and creating an Arduino library to go with it.  I was disheartened to find Sparkfun and EOL'ed the boards.

MiniMoto Boards

Probably because buttholes like me kept buying them off eBay.  I've got some mixed feelings here -- one of them is guilt.


Anyway, I was surprised to find the mounting holes on the DRV8830s matched a set on the chassis. I decided to attempt using one module to drive two motors, thereby only needing two DRV8830 modules to drive the entire bot.

I've had some thermal paste lying about for years--it works nicely as an adhesive.  Also, I was hoping to use the chassis to heatsink the motor drivers.







A bit of a tangent.  At work one of the skills which is useful for our team is being able to work with APIs.  For awhile I've wanted to learn NodeJS, since it seems to be the goto framework for solid back-end business applications.  It doesn't hurt StackOverflow's Developer Survey for the last few years has shown JavaScript is a solid language to stay sharp on.  Specifically, being able to work within the NodeJS framework makes one pretty darn marketable.

StackOverflow's 2018 Develop Survey

Ok, for these reasons I decided to build this bot using NodeJS.  I've written a separate article on setting up NodeJS, working with i2c-bus, and porting the DRV8830 Sparkfun library to NodeJS.

Not yet written (shesh, been busy.  Judge much? :P)


It didn't take time at all to get the little motor spinning using NodeJS largely due to Michael Hord's (Sparkfun) MiniMoto library. (Again, some guilt here.)

NodeJS DRV8830 Library

I drove the motor shown using two series Li-Ion batteries connecting to a buck converter set to output ~5.0v.  The motor spun nicely and pulled around 200mA.  However, the real test would be connecting to _two_ geared motors per DRV8830.


Code: [Select]
'use strict';
var i2c = require('i2c-bus'), i2c1 = i2c.openSync(1);
var sleep = require('sleep');
var drv8830 = require('./drv8830');

const motorAddressOne = 0x61;
const motorAddressTwo = 0x67;

var motor1 = new drv8830(motorAddressOne, i2c1);
var motor2 = new drv8830(motorAddressTwo, i2c1);

motor1.drive(50);
motor2.drive(50)
sleep.msleep(3500);
motor1.drive(-50);
motor2.drive(50);
motor1.stop()
motor2.stop()



It was time to wire up the chassis motors and create a test of the system.  The wire used was some eBay single core aluminum wire (the cheap stuff).  Wiring was pretty straightforward.

However, I did make a little i2c bus board from perfboard and JST connectors.  Adding both ceramic and electrolytic decoupling capacitors for smoothing and to aid peak discharge.

Note the heaping amount of heatsink goop on the underside of the perfboard, this was a hacker's solution to galvanically isolating the perfboard from the steel chassis.







One-B-One Schematic

Code: [Select]
+--------------+                    +------------------+           +------------------+
|              |                    |                  |           |                  |
|              +--+LEAD1+----+OUT1+-+                  |VCC----+5V-+                  |
|              |                    |                  |           |                  |
| Motor 1      +--+LEAD2+----+OUT2+-+   DRV8830+A      +----GND----+  Buck Regulator  |
|              |                    |                  |           |                  |
|              |                    |                  |           |                  |
|              |                    |                  |           |                  |
+--------------+                    +-----+---+--------+           +--+--+------------+
                                          |   |                       |  |
                                      SDA1|   | SCL1               5V |  | GND
                                          |   |                       |  |
                                          |   |                       |  |
                                          |   |                       |  |
                                          |   |                       |  |
                                     +----+---+--------+              |  |
                                     |                 |              |  |
                                     |                 |              |  |
                        +----+VCC2+--+  ADUM1250ARZ    ++VCC1+--------+  |
                        |            |                 |                 |
                        |   ++GND2+--+                 ++GND1+-----------+
                        |   |        |                 |
                        |   |        +----+--+---------+
                        |   |             |  |
                        |   |         SDA1|  | SCL2
                        |   |             |  |
                        |   |             |  |
                        |   |             |  |
                  +-----+---+-------------+--+-------+

                            Raspberry Pi Zero W

The ADUM1250ARZ is a bi-directional galvanic isolator for digital communication up to 1mbs.  It's the first chip I ever designed a PCB for and it's still my favorite.  Essentially, the ADUM1250 seperates the rp0w from the noisy motors -- and more importantly, if I screw something up on the motor side, won't kill my rp0w. The ADUM1250 is not necessary for most people, just me

ADUM1250 (Mouser)
Eagle Breakout PCB
Datasheet
_Very_ Old Work with the IC


The last bit I had to figure out was the the Raspberry Pi's power.  I attempted to use a single Li-Ion battery and a boost regulator to power it, but the regulator's I bought were DOA.

Then I remembered the load-sharing and boost converter circuit salvaged from a battery bank.  The charge circuit was built for Li-Po chemistry and the only Li-Po I had lying about was a 350mA.  I wired it up and was surprised the whole thing worked, with the added benefit of being able to charge the rp0w battery without disconnecting it.  _Booyah!_

The last bit I did for the video.  I pulled the [code single]npm[/code] package keypress and wrote this little program.

Code: [Select]
'use strict';
var i2c = require('i2c-bus'), i2c1 = i2c.openSync(1);
var sleep = require('sleep');
var drv8830 = require('./drv8830');
var keypress = require('keypress');

const motorAddressOne = 0x61;
const motorAddressTwo = 0x67;

var motor1 = new drv8830(motorAddressOne, i2c1);
var motor2 = new drv8830(motorAddressTwo, i2c1);

// var speed = 63;
var turnSpeed = 33;
var driverSideSpeed = 63;
var passangerSideSpeed = 63;

// make process.stdin begin emitting "keypress" events
keypress(process.stdin);
 
// listen for the "keypress" event
process.stdin.on('keypress', function (ch, key) { 
  if (key && key.ctrl && key.name == 'c') {
    process.stdin.pause();
  }
  switch(key.name) {
       
    case 'w':
        motor1.drive(driverSideSpeed);
        motor2.drive(passangerSideSpeed);
        break;
    case 's':
        var motors = [motor1, motor2];
        setDriveWithAcceleration(motors, driverSideSpeed, 10);
        break;
    case 'd':
        motor1.drive(turnSpeed);
        motor2.drive(turnSpeed*-1);
        break;
    case 'a':
        motor1.drive(turnSpeed*-1);
        motor2.drive(turnSpeed);
        break;
    default:
        motor1.stop();
        motor2.stop();
  }

});
process.stdin.setRawMode(true);
process.stdin.resume();

var setDriveWithAcceleration = function(motors, desiredSpeed, accelTimeMilliSec) {
    for(var i = 0; i < desiredSpeed; i++){   
        motors[0].drive(i);
        motors[1].drive(i);
        sleep.msleep(accelTimeMilliSec);
    }
}

Then, I shot the following video and called it donesies.


viswesh

  • Member
  • ****
  • Posts: 57
    • opamps sensors audio amplifier
Re: 1B1 -- RAN Stack
« Reply #1 on: April 14, 2018, 10:18:44 AM »
nice sir. great work , I like the 18650 battery holder.

Ladvien

  • Alabtu-ian Refugee
  • Member
  • *
  • Posts: 57
Re: 1B1 -- RAN Stack
« Reply #2 on: April 14, 2018, 10:40:54 AM »
Thanks, Vis.  Printed those awhile back and this was the first chance to use them.

https://www.thingiverse.com/thing:456900

They are nice because it only takes wire and solder to get them going.

 

* Search


* Recent Topics

Sloooow progress on the I3 clone by KingBeetle
[July 16, 2018, 04:20:59 AM]


ESP32 - Stepper - LIDAR - Platform by jinx
[July 15, 2018, 04:58:51 AM]


MKS Gen L 1.0 by jinx
[July 15, 2018, 03:55:57 AM]


Motor rewinding machine by 1 what
[July 10, 2018, 06:03:46 PM]


All the stories in the forum are most important. by ZeroMax
[July 01, 2018, 09:44:53 PM]


Parallax CR Servo with Built-In Encoder by 1 what
[June 28, 2018, 12:13:32 PM]


He's Back...BoB V3.0 by k120189
[June 21, 2018, 07:03:17 PM]


Funding by MEgg
[June 21, 2018, 04:34:36 PM]


Robot Hive by jinx
[June 12, 2018, 03:58:03 AM]


Hi, Mushroom glue here. by Andrewsz
[June 11, 2018, 12:23:20 AM]


CZ-1 2.0: problems, calibration and printing, part2 by MEgg
[June 10, 2018, 06:10:53 AM]


Greetings! by Protowrxs
[June 05, 2018, 04:45:02 PM]


Raspberry Pi / Python eBook - free for the next 11 hours! by MEgg
[June 04, 2018, 05:21:07 PM]


All metal Titan Extruder by jinx
[May 27, 2018, 04:24:23 AM]


UConduit H-Bot printer design by KingBeetle
[May 26, 2018, 02:10:38 PM]

* Recent Posts

Re: Sloooow progress on the I3 clone by KingBeetle
[July 16, 2018, 04:20:59 AM]


Re: Sloooow progress on the I3 clone by MEgg
[July 15, 2018, 08:44:53 AM]


Re: ESP32 - Stepper - LIDAR - Platform by jinx
[July 15, 2018, 04:58:51 AM]


Re: MKS Gen L 1.0 by jinx
[July 15, 2018, 03:55:57 AM]


Re: Sloooow progress on the I3 clone by jinx
[July 15, 2018, 03:46:18 AM]


Re: MKS Gen L 1.0 by KingBeetle
[July 14, 2018, 04:05:49 PM]


Re: Sloooow progress on the I3 clone by KingBeetle
[July 14, 2018, 11:13:35 AM]


Re: ESP32 - Stepper - LIDAR - Platform by 1 what
[July 14, 2018, 07:02:46 AM]


Re: Sloooow progress on the I3 clone by MEgg
[July 14, 2018, 05:38:34 AM]


Re: Sloooow progress on the I3 clone by KingBeetle
[July 14, 2018, 03:45:21 AM]


Re: ESP32 - Stepper - LIDAR - Platform by jinx
[July 14, 2018, 02:49:04 AM]


Re: ESP32 - Stepper - LIDAR - Platform by 1 what
[July 13, 2018, 10:03:12 PM]


Re: ESP32 - Stepper - LIDAR - Platform by Gareth
[July 13, 2018, 04:19:01 PM]


Re: ESP32 - Stepper - LIDAR - Platform by jinx
[July 13, 2018, 01:33:15 PM]


ESP32 - Stepper - LIDAR - Platform by Gareth
[July 13, 2018, 04:28:46 AM]