Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!
Hi, I'm trying to do electronics and have no idea what I'm doing.

So my state right now is I have a raspberry pi zero, the pi-blaster thing to control GPIO pins, and a couple of servos. I managed to get one of the servos to whirr one time, but now I can only persuade it to twitch in an annoying fashion where I'm not sure if it's even heading for the angle I'm trying to set it to, or just twitching in place. I was doing the thing that seems to be half and half "this is fine" or "don't do this everything will break"; powering the servo straight off the 5v pin. Maybe that's my problem, maybe the servo sucks, maybe both. It's definitely using the expected GPIO pin, because it stops twitching if I set that output to steady off or steady on.

At this point I'm thinking I probably didn't really want to be using servo motors in the first place, they seem finicky and I now gather quite sensitive (a lot of people saying they'll jitter if your signal isn't perfect, and you won't get a perfect signal out of a pi because interrupts etc. - I'm running a low-end pi with also a camera at the same time so I expect my signal quality is not going to be the best). For my use-case I don't really need "point this way" I just need e.g. "turn left this much" which seems like a better fit for a plain old motor with "high torque low speed" gearing, where if the signal update is delayed by a millisecond or two it just turns slightly more than you wanted and that's fine. (I realize it sounds actually like a job for a stepper motor but I think that leans towards the "annoying signal" problems again, and also costs more - I'm fine with software-timing-based imprecision here.)

But then it looks like I probably need some extra hardware in the middle because a motor is just "you got this voltage and amps and now you spin" two-wire input, and there's no direct control over that sort of thing from a pi. So I think I'm looking at a TB6612 as a controller for two motors, and maybe these motors, but then I'm lost when it comes to this: "Just make sure they're good for 1.2 Amp or less of current, since that's the limit of this chip"; what controls the amps going to a motor in this situation, and how do you know what amps a motor is "good for"?

Is it feasible to power such motors from the pi's 5v pins (perhaps with a capacitor on there to reduce brownouts) or do I have to introduce another power supply brick here? Is there some sort of thing people typically use for this purpose, like something with a USB-out to power a pi *and* some basic "act like a set of batteries" wires? All the example projects I see using motors put actual bundles of batteries into their things, which I'd really rather not.

Also, is there a simpler control method for this task, given I don't really need speed controls? I think maybe an L293D can do it (and also has PWM speed controls!) but maybe I'd just be making my life more difficult as that thing seems like it maybe needs me to understand the electronics more. Or maybe it's literally the same thing just with bare spike-things instead of pins that aren't even soldered on anyway?

(The totality of the project is a remote-controlled remote-aimed water-pistol turret, essentially.)

Adbot
ADBOT LOVES YOU

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Rexxed posted:

Anyway for your first step I'd get to the point where the Pi is controlling your servo. That will be the main thing your program needs to be able to do to make the rest work. You can set that up with just the Pi and one servo to start but you may need an separate power supply for the servo (and tie the grounds together if you do it this way). That's just to get started, though, you can't do everything at once.
Yeah, that's the part that was aggravating me by half-working in a way that I don't really have any ideas to make it better, though!

I did some multimeter tests on the pins to ensure that they have the expected voltage, and the pi doesn't die when the servo starts doing stuff, which I assume means the servo isn't draining so much power that it's causing a problem, but it's also not working. My multimeter doesn't have frequency analysis capabilities so I can't tell if the signal timing is right, but I *can* tell from the command-line (raspi gpio get 14) that it is on/off proportional to the expected amount. I guess I do have three servos so I could try connecting different ones to determine whether it's the pi or the servo that's failing to do what I want.

One thing that's maybe making it difficult is that the servos are some generic brand sg90 with no datasheet - I don't know if all sg90 have the same PWM frequency etc. The datasheets I found both say 20ms PWM period (50Hz), 1-2ms duty cycle. I notice pi-blaster seems to have a 10ms PWM period (100Hz), but I don't know if that means it's expected to be straight up incompatible, or if I should be halving the 'on' fraction of the duty cycle, or it's okay using the same fraction, or what? (It is possible to change the period but I assumed from the fact that doing so requires rebuilding the whole library that it's not normal to do so - maybe that assumption is wrong.)

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!
Perhaps someone can answer the question in this simple form - if you have a servo and the datasheet suggests it expects a signal like the top graph and you give it a signal like the bottom graph, what would you expect to happen?

Only registered members can see post attachments!

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Foxfire_ posted:

:shrug: it will depend on how they implemented the thing, may be inconsistent part-to-part, and probably nobody has spent much time thinking about what exactly happens.

"Don't do that" and "If you do, it's up to you to figure out what happens" are the likely official answers
Thanks, that's a helpful answer - I wasn't sure if it's like "X% of the signal during a PWM cycle should be hot" or if it actually has to be in one shot. Guess I can try reconfiguring pi-blaster then before I give up and switch to using motors. (Still wishing I'd gone with simple motors in the first place though.)

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Cojawfee posted:

Are you unable to produce the required signal? Servos are usually controlled by an IC reading the PWM you are sending it and it might not be able to read such a narrow pulse.
The standard build of pi-blaster has a 100Hz cycle, so I could either do the right bump but twice as often as I'm supposed to, or the half-bump twice as often, using that code. But it's open source and that value is configurable in the source code. (It's weird to me that it's not configurable *at runtime* rather than being a rebuild, but I guess this is probably just what happens when an electronics person tries to program a thing, just like the fuckup I'm doing as a programmer trying to make electronics work.)

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

csammis posted:

source: currently working on a project with a dozen cheapass sg90 servos which don’t do poo poo if driven out of spec and barely do poo poo when driven in spec :v:
Perfect, thanks. Twitching is in fact what happens, and it's probably even the same lovely servos! (They came with a cheap gimbal-mount kit.)

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!
Update on my servos from a while back - either I wrecked the servo that was twitching, or it was bad in the first place, because after changing the signal frequency it still only twitched, but switching the same wiring and signal over to the *other* supposed-to-be-identical cheap servo has that one responding as expected now.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

ryanrs posted:

Tonight at 2 AM, the angry alarm went off.

[details omitted]

And the two thieves are in jail right now!
That's awesome that your thing worked, but now I'm really curious how you managed to transform an alarm going off to people actually getting arrested. I find it hard to imagine police being available quickly enough to be of any use, unless you know of some police who live in the apartment complex? Did you just prepare a mob to capture them while you wait for police to show up? Was there also a Home Alone style series of traps in addition to the alarm?

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

ryanrs posted:

I'm out on the street directing the cops.
I walked up and down the street feeling car hoods, and found their car.
Thanks, that makes sense of it - useful police response time is still surprising at any time of day, but you doing most of their job for them is the real story.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!
As a not-electronics person, the problem of securing a USB port against overload *and* screwdriver-jamming seems eminently solvable if you have no cost constraints. Simply arrange:
Protected USB port : wifi adapter or similar radio signal : physical barrier : USB-data-to-wifi-or-radio transformer : new USB port to which the hostile party has access

Transform the data from the unprotected USB port into some over-the-air format at that end, and back to USB data at your protected port, and there's no possibility of overloading it. Boom.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!
I would think some supercapacitors would be good for "smoothing" battery use in long-term things with weird behaviors, like if you have solar panels and a battery inverter thing and you have something connected to it that uses *about* the same amount of power as the panels produce, instead of constantly charging and discharging the battery a little bit you could do that rapid-cycling in a capacitor instead, which would be an improvement for the battery's long-term lifespan?

Or is batteries' lifespan being measured in cycles misleading? Or do capacitors also have a limited number of cycles?

Adbot
ADBOT LOVES YOU

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

kid sinister posted:

Oh man. That gives me a flashback. I bought Microsoft's first gen wireless keyboard and mouse. Either one took 2 AAs. The batteries in the mouse lasted 1 week. The keyboard lasted a month.
Related, I'm absolutely amazed by the logitech pebble mouse, which runs for like 8 months on a single rechargeable AA battery, how is that possible with radio transmitting and laser sensing and enough processing to make sense of things? I mean I know it's not actually 8 months straight, but I use it *a lot*, and even going for like 24 hours for those requirements seems impressive, like the lowest powered raspberry pi or arduino doing literally nothing can go for about 3 days.
(NB. this is using the dedicated USB radio receiver, I assume using bluetooth would make it drain a lot faster.)

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply