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 1385 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.

ZeroMax

  • Badass when not suffering from IBS
  • Member
  • *
  • Posts: 117
  • Do you want ants? Because that's how you get ants.
    • DON'T LOOK AT MY ART!
Re: 1B1 -- RAN Stack
« Reply #3 on: August 25, 2018, 06:53:15 PM »
Okay, late to the party, but controlling a robot with NodeJS feels a little like getting a call from the boss on the weekend.  I’m not surprised it was you that you made it work though. You’re Always full of resourceful surprises. Nice work Lad-good to hear from you last week!
DROP * FROM* WHERE 1=1
SUDO RM /DEV/

Bajdi

  • Member
  • *
  • B
  • Posts: 76
Re: 1B1 -- RAN Stack
« Reply #4 on: August 27, 2018, 09:58:53 AM »
Okay, late to the party, but controlling a robot with NodeJS feels a little like getting a call from the boss on the weekend.  I’m not surprised it was you that you made it work though. You’re Always full of resourceful surprises. Nice work Lad-good to hear from you last week!

What software would you recommend for remote controlling a robotic vehicle via a web interface with a raspberry pi (web interface + camera stream) + arduino (hardware control)? I've tried/done this a couple of times but never found a decent solution.

tinhead

  • Member
  • ****
  • t
  • Posts: 36
Re: 1B1 -- RAN Stack
« Reply #5 on: August 27, 2018, 04:06:01 PM »
<just because I have lately been in love with go-lang>
Gobot.io yuss

TH from the black sea side  >:D

Protowrxs

  • Member
  • *
  • Posts: 145
    • The Protowrxs World
Re: 1B1 -- RAN Stack
« Reply #6 on: September 12, 2018, 05:35:59 PM »
<just because I have lately been in love with go-lang>
Gobot.io yuss

TH from the black sea side  >:D

This looks like an interesting approach. Especially with so many platforms and options.

Mainly I like the MQTT possiblilities for integration with my HASSIO home automation setup.

If only there more time...

-Stephen
The past is done, the future is not here, live today...
My Bots: http://www.Protowrxs.com/Robotics

 

* Search


* Recent Topics

Gordon McComb Passes by jinx
[September 18, 2018, 02:12:53 AM]


sdsds by jinx
[September 16, 2018, 04:11:16 AM]


1B1 -- RAN Stack by Protowrxs
[September 12, 2018, 05:35:59 PM]


Picture Topic by Underwooz
[September 05, 2018, 12:27:28 AM]


ESP32 - Stepper - LIDAR - Platform by ZeroMax
[August 25, 2018, 06:48:32 PM]


NASA bot by ossipee
[August 05, 2018, 06:52:36 PM]


Android Adware by Pittmanz
[July 24, 2018, 12:40:23 AM]


Greetings! by Pittmanz
[July 24, 2018, 12:39:20 AM]


Sloooow progress on the I3 clone by KingBeetle
[July 16, 2018, 04:20:59 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]

* Recent Posts

Re: Gordon McComb Passes by jinx
[September 18, 2018, 02:12:53 AM]


Gordon McComb Passes by erco
[September 17, 2018, 10:00:37 PM]


Re: sdsds by jinx
[September 16, 2018, 04:11:16 AM]


sdsds by sdsds
[September 15, 2018, 03:55:20 PM]


Re: 1B1 -- RAN Stack by Protowrxs
[September 12, 2018, 05:35:59 PM]


Re: Picture Topic by Underwooz
[September 05, 2018, 12:27:28 AM]


Re: 1B1 -- RAN Stack by tinhead
[August 27, 2018, 04:06:01 PM]


Re: 1B1 -- RAN Stack by Bajdi
[August 27, 2018, 09:58:53 AM]


Re: 1B1 -- RAN Stack by ZeroMax
[August 25, 2018, 06:53:15 PM]


Re: ESP32 - Stepper - LIDAR - Platform by ZeroMax
[August 25, 2018, 06:48:32 PM]


NASA bot by ossipee
[August 05, 2018, 06:52:36 PM]


Updates 20180728 :- new Steppers - Perfboard Migration - wheel inserts by Gareth
[July 28, 2018, 09:57:11 AM]


Re: Android Adware by Pittmanz
[July 24, 2018, 12:40:23 AM]


Re: Greetings! by Pittmanz
[July 24, 2018, 12:39:20 AM]


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