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
babyeatingpsychopath
Oct 28, 2000
Forum Veteran


ante posted:

You'll want to switch the negatives though, not the positives. It won't work properly, otherwise

For reference, how can you tell those are high-side switches and not low-side switches?

High side: +V -> FET -> Load -> GND
Low side: +V -> Load -> FET -> GND

Adbot
ADBOT LOVES YOU

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
They're N-FETs, which can't do high side switching.

Given that the gate needs to be at the source voltage+10v (for example) to be on. When the transistor is on, and the drain is connected directly to the power source, then the source will be at, say, VCC-0.1V. So unless you have a special power supply for the gate that is above your battery voltage, you'll never get a proper turn on.

It is possible to do high side switching with a P channel MOSFET, but that comes with more complications and lower efficiency

cruft
Oct 25, 2007

babyeatingpsychopath posted:

The diagram is getting a bit strained, but it's basically the same concept. Each of those boards is a replacement for a relay. However, instead of a relay having a normally open and normally closed contact, this one only has a normally open contact that can ONLY switch + to LOAD.

So your pin names have changed slightly. There's no more "COM" because COMmon is now directly connected to DC+. DC- is now "-". "GND" is the reference to the microcontroller. If you're powering the micro with USB, do not connect "DC+" to "BAT", but do connect "GND" on the FET board to "GND" on the micro. "IN" is now called "PWM". That's it.



Whoa, hey, can this person's microcontroller take 12V?

That relay board they're using has a neat feature where it provides an on-board buck converter with 5V out. They may be powering their microcontroller from that, it's not clear from the video they posted. But it looks like a microcontroller that will let the blue smoke out if you give it 12V.

cruft fucked around with this message at 19:37 on Sep 28, 2023

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


cruft posted:

Whoa, hey, can this person's microcontroller take 12V?

That relay board they're using has a neat feature where it provides an on-board buck converter with 5V out. They may be powering their microcontroller from that, it's not clear from the video they posted. But it looks like a microcontroller that will let the blue smoke out if you give it 12V.

Yes, I selected that specific board because it's got a 5V regulator good up to 16V input.


ante posted:

They're N-FETs, which can't do high side switching.

Given that the gate needs to be at the source voltage+10v (for example) to be on. When the transistor is on, and the drain is connected directly to the power source, then the source will be at, say, VCC-0.1V. So unless you have a special power supply for the gate that is above your battery voltage, you'll never get a proper turn on.

How can we, as casual hobbyists, determine whether those are high-side or low-side switches? For something like this the topology is already figured out, right?

babyeatingpsychopath fucked around with this message at 19:49 on Sep 28, 2023

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
They are never high side switches.

There is no reason to do that.


Relays can get around that because they are just an isolated wire, not a semiconductor.


Edit:
As a hobbyist, it is very within your power to look into basic transistor circuit analysis and prove me wrong. Learning about BJTs is a little easier, but conceptually largely the same for your purposes. Getting a better understanding will help in many other aspects as well.

ante fucked around with this message at 19:53 on Sep 28, 2023

cruft
Oct 25, 2007

babyeatingpsychopath posted:

Yes, I selected that specific board because it's got a 5V regulator good up to 16V input.

Sorry to beat this point, but what specific board? I only see you specifying a MOSFET breakout board.

I want to make sure OP doesn't fry their microcontroller.

e: Earlier you said ItsyBitsy which, yes, can handle 16V. I withdraw my concern.

cruft fucked around with this message at 19:56 on Sep 28, 2023

Foxfire_
Nov 8, 2010

Mohamed Atalla can have an alliterative superhero name for making all of modern electronics possible.


babyeatingpsychopath posted:

Yes, I selected that specific board because it's got a 5V regulator good up to 16V input.

How can we, as casual hobbyists, determine whether those are high-side or low-side switches? For something like this the topology is already figured out, right?

For those, there is no real way to know definitively since there's basically no documentation. Basically just guess because n-channel are more common. A less sketch/more expensive part would be telling you the chip on it, and the datasheet will say what kind it is (+lots of other things like max temp, transfer functions, switching speed, ...)

cruft
Oct 25, 2007

Foxfire_ posted:

Mohamed Atalla can have an alliterative superhero name for making all of modern electronics possible.

:hai: seems fair

shame on an IGA
Apr 8, 2005

Foxfire_ posted:

Mohamed Atalla can have an alliterative superhero name for making all of modern electronics possible.

For those, there is no real way to know definitively since there's basically no documentation. Basically just guess because n-channel are more common. A less sketch/more expensive part would be telling you the chip on it, and the datasheet will say what kind it is (+lots of other things like max temp, transfer functions, switching speed, ...)

the linked board is available with buyers choice of four different mosfets and the descriptions say exactly which ones they are?

Foxfire_
Nov 8, 2010

The aliexpress one says what they are. The amazon link babyeatingpsychopath asked about is a different one that's just one unspecified design outside of a couple numbers far as I can tell.

power crystals
Jun 6, 2007

Who wants a belly rub??

Is there a recommended board/micro for something that can do USB host, including enumerating devices through hubs (which it seems like basically everything has a disclaimer including lack of support for)? Ideally something cheaper than a full on Teensy 4 or similar. The RP2040 claims to have host support, but the only things I can see describing it is adafruit managing to fake it by bitbanging its IO pins (which would work, I guess, but I'm hoping there's something more native) which seems to contradict the statement that it has host support native. This would just be for HID or other very slow devices so USB 1.1 max speed is fine. A single USB controller that does both/OTG is also fine, I don't need it to be a client. 5V native IO preferred for the rest of the circuit but I can use shifters if that makes the USB side easier.

Not specifically looking for an arudino-compatible though that'd probably be the easiest option, but this is the closest thread to "general embedded development" I know of so forgive me if I picked the wrong one.

mewse
May 2, 2006

power crystals posted:

Is there a recommended board/micro for something that can do USB host, including enumerating devices through hubs (which it seems like basically everything has a disclaimer including lack of support for)? Ideally something cheaper than a full on Teensy 4 or similar. The RP2040 claims to have host support, but the only things I can see describing it is adafruit managing to fake it by bitbanging its IO pins (which would work, I guess, but I'm hoping there's something more native) which seems to contradict the statement that it has host support native. This would just be for HID or other very slow devices so USB 1.1 max speed is fine. A single USB controller that does both/OTG is also fine, I don't need it to be a client. 5V native IO preferred for the rest of the circuit but I can use shifters if that makes the USB side easier.

Not specifically looking for an arudino-compatible though that'd probably be the easiest option, but this is the closest thread to "general embedded development" I know of so forgive me if I picked the wrong one.

I came across this project recently that interfaces modern usb controllers with old sega saturn consoles by using an arduino + usb host shield. I don't know how robust, available, or affordable the usb host shield is, but it looks like it has a decent software library.

https://docs.arduino.cc/retired/shields/arduino-usb-host-shield

cruft
Oct 25, 2007

I made an electronics thing that people are actually asking for. It's a weird clock, a kinetic art display, and also plays 8x8 animations my sister in law and I upload to my double secret server on the Internet. We've been doing a lot of winter themed ones lately.

The original intent was sending little messages to my kid while she's away at college. She likes seeing new animations pop up from her loved ones.



I made 3 the first run, now I'm making 4 more to fill requests.



They cost about $60 each to make, because I'm using Gen-You-Ine Adafruit parts.

If anyone ITT is business minded, I bet you could sell these with very few changes for production. I've done most of the R&D and all the source code is MIT license.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Oh very cool.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


Is there a BOM available?

If you make the thing, is there a way to point it at some other double-secret server?

cruft
Oct 25, 2007

babyeatingpsychopath posted:

Is there a BOM available?

If you make the thing, is there a way to point it at some other double-secret server?

BOM and 3D printer parts are here: https://learn.adafruit.com/sqaure-neopixel-display-with-black-led-acrylic

You can direct wire the Feather to the grid and skip the wing.

The Arduino code and server code are both 100% my creation and MIT licensed. The server URL is in a couple #defines in the .ino file.

The server itself lets you upload animated gifs. If you want to password protect it or use HTTPS, you have to set that up in Caddy or nginx or something.

I'd be happy to help anybody set up their own instance! I can even set you up with some animations :)

cruft
Oct 25, 2007

Anybody know an algorithm for debouncing an array of 16 switches?

My poll loop currently runs about 13 times per millisecond, on this 8MHz 3.3v Atmel 32u4. I don't have a whole lot of instructions to spare here, unfortunately. I know I could just move to something like an RP2040 and get interrupts on all GPIOs, a separate PIO thread for USB, and a gajillion more instructions per millisecond, but I like a challenge :)

I'm building a Rock Band drum kit. It's working great except for the bouncing killing my streaks.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
Are analog RC filters on the switches an option?

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


PDP-1 posted:

Are analog RC filters on the switches an option?

If so, then RC + Schmitt trigger is the classic circuit.

There's also the OnSemi MC14490 or Maxim MAX6818. Like $10 per chip in small quantities, but this is a way to get automotive-grade debouncing.

There's also throwing another tiny microcontroller off the side and multiplexing the inputs and only doing switch debouncing with the other micro...

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
You can do a similar hysteresis function in hardware by having a byte for each pin that gets incremented (up to some max value) each time the button is pushed and decremented (limited to zero) when it isn't pushed. Only change the output state when the counter hits one of those limits.

cruft
Oct 25, 2007

I cheaped out and coded up a 254-sample (40ms) blackout period per pin after an edge is detected. Seems to do the trick, for this application.

I considered doing it with hardware, but I'm a lazy jerk, and don't want to solder any more junk on. :classiclol:

E: I just realized that fits into a uint8. I used a uint16 because I wasn't sure how many samples it would be. What's weird is that my benchmarks showed no speed difference between 8-bit integer arithmetic and 16-bit, even though the 32u4 is an 8-bit CPU. I think.

Anyway the family is playing rock band with it now, so electronics time is over.

cruft fucked around with this message at 20:48 on Jan 1, 2024

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
It could be that the compiler saw that your value never gets above 255 and just changed it to be uint8.

cruft
Oct 25, 2007

On the one hand, I'm really proud of myself for squeezing enough performance out of an 8MHz CPU to get software-debounced drum pad hits that apparently only close the momentary switch for under 20ms.

On the other hand, I'm appalled that this chip is running at almost twice the clock speed of my first desktop computer, and all I'm doing with it is asking over and over if 14 buttons have been pressed.

shame on an IGA
Apr 8, 2005

cruft posted:

On the one hand, I'm really proud of myself for squeezing enough performance out of an 8MHz CPU to get software-debounced drum pad hits that apparently only close the momentary switch for under 20ms.

On the other hand, I'm appalled that this chip is running at almost twice the clock speed of my first desktop computer, and all I'm doing with it is asking over and over if 14 buttons have been pressed.

asking if buttons have been pressed is the only thing computers do if you think about it too much

Sagebrush
Feb 26, 2012

cruft posted:

On the one hand, I'm really proud of myself for squeezing enough performance out of an 8MHz CPU to get software-debounced drum pad hits that apparently only close the momentary switch for under 20ms.

On the other hand, I'm appalled that this chip is running at almost twice the clock speed of my first desktop computer, and all I'm doing with it is asking over and over if 14 buttons have been pressed.

yeah but it can check if the buttons are pressed almost twice as fast

cruft
Oct 25, 2007

:siren: :frogsiren: :siren:

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
That's the long answer, as well

Collateral Damage
Jun 13, 2009

Long answer: "Nooooooooo."

cruft
Oct 25, 2007

Is it possible for a USB device to know what host it's talking to?

I'm working on this toy drum controller for Wii Rock Band, and it's just beyond me how to get it working right in this PC game called Clone Hero. The interface is this bonkers combination of 12 gamepad buttons for 9 switches, and I've got it working on the Wii, but I'd like to have it go "oh, you're a PC, you get one button per input switch". Without requiring the user to do anything.

Is that even possible?

Hadlock
Nov 9, 2004

Yeah there's almost some sort of host client negotiation going on. The controller is almost certainly sending a digital signal not raw analog values. The last fully analog controller was possibly the Atari 2600 joystick

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


cruft posted:

Is it possible for a USB device to know what host it's talking to?

I'm working on this toy drum controller for Wii Rock Band, and it's just beyond me how to get it working right in this PC game called Clone Hero. The interface is this bonkers combination of 12 gamepad buttons for 9 switches, and I've got it working on the Wii, but I'd like to have it go "oh, you're a PC, you get one button per input switch". Without requiring the user to do anything.

Is that even possible?

It's a good question. The burden of data is on the device to supply information to the host. I have the workflow for device enumeration down pretty solid, but I'm not seeing anything that requires the host to TRANSMIT to the device beyond "give me X."

So the steps to get a USB device working are basically:
Host reads Device Descriptor
Host reads Configuration Descriptor(s)
Host reads Interface Descriptor(s)
Host reads Endpoint Descriptor(s)

I think you could have a device with two Endpoints; one for the Wii which is standard and one for the PC. After the PC gets all the data, then it requests endpoint 1 and your code does the "1 button=1switch" mode. If the host never requests endpoint 1, you default to endpoint 0 and assume that's the Wii.

Of course, it might be a different Interface and not Endpoint; I'm not real solid on that part of the USB spec.

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
Is this a custom thing you're making? Is it possible to just put in a switch that goes between PC and Wii mode? Seems like that's what a lot of devices do these days. There's either a switch or a button combo you do to switch between host modes.

shame on an IGA
Apr 8, 2005

Hadlock posted:

Yeah there's almost some sort of host client negotiation going on. The controller is almost certainly sending a digital signal not raw analog values. The last fully analog controller was possibly the Atari 2600 joystick

even just on/off digital buttons have been fully serialized since at least the NES, probably earlier

Sagebrush
Feb 26, 2012

shame on an IGA posted:

even just on/off digital buttons have been fully serialized since at least the NES, probably earlier

Game Port joysticks, which were still available until the early 2000s, have dedicated pins for each button, and connect directly to the axis potentiometers and do the ADC on the computer. No logic on the stick itself at all.

Sagebrush fucked around with this message at 00:10 on Jan 8, 2024

cruft
Oct 25, 2007

babyeatingpsychopath posted:

I think you could have a device with two Endpoints; one for the Wii which is standard and one for the PC. After the PC gets all the data, then it requests endpoint 1 and your code does the "1 button=1switch" mode. If the host never requests endpoint 1, you default to endpoint 0 and assume that's the Wii.

That is a hell of a clever idea. And that's exactly how the Wii works: I have to disable the serial connection on the board because it uses endpoint 0.

Fortunately, I was able to once again shoot in the dark enough to figure out what the undocumented mapping values in Clone Hero were expecting, so I don't have to do this after all.

Cojawfee posted:

Is this a custom thing you're making? Is it possible to just put in a switch that goes between PC and Wii mode? Seems like that's what a lot of devices do these days. There's either a switch or a button combo you do to switch between host modes.

I considered this, yeah. I was just wondering if there were a more clever thing I could do with USB, and it looks like, yes.

BBL, gotta go play a bunch of video games to verify everything's working properly :D

5TonsOfFlax
Aug 31, 2001
Anyone dealt with Seeed studio xiao nrf52840 sense? I'm trying to build a gesture recognizing ring which will need to:
1. Wake on double tap (found example code)
2. Recognize 3d gestures (got this working)
3. Be a BLE HID device. Preferably with pairing and all.
4. Very low power sleep most of the time.

The problem is that there are two arduino boards for this thing. The "mbed" enabled one is what i used for recognizing gestures, but it doesn't support the nice adafruit bluefruit libraries which make HID reasonable. The plain non-mbed does support adafruit bluefruit, but the ml sketch doesn't work as well. Not sure if it's just a timing thing since the "sampling now" prompt doesn't appear until _after_ the sampling is done, making it difficult to perform gestures at the right time.

Anyone successfully used edge impulse models on the non-mbed version? Or got BLE HID working on the mbed version?

5TonsOfFlax
Aug 31, 2001
It turns out that it was merely a difficulty in timing the sampling causing my troubles. I replaced the late-printing message with turning on a led to let me know, and the non-mbed runs the edge-impulse model just fine. So I should be able to use all the nifty Adafruit bluefruit and power management stuff.

Dia de Pikachutos
Nov 8, 2012

Deadite posted:

That's interesting, I don't know much about lighting controls and thought this whole thing would be much simpler than it is turning out to be. Do the DMX LED controls come in smaller versions?

I make neon-style LED signs and I'm trying to animate my first sign, but if this works it opens up a whole new area for me.

For this first one I just need the three sections to blink in sequence to look like the teeth of a chainsaw are moving:



Hey I'm not sure if this is any use to you, but I'm designing a carrier board that takes Arduino Nanos and connects the 6 PWM pins to mosfets and XT30 connectors for a purpose that isn't too dissimilar to yours (and lets it do fade effects).



I need to finish the silkscreen and check a few things, but once I have you're welcome to the KiCad file.

Dia de Pikachutos fucked around with this message at 11:06 on Mar 27, 2024

wolrah
May 8, 2006
what?

Sagebrush posted:

Game Port joysticks, which were still available until the early 2000s, have dedicated pins for each button, and connect directly to the axis potentiometers and do the ADC on the computer. No logic on the stick itself at all.
Except when there was logic on the stick, which was not uncommon in the late '90s where USB was not even widespread much less universal but people still wanted to have more than four buttons and four axes, like for example a lot of the Microsoft Sidewinder products: https://github.com/MaZderMind/SidewinderInterface

They use the fact that the analog axes produce a pulse when read by the host to signal a request for data and then the controller responds with a clock signal on the button 1 line and serial data on button 2 which makes it work kinda like the NES/SNES. I have a Saitek gamepad from the early 2000s that's pretty much a PSX dual analog knockoff and supports game port as well as USB presumably through a similar trick.

Deadite posted:

That's interesting, I don't know much about lighting controls and thought this whole thing would be much simpler than it is turning out to be. Do the DMX LED controls come in smaller versions?

I make neon-style LED signs and I'm trying to animate my first sign, but if this works it opens up a whole new area for me.

For this first one I just need the three sections to blink in sequence to look like the teeth of a chainsaw are moving:


I know this is way late for your target of Halloween on this particular project, but if you are interested in building these sorts of things in general and want to animate them I strongly recommend that you get to know addressable LEDs. WLED firmware on an ESP32 takes literally minutes to set up from unboxing the hardware to animating LEDs and gives you a nice web interface that's even mobile friendly to control it from (as well as support for basically every network automation protocol you might want).

Addressable LEDs are not always the right answer but they're cheap and easy enough these days that they can be used to brute force a solution for less mental effort than doing it what might be the absolute most cost or power efficient way.

wolrah fucked around with this message at 18:05 on Mar 27, 2024

Adbot
ADBOT LOVES YOU

Spazzle
Jul 5, 2003

wolrah posted:


I know this is way late for your target of Halloween on this particular project, but if you are interested in building these sorts of things in general and want to animate them I strongly recommend that you get to know addressable LEDs. WLED firmware on an ESP32 takes literally minutes to set up from unboxing the hardware to animating LEDs and gives you a nice web interface that's even mobile friendly to control it from (as well as support for basically every network automation protocol you might want).

Addressable LEDs are not always the right answer but they're cheap and easy enough these days that they can be used to brute force a solution for less mental effort than doing it what might be the absolute most cost or power efficient way.

I haven't looked too deeply into WLED, but aren't you basically stuck using premade patterns unless you stream pixel data from external sources? I'd usually use fast LED on an Arduino or use a pixelblaze if I wanted a custom pattern.

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