Coming in tomorrow to work on a balance bot and wondering if I could get some help

58 views
Skip to first unread message

Luke Parker

unread,
Jun 25, 2016, 1:43:13 PM6/25/16
to Arch Reactor

Hello,

My name is Luke Parker, I'm a junior intern at the Science Center makerspace. I'm currently working on a balance bot and am still in the very early stages and needing some help. I put a list of all the hardware I'm using down below. My biggest problem right now is getting power to the DC & Stepper controller. I have a terminal block I need help soldering to the board for power. After the terminal block is soldered I need help wiring the terminal block to my DC battery pack. I have a female DC to male terminal power converter, so I just need help wiring two terminal blocks together. Once I get power to the board I need help wiring my DC motor to the DC & Stepper controller. For now I am just using putty to control the Raspberry Pi. If anyone is planning on coming tomorrow I would really appreciate some help. 

Thanks  

Raspberry Pi 3
Adafruit DC and Stepper Motor Hat
DC 5.5X2. 1mm Male Connector 8x1.5v 12v Battery Holder Case
Nextrox Mini 12V DC 60 RPM 
Female DC Power adapter - 2.1 mm jack to screw terminal blcok



   

Derek Sigler

unread,
Jun 25, 2016, 4:19:54 PM6/25/16
to arch-r...@googlegroups.com



I'll get there between 7 and 7:30. I've committed the evening to one of Neil's projects, but can help you solder.
-derek
Message has been deleted

Luke Parker

unread,
Jun 25, 2016, 9:00:18 PM6/25/16
to Arch Reactor, derek...@yahoo.com
Thanks I really appreciate it. 


Luke Parker

unread,
Jun 27, 2016, 2:29:46 AM6/27/16
to Arch Reactor, derek...@yahoo.com
Hey I couldn't find email. I was wondering if you could take a look at some parts I'm looking at. I put links to everything down below. I was looking at ways to connect the encoders and I heard people talking about connecting them straight to the GPIO pins. So would it be possible to just solder another terminal block onto those GPIO forward pins and screw the encoder wires into the terminal block? I'm amusing there would be two wires, positive and negative. Thanks again for all the help I really appreciate it. 

Thanks,
Luke Parker

Motor:

Accelerator/Gyro: 
https://www.amazon.com/gp/product/B00ZN3RAA2/ref=ox_sc_act_title_1?ie=UTF8&psc=1&smid=AM0JQO74J587C 
Message has been deleted

directoro...@archreactor.org

unread,
Jun 27, 2016, 4:12:16 PM6/27/16
to Arch Reactor, derek...@yahoo.com
Hello,

I look over the parts you have so far, the motors should work well, motors rated over 250rpm's are just about right for a balancing robot. You however will need to be sure to provide at least 11 volts if not 12 volts to power the motor controller battery input. The motor encoder will be most likely 4 wire a VCC, GND,A, and a B. The VCC needs to be 5 volts. The outputs A and B cannot be wired straight to the I/O pins on the Pi as there are 3.3 volt logic. You will need a intermediate Arduino or logic level converter board.

Hopefully this helps you with your project moving forward.

Regards,

Apollo Timbers
Director of Education
Arch Reactor

Luke Parker

unread,
Jul 1, 2016, 12:42:50 AM7/1/16
to Arch Reactor, derek...@yahoo.com, directoro...@archreactor.org
Thank you so much. Just to clarify, your saying I need an Arduino to be able to use the encoders on the Motor. 

directoro...@archreactor.org

unread,
Jul 1, 2016, 9:10:51 AM7/1/16
to Luke Parker, Arch Reactor, derek...@yahoo.com
That or a logic level converter that take the 5volt logic and converts it to 3.3volt. Sparkfun sales a few of those boards. It would keep you from needing a Arduino.



Apollo

Sent from my iPhone



Sent from my iPhone

Morganism

unread,
Jul 1, 2016, 9:15:07 AM7/1/16
to Arch Reactor
Arduinos are not expensive any more. The Space has several that you can use and experiment with to see if it is the right solution for you before buying one.

Chris Weiss

unread,
Jul 1, 2016, 9:21:59 AM7/1/16
to arch-r...@googlegroups.com
if you use 5V to power it, A and B will put out 5V which can damage the Pi.  you can use a level shifter or maybe a zener diode to clamp the voltage below 3.3V, but I also see projects using 3.3V to power it.  I've no idea if that applies for all encoders or if it affects reliability. 

I wonder if the Pi's IO is fast enough for multiple encoders.  I know there's some interrupt support, but the Pi is still not a RealTime system so they won't be true interrupts.  you can probably do them in worker threads and it might be good enough, won't know until you try.  if it's not, then an arduino mini can do the counting for you with a simple ttl serial protocol (which you would need a level shifter for)

EschewObfuscation

unread,
Jul 1, 2016, 9:15:09 PM7/1/16
to Arch Reactor
If you're talking quadrature encoders, you do realize, I trust, you can use simple up/down counters to track their absolute count in real time, and simply read (software debouce ofc) their state? Use CMOS and they're highly Vcc agnostic. Just don't apply 5V to the I/O if you're running them at 3.3 lest you achieve SCR latchup and you'll be fine. The reverse is no problem.

Also, level shifting is not a black art: a 3.3 V output driving 5V devices requires nothing more than a single transistor per line. 5V peripheral driving a 3.3V input you can quick-and-dirty with a resistor divider. None of this is difficult stuff requiring specialized ICs; I'm sure all necessary parts are already lying about at the space. Don't over engineer it; you're not driving fiber optics at wavelength-limited speeds.

Luke Parker

unread,
Jul 1, 2016, 11:36:44 PM7/1/16
to Arch Reactor
I'm a little confused. So I can't run the encoders off the IO pins because they would draw too much power. So in order to use the encoders I would have to run the leads for the encoder to an Arudino? Or I would use a level sifter to bring the 5 V down to 3.3 V and hook that up to the IO pins? If I did use an Arduino how would I hook that back up to the PI? Thank you all so much for the help and the suggestions, this is my first robotics project outside of FTC. 


On Saturday, June 25, 2016 at 12:43:13 PM UTC-5, Luke Parker wrote:

EschewObfuscation

unread,
Jul 2, 2016, 2:03:11 PM7/2/16
to Arch Reactor
On Friday, July 1, 2016 at 10:36:44 PM UTC-5, Luke Parker wrote:
I'm a little confused. So I can't run the encoders off the IO pins because they would draw too much power. So in order to use the encoders I would have to run the leads for the encoder to an Arudino? Or I would use a level sifter to bring the 5 V down to 3.3 V and hook that up to the IO pins? If I did use an Arduino how would I hook that back up to the PI? Thank you all so much for the help and the suggestions, this is my first robotics project outside of FTC. 

Okay, there are a couple of topics here. Raspberry runs at 3.3 Volts. We do not want to apply 5V signals to a 3.3V device, as that will most likely break it. (Nevermind the actual voltages are rarely 0-3.3 or 0-5, we'll pretend for worst case as if they were.)

So one issue is "do we have 5V signals to deal with?", another issue is, "assuming we do, how do we handle that?".

First off, Raspberry isn't software architected for real time stuff, as it's running a linux. So using it to do RT stuff is a bit iffy. But suppose we were to go that route, so Raspberry is to look at these encoder signals directly.

The encoder is almost certainly just an LED/phototransistor interrupter, turned on and off by a small plate attached to the motor shaft, two channels so it's quadrature style. It's most likely designed for 5V operation, but *it may work fine at 3.3*. The way to find that out is hook it up to a power supply at 3.3, look at the outputs with a scope, see what's there. That'll at the same time tell you if your encoder is working.

If it works at 3.3, you're good, you can run those signals directly to the Pi. It would be better to buffer them with, say, a Schmitt trigger, but that's good engineering practice; this is amateur night, so no worries.

If it does not work at 3.3, but does work at 5, then some level shifting is in order. A simple resistor divider would do, 2/3 ratio would work fine.

A side note: people here are subject to Hammer Syndrome. "To a man with a hammer, everything looks like a nail". So you will often ask a question whose answer is "a resistor will fix that" or "you need one transistor there" and people will say "you could probably do that with an arduino..." This is true, and as 'duinos are so cheap now, you can in fact get away with it. It's, however, somewhat akin to cracking walnuts by driving over them with your car. It works, and might be a sensible field expedient, but is a silly way to do it routinely. A nutcracker or hammer makes more sense most of the time. But arduino runs at 5V and can be configured to output 3.3V signals as there are 3.3V shields on the market. Hence, a multimillion gate ultraversatile microprocessor on its own PCB really can be used to do the work of a resistor and/or a counter chip. And it may even be the easiest or quickest way to do this, as there may be more people at hand who know how to work with arduinos than know what to do with a transistor. Just don't assume there's some sophisticated reason that's the best solution, okay?

An all around better approach would be to use external circuitry to track the motor position, so the real time deficiencies of the Pi are unimportant. A simple quadrature decoder can be made from up/down counter IC's, trivial stuff. But you may not have heard of this, because it's the sort of thing known to classically trained EEs, and rarely mentioned in how-to's which are themselves written by amateurs. Not your fault they don't talk about these things, as they don't know the basics, either. We can discuss the principles of that approach if you are interested.

A final comment, as I may be misreading a comment above: while sometimes people get away with powering an LED or some such directly from a Pi, arduino etc output pin, don't plan on that. Don't plan on powering anything but maybe the base or gate of a transistor from those. Those are signal pins, not power devices. Always power your devices from the system rail, not from a signal line.

Did any of that clarify matters any?

nfolken

unread,
Jul 2, 2016, 3:59:00 PM7/2/16
to Arch Reactor
A raspberry pi is a full computer that is doing all kinds of things at the same time. While it is very fast, you can't rely on it to accurately keep track of a quickly changing pin while it is juggling all the other tasks of an entire operating system. The GPIO pins on a raspberry pi are best used for simple on-off stuff. An Arduino on the other hand is only running your program, so it can pay 100% attention to keeping track of the encoder and telling the motor what to the instant after. Raspberry Pi's are great for more complicated stuff, like machine vision and internet access. It is very common to attach an Arduino to a Raspberry Pi to get the best of both, but as Eschew points out, you don't have to use an Arduino to keep track of the encoders, but its the hammer most hackers use, and then you can easily use it for other things too.

For a balance robot, I think using just an Arduino with a motor shield is a perfect match. The Arduino pins signal at 5v, so you can directly connect the encoder. The gyroscope signals at 3v, which isn't high enough for the Arduino to sense it, so you will need some transistors and resistors to change the voltage, or just use a level shifter board like this one. If you want to try and use just a Pi, you could use the same board to connect the encoder and see if the Pi is able to keep close enough track.

EschewObfuscation

unread,
Jul 2, 2016, 5:46:24 PM7/2/16
to Arch Reactor
Or you can buy 3.3V arduinos, and just divide down (if necessary) the encoder inputs? If all the project needs to do is balance, and not run an LCD display, take commands via bluetooth, that sort of fancy stuff, I'd say just use a 'duino and stop there.

Luke Parker

unread,
Jul 2, 2016, 5:48:26 PM7/2/16
to Arch Reactor
Computer Vision is something I would like to incorporate at some point, that's why I picked the Pi. I've been messing around with Opencv 2 for a couple of months. I'm now thinking about getting an Arduino with a motor shield to drive the balance bot and have the Raspberry Pi for opencv. I will be coming in tomorrow if anyone is going to be there that I could talk to that would be amazing.   

Chris Weiss

unread,
Jul 2, 2016, 5:56:40 PM7/2/16
to arch-r...@googlegroups.com
Since you use the words "draw power" I'd like to address that.

Power (at least at this level of electronics) is Watts, which is volts times amps. when we talk about "too much power for an IO pin" what's generally being referred to is having a motor or high power LED draw power from the IO pin, in which case amp is the real issue.  but when a pin is in input mode, it does not supply any power at all, but it can consume a very small amount, just enough to tell if the voltage is present.

since the encoder has a separate VCC pin to supply it power, power isn't the issue.  the issue is what voltage is exposed on the A and B pins that the Pi will consume, and I think that's been covered well above.

but then the speed at which the Pi can read the IO pins may also be an issue.  I'd recommend trying to power one encoder ay 3.3V and write a test script to read it.  I'd imagine there's some libraries out there to make that easy.  if it doesn't work then they will need 5V and shifter.  if it only works when moving slow, then you'll need another IC to help out.  there are encoder ICs that simplify the signal and you'd need 2 of them, but an Arduino Mini is quite cheap and should easily run both encoders.

jimski...@gmail.com

unread,
Jul 4, 2016, 10:44:46 AM7/4/16
to Arch Reactor
On Saturday, July 2, 2016 at 4:48:26 PM UTC-5, Luke Parker wrote:
> Computer Vision is something I would like to incorporate at some point, that's why I picked the Pi. I've been messing around with Opencv 2 for a couple of months. I'm now thinking about getting an Arduino with a motor shield to drive the balance bot and have the Raspberry Pi for opencv. I will be coming in tomorrow if anyone is going to be there that I could talk to that would be amazing.   
>
An Arduino and a Pi make a cheap solution. I have used this combination for other things. As you say, the Arduino can handle the motor control and the Pi can do opencv. Also, if you mess up something and fry the Arduino they are cheaper than the Pi. There are chips to do the encoder decoding in hardware that aren't very expensive or you can make up the circuit of very cheap IC counters and logic. One cleaver way to do it is to decode the encoder signals into up count pulses on one line and down count pulses on another line. then run those signals into 2 counters on the Arduino and subtract the the counters when you need to know position. There are examples of this on the net. It can be very fast. Perhaps you don't need that fast. You might also want to look at boards faster than the Pi depending on what you want to do with opencv. I don't have any direct experience with opencv but a Pi3 is probably fast enough to at least get started - it sounds like you are already started on that and it isn't the main issue at this point.

Luke Parker

unread,
Jul 4, 2016, 11:07:10 AM7/4/16
to Arch Reactor
I just ordered a bunch of parts I put links down below but it's just about the same as what I posted above. I added a level converter for the Gyro/Acceleromiter. I decided to do a combination of Arduino and Raspberry Pi, so I went ahead and got an Arduino Uno and an Adafruit motor controller to go with it. Now the next task is to design the robot itself. For now my main question has to do with placement of the Gyro/Acceleromiter. I was told that the best place for the Gyro is pretty much as high above the wheel as you could get. So my question is would the higher placement of the Gyro/Acceleromiter negatively effect the efficiency of the accelerate?    

Reply all
Reply to author
Forward
0 new messages