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
PBCrunch
Jun 17, 2002

Lawrence Phillips Always #1 to Me
I want to use a Raspberry Pi Pico acting like a USB keyboard to set the system volume to absolute levels (like 0%, 20%, 40%, 60%, 80%, 100%). I don't really want to just do volume up/down. Ideally this device would work with Windows and Linux. Is it possible to send an absolute volume level via USB HID?

Adbot
ADBOT LOVES YOU

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
You could mash volume down a whole bunch until you're certain it's zero, then turn it up to the right level.


That's assuming they're isn't a HID command to just do it, I haven't looked into it

cruft
Oct 25, 2007

PBCrunch posted:

I want to use a Raspberry Pi Pico acting like a USB keyboard to set the system volume to absolute levels (like 0%, 20%, 40%, 60%, 80%, 100%). I don't really want to just do volume up/down. Ideally this device would work with Windows and Linux. Is it possible to send an absolute volume level via USB HID?

Not with a keyboard: keyboards send "key down" and "key up" events. And there's no guarantee how the computer is going to handle "volume up": does that mean increase by 3%? 5%? 10%?

There are other USB HID devices that could do this, but you'd need something on the other end to listen.

wolrah
May 8, 2006
what?

PBCrunch posted:

I want to use a Raspberry Pi Pico acting like a USB keyboard to set the system volume to absolute levels (like 0%, 20%, 40%, 60%, 80%, 100%). I don't really want to just do volume up/down. Ideally this device would work with Windows and Linux. Is it possible to send an absolute volume level via USB HID?
No. USB HID volume control codes are purely relative, just increase, decrease, and toggle mute.

https://usb.org/sites/default/files/hut1_3_0.pdf#page=145&zoom=100,57,57

Section 15.9.1 if the anchor location doesn't work properly.

Like cruft said you'd need to have some custom app talking to the USB device to do what you want. It probably wouldn't be super hard to do as a "my first libusb project" type thing but it definitely would not be as straightforward as having it act like a keyboard.

PBCrunch
Jun 17, 2002

Lawrence Phillips Always #1 to Me
I would much rather live with the volume up/down limitations than have to run some kind of custom driver on the host machine. Thanks for the input (:dadjoke:) though.

Lichtenstein
May 31, 2012

It'll make sense, eventually.
Hi there, thread. I don't know jack poo poo about arduinos and raspberries and such, but wanted to do some research into what I think might be a fun learning project. Apologies if this is a very basic question - but when it comes to hardware I'd have to go and order and be stuck with, I'd rather not act on my own vague understanding of things.

A couple days ago I've used a MIDI translator to use a piano keyboard as a stickless arcade controller for fighting games on a lark. Then I found I actually really like it and started training with it and coding own SOCD cleaners (rules for handling opposing directional directions to be ~tournament legal~). Now, while I don't really need it, I've started talking with some friends about making a for-funsies project of grabbing an arduino or something similar to make my own plug'n'play adapter to be able to just roll up to some local meetings or something.

The thing I'd need this thing to do:
- Read MIDI inputs, preferably through a USB cable.
- Translate them to other key presses internally, so I don't have to install poo poo on target machine running the game and output them by another USB connection.
- Be able to swap between modes of pretending to a PC or Playstation controller - I know the consoles have some different I/O standards, but I have no idea if it has any hardware/connector implications.
- If it could just mooch power through these USB connectors and not require it's own power plug, it'd be super sweet.
- Some case to be able to just chuck in into a backpack. Any considerations for Stuff To Fit Inside I should be aware of?

What would I need to grab hardware-wise to possibly get such a gizmo to work?

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
Yeah, that seems like a decent beginner project.


I'm not sure what the most recommended keyboard HID capable Arduino is lately. Maybe the Teensy? First step would just be picking up one of those and then getting it to simulate keyboard inputs.

cruft
Oct 25, 2007

ante posted:

Yeah, that seems like a decent beginner project.


I'm not sure what the most recommended keyboard HID capable Arduino is lately. Maybe the Teensy? First step would just be picking up one of those and then getting it to simulate keyboard inputs.

Agreed that this is a great first project.

For this project, for an absolute beginner, I recommend starting with a genuine Arduino Leonardo or Arduino Micro. It will do USB junk, and works with everything.

My recommendation for programming it, for absolute beginners, is Arduino Create, which runs in the browser and even works on a Chromebook.

Lichtenstein
May 31, 2012

It'll make sense, eventually.
One aspect I'm a little unsure of is what would I need to have an input USB and output USB working at the same time. From what I've gathered, due to USB hosts being a bit tricky, the options here are either Due or any of the other USB-friendly models with an added USB host shield?

cruft
Oct 25, 2007

Lichtenstein posted:

One aspect I'm a little unsure of is what would I need to have an input USB and output USB working at the same time. From what I've gathered, due to USB hosts being a bit tricky, the options here are either Due or any of the other USB-friendly models with an added USB host shield?

Oh. Yeah.

You can't be a USB host and a USB client at the same time on the same cable. You'll need two USB endpoint devices.

My recommendation here is to just get some off-the-shelf USB to MIDI adapter, and run those pins into header pins on the Arduino, using the normal MIDI serial communications. I don't have any experience with a "USB host shield" but my hot take is that USB is a very complicated protocol, and juggling all the libraries to do this on a single device is going to be challenging. Might be a good milestone for the second version, after you get the first one working.

That's what I'd do, anyway.

Lichtenstein
May 31, 2012

It'll make sense, eventually.
I do have an option to use either USB or proper MIDI cable for input - and I reflectively assumed the former to be more hassle-free, but that's probably just PC habits. Though if you think about it, it's really just needlessly adding a middleman, isn't it?

cruft
Oct 25, 2007

Lichtenstein posted:

I do have an option to use either USB or proper MIDI cable for input - and I reflectively assumed the former to be more hassle-free, but that's probably just PC habits. Though if you think about it, it's really just needlessly adding a middleman, isn't it?

Once you strip off all the USB stuff, the MIDI protocol over USB is (almost) exactly the same as the normal MIDI protocol. Many modern MIDI devices don't have a DIN-9 MIDI output jack, though: they only have USB.

It's not silly to want to consider a USB in and a USB out. It's just that, for this application, I think you're going to have a much easier time if you start out with an old school MIDI jack, and then put a pre-built USB-MIDI adapter on it if you need one.

Lichtenstein
May 31, 2012

It'll make sense, eventually.


It works! The coding part was admittedly dead easy compared to triple-checking how this stuff works on the hardware level, but no matter how basic, there's still a visceral thrill of loading up code and having it work on a first attempt.

cruft
Oct 25, 2007

I'm sure somebody in here has experience wiring up WS2812B LEDs.

I need to make a portable cylinder, 8-10 feet tall, with at least 4 runs of LEDs going down it. It needs to be packable, and not look awful. It's going to be used at a conference so it needs to stand up to some level of curious people touching it.

I'm currently thinking of using a lighting stand with a custom-made metal triangle mounted on the top, then draping black polyester fabric down the sides to the legs of the stand, and running WS2812B strands down it. The triangle would need to mount on the holes at the top of the lighting stand.

The Arduino and beefy PSU would get tied to the pole in the center with a bungee cord.

This is pretty similar to your standard christmas tree lighting thing, except I need to provide the tree.

I'm wondering if the combined expertise of the Arduino thread has enough experience making junk similar to this that they'd have some advice?

shame on an IGA
Apr 8, 2005

whats the diameter

cruft
Oct 25, 2007

shame on an IGA posted:

whats the diameter

I don't know yet, depends on how it's built. If I use the lighting tree, that's probably 3 feet diameter, maybe 4.

Foxfire_
Nov 8, 2010

A SK9822 or APA102 strip is easier to control. It has a separate clock line and uses normal SPI instead of a single data line that needs specific bit times

cruft
Oct 25, 2007

Foxfire_ posted:

A SK9822 or APA102 strip is easier to control. It has a separate clock line and uses normal SPI instead of a single data line that needs specific bit times

Heh, okay. The code's already written though, I just need to build the structure :)

Foxfire_
Nov 8, 2010

Do you have mspaint scribble, or a picture of a standard christmas tree lighting thing? Hard to picture what you mean

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


cruft posted:

I'm sure somebody in here has experience wiring up WS2812B LEDs.

I'm wondering if the combined expertise of the Arduino thread has enough experience making junk similar to this that they'd have some advice?

I'm not sure what your question is? How to wire power? How to wire data? How to build it out of metal/plastic/wood/fiberglass?

cruft
Oct 25, 2007

Foxfire_ posted:

Do you have mspaint scribble, or a picture of a standard christmas tree lighting thing? Hard to picture what you mean

Picture a tree trunk with strands of lights falling down it. Here's an ascii art version:

pre:
 _____
|  |  |
|  |  |
|  |  |
|  |  |
|  |  |
 _____
It doesn't need to be round, it can be a triangular prism, maybe even a monolith shape. It just needs to be tall, and difficult to tip over.

babyeatingpsychopath posted:

I'm not sure what your question is? How to wire power? How to wire data? How to build it out of metal/plastic/wood/fiberglass?

Yeah, I didn't actually state what I need help with, sorry.

I need advice on:

  • How to construct the thing so it can be packed into a suitcase
  • How to make it somewhat durable

So far a light tree with fabric seems like the best idea I've had, but I'm really bad at physical design and maybe this is an awful idea. I'm hoping someone in this thread has done enough larger-scale designs that they have some advice. Maybe this isn't the right thread, either; I didn't find one that looked more appropriate, other than maybe cosplay.

Thanks :)

drunk mutt
Jul 5, 2011

I just think they're neat

cruft posted:

Picture a tree trunk with strands of lights falling down it. Here's an ascii art version:

pre:
 _____
|  |  |
|  |  |
|  |  |
|  |  |
|  |  |
 _____
It doesn't need to be round, it can be a triangular prism, maybe even a monolith shape. It just needs to be tall, and difficult to tip over.

Yeah, I didn't actually state what I need help with, sorry.

I need advice on:

  • How to construct the thing so it can be packed into a suitcase
  • How to make it somewhat durable

So far a light tree with fabric seems like the best idea I've had, but I'm really bad at physical design and maybe this is an awful idea. I'm hoping someone in this thread has done enough larger-scale designs that they have some advice. Maybe this isn't the right thread, either; I didn't find one that looked more appropriate, other than maybe cosplay.

Thanks :)

Start getting into conflicting goals here with the "fits in a suit case" and "hard to knock over". I'd probably lean to speaker stands with PVC that gets your strands to the desired height. Just make sure if you do anything to extend outward anywhere near the top that it's light materials so the center of balance stays towards the middle of the tripod.

Fanged Lawn Wormy
Jan 4, 2008

SQUEAK! SQUEAK! SQUEAK!
Yeah I think a speaker tripod would be sturdier bit I’m not sure how small it could get. Defining “suitcase” would help. Carryon size? Checked size?

I’ve worked a ton with pixel strips for exhibit installations. I think the most important thing i can recommend for durability is to make sure your soldered ends are very secure. Because of how the pixel strips are made, the data line solder joint is extremely susceptible to breaking. Make sure the last inch or more is secured so it cannot wiggle at all, and do the same for your wire.

If at all possible, try and stick with 20 or 22 AWG wire for your connections. 18 awg, while better for power concerns, tends to be stiff enough that it will rip pads right off if you flex it wrong. The copper used in most pixel strips Ive handled seem more brittle than typical rgb or white strips. Maybe its just thin.

I sometimes will do a splice for the last 3 inches of the wire run using 18 awg. I then go to smaller for the connection. Its not electrically ideal but it seems better than pumping 5-10 amps of 5V over 8ft runs of smaller gauge.

cruft
Oct 25, 2007


I feel like an idiot for not thinking of this right away. Building a rectangular prism out of PVC seems like the obvious solution. Built on its side and then erected, PVC should pack up pretty nicely. I can get some sort of thick plastic bags to fill with water once we've arrived, and use those to weigh it down. Maybe throw in some nylon rope to use as guy wires to keep it rigid.

pre:
        _______________________________
       -/             -/             -/
     - /            - /            - / 
   -______________-__/___________-  /  
  /  -           /  -           /  -
 / -            / -            / -
/-_____________/-_____________/-
Good advice on the pads ripping off. I've actually had this happen in a few projects too, now that I'm thinking of it. I might also 3D print some sort of case for the end of the strip with the connection in it, to prevent it flexing and potentially popping off a pad, or get some hot tips from my textile pals on how I can sew the strips in such a way that the flex happens inside the wire instead of at the solder junction.

Thanks!

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


No clue what your budget is, but there are piles of pop-up pavilions and displays and whatnot for trade shows that you could take inspiration from or buy.

As far as durability: good connectors, plenty of strain relief, and as much potting and mechanical control as you can get for the wires near any connection points. I have a few spools of 22ga silicone wire that i use for all my hookups, crimped into JST connectors. 2-3" of wire, soldered onto the pad, then covered in epoxy. then zip-tie the epoxy blob to the structure. then wrap the whole thing in tape so only the connector is exposed. Then, when something inevitably catches on the wire, the connector unplugs or the wire tears out of the crimp before managing to use up all of the crash structure that is zip ties wrapped in tape.

shame on an IGA
Apr 8, 2005

yeah if you've got decent budget for this I would suggest using M12 connectors and multistrand industrial sensor cable for all your breakdown connections.

As for the mechanics, woodworking or blacksmithing threads will probably have good input if you ask there

namlosh
Feb 11, 2014

I name this haircut "The Sad Rhino".
So, I have a question regarding programming the fuses/bootloader etc of ATMEGA chips.

I want to be able to run them without a crystal... I've heard that the internal crystal sucks. What really are the ramifications of this? Like, I won't be able to listen to the chip in Serial monitor? I have to default to a slower baud rate? I won't be able to program it anymore? Everything on these chips uses Serial doesn't it, even ICSP?

Do I need a USBASP? Is it (or an Arduino) absolutely needed to program the fuses and eeprom directly? Can it be done with an FTDI usb->serial adapter? if so, how difficult is it? should I just save the headache and buy the thing?
Is it needed if I get a bunch of ATMEGA variants? like the ATTINY? I had aquired a smattering of different AT-chips
For context, I have an arduino, a Duecimilanove and some esp32s along with a couple of serial boards (FTDI and such).

This kind of thing would all be done with ICSP right?

Sorry if this is poorly organized, but I did a bunch of research a few months ago but then had to drop it and I'm trying to have a quicker start this time.

Thanks!

ToxicFrog
Apr 26, 2008


namlosh posted:

So, I have a question regarding programming the fuses/bootloader etc of ATMEGA chips.

I want to be able to run them without a crystal... I've heard that the internal crystal sucks. What really are the ramifications of this? Like, I won't be able to listen to the chip in Serial monitor? I have to default to a slower baud rate? I won't be able to program it anymore? Everything on these chips uses Serial doesn't it, even ICSP?

You can't run the chip without some sort of clock. The default fuse settings use an internal RC oscillator, which is not crystal-based -- it's a little ball of resistors and capacitors that produce a sine wave when powered. Fiddling with the fuses is done when you want to run the chip off an externally connected crystal oscillator, the clock-out pin of another microcontroller, or the like. Most (all?) arduinos have a crystal oscillator on the board and are pre-fused to use it, but "naked" atmega chips out of the box won't be.

Don't know about the programming aspect, but I suspect that even for an arduino you'll need an external programmer (although if you have a spare usb-programmable board like an arduino lying around you can turn it into the programmer and use it to re-fuse the rest, IIRC).

Foxfire_
Nov 8, 2010

The internal RC oscillator will be less stable and less accurate than a crystal. e.g. an ATMega8U2's internal RC is nominally 8Mhz @ 25C and factory calibrated to be within +/-10% of that. Even a very crappy $0.15 8MHz crystal will have an accuracy specification of something like 50ppm (0.005%). The RC will also jitter more cycle-to-cycle, shift more with temperature changes, and drift more over time. (The internal one is a resistor and capacitor formed out of semiconductor just like the rest of the IC so it's basically free. An external crystal is a block of quartz physically cut to have a specific resonant frequency. It isn't straightforward to package that into the same chip)

If you did something like set up a UART for nominally 115200 baud then measured the actual bit rate, you'd see something higher or lower depending on how far off the oscillator was from nominal. Whether another device can successfully talk to that will depend on how much tolerance it has for clock recovery. Or if you were doing something like playing an audio file where you are ideally producing DAC samples at some fixed sampling rate, a 10% error in the clock would be audible as shifted pitches.

For programming/debugging, an ATMega has a few interfaces. You are probably using the serial programming one that uses a couple SPI-like pins and can program flash and most fuses. It can't change all possible fuses (e.g. you can't disable serial programming using it). It also doesn't support debugging stuff like breakpoints or single stepping instructions. For hobby stuff, you probably aren't going to need to change most fuses, so if you don't care about debug features, it probably doesn't matter to you whether you are using serial programming or debugWire

Rat Poisson
Nov 6, 2010

You can use one of the many ICSP programmers (USBtiny, AVR MKII etc) or another Arduino as the ICSP (search "Arduino as ISP") to set the fuses for using the internal oscillator and to burn the bootloader that will then allow you to upload sketches via a typical FTDI USB-serial adapter.

I regularly build devices using the internal 8MHz oscillator on the ATmega328p, and the main concession is that I use 57600 baud for serial communications instead of the Arduino default 115200, because I'd occasionally get errors at 115200. Besides that I haven't had any issues with my typical set of peripherals like microSD cards, various sensors, real time clocks etc, since those are all running on some slower protocol (I2C, SPI) that can work within the lower overall 8MHz clock speed. But none of my applications require very fast and tight timing.

I generally set up new chips by putting the Optiboot bootloader https://github.com/Optiboot/optiboot on, which has options for setting fuses at 8MHz on the internal oscillator when you burn the bootloader.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


Rat Poisson posted:

You can use one of the many ICSP programmers (USBtiny, AVR MKII etc) or another Arduino as the ICSP (search "Arduino as ISP") to set the fuses for using the internal oscillator and to burn the bootloader that will then allow you to upload sketches via a typical FTDI USB-serial adapter.

I regularly build devices using the internal 8MHz oscillator on the ATmega328p, and the main concession is that I use 57600 baud for serial communications instead of the Arduino default 115200, because I'd occasionally get errors at 115200. Besides that I haven't had any issues with my typical set of peripherals like microSD cards, various sensors, real time clocks etc, since those are all running on some slower protocol (I2C, SPI) that can work within the lower overall 8MHz clock speed. But none of my applications require very fast and tight timing.

I generally set up new chips by putting the Optiboot bootloader https://github.com/Optiboot/optiboot on, which has options for setting fuses at 8MHz on the internal oscillator when you burn the bootloader.

I do the same thing. I've got a box of 328pu's and an ancient uno that's permanently wired as an ICSP with a socket on a breadboard. 8MHz is fine for most stuff as long as you're not doing audio.

namlosh
Feb 11, 2014

I name this haircut "The Sad Rhino".
This is awesome, thx for the replies. I’m going to do some experimentation tonight and get back.

It turns out that I have one of these:
https://www.amazon.com/gp/aw/d/B01CZVZ1XM
USBTINYISP

I assume I can use it via avrdude to program the boot loader and fuses of most of the AT chips.

The big thing I want to address first is to reprogram the correct arduino duecimilanove boot loader onto that boards chip. I think I borked the boot loader on that board accidentally from my Macbook by getting too aggressive with the upload button in the arduino IDE. It won’t do anything at the moment via usb, so I’m going to try to fix it using ICSP next.

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen

namlosh posted:

getting too aggressive with the upload button in the arduino IDE

it's the only way they'll learn! :arghfist::dadjoke:

namlosh
Feb 11, 2014

I name this haircut "The Sad Rhino".
That’s what I thought! Lol

But evidently pushing it in macOS or Linux can cause it to overwrite the boot loader with crap…

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
That's hilarious. Luckily, I think you can always recover it with the ICSP pins unless you set the fuses to lock the chip.

cruft
Oct 25, 2007

namlosh posted:

That’s what I thought! Lol

But evidently pushing it in macOS or Linux can cause it to overwrite the boot loader with crap…

Not entirely sure what you mean but I've set fuses / programmed dozens of Atmel chips with avrdude from Linux using that same type of USB programmer, and I've never had a problem. So I sort of doubt the operating system is the issue.

E: I guess I ought to point out that if you're doing things at this level, you might be ready to stop using the Arduino IDE / bootloader, and just run gcc and avrdude yourself. It'll free up some space in the memory of the chip that would otherwise be taken by the bootloader.

EE: unless you're trying to update the firmware on your USBTiny? Sorry for the spam if that's the case. Brain's still fuzzy from COVID.

cruft fucked around with this message at 19:58 on Jul 12, 2022

namlosh
Feb 11, 2014

I name this haircut "The Sad Rhino".

cruft posted:

Not entirely sure what you mean but I've set fuses / programmed dozens of Atmel chips with avrdude from Linux using that same type of USB programmer, and I've never had a problem. So I sort of doubt the operating system is the issue.

E: I guess I ought to point out that if you're doing things at this level, you might be ready to stop using the Arduino IDE / bootloader, and just run gcc and avrdude yourself. It'll free up some space in the memory of the chip that would otherwise be taken by the bootloader.

EE: unless you're trying to update the firmware on your USBTiny? Sorry for the spam if that's the case. Brain's still fuzzy from COVID.

Dang I can’t find it now, but there was a support article or post on the arduino forums or something stating that Linux and MacOS could overwrite the boot loader if you hit the upload button a couple of times before it could finish. It’s possible it was only an issue with the old rear end Duecimilanove I have. Either way I broke it and was trying to get it working again.

And good point… I’m actually using platformio for things now but go back to arduino ide for some stuff because there’s just so much more support and I can copy the command line args it generates to use as a template

Speaking of which, someone mentioned a plug-in for Visual Studio (not vscode) for working with microcontrollers? I like vscode and all, but have enterprise MSDN so thought I’d see if there was anything to be gained… plus it would help to not have
to remember different keyboard shortcuts

Fanged Lawn Wormy
Jan 4, 2008

SQUEAK! SQUEAK! SQUEAK!
Ah, thats Visual Micro. Its pretty good! They have a full feature trial, but you have to buy it eventually. Pretty reasonable price though.

Im pretty stupid but it works great for me.

namlosh
Feb 11, 2014

I name this haircut "The Sad Rhino".

Fanged Lawn Wormy posted:

Ah, thats Visual Micro. Its pretty good! They have a full feature trial, but you have to buy it eventually. Pretty reasonable price though.

Im pretty stupid but it works great for me.

”visual micro website” posted:

Debug your ESP32/8266/NINA WiFi project remotely so you can debug your project in its real environment, from the comfort of your PC

All Serial Debugging Features (Charting/Performance Monitoring etc) are available remotely with these boards.

Is that true? Have you used it? That seems like it would be a killer app for me

Adbot
ADBOT LOVES YOU

Fanged Lawn Wormy
Jan 4, 2008

SQUEAK! SQUEAK! SQUEAK!
I have not - I tend to avoid wireless. but I believe it! The debug console and graphs are nice.

Contact the dev or ask on their forums, Ive found they are nice folks.

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