Notifications
Clear all

Code and Wiring for DB1 Motor Control  

Page 3 / 4
  RSS

DroneBot Workshop
(@dronebot-workshop)
Workshop Guru Admin
Joined: 1 year ago
Posts: 627
2020-04-20 9:03 am  

Just FYI I'm using Scheme-it, the online tool from DigiKey, to draw up the schematics for this board, as I have for the others. It does have an "Export to KiCad" feature that includes LIB & SCH files - I assume these are Library and Schematic files (I have no experience with KiCad, so I'm guessing here).

Not sure if they are of any use to you, the one issue might be that I had to create my own components for the ATmega328's and the 74LS11 3-input AND gate.  But I can send it to you if you like, once I finish drawing the schematic.

The motor controller is on a solderless breadboard right now. The wiring of the ATMega328's is pretty standard. I actually just followed my own article on using the ATMega328. Each one has it's own connector for an FTDI adapter, and each one has a 2-position jumper to allow the microcontroller to be powered by either the main power supply (which it would be in normal operation) or by the FTDI adapter, which you could use when the board is being programmed and is not connected to the power supply.

The 74LS11 is being used as for the Emergency Stop, it takes the 4 Emergency Stop signals from the I/O distribution (which have already been inverted and cleaned-up by the Schmitt triggers on that board), plus two more emergency stop signals (one from the Mega board, another from an Emergency Stop pushbutton on the motor controller board itself) and combine them into one signal. Essentially it is being used as a 6-input AND gate by tying the three gates together.

As I said it's on a solderless breadboard right now, I've tested the motor controller part (which is nearly identical to the design with the Arduino Nanos) but still need to work on the Emergency Stop, which is part of the reason I don't have a schematic completed yet - I need to make sure that my design will work.  An Emergency Stop signal will cause an Interrupt (INT1), using the signal combined with the AND gate arrangement, as well present itself on one of 6 inputs to the ATMega328 (so that we can tell which of the 6 EM Stop lines caused the interrupt). The timing here is what concerns me, and may make the coding challenging.  I'm hoping not to have to add another IC (i.e. a latch) here, as I don't have room for any additional components on my circuit board, which is the same size as the Nano design.

I have tried to make it as compatible with the old version of the controller as possible, however, I did change the PWM output pin. The old design used Arduino pin 10 (ATmega328 pin 16) as the output, I switched to Arduino pin 11 (ATmega328 pin 17) as there are more PWM frequencies available here.

Here is a link to a Google Doc for the Motor Controller.  It has everything except the schematic and parts list, which I will paste in once I have finished drawing it.  One thing you may find useful is the chart I made at the end of the document that illustrates the function of each ATMega328 pin, as well as the changes from the original Nano-based design.  I thought that would help those who already have the Nano design convert their boards.

After I finish testing on the breadboard I'll complete the schematic.

😎

Bill

"Never trust a computer you can’t throw out a window." — Steve Wozniak


ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 1 year ago
Posts: 738
2020-04-20 11:50 am  

@robo-pi

The original motors that were on the bill of materials for DB1 are no longer available and the following link comes the closest with the exception it is a planetary versus a spur gear motor and much more expensive: DB1 Motors

I'm sure many other models would work as well, but I only have experience with the original motors, so let us know what you experience with your motors.  The original and the one in the link above where a lower RPM than the one in your link.

SteveG


ReplyQuote
DroneBot Workshop
(@dronebot-workshop)
Workshop Guru Admin
Joined: 1 year ago
Posts: 627
2020-04-20 12:32 pm  

Yes, the motors going out of stock was something I didn't anticipate, especially as those motors were very popular in school robotics competitions.  

I'd pick up a set of these replacements, however, I can't do that right now as during the current COVID-19 situation I'm limited to parts I can buy from Canadian vendors and neither RobotShop or Abra (the two local vendors who stock Servo City parts) don't have them listed.  If anyone knows of another Canadian source fo these please let me know and I'll purchase a couple.

I originally chose the lower RPM motors for their increased torque, but it's not to say hat higher RPM ones won't work.  And the encoder doesn't need to have the same number of pulses per revolution, that's just a counter in software so it could be adjusted.

"Never trust a computer you can’t throw out a window." — Steve Wozniak


ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 1 year ago
Posts: 738
2020-04-20 12:55 pm  
Posted by: @dronebot-workshop

I'd pick up a set of these replacements

Meaning which ones?  The link @robo-pi provided or the one I provided?  Or still another model?

Wow I full of questions this morning! 😎 

SteveG


ReplyQuote
DroneBot Workshop
(@dronebot-workshop)
Workshop Guru Admin
Joined: 1 year ago
Posts: 627
2020-04-20 1:02 pm  

@codecage

I was speaking of the link you provided, although the ones James provided are also from Servo City.  So I'm in the same boat unless I can find a Canadian supplier.

"Never trust a computer you can’t throw out a window." — Steve Wozniak


ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 1 year ago
Posts: 738
2020-04-20 1:24 pm  

@dronebot-workshop

His link was for one with a higher RPM and it was a spur-gear motor, but not the heavy duty variety as the original motors you were using.  I guess the "heavy duty" was the biggest price difference.

SteveG


ReplyQuote
huckOhio
(@huckohio)
Trusted Member
Joined: 1 year ago
Posts: 63
2020-04-20 3:04 pm  

First of all, how much work can you get done outside at 0300?  I see a few emails coming in from 0-dark-30. 

I am going start capturing a block diagram at the board level with signal types that are sent between boards.  I really don't understand the purpose of the Mega, but i guess that will come in time.


ReplyQuote
DroneBot Workshop
(@dronebot-workshop)
Workshop Guru Admin
Joined: 1 year ago
Posts: 627
2020-04-20 3:13 pm  

There actually is a ServoCity motor that I can get locally at RobotShop, but it's a bit more expensive. And I haven't looked to see if the size is a consideration.

84 RPM HD Premium Planetary Gear Motor w/Encoder

It's not a drop-in replacement as it uses a different connector, so a board with a 6-pin JST would be needed to "split" the power and encoder connections between the motor controller and the power distribution board.

Interestingly, it's a 2mm JST connector and not a 2.54mm one. I know that the I/O distribution PCB that Mike has created uses those connectors and he had to order a kit of them, so this motor can make use of them as well if the need be.

Right now I'll stick with the motors I have, of course!

"Never trust a computer you can’t throw out a window." — Steve Wozniak


ReplyQuote
DroneBot Workshop
(@dronebot-workshop)
Workshop Guru Admin
Joined: 1 year ago
Posts: 627
2020-04-20 4:04 pm  
Posted by: @huckohio

I really don't understand the purpose of the Mega, but i guess that will come in time.

Here is what the boards on the base all do:

Arduino Mega

This is the I2C Master for all of the sensors, the motor controller, status display(s) and a PCA9685, which will drive a few servos used by the sensors.

It is also an SPI slave to the Raspberry Pi 4.

It is used as opposed to allowing the Raspberry Pi to do all of the I/O and sensor connections. Being a microcontroller it is more suited to this task, and it frees up the Raspberry Pi to do more advanced stuff.

Raspberry Pi 4

This can be used in two modes, depending upon if you are building a full-fledged "intelligent" robot, or are just using the Base layer as a remote-controlled platform.

In both modes, it is the SPI master to the Arduino Mega.  It sends "higher level" commands to the Arduino Mega and lets it do the communicating between the sensors and motor controller to get the job done.

In a "remote-controlled platform" mode it provides a Bluetooth interface for an external controller.

In the "full-fledged" mode it is a ROS node, accepting instructions via an Ethernet connection from the other layers.

Motor Controller

Probably rather obvious, it controls two motors and also accepts their rotary encoder outputs to measure speed and wheel rotation. It can accept Emergency Stop signals from the corner sensors or from the Arduino Mega. It provides PWM signals for the Cytron motor drivers.

I/O Distribution Board

This splits the I/O connections into four, sending each one out to a different part of the robot.

  1. The Front of the robot base
  2. The Rear of the robot base
  3. The Middle Layer
  4. The Top Layer

 

This board splits the I2C signals into separate I2C busses, to be routed to the four I/O Node boards where they will connect to devices like sensors.  A fifth I2C bus is used for a status display connection, and the remaining three I2C busses from the TCA9549A are just wired to a 7-pin JST connector for future use.

It also routes Emergency Stop signals and cleans them up with a 74LS14 Schmitt Trigger to avoid false alarms.  Finally, it routes some extra I/O signals from the Arduino Mega to the four I/O nodes.

The purpose of those extra I/O signals is simply for future expansion, which is part of the design philosophy here. I would rather wire in extra connections now as opposed to wishing I had them later.  Ditto for those extra I2C connections.

I/O Node Boards

This is where the I/O distribution lines terminate. These boards (there are four of them in total) bring out the I2C connections for sensors and other I2C devices. They also have multiple inputs for the Emergency stop, combined and inverted using a 74LS27 triple 3-input NOR gate, as well as a connector for that mythical "extra I/O" signal.

Corner Sensor Boards

These are going to be difficult to wire up on perf board, I might have to get one of you talented folks to create some printed circuit boards for me!  I have one on a solderless breadboard now, and if you look at the I2C video I did about building your own I2C sensors you can get an idea as to how they work.

There are four of these boards on the base, each one mounted on a corner of the robot.  There will be similar boards on the other layers as well, but they may have to use a physically different design.

I'm considering altering the design of these based upon some premanufactured sensors I've seen since I started the project. But as it stands now each of these boards has two HC-SR04 ultrasonic sensors, two Infrared collision sensors, and a big 10mm RGB LED.

The basic purpose of the corner sensors it to avoid slamming into a wall or other obstacle, if that's about to happen they initiate an Emergency Stop.  I hadn't intended on using them for anything else, like navigation, as that would be handled on another layer.  

And the big fat RGB LED is just for effect!

As it stands each corner sensor uses an ATMega328, the premanufactured sensors I've examined are already I2C devices and wouldn't require their own microcontroller. They are, however, quite expensive.

 

I hope that clarifies some of this.

If you have any questions feel free to ask, however, you might not get an answer for several hours. I'm heading to the workshop, both to work on some of this and to escape the noise my neighbors are making, they are also stuck at home and are choosing to spend their time seeing how loud they can play their sound system.  The soundproofing I added to my workshop has really come in handy this month!

😎

Bill

"Never trust a computer you can’t throw out a window." — Steve Wozniak


Spyder liked
ReplyQuote
huckOhio
(@huckohio)
Trusted Member
Joined: 1 year ago
Posts: 63
2020-04-20 4:23 pm  

Perfect!  Thank you Bill!!!!

LMK if you want me to design the PCBs in KiCAD.  I've enjoyed making the power distribution and IO distribution boards.


ReplyQuote
starnovice
(@starnovice)
Estimable Member
Joined: 1 year ago
Posts: 169
2020-04-20 5:22 pm  

Bill,

This is very useful information.  I'm sure you have covered most of it in your videos but it helps to see it all together in one place. Thank you.

Pat Wicker (Portland, OR, USA)


ReplyQuote
huckOhio
(@huckohio)
Trusted Member
Joined: 1 year ago
Posts: 63
2020-09-19 3:39 pm  

@codecage

Did you ever order your motors?  In testing I noticed that one of the original 53:1 motors is slipping internally.  I tried to open the motor but the hosing screw stripped.  Since the original motor is no longer available, I'll need to order two new motors.  I was wonder which motors your purchased. 


ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 1 year ago
Posts: 738
2020-09-19 9:05 pm  

@huckohio

I have had the original motors and have had them for some time.  I had however noticed that one motor was running slightly faster than the other.  Not sure if that was slippage on the part of the slower motor.

SteveG


ReplyQuote
huckOhio
(@huckohio)
Trusted Member
Joined: 1 year ago
Posts: 63
2020-09-19 10:01 pm  

@codecage

Ok.  I am going to order the 5202 yellow jacket motors.


ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 1 year ago
Posts: 738
2020-09-19 10:31 pm  

@huckohio

OK let us know how they work out.  Been thinking about those myself if the speed difference between my motors becomes too big of an issue.

SteveG


ReplyQuote
Page 3 / 4