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
poeticoddity
Jan 14, 2007
"How nice - to feel nothing and still get full credit for being alive." - Kurt Vonnegut Jr. - Slaughterhouse Five
If I was going to try to build a KSP controller I'd do inputs as an HID on one uC and outputs over serial on another uC and just hide the extra bit of cabling so I didn't have to deal with bidirectional serial communication.

Adbot
ADBOT LOVES YOU

jmzero
Jul 24, 2007

poeticoddity posted:

If I was going to try to build a KSP controller I'd do inputs as an HID on one uC and outputs over serial on another uC and just hide the extra bit of cabling so I didn't have to deal with bidirectional serial communication.

You can make a "keyboard+joystick+serial" device with a single teensy - it's one of the built-in configs, and I think that makes sense here.

But yeah, I guess he might run out of IO pins, so the simplest answer might be 2 connections anyway. And it looks like a fun project.

Ambrose Burnside
Aug 30, 2007

pensive

poeticoddity posted:

If I was going to try to build a KSP controller I'd do inputs as an HID on one uC and outputs over serial on another uC and just hide the extra bit of cabling so I didn't have to deal with bidirectional serial communication.

Yeah, I think that's the way to go; apparently the hale old plugin I was gonna use has issues with sending serial signals (but can receive them just fine) in windows 10, so it sounds like you can basically work around that by configuring the input controller as a keyboard and directly keymapping the various inputs, while using a second system to receive serial telemetry data and output it to 7-segment displays or VFD tubes or nixies or sth. so cleanly separating I from O in two different systems using different protocols sounds like it makes sense here. unless a Teensy can simulate a keyboard and serial connection simultaneously, which might be where a teensy 4.0 is worth the expense. I need to read some datasheets I think

Ambrose Burnside fucked around with this message at 22:19 on Sep 28, 2020

Fanged Lawn Wormy
Jan 4, 2008

SQUEAK! SQUEAK! SQUEAK!
I know you already made a good choice her but I wanted to chime in with the agreement that the blue pill STM whatever controllers are absolute trash jokes

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
The price is right, but only if you want A Project and don't value your time.

I've used them a lot, and they're great, but I've definitely put the work in

Dominoes
Sep 20, 2007

Fanged Lawn Wormy posted:

I know you already made a good choice her but I wanted to chime in with the agreement that the blue pill STM whatever controllers are absolute trash jokes
Bro...

Sagebrush
Feb 26, 2012

yeah i have a handful of the bluepills just because they're so cheap, and I periodically pull them out when starting a new project to see if this will be the time I use one, but it always becomes far more than $8 worth of pain so I just get another teensy-LC and everything works correctly.

If only I could order those in bulk from aliexpress...

Dominoes
Sep 20, 2007

What issues do you run into with Blue Pills? I haven't used one, but from what I gather, it's a minimal STM32F1 dev board with GPIO headers, HSE/LSE, and USB. Seems like a solid way to test stuff. Doesn't look like it has a debug chip though.

Fanged Lawn Wormy
Jan 4, 2008

SQUEAK! SQUEAK! SQUEAK!
Ehh, I’m probably spoiled on the Arduino ecosystem. Despite reading and comprehending and re reading the boot loader setup I struggled for quite awhile to actually get it to boot. I did eventually, but it’s been the worst experience I’ve had with a micro so far.

It also doesn’t seem encouraging that some of the guides I read had mentions of weird hardware inconsistencies, like “check the chip to make sure it actually is a blue/black pill” and “check the resistance here to make sure it matches such and such”. Not confidence inspiring. It also seems weird to me they just kind of exist with no real central portal of documents on who is producing them as far as I can tell? Like obviously the chipset is fine, but it’s a bunch of random manufacturers on amazon as far as I can tell.

The arduino integration part seems like an afterthought. If you’re going to go that route, it should ship with a boot loader and have a handful of example sketches.

Teensy, in comparison, has a single source, is well documented (though the site navigation is a mess, it’s all there) and is actively involved in the development of the arduino project. It works out of the baggie.

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
Arduino is fun until you go too far and gently caress up the bootloader and you have to google how to reflash it with the SPI pins.

Dominoes
Sep 20, 2007

Fanged Lawn Wormy posted:

Ehh, I’m probably spoiled on the Arduino ecosystem. Despite reading and comprehending and re reading the boot loader setup I struggled for quite awhile to actually get it to boot. I did eventually, but it’s been the worst experience I’ve had with a micro so far.

It also doesn’t seem encouraging that some of the guides I read had mentions of weird hardware inconsistencies, like “check the chip to make sure it actually is a blue/black pill” and “check the resistance here to make sure it matches such and such”. Not confidence inspiring. It also seems weird to me they just kind of exist with no real central portal of documents on who is producing them as far as I can tell? Like obviously the chipset is fine, but it’s a bunch of random manufacturers on amazon as far as I can tell.

The arduino integration part seems like an afterthought. If you’re going to go that route, it should ship with a boot loader and have a handful of example sketches.

Teensy, in comparison, has a single source, is well documented (though the site navigation is a mess, it’s all there) and is actively involved in the development of the arduino project. It works out of the baggie.

$7 ST-Link on Amazon It would be nice to have a user manual showing the layout, schematic and pins. As you point out, the most important docs are for the MCU. The STM32F_Discovery boards have detailed user manuals, more pins, some solder bridges, an onboard ST-LINK, and some peripherals like gyro, compass, LEDs. But they're more expensive: $35-40USD.

Dominoes fucked around with this message at 15:09 on Sep 29, 2020

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
Anyone know if it's possible to burn a bootloader onto an Atmega32U4 without another Arduino board or a programmer? I've got a bunch of not-AVR things (ESP32, Teensy 4, W600, STM32) but I just blew away the bootloader on my only AVR board, a Sparkfun Pro Micro clone, and have no idea how to fix it without buying another AVR board. Google is being exceptionally unhelpful.

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
Should be able to - You're finding like a million tutorials on flashing the bootloader using an Arduino Uno, right?

That's not actually exclusive to the Uno, the Arduino framework (largely) doesn't care* what hardware it's actually running on, so the same procedure will work on your ESP32 running the Arduino sketch, or the Teensy, or the STM32.

The one caveat is that those are all running at 3.3v and I'm not totally sure it will work, I haven't looked into it. Depends what the Atmega32U4 is running at, but even still, may work.







* don't @ me, I know this is an oversimplification

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
For some reason I never actually noticed that ArduinoISP is provided as an example sketch and assumed it was some weird hardware thing. Couldn't get the ArduinoISP to actually work, though, Windows just declared that a device I had connected had malfunctioned. Probably misconfigured something somewhere. I did find this firmware for an STM32F103 and was able to restore the bootloader with it. Unfortunately I keep obliterating the bootloader, but at least I have a way to fix it now. Thanks.

Dominoes
Sep 20, 2007

The official STM32 ST-LINK also provides ways to fix incorrectly-flashed STM32 devices.

huhu
Feb 24, 2006
Edit: Removing everything from before because that was wrong.

I upload the following code to a Pro Micro:

code:
void setup() {
  Serial.begin(9600);
  while (!Serial) ; /* Needed for Arduino Leonardo */
  Serial.println("hello");
}

void loop() {
}
I hit upload and I get "hello" in the Serial Monitor. I power cycle the pro micro and nothing. If I upload the code again it works. What's happening?

I was playing around with the EEPROM library. Chances I borked my pro micro?

huhu fucked around with this message at 23:57 on Nov 26, 2020

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
Basically zero


Your code has a while(!Serial) line that locks the microcontroller up until it has a serial connection. Think very carefully about what that's doing

huhu
Feb 24, 2006

ante posted:

Basically zero


Your code has a while(!Serial) line that locks the microcontroller up until it has a serial connection. Think very carefully about what that's doing

https://forum.arduino.cc/index.php?topic=171889.0

I don't understand your answer.

Dominoes
Sep 20, 2007

Your program will not make it past the while loop step until it establishes a connection. So, if it doesn't print, it's not making it past that line.

Dominoes fucked around with this message at 00:41 on Nov 27, 2020

General_Failure
Apr 17, 2005
Help. I fell down the blue pill hole again.

Long story short. The blue pill is probably the best the best tool for the job that I want to do. I'm trying to use the STM32 board defs because the dan.drown one is missing features, doesn't have the right board Def and binary size blows out fast.

What I'm stuck on is the bootloader. The stmduino one worked well (enough) but it's not supported by the STM32 bootloader.

I tried the HID bootloader but maybe I'm doing something wrong. I can see the device with lsusb, but when I flash it with hid-flash something seems to be wrong. The serial port device doesn't appear after boot. I'm not sure what my other options are. I remember at least one other person in this thread has experience with the blue pill. So, suggestions please?

As a side note, the built sketch is put under /tmp so I need to go there to get the bin to flash.

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
Do you need to use the bootloader?

I gave up after a while - It seemed super flaky, and just added a whole other level of complication. The clone ST Link is $2 and works really well, so it was totally worth my time to use it

General_Failure
Apr 17, 2005

ante posted:

Do you need to use the bootloader?

I gave up after a while - It seemed super flaky, and just added a whole other level of complication. The clone ST Link is $2 and works really well, so it was totally worth my time to use it

I have an ST Link clone. It's how I put the bootloader on. Trouble is it seems I'm a dumbass that can't understand something apparently obvious. I have no idea how to put a built sketch on to the blue pill. It's something I feel I knew a year ago but it escapes me now.

The project is the balancebot I started on ages ago. It's been sitting for months. every so often I have another try at it and hit a wall. One of the main problems was what uC to use. AVR is slow and 5v usually. esp8266 doesn't have enough pins. esp32, one board I have is too big, the other doesn't have enough pins. Not wasting a k210 on it.

Ideally I want to have an i2c master for the accel / gyro. i2c device for something better to issue commands to the uC. 4 pins, two of which PWM for controlling the dual H bridge. A nice but useless bonus would be a UART for connecting a GPS to provide declination for the magnetometer in the accelerometer. It's not like the bot has an actual use anyway.

General_Failure
Apr 17, 2005
Oh. Oh no. I didn't realise that the stm32 arduino definition I was using was customised. I don't even remember doing that. Just sent it to oblivion. Because I'm using arm64 I've had to put together some definition files myself. Guess I forgot about that one.
e: Worked it out. What i had done previously is edit platform.txt to change the toolchain directory to the system one.
e again: manually using st-link to flash the chip with no bootloader. Seems to work fine.

General_Failure fucked around with this message at 12:49 on Dec 6, 2020

General_Failure
Apr 17, 2005
I got it!

This page was the missing piece.
https://www.stm32duino.com/viewtopic.php?t=57
That got the /dev/ttyACM0 device up and running. hid-flash wants to access that device first to send a reset signal to the uC. That reboots it and it snags the bootloader USB device to do the flashing.

Neither here nor there but I did encounter a red herring. I switched from the blink example to fade, and PC13 keeps blinking. I thought the sketch binary wasn't being updated. I think it's just something to do with the mode of operation, and not the sketch.

Harvey Baldman
Jan 11, 2011

ATTORNEY AT LAW
Justice is bald, like an eagle, or Lady Liberty's docket.

If I have something like a ten-segment bar graph LED and I want to control it with a minimum number of pins from an Arduino, what's the best approach? Is there some kind of smart design where I can use a PWM pin at 10% intervals to progressively light the bar graph?

Edit: I see Sparkfun has something kinda like what I was describing, although now I'm wondering how hard it would be to make a PCB for WS2812 LEDs and just use the addressable nature of them to cheat it with a smaller footprint.

Edit edit: And I guess those exist as an off-the-shelf thing. Hm.

Harvey Baldman fucked around with this message at 23:56 on Dec 9, 2020

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
Look up "Charlieplexing"

Sagebrush
Feb 26, 2012

The best approach is to use a separate driver IC, which will run any number of segments (within reason) using only power, ground, and two data lines.

https://www.adafruit.com/product/1721

Failing that, Charlieplexing is workable.

e: yeah if you're okay with each segment being relatively large, the WS2812 strips are even better because they are cheap as hell and only need three pins and can turn any color.

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
Do you want them to act like a bar graph or do you want to control them individually? You can also use a couple shift registers. It's a bit slower, because you have to shift out the all the bits every time one changes, but you can control as many LEDs as you want (within reason) with two wires.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


Harvey Baldman posted:

If I have something like a ten-segment bar graph LED and I want to control it with a minimum number of pins from an Arduino, what's the best approach? Is there some kind of smart design where I can use a PWM pin at 10% intervals to progressively light the bar graph?

If your bar graph IC takes 0-5 volts, then you absolutely can PWM (with a low-pass filter) and have the thing light up. What specific bar graph product are you looking at?

Kaiser Schnitzel
Mar 29, 2006

Schnitzel mit uns


Hello Hobbyists and Crafters of all sorts! Our friends from Creative Convention are visiting with their Travelling Showcase of Wonders and they want to see all the cool and fantastic things you've been working on! Go show them off and admire the handiwork of other talented goons!

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

thehustler
Apr 17, 2004

I am very curious about this little crescendo
I made a PCB with a standalone 328p and I may have hosed it up. Reset and the I/O header this way around?

The standard Uno schematic has it the other way around. Does sending data (from another Uno with the chip pulled out, like) pull the reset line to ground? It’d take it the 5V input through the pin 1?

Or does the order not matter? It doesn’t appear to if I’m right. Otherwise I’ve got 5 useless boards :-D

https://ibb.co/vcryWXv

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


Pin 1 is reset, 2 is rx, 3 is tx. Your board looks right.

thehustler
Apr 17, 2004

I am very curious about this little crescendo

babyeatingpsychopath posted:

Pin 1 is reset, 2 is rx, 3 is tx. Your board looks right.

It was more “does the resistor come before the header” but I appreciate you confirming that for me, thanks.

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
I would assume you would want the header and the pins on the 328 to be the same, so you'd have the header and pins connected together and then to the resistor that I am guessing goes to VCC to hold the reset pin high.

thehustler
Apr 17, 2004

I am very curious about this little crescendo

Cojawfee posted:

I would assume you would want the header and the pins on the 328 to be the same, so you'd have the header and pins connected together and then to the resistor that I am guessing goes to VCC to hold the reset pin high.

Indeed it does.

So essentially with a cable connected from another Arduino with the chip pulled out the reset line is pulled to ground which should redirect the supply from the resistor output up pin 1 on the header and disconnecting the target 328 on the PCB from the VCC supply, allowing code upload.

I suppose in that instance it doesn’t really matter what side of the resistor the header goes on because it’ll shoot up the cable regardless when it’s pulled to ground.

Edit: boards have arrived! Will get one made up and see how it goes.

thehustler fucked around with this message at 13:13 on Dec 30, 2020

thehustler
Apr 17, 2004

I am very curious about this little crescendo
My boards arrived! They *look* good.



But looking good is where they stop. Unfortunately they won’t boot up a chip. All of the LEDs come on which makes me think the chip is stuck in reset and all the outputs are high? Or do they go low on reset? I forget now.

Only issue with that theory is that there is voltage at the reset pin beyond the 10k resistor as expected, so the only other thing I can think of is the bootloader or the crystal.

The sketch uploaded to a chip in an Uno just fine. And if I’m providing a 16 MHz crystal the chip should work fine straight out of my Uno, right?

Edit: expected voltages at the power pins too. A smidgeon off 5V, from the 9V coming in, L7805 regulator all working fine.

Edit 2: I guess I could also check the soldering too, but it certainly all seems good.

thehustler fucked around with this message at 23:18 on Dec 31, 2020

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
That's why I went straight to just using Microchip studio and programming my 328P directly. I don't really get all the stuff the arduino does and wouldn't know what to do with anything outside of the actual arduino board. But the directly manipulating the ports in C is making sense to me so far.

thehustler
Apr 17, 2004

I am very curious about this little crescendo

Cojawfee posted:

That's why I went straight to just using Microchip studio and programming my 328P directly. I don't really get all the stuff the arduino does and wouldn't know what to do with anything outside of the actual arduino board. But the directly manipulating the ports in C is making sense to me so far.

I get what you’re saying and have gone down this route myself with ATTiny chips, but the approach of using the IDE with a breadboarded 328P chip has worked for me before, about six months ago. Forgot if there was anything specific I did.

Do I NEED to download the breadboard stuff for the IDE if I’m providing a chip with the same setup as an Uno?

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

thehustler posted:

I get what you’re saying and have gone down this route myself with ATTiny chips, but the approach of using the IDE with a breadboarded 328P chip has worked for me before, about six months ago. Forgot if there was anything specific I did.

Do I NEED to download the breadboard stuff for the IDE if I’m providing a chip with the same setup as an Uno?

I'm not really sure what you mean by breadboard stuff.

Adbot
ADBOT LOVES YOU

thehustler
Apr 17, 2004

I am very curious about this little crescendo

Cojawfee posted:

I'm not really sure what you mean by breadboard stuff.

Oh, the board definitions for breadboard use. Seems this guide on the Arduino website answers my question: they’re only needed if you’re not using a crystal as on an Uno board, otherwise unneeded.

https://www.arduino.cc/en/Tutorial/BuiltInExamples/ArduinoToBreadboard

Edit: Which means there must be an issue with my board, I think.

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