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
Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
I had not found that second thread, so thanks for that. I'll take a look a bit later.

Adbot
ADBOT LOVES YOU

mod sassinator
Dec 13, 2006
I came here to Kick Ass and Chew Bubblegum,
and I'm All out of Ass
If you're doing low level USB stuff pull out a Raspberry Pi and use it to connect and examine the device you're creating. The Linux kernel has way, way better USB diagnostic tools like lsusb and such. There's very likely an esoteric bit or string or something that needs to be set in the USB packet. You might even need to look at something like wireshark to get a raw capture of all the USB packets: https://wiki.wireshark.org/CaptureSetup/USB

But that said, it's a deep rabbit hole to start debugging USB at a low level. If you just want something working, I'd find some code and use it--even if that means grabbing a new Teensy. You might check of the Teensy 3 LC would work: https://www.pjrc.com/teensy/teensyLC.html It's a cheaper version but with a similar fancy ARM Cortex M0 like the Teensy 3 (but not the 2, that thing uses an older AVR chip without nearly as nice USB libraries).

Jaded Burnout
Jul 10, 2004


Gang tag contest!

https://forums.somethingawful.com/showthread.php?threadid=3903115

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
I was able to modify the example from the second link One Legged Ninja posted and finally got it working, somewhat. I changed it to 34 buttons, 3 10bit axes, and 4 8bit axes. I think that should actually work fine. 10bit for the rotational axes and 8bit should work fine for translation and throttle. Maybe I'll continue messing with it to get more axes or get more resolution for the others but I think this should work well enough. Thanks for the help, everyone.

Hadlock
Nov 9, 2004

Not sure where to put this, but there are a bunch of $15-35 Fitbit clones out there, which are probably at least partially splash resistant, marketed as a "fitness tracker" aka Fitbit Charge

Does anyone know if any of these platforms are open-esque, with probably similar to an esp8266 cpu + ssd1306 oled display and some kind of battery

Would like to write an app that consumes UDP data over Bluetooth, then displays some facts about that data (navigational data) like heading, course, velocity made good towards a waypoint etc

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
It's 13 bucks, I'm sure it wouldn't hurt to buy one and crack it open to see what's in there.

mod sassinator
Dec 13, 2006
I came here to Kick Ass and Chew Bubblegum,
and I'm All out of Ass

Hadlock posted:

Not sure where to put this, but there are a bunch of $15-35 Fitbit clones out there, which are probably at least partially splash resistant, marketed as a "fitness tracker" aka Fitbit Charge

Does anyone know if any of these platforms are open-esque, with probably similar to an esp8266 cpu + ssd1306 oled display and some kind of battery

Would like to write an app that consumes UDP data over Bluetooth, then displays some facts about that data (navigational data) like heading, course, velocity made good towards a waypoint etc

Check out the nRF52-based trackers: https://hackaday.io/project/160618/instructions and https://github.com/curtpw/nRF5x-device-reverse-engineering

I actually picked a few of these guys up recently and they're the same as the one suggested in that project: https://www.amazon.com/gp/product/B077D7BVMR It's still kind of a pain to open them up and get to the programming pads, but once there it has nice big labeled pads that are easy to solder some small gauge wires. I ended up using a Blackmagic probe to program them with GDB, but a Segger J-link might work too (it's just a colossal pain in the rear end with their tools).

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


Cojawfee posted:

I was able to modify the example from the second link One Legged Ninja posted and finally got it working, somewhat. I changed it to 34 buttons, 3 10bit axes, and 4 8bit axes. I think that should actually work fine. 10bit for the rotational axes and 8bit should work fine for translation and throttle. Maybe I'll continue messing with it to get more axes or get more resolution for the others but I think this should work well enough. Thanks for the help, everyone.

I did this back in 2012 (on page one of this thread) and again in 2014. I got the USB tool from usb.org and wrote my own HID descriptor, then generated the .h file.

I used an uno for my first example and a nano for my second, both of which are a 8u2 talking over USB and an 328p reading the buttons and whatnot then sending that data to the 8u2 over serial, but I think it's basically the same process, except without having to upload code to two different chips on the same board.

If you've got something that already works, good on you, but ask some more specific questions and I can answer them.

Shadow0
Jun 16, 2008


If to live in this style is to be eccentric, it must be confessed that there is something good in eccentricity.

Grimey Drawer
Apparently my relay plan worked:
https://www.youtube.com/watch?v=_QoIaG0rRJs

And I finally finished the whole project:
https://www.youtube.com/watch?v=fsdmQlk0hv4
It's a buzzer game for class. Which I will probably only use for only one lesson. :eng101:

It's not exactly in the best shape, but it works (mostly).

Also, yes, I did use hot glue which was probably a bad idea. I have a lot of frayed wires and I didn't want them moving and shorting or something. Though they seem to do that anyway.
I wish I had bought better wires to use for this. It would have made my life a lot easier.

But this was my first project, and I'm happy with it.
Now I just need to try to 3-D print a case for all of it.

Shadow0 fucked around with this message at 15:44 on Nov 16, 2019

Sockser
Jun 28, 2007

This world only remembers the results!




Feeling like a mega dummy right now, especially because I've done this before--

code:
const int pinLeftUp = 2;
const int pinLeftDown = 3;
const int pinRightUp = 23;
const int pinRightDown = 22;
 
void setup()
{
  Serial.begin(57600);
  Serial.println("BEGIN:");
  pinMode( pinLeftUp, INPUT_PULLUP );
  pinMode( pinLeftDown, INPUT_PULLUP );
  pinMode( pinRightUp, INPUT_PULLUP );
  pinMode( pinRightDown, INPUT_PULLUP );
}
 
void loop()
{
  if (digitalRead(pinLeftUp) == LOW){ Keyboard.set_key1 (KEY_W); }
  if (digitalRead(pinLeftDown) == LOW){ Keyboard.set_key2 (KEY_S); }
  if (digitalRead(pinRightUp) == LOW){ Keyboard.set_key3 (KEY_R); }
  if (digitalRead(pinRightDown) == LOW){ Keyboard.set_key4 (KEY_D); }
  Keyboard.send_now();
  delayMicroseconds(10);
}
Basic-as-gently caress Teensy "press a button, it sends a key" program, or it should be.

Instead, if I jump, say, pin 2 to gnd, it sends a constant stream of Ws until I either reboot the teensy or jump another pin to ground. To be clear, I want it to repeat as long as the pin is jumped, but it doesn't stop when I disconnect the jumper, and I can't figure out why


e: Naturally I remembered I need to y'know, release the keys, immediately after I posted this

Sockser fucked around with this message at 09:14 on Dec 27, 2019

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
Your input pin is floating, so it's basically showing whatever electrical charge is on the pin


Use pull ups, either physical or in software

Edit: oh wait you did that

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
Do any of the other pins do that?

Is pin 2 perhaps tied to the onboard LED? I ran into something like that when making my controller. Pin 6 I think was tied to the onboard LED on my teensy, so when I pushed the button connected to that pin, it would stay pressed. If that is the case, you can't use pullup like normal. You either need to figure out another way to do it, or remove the LED. I put a 1k resistor from the pin to ground and it solved my problem.

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS

Cojawfee posted:

Do any of the other pins do that?

Is pin 2 perhaps tied to the onboard LED? I ran into something like that when making my controller. Pin 6 I think was tied to the onboard LED on my teensy, so when I pushed the button connected to that pin, it would stay pressed. If that is the case, you can't use pullup like normal. You either need to figure out another way to do it, or remove the LED. I put a 1k resistor from the pin to ground and it solved my problem.

He figured it out, I think, from the edit.

I've never used the Teensy or anything for keyboard emulation, but I guess Keyboard.send_now() sends a keydown event, and requires another command to release the key after you're done

Sockser
Jun 28, 2007

This world only remembers the results!




Yeah I was just never releasing the key.
Every other time I’ve done a keyboard emulation I checked falling edge so it only pressed once and the release completely escaped me.

General_Failure
Apr 17, 2005
Has anyone had any success making a two wheeled balancing robot? I've been trying for a good couple of months with no real success. I know there are examples with code out there. I've used them as a basis.
The main difference is I'm trying to use an MPU9250 instead of an MPU6050 accel / gyro. I just absolutely cannot work out what it's drat problem is, besides the painfully obvious one that the libraries that people chose to use for their robots aren't very compatible with other ones in some way.

Just a few minutes ago the MPU6050s I ordered in defeat just arrived. They'll make a good test case to see where the issue lies.

What I've been seeing in my experiments are numbers that look nice on the terminal, but seem to be sluggish. At one point I ported a version of the code over to esp8266, including the timed interrupts, and adding support for the little OLED hat thing it has. Talking about a WeMos D1 mini.
It didn't seem to make much difference.

I know it's more of a ramble than a question. It's just it's been getting under my skin.

Rapulum_Dei
Sep 7, 2009

Shadow0 posted:

Apparently my relay plan worked:
https://www.youtube.com/watch?v=_QoIaG0rRJs

And I finally finished the whole project:
https://www.youtube.com/watch?v=fsdmQlk0hv4
It's a buzzer game for class. Which I will probably only use for only one lesson. :eng101:

It's not exactly in the best shape, but it works (mostly).

Also, yes, I did use hot glue which was probably a bad idea. I have a lot of frayed wires and I didn't want them moving and shorting or something. Though they seem to do that anyway.
I wish I had bought better wires to use for this. It would have made my life a lot easier.

But this was my first project, and I'm happy with it.
Now I just need to try to 3-D print a case for all of it.

Is there a vistaprint or moonpig for PCBs where you can submit your design and they'll make and ship you one/ a few for projects like that?

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius

Rapulum_Dei posted:

Is there a vistaprint or moonpig for PCBs where you can submit your design and they'll make and ship you one/ a few for projects like that?

JLCPCB or PCBWay

JLCPCB can be as low as 2 dollars for 5 pieces for 2 layers.

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
No it can't

Why do people always neglect shipping on JLCPCB in particular. It's their marketing thing and it really seems to be working. And they've really hosed me on shipping.

Check out pcbshopper.com for price comparisons. The majority of them are in the realm of $14 for 5x5cm, qty 10.
I like PCBWay, or Seeed, but it's mostly all the same

ante fucked around with this message at 19:55 on Jan 2, 2020

JawnV6
Jul 4, 2004

So hot ...

General_Failure posted:

Has anyone had any success making a two wheeled balancing robot? I've been trying for a good couple of months with no real success. I know there are examples with code out there. I've used them as a basis.
The main difference is I'm trying to use an MPU9250 instead of an MPU6050 accel / gyro. I just absolutely cannot work out what it's drat problem is, besides the painfully obvious one that the libraries that people chose to use for their robots aren't very compatible with other ones in some way.

Just a few minutes ago the MPU6050s I ordered in defeat just arrived. They'll make a good test case to see where the issue lies.
What's the difference between those two chips? Like have you pulled up the data sheets and compared?

There might be some benign register adjustment (i.e. sample rate moved from offset 0x14 to 0x1c) that's causing them to behave differently.

Rapulum_Dei posted:

Is there a vistaprint or moonpig for PCBs where you can submit your design and they'll make and ship you one/ a few for projects like that?
https://pcbshopper.com

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius

ante posted:

No it can't

Why do people always neglect shipping on JLCPCB in particular. It's their marketing thing and it really seems to be working. And they've really hosed me on shipping.

Check out pcbshopper.com for price comparisons. The majority of them are in the realm of $14 for 5x5cm, qty 1.
I like PCBWay, or Seeed, but it's mostly all the same

Turns out shipping things across the world is expensive if you want them faster than on a boat.

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
Huh? No I'm saying they literally lie about the price. They're the same price as everyone else, including shipping, because everyone else does "free shipping". Which is obviously also technically incorrect, but a whole lot less dishonest

They also pull some shipping shenanigans that have triggered duties or required me to self clear, and I'm not sure what they're doing differently to make that happen. It's only them, though

ante fucked around with this message at 19:57 on Jan 2, 2020

General_Failure
Apr 17, 2005

JawnV6 posted:

What's the difference between those two chips? Like have you pulled up the data sheets and compared?

There might be some benign register adjustment (i.e. sample rate moved from offset 0x14 to 0x1c) that's causing them to behave differently.

tbqh I haven't bothered. Part of the drivers for these consists of magic incantations from reverse engineering.

I plugged in the mpu6050 and tried it with one of the main ones I've been using as a base

https://www.instructables.com/id/Arduino-Self-Balancing-Robot-1/
Really I find this code to be a bit of a pain so there's a couple of others I've been messing with too.

Then there's mine. I just grabbed a PID library, a PWM motor control library, and an mpu9250 library with builtin quaternion calculation. Because why reinvent the wheel?
pain in the rear end about it is I realised that it wasn't doing the magic of combining the gyro and accelerometer readings so the output twitches around a lot. It couldn't balance either. I'm going to make an mpu6050 version of my code shortly.

While my robot looks different to other ones on line, it's functionally the same so that's probably not the issue.

e: I adapted my little test code to use an mpu6050 library. In this case https://github.com/tockn/MPU6050_tockn
This library seems to already do the addition / filtering using the gyro and accelerometer. It also seems to do the quaternion calculations.
I don't think I said that I had to flip the accelerometer over. Well I did.
Anyway i just tested the code. It doesn't balance, but it's easily the closest I've gotten. I think most of what needs tuning is the PID variables, and possibly adding some minimum duty cycle thing for the motors.
I don't mind posting code. Just not sure what the best way to post an arduino sketch would be.

General_Failure fucked around with this message at 03:27 on Jan 3, 2020

drunk mutt
Jul 5, 2011

I just think they're neat

General_Failure posted:

I don't mind posting code. Just not sure what the best way to post an arduino sketch would be.

Easiest would probably be to use https://gist.github.com/ and create a secret one if you're concerned about anybody outside of the thread checking it out.

General_Failure
Apr 17, 2005

drunk mutt posted:

Easiest would probably be to use https://gist.github.com/ and create a secret one if you're concerned about anybody outside of the thread checking it out.

That works. I'd never used gist before.
It's hardly great code. Just duct tape and bailing wire to see if the concept works.

https://gist.github.com/experimentech/fc962af8c50770e840ba612cfd3dcc07

mobby_6kl
Aug 9, 2009

by Fluffdaddy
What kind of mic/amp setup would y'all recommend to pick up normal conversation or TV level sound in a room? I tried a MEMS as well as electret mic like this one below, supposedly MAX4466 based, but neither can pick up poo poo. I've been testing with a frequency generator on the phone and have to crank up the gain to the max as well as the volume to the point it's unpleasant for it to pick anything up from like 10cm. I'm not trying to make an Alexa, just need to do FFT on the signal.



In the end I'll need to make my own PCB but for development and testing a module would be ok.

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
A human voice will carry farther than a phone speaker, so keep that in mind.

mewse
May 2, 2006

mobby_6kl posted:

What kind of mic/amp setup would y'all recommend to pick up normal conversation or TV level sound in a room? I tried a MEMS as well as electret mic like this one below, supposedly MAX4466 based, but neither can pick up poo poo. I've been testing with a frequency generator on the phone and have to crank up the gain to the max as well as the volume to the point it's unpleasant for it to pick anything up from like 10cm. I'm not trying to make an Alexa, just need to do FFT on the signal.



In the end I'll need to make my own PCB but for development and testing a module would be ok.

Did you already rule out mic arrays like this:

https://www.seeedstudio.com/ReSpeaker-Mic-Array-v2-0.html

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

I'll say that I don't know a ton about microphones but once upon a time I used DIY electret capsule microphones to record punk shows. It was just two capsules, wires, and a minidisc as the amplifier. And it sounded really good. Maybe you need a second amplifier after the MAX4466?

taqueso fucked around with this message at 22:56 on Jan 8, 2020

mod sassinator
Dec 13, 2006
I came here to Kick Ass and Chew Bubblegum,
and I'm All out of Ass
The mic is only half of the equation, don't forget your ADC needs to be tuned to the output of the mic amplifier. Think of it this way, if your mic amplifier is outputting a max of 1 volt but your ADC range is going from 0 to 5 volts then it doesn't matter how powerful or awesome the mic is--everything will be quiet. Try to have the mic amp and ADC voltage range matched up perfectly.

mobby_6kl
Aug 9, 2009

by Fluffdaddy
^^^
Yeah good point. I played around with the different attenuation settings before and think I got the best one but I'll try to actually measure what it's outputting tomorrow and see if I can better match it to the ADC

Cojawfee posted:

A human voice will carry farther than a phone speaker, so keep that in mind.
That's true but the difference doesn't seem to be huge in this case, I still pretty much have to shout into it to get anything.

mewse posted:

Did you already rule out mic arrays like this:

https://www.seeedstudio.com/ReSpeaker-Mic-Array-v2-0.html
Do you mean a compete module like this or DIYing something? Either way it seems like it'd be overkill for what I need. But maybe I'm overestimating what's possible with a single electret mic...

taqueso posted:

I'll say that I don't know a ton about microphones but once upon a time I used DIY electret capsule microphones to record punk shows. It was just two capsules, wires, and a minidisc as the amplifier. And it sounded really good. Maybe you need a second amplifier after the MAX4466?
Could be, I really know gently caress all about this analog stuff :v:

mewse
May 2, 2006

mobby_6kl posted:

Do you mean a compete module like this or DIYing something? Either way it seems like it'd be overkill for what I need. But maybe I'm overestimating what's possible with a single electret mic...

I'm not an expert and I haven't done anything in this space, I'm just confused that you're not doing anything like Alexa but you want to receive voices from across the room

mod sassinator
Dec 13, 2006
I came here to Kick Ass and Chew Bubblegum,
and I'm All out of Ass

mobby_6kl posted:

^^^
Yeah good point. I played around with the different attenuation settings before and think I got the best one but I'll try to actually measure what it's outputting tomorrow and see if I can better match it to the ADC

That's true but the difference doesn't seem to be huge in this case, I still pretty much have to shout into it to get anything.

Do you mean a compete module like this or DIYing something? Either way it seems like it'd be overkill for what I need. But maybe I'm overestimating what's possible with a single electret mic...

Could be, I really know gently caress all about this analog stuff :v:

Yeah check out the datasheet for the CPU you're using and if it has any fancy ADC capabilities like an analog reference voltage you can set. If you're using a dev board like an Arduino they usually set the analog reference to something generic like 1v, 3.3v, 5v, etc. and sometimes give you a pin to explicitly set the voltage.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

I should mention the electret mics I made were very sensitive, they would absolutely be able to 'hear' a voice across a room.

Foxfire_
Nov 8, 2010

Put a scope on it. Is your signal clean but just too small (so you would benefit from more gain), or lost in the noise floor?

General_Failure
Apr 17, 2005
I fixed a bunch of errors and introduced a bunch more in the balancebot code. Haven't uploaded it.
I tried using AutoPID instead of FastPID too. Both have their strengths. Although AutoPID is nice, it seems to get stuck sometimes. Ie the output value just stops updating.

Progress is stopped for now. There was a minor mishsp that killed the dual battery controller I put on the 18650s. The setup is fragile at best.

A couple of days ago I dug out a project case that didn't get used, set up a pair of the yellow geared motor and wheel assemblies on the sides, and test assembled it with a 6xAA battery holder, and an Uno with an L293D motor shield. It all fits amazingly well, but there's a problem. I think the shield utilises the pins normally used for I2C, which are needed.

Also I think I worked out why people use the MPU6050 gyro instead of the MPU9250. The 6050 module appears to be 5v tolerant. I've been using it with 3v3 and level shifters.

Hadlock
Nov 9, 2004

If someone is looking for an arduino project, Amazon is now selling this posture-modifier that basically is a Tiny86 attached to a tilt sensor and if it goes more than X from vertical it activates a vibration motor to tell you to sit up straight. They cost $89 retail

poeticoddity
Jan 14, 2007
"How nice - to feel nothing and still get full credit for being alive." - Kurt Vonnegut Jr. - Slaughterhouse Five

Hadlock posted:

If someone is looking for an arduino project, Amazon is now selling this posture-modifier that basically is a Tiny86 attached to a tilt sensor and if it goes more than X from vertical it activates a vibration motor to tell you to sit up straight. They cost $89 retail

If you're going to go through all that trouble, instead of a vibrator motor it should shock you like in that episode of the briefly lived Dilbert television series.

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius

poeticoddity posted:

If you're going to go through all that trouble, instead of a vibrator motor it should shock you like in that episode of the briefly lived Dilbert television series.

He's got the knack.

General_Failure
Apr 17, 2005

Hadlock posted:

posture-modifier

So it's $5 - $10 of hardware, with probably R&D, assembly + a healthy profit margin.

Adbot
ADBOT LOVES YOU

Hadlock
Nov 9, 2004

General_Failure posted:

So it's $5 - $10 of hardware, with probably R&D, assembly + a healthy profit margin.

There's some sort of mobile app and data collection too, which probably cost 10x to develop

Seems like one of those devices that would get cloned in China and delivered before the American version hit the market. But yes, very healthy margins.

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