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
Rexxed
May 1, 2010

Dis is amazing!
I gotta try dis!

Sparkfun had a bunch of HP bubble displays a couple of years ago but it might've been a crate of new old stock they found or something. Unfortunately they're sold out now.
https://www.sparkfun.com/products/retired/12710

edit: oh god it was 2014, feels like two years ago
https://www.youtube.com/watch?v=sYSxy4lUOEo&t=67s

Rexxed fucked around with this message at 06:42 on Sep 30, 2020

Adbot
ADBOT LOVES YOU

Splode
Jun 18, 2013

put some clothes on you little freak

huhu posted:

Anyone else notice PCBs from China increasing in price? I swear the last pack of 10 PCBs I ordered cost half as much as my most recent order. Has Covid-19 really had that much of an impact on electrical components and such? I launched an electronics Kickstarter a few years back and I'd like to launch another one but I feel like now might be dumber than ever.

Pricing seems the same for me, but the lead times on everything definitely got longer

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


Dominoes posted:

My understanding is that SPI and I2C are ideally for onboard comms, and secondarily for short runs. (Ie, I've been selling some sensor modules that connect via I2C jumper wires, but I wouldn't run them on the order of meters)

I'm building a multi-sensor water monitor. (pH, ORP, EC, temp). It has an epaper display, runs on batteries or USB-C power, and is standalone.It can connect to accessories I'll make in the future, or PC/Pi to share its readings. I'm trying to release an MVP ASAprac, but have taken longer than I estimated due to multiple technical issues. I won't release anything until I'm confident I can patch the software with USB firmware updates, and it can talk to peripherals. I don't have the budget for injection molding, and affordable CNC routers are only appropriate for short heights... the ports will be on the long edge. So, all ports need to be made with a drill press. From an efficiency/etc POV, I see why USB comm seems inappropriate, and I now know it's unfeasible but... you can probably see why it was worth trying.

I can post a schematic if that would help, but don't have a block dia.

At this point, the path seems clear: Use a 3-pin JST connector like Forsetti mentioned with UART (cheaper/simpler and probably fine), or ST-485 (More robust, requires extra IC) for MCU-based accessories. Use USB for sharing with computer/RPi.

edit: USB flashing/bootloader solved! It was me not knowing how 4-pin buttons work. Pressing shorts all 4 pins.The lower resistor on gnd pull won, leading it to always boot to Main Flash Memory. This prevented boot0 from pulling high, which is required to enter the bootloader located in System memory.

Grab a piece of paper. Using a pen, draw your system. List your problems.

As I understand it, you've got a base station with an e-paper display.
  • This base station must be able to get firmware updates over USB.
  • This base station communicates with peripherals, each with an embedded microcontroller.
  • These peripherals must also be able to receive firmware updates in some way.
  • You need to communicate with the peripherals over distances of meters in a robust way.
  • Maybe these peripherals need to be powered over the comms wire?
  • The whole system must be able to be manufactured using only a drill press and off-the-shelf components.
  • You insist on programming the whole thing in Rust for portability even though that is ~95% not applicable to microcontrollers in general.
  • You are new at small-scale electrical engineering, specifically PCB design, chip selection EMI compatibility, how physical components work, datasheets.
  • You are new at microcontrollers, specifically UARTs, pin modes, interrupts and their vectors, pin states, chip-to-chip protocols, low-level hardware access and all the normal "bit banging" that goes on inside tiny tiny computers.

This is my summary of your problem space from this post specifically (those parts that I can understand -- what's "MVP ASAprac"). Try to solve only one problem at a time. Get pieces of your system working before spinning multiple board revisions. Solve one problem instead of trying to solve the whole thing at once.

Shame Boy
Mar 2, 2010

babyeatingpsychopath posted:

(those parts that I can understand -- what's "MVP ASAprac")

MVP is Minimum Viable Product, which is project manager language for "basic working prototype"

ASAprac I assume is just As Soon As Practical

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib

Shame Boy posted:

MVP is Minimum Viable Product, which is project manager language for "basic working prototype"

ASAprac I assume is just As Soon As Practical

Awww, I was hoping it was a misspelling of Aesop Rock: https://youtu.be/7T_KKiQiolk

Ambrose Burnside
Aug 30, 2007

pensive

Shame Boy posted:

There might be some weird Russian company second-sourcing them for ancient military technology that still uses them or something but yeah I wouldn't count on it. There seems to be a bunch of new old stock on Ebay but it's like $30 a pop.

The closest thing I can think of that they still make are these, which aren't as cool but are at least tiny:



oh hell yeah, what's the part number?

I'm trying to pick a telemetry display approach for that Kerbal controller i'm building and really wanna do sth retro-styled and not just a bog-standard modern 7-segment display, but everything else I can find is out of production, absurdly expensive, or both. Bubble displays are overpriced on ebay, like you said; those LTP-305 single-character matrices i posted earlier are about $5 a pop, and the Broadcom displays that pack a bunch of those 305 displays together- these guys-

manage to cost more than the displays bought individually. almost $90 CAD for 16 characters ain't gonna cut it. even the quirkier VFDs i can find are similarly priced, this bad boy is $92 for 2x16 chars-

even numitrons seem unreasonably-pricey

soviet nixies and single-tube VFDs actually seem to come in as the absolute cheapest on a per-character basis if i buy a 50-case of common tubes like IV-4s or IV-12s. Like, a dollar or less per tube in some cases. i dont particularly want a 170V-supplied video game controller, and driving dozens of tubes sounds like a nightmare, but...

Ambrose Burnside fucked around with this message at 16:00 on Sep 30, 2020

Shame Boy
Mar 2, 2010

Ambrose Burnside posted:

oh hell yeah, what's the part number?

According to the ebay page I pulled that image from, L104G or SEL620:

https://www.ebay.com/itm/6-pcs-7-segment-LED-Display-Numeric-Red-Digital-Gold-pins-L104G-SEL620-USSR/192823123296

There's also green ones if you look around. It's $10 for 6 of em', which isn't great, but better than those bubble displays.

e: Keep in mind though that the reason the bubble displays have the bubble in the first place is these are really really tiny, and probably kinda dim since they're using old LED technology. Like the listing says these have a digit height of only 2.5mm which is like half the height of this font on my screen right now.

e2: I just measured and it's more like equal to the height of this font on my screen, which is actually fine, nevermind!

Shame Boy fucked around with this message at 16:10 on Sep 30, 2020

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
10 + 8 for shipping. You're paying 3 dollars each at the end.

Ambrose Burnside
Aug 30, 2007

pensive
i'm almost tempted to get one of these bizarrely-cheap 32x32 nixie matrixes, the Igg1-32 panel

and use it for the entire telemetry display, using a faceplate to cover up the spaces between rows to make it look like separate displays. 3mm cells/5mm spacing between cells is oversized for what i need, though


the silver lining of going w some sort of nixie/neon indicator is "in for a penny, in for a pound"- once I need that stupid flyback transformer for a single tube, i might as well stick a bunch in there, right? not just for numeric displays but bargraphs, multi-segment dot displays, humdrum neon lamps, etc. why indicate craft staging with ordinary LEDs when you could use a dekatron or 7-segment bar tube :allears:

Ambrose Burnside fucked around with this message at 16:41 on Sep 30, 2020

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

Ambrose Burnside posted:

oh hell yeah, what's the part number?

I'm trying to pick a telemetry display approach for that Kerbal controller i'm building and really wanna do sth retro-styled and not just a bog-standard modern 7-segment display, but everything else I can find is out of production, absurdly expensive, or both. Bubble displays are overpriced on ebay, like you said; those LTP-305 single-character matrices i posted earlier are about $5 a pop, and the Broadcom displays that pack a bunch of those 305 displays together- these guys-

manage to cost more than the displays bought individually. almost $90 CAD for 16 characters ain't gonna cut it. even the quirkier VFDs i can find are similarly priced, this bad boy is $92 for 2x16 chars-

even numitrons seem unreasonably-pricey

soviet nixies and single-tube VFDs actually seem to come in as the absolute cheapest on a per-character basis if i buy a 50-case of common tubes like IV-4s or IV-12s. Like, a dollar or less per tube in some cases. i dont particularly want a 170V-supplied video game controller, and driving dozens of tubes sounds like a nightmare, but...

I have no idea what the pricing is because you have to request a quote, but it'd be cool AF to get some of the Alpha Zeta mechanical displays for that if you don't need them backlit.

Though that's definitely a bad option if a constant stream of noise during game play is a deal breaker.

Ambrose Burnside
Aug 30, 2007

pensive

poeticoddity posted:

I have no idea what the pricing is because you have to request a quote, but it'd be cool AF to get some of the Alpha Zeta mechanical displays for that if you don't need them backlit.

Though that's definitely a bad option if a constant stream of noise during game play is a deal breaker.

my fuckin kingdom for an electromechanical flip-dot/7-segment display, alas

ages back i read a build log from someone who made a big art panel of those and he got a quote from those guys, iirc the per-pixel price for a simple matrix dot was like $4 USD, with a bulk discount; they also have 7-segment electromechanical characters too but the smallest is an inch tall and $$$$$. he ended up buying a surplus flip-dot display off ebay that came from a transit bus' route number display panel. apparently that's a fairly cheap way to get a hold of one, but 1) driving the thing is a huge headache if you don't also score a controller for it, and 2) youre stuck with the very large matrix dots + awkward form-factor intended for long-range visibility

One Legged Ninja
Sep 19, 2007
Feared by shoe salesmen. Defeated by chest-high walls.
Fun Shoe

Ambrose Burnside posted:


the silver lining of going w some sort of nixie/neon indicator is "in for a penny, in for a pound"- once I need that stupid flyback transformer for a single tube, i might as well stick a bunch in there, right? not just for numeric displays but bargraphs, multi-segment dot displays, humdrum neon lamps, etc. why indicate craft staging with ordinary LEDs when you could use a dekatron or 7-segment bar tube :allears:

A few years ago I started working on a VFD clock powered via USB that used one timer from an ATMega 32u4 and a few components as a boost converter to power the tubes. It was only 30v, not 170, but it was plenty for the purpose. I never finished the project, but it did functionally display things after I fixed a couple mistakes on the board layout. I have it in my mind that I might redesign it to be modular some day.

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
I don't think "flyback transformer" is something you want to put into a hobbyist project that you will be plugging into your computer. I know you want something unique for your controller, but those 2x16 character LED displays are like 12 bucks and are powered off 3-5 volts.

Shame Boy
Mar 2, 2010

Cojawfee posted:

I don't think "flyback transformer" is something you want to put into a hobbyist project that you will be plugging into your computer. I know you want something unique for your controller, but those 2x16 character LED displays are like 12 bucks and are powered off 3-5 volts.

Speaking as someone whose hobby these days is pretty much entirely "design dangerously high voltage things that you plug into your computer", yeah don't go for anything like that. All the stuff I design has big ol' isolation gaps and antitracking slots and all the high voltage stuff is fully galvanically isolated because the last thing I want is to nuke my computer cuz my dinky circuit board hosed up. That's all overkill (and will add a ton to the cost) for something that's just a display.

VFD's can operate down to like 10-15V I think though, and you can get that with a simple boost converter and it should be reasonably safe. Maybe throw in some TVS diodes just in case it finds its way back onto the data pins, but whatever. Also they're not really "nixie" displays at all, it's just Ebay sellers call them that so they come up in searches.

Forseti
May 26, 2001
To the lovenasium!

Ambrose Burnside posted:

I'm trying to pick a telemetry display approach for that Kerbal controller i'm building and really wanna do sth retro-styled and not just a bog-standard modern 7-segment display, but everything else I can find is out of production, absurdly expensive, or both.

My dude, buying a part off the shelf doesn't sound like your style and I know the perfect thing for this task:

https://www.youtube.com/watch?v=Z2o_Sp2-aBo

Shame Boy
Mar 2, 2010

Forseti posted:

My dude, buying a part off the shelf doesn't sound like your style and I know the perfect thing for this task:

https://www.youtube.com/watch?v=Z2o_Sp2-aBo

It's not really related to anything but that video really bums me out because Fran at FranLab was working on doing the exact same thing for like, months, and that video by applied science dude just kinda pops out of nowhere when she's almost done and is like "oh hey look what I built" and it just completely wrecked her confidence for a while :smith:

Also more on topic: EL displays require pretty high voltage too so like, yeah.

Stack Machine
Mar 6, 2016

I can see through time!
Fun Shoe
If you really need 170V and you live in a place with 120VAC mains, who needs a high-voltage flyback? 120*sqrt(2) is like 169.7.

(Please don't do this. And if you decide to do it anyway at least use a 1:1 isolation transformer.)

Forseti
May 26, 2001
To the lovenasium!
Oh drat, that sucks, was it just straight up bad coincidence? I hope the Applied Science dude didn't intentionally scoop her or something like that, I really enjoy his videos and he seems to just be a professional nerd nerding the gently caress out (I think he works at one of the Google skunk works, which gently caress Google, but that would be a fun job).

Shame Boy posted:

Also more on topic: EL displays require pretty high voltage too so like, yeah.
They don't need much current though I think? I used some LCDs that had EL backlighting back in the day and IIRC they just used a charge pump to make the high voltage they needed.

Shame Boy
Mar 2, 2010

Forseti posted:

Oh drat, that sucks, was it just straight up bad coincidence? I hope the Applied Science dude didn't intentionally scoop her or something like that, I really enjoy his videos and he seems to just be a professional nerd nerding the gently caress out (I think he works at one of the Google skunk works, which gently caress Google, but that would be a fun job).

I don't think he did it intentionally or anything, but she was a lot more open about the whole development process while it was in progress, so I get the feeling he saw that, wanted to make his own (cuz who doesn't?) and didn't really realize that like, he's in a much more secure and advantageous position than she is since he has a job outside of youtube and a larger fanbase to boot. So for him it was another cool project, for her it was kinda torpedoing a rare chance to get noticed for doing something unique.

Forseti posted:

They don't need much current though I think? I used some LCDs that had EL backlighting back in the day and IIRC they just used a charge pump to make the high voltage they needed.

Nah and you can get drivers for them for real cheap too - look up EL wire, it's incredibly inexpensive now that everyone uses it for costumes and stuff, and always comes with a dinky battery pack with a boost circuit in it. I think I got a ten pack of em' for like $15 off ebay a while ago.

It doesn't take much current to nuke a computer though so eh, do it at your own risk.

Ambrose Burnside
Aug 30, 2007

pensive

Cojawfee posted:

I don't think "flyback transformer" is something you want to put into a hobbyist project that you will be plugging into your computer. I know you want something unique for your controller, but those 2x16 character LED displays are like 12 bucks and are powered off 3-5 volts.


Shame Boy posted:

Speaking as someone whose hobby these days is pretty much entirely "design dangerously high voltage things that you plug into your computer", yeah don't go for anything like that. All the stuff I design has big ol' isolation gaps and antitracking slots and all the high voltage stuff is fully galvanically isolated because the last thing I want is to nuke my computer cuz my dinky circuit board hosed up. That's all overkill (and will add a ton to the cost) for something that's just a display.

VFD's can operate down to like 10-15V I think though, and you can get that with a simple boost converter and it should be reasonably safe. Maybe throw in some TVS diodes just in case it finds its way back onto the data pins, but whatever. Also they're not really "nixie" displays at all, it's just Ebay sellers call them that so they come up in searches.

in my heart of hearts i knew this from the beginning but "tube indicator spaceship game controller" is a fantasy worth running with long enough to do some extremely reckless parts-picking

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS

Shame Boy posted:

Speaking as someone whose hobby these days is pretty much entirely "design dangerously high voltage things that you plug into your computer", yeah don't go for anything like that. All the stuff I design has big ol' isolation gaps and antitracking slots and all the high voltage stuff is fully galvanically isolated because the last thing I want is to nuke my computer cuz my dinky circuit board hosed up. That's all overkill (and will add a ton to the cost) for something that's just a display

Careful man, you'll get Dominoes interested

Forseti posted:

Oh drat, that sucks, was it just straight up bad coincidence? I hope the Applied Science dude didn't intentionally scoop her or something like that, I really enjoy his videos and he seems to just be a professional nerd nerding the gently caress out (I think he works at one of the Google skunk works, which gently caress Google, but that would be a fun job).

They don't need much current though I think? I used some LCDs that had EL backlighting back in the day and IIRC they just used a charge pump to make the high voltage they needed.
Yeah, Ben Krasnow works at Verily, the medical Google skunkworks thing.

He's never hinted at what they actually do, but the company put out a cool promo video a few years ago about raising and releasing sterile male mosquitoes everywhere

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
everyone was going nuts for Apollo stuff at the time, so it very well could have been a coincidence. That display ended up being part of the DSKY that went with the restored AGC that Curiousmarc did a series on. And speaking of Curiousmarc, he recently put out a video about some chips that were repackaged TI digital watch ICs and used some 7 segment bubble displays.

Ambrose Burnside
Aug 30, 2007

pensive
oh yeah, i have an antique telephone magneto now. my Vintage Electrical Affliction worsens


it's dirty and full of barn debris but basically seems to be in good working order mechanically-speaking, the rotor turns freely.


here's a bad attempt at showing the rotor w winding. i haven't tried to hook anything up to the leads or even check the armature continuity yet, i'm afraid it'll be an open circuit and ill have to rewind it from scratch




so uh, what sorts of things can you do with these aside from stun fish or extract confessions from people

Stack Machine
Mar 6, 2016

I can see through time!
Fun Shoe
My dad worked for the railroad when I was a kid and scored a few of those from old trackside phone installations. The most fun I had with it was trying to power household appliances with it. If I recall correctly, ~100V was easy to hit at vert light load and it would power up a cheap boombox without much effort. I think the modern equivalent would be charging your phone through a wall wart until your hand gets tired.

Dominoes
Sep 20, 2007

babyeatingpsychopath posted:

Grab a piece of paper. Using a pen, draw your system. List your problems.

As I understand it, you've got a base station with an e-paper display.
  • This base station must be able to get firmware updates over USB.
  • This base station communicates with peripherals, each with an embedded microcontroller.
  • These peripherals must also be able to receive firmware updates in some way.
  • You need to communicate with the peripherals over distances of meters in a robust way.
  • Maybe these peripherals need to be powered over the comms wire?
  • The whole system must be able to be manufactured using only a drill press and off-the-shelf components.
  • You insist on programming the whole thing in Rust for portability even though that is ~95% not applicable to microcontrollers in general.
  • You are new at small-scale electrical engineering, specifically PCB design, chip selection EMI compatibility, how physical components work, datasheets.
  • You are new at microcontrollers, specifically UARTs, pin modes, interrupts and their vectors, pin states, chip-to-chip protocols, low-level hardware access and all the normal "bit banging" that goes on inside tiny tiny computers.

This is my summary of your problem space from this post specifically (those parts that I can understand -- what's "MVP ASAprac"). Try to solve only one problem at a time. Get pieces of your system working before spinning multiple board revisions. Solve one problem instead of trying to solve the whole thing at once.

That's all correct, with one exception: the reason for Rust isn't portability; AFAIK, it's the nicest language and toolchain suitable for embedded. Thankfully, most of the electronics problems are now solved. (Was NOT true until this week)



+ other things like check if I need FCC review/approval for emissions; check if sensors interfere with each other either in the water or circuit (Maybe stagger excitation current for EC etc); confirm durability and drift rates of probes are acceptable; packaging etc.

Dominoes fucked around with this message at 00:13 on Oct 1, 2020

Forseti
May 26, 2001
To the lovenasium!

Dominoes posted:

That's all correct, with one exception: the reason for Rust isn't portability; AFAIK, it's the nicest language and toolchain suitable for embedded.

:munch:

Edit: I should probably add some real content, but that's just like, you know, your opinion, man. Which is fine, Rust seems pretty cool but there's a lot of nuance to the best tool for the job and I'm sure you didn't mean it but that's like a classic troll. But anyway, there's a strong argument to be made for first party tools from the manufacturer which are usually C, or GCC because it's been around the block a time or two, or even assembly language for highly resource constrained MCUs like the ATTiny10 or if you want to control to the clock cycle how long a chunk of code will take to execute or want to make use of special instructions that exist on your platform and compilers don't implement.

That said, go nuts with Rust if you enjoy it!

Forseti fucked around with this message at 00:18 on Oct 1, 2020

Dominoes
Sep 20, 2007

I can see how that came across as snarky. You're right. I wouldn't suggest someone port an existing project to it; a company switch to it on a project with an established code base or team; someone looking to get into embedded as a career.

Working on my own projects, I'm free of those constraints. The overall experience is nice: It's easy to think of Rust as a safe language, but that's not why I like it. Other points:

- High-level features and consistent language design
- Auto-generated, centralized docs
- Modern project and dependency management
- Built-in, standardized tooling, like linter and formatter
- Compiling and flashing with `cargo run`, minimal project config, and no ties to IDEs. This is a big problem in embedded, and I'm optimistic it'll fade on the C/++ side too. I'd guess the current situation is a reason Arduino's so popular.

Of note, you can take advantage of manufacturer SVD data in any language, by parsing the files and making bindings.

Dominoes fucked around with this message at 00:53 on Oct 1, 2020

Splode
Jun 18, 2013

put some clothes on you little freak
For embedded nothing beats C. C++ is occasionally necessary.

I have no idea why someone reinvented the wheel and made rust.

None of those pros you list have anything to do with the programming language

Dominoes
Sep 20, 2007

No wheel was reinvented. We learn from past successes and failures; it's evident Rust was designed carefully with this in mind. Patching things has constraints when backwards-compatibility is expected... It seems that you have to start clean from time to time, in programming languages and elsewhere. (Or gradually depreciate things).

Extrapolate the form of your second line: Could you replace rust with something else? (perhaps related to programming; perhaps not). Can you see how that reasoning might have been used in the past, in contexts that sound ludicrous today?

Splode posted:

None of those pros you list have anything to do with the programming language
This is an interesting point too - What does a programming language mean to you? Is it the syntax rules? Does it refer to the symbols that can be ran through a specific compiler? Is Arduino a language? Are CPython and PyPy the same language? Is Pip (official; now included in installers; formally wasn't) part of Python? Is Cargo (included with Rust compiler) part of Rust? Is C compiled using GCC and a makefile the same language as C run through the STM32Cube IDE? I argue your implied definition of programming language in this context isn't wrong, but isn't the only one!

Dominoes fucked around with this message at 01:44 on Oct 1, 2020

taqueso
Mar 8, 2004


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

:pirate::hf::tinfoil:

Splode posted:

For embedded nothing beats C. C++ is occasionally necessary.

I have no idea why someone reinvented the wheel and made rust.

None of those pros you list have anything to do with the programming language

Have you used rust? It avoids all the classic c foot guns.

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS

Splode posted:

For embedded nothing beats C. C++ is occasionally necessary.

I have no idea why someone reinvented the wheel and made rust.

None of those pros you list have anything to do with the programming language

What an antiquated opinion


Edit:

I'm not yet using Rust for my embedded stuff and would argue that I have some good reasons to avoid it. Also not using it for desktop stuff, but am considering dipping my toe in.
This article was eye-opening, though:
http://cliffle.com/blog/prefer-rust/

And regardless on your feelings on Rust in general, modern compilers will now usually generate equal/comparable code between C and C++, so avoiding C++ is demonstrably an old-person tendency, on par with greybeards who refuse to graduate from assembly.

There's no technological reason C is better to use than Rust, other than maturity. And the dude in the article believes that the current maturity has hit the tipping point. I'm not totally convinced, but it definitely is coming, eventually

ante fucked around with this message at 01:59 on Oct 1, 2020

Forseti
May 26, 2001
To the lovenasium!
Yeah I'm glad people are out there trying new things for sure and I definitely want to check out Rust, just haven't gotten around to it yet. Personally I'd be wary of growing pains because it's still relatively young and especially wary of compiler bugs on MCU platforms. Does Rust use LLVM or do they write the compiler to turn it all the way into machine language? Someone needs to be a pioneer though, so glad it's working for your project!

What is the memory model like in Rust, does it have a garbage collector like Go or is it more like Objective C where freeing memory allows processes that still need it to keep it from being freed? I really haven't poked around with Rust in even a basic sense, but I have to admit that it getting allowed into the Linux kernel got my attention.

Edit: I think one of the main reasons C became so widespread is that it's relatively straightforward to implement on a new architecture. Not sure how much work it is to port LLVM if that is indeed what Rust uses.

Double Edit: Since I'm geeking out on comp sci now, the compiler bugs part made me think of Ken Thompson's awesome paper Reflections on Trusting Trust which is a nice short (3 page) read and highly interesting I think. It talks about how the C compiler is bootstrapped on a new platform (basically you write a very basic C compiler and then use that to compile the real deal C compiler, which is actually written in C) and the idea of untraceable security holes written into the compiler.

Forseti fucked around with this message at 02:16 on Oct 1, 2020

Splode
Jun 18, 2013

put some clothes on you little freak
I'm sure it's technically a better language than C and C++, but the last thing embedded needs is the endless treadmill of flavour of the month programming languages that desktop programming has. C isn't perfect but it's more convenient than assembly and that is usually enough.

Also when all the tools and all the libraries are all written in C or C++, you don't get a choice in the professional world. It's very unlikely that any project manager is going to approve porting every library for every peripheral on a board just because you want to try some new language.

People keep saying C/C++ will die but it never does. Maybe it's time we stopped trying to kill it.

Dominoes
Sep 20, 2007

Rust uses LLVM. It uses a (AFAIK) unique model, where its compiler enforces safe memory use through something called ownership. This topic from the official book describes it.

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS

Splode posted:

I'm sure it's technically a better language than C and C++, but the last thing embedded needs is the endless treadmill of flavour of the month programming languages that desktop programming has. C isn't perfect but it's more convenient than assembly and that is usually enough.

Also when all the tools and all the libraries are all written in C or C++, you don't get a choice in the professional world. It's very unlikely that any project manager is going to approve porting every library for every peripheral on a board just because you want to try some new language.

People keep saying C/C++ will die but it never does. Maybe it's time we stopped trying to kill it.

Normally, I would completely agree with you, but Rust has popular support in a way that I've never seen before. Including, as mentioned, inclusion in Linux.

I'm also not sure how Rust works, but if it uses LLVM, it looks like it can use C/C++ object files. So you'd only need to port the API, which is trivial. They can exist in harmony, no killing necessary!

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


Splode posted:

I'm sure it's technically a better language than C and C++, but the last thing embedded needs is the endless treadmill of flavour of the month programming languages that desktop programming has. C isn't perfect but it's more convenient than assembly and that is usually enough.

Also when all the tools and all the libraries are all written in C or C++, you don't get a choice in the professional world. It's very unlikely that any project manager is going to approve porting every library for every peripheral on a board just because you want to try some new language.

People keep saying C/C++ will die but it never does. Maybe it's time we stopped trying to kill it.

I think I'm in this boat. I still see "embedded computing" and "microcontroller" as two different worlds.

In a microcontroller, you've barely got enough room to do everything you want. 16k of program space and 1k of ram, say, or even smaller, like the aforementioned ATTINY5 which has 32 bytes of memory and 512 bytes of program space. In something like this, you don't need a memory manager. You don't need any high-level language constructs or abstractions. There isn't any room for a memory manager; but you don't need one, because you can just remember what all the memory's doing anyway. Besides which, if your memory manager is taking cycles to figure out where to put stuff, your processor is choking because it's running at 8MHz or something.

Embedded computing gets you arbitrary-length mutable strings and arrays that can change size and stuff where it'd be a good idea to have a memory manager if you don't want to worry about memory leaks. You get multiple flavors of peripherals to work with beyond the generic set of DACs, ADCs (maybe), and a UART. You may have embedded USB, CAN, 1-wire, or other hardware, in addition to a couple of UARTs. This is where it's nice to have something high-level to abstract away the different ways of talking to peripherals. That said, it's best if the generated code is still tight at the machine level. It does no good if talking to 1-wire is 10% the speed of CAN because whoever wrote the library messed it up.

In either case, there's no "operating system" going on. There's just your program doing everything. This means whatever language you use has to be able to get you down really close to the hardware when you need it. The init routines in either case are going to be target-specific blocks of assembler to set fuses and clocks and get the registers set up correctly to run. I don't see "portability" or "backwards compatibility" as very important in microcontroller projects. You write the thing, flash the code, set it running, and leave it there until it catches fire. Maybe you get to add some features if you go from an ATTINY5 to an ATTINY10, or if you're going from a ATmega640 to an ATmega2560 to get a bigger program space so you can use all of your I/O pins, but you're still not leaving the family behind. If you want to go from an ATmega family over to an STM, I get this feeling that there's not going to be very much code used between the two.

Maybe I'm wrong and the future is to have the ability to use the same main code on a 32-bit STM or PIC32 or SAME5 or AVR32 or ESP32, and just have your common toolchain set up all your clocks and peripherals properly with no register-level access ever required.

Anyway, I look in the mirror and see a lot of gray in my beard now, so I'll stick to writing C because I write for microscopic microcontrollers like the ATtiny and small ATmegas and just string piles of them together with simple, robust serial protocols.

Shame Boy
Mar 2, 2010

ante posted:

And regardless on your feelings on Rust in general, modern compilers will now usually generate equal/comparable code between C and C++, so avoiding C++ is demonstrably an old-person tendency, on par with greybeards who refuse to graduate from assembly.

As someone who likes C++ and tries to shove it in lots of places it really does not like to be, hoo boy is this only conditionally true. I went in naively to a project a while back thinking that, only to find by the end of it like half my goddamn RAM was v-tables. It's a completely fine language (if you're into that sort of thing) as long as you know what it's doing behind the scenes and avoid certain patterns that are otherwise standard on non-embedded systems with all the ram they want, but yeah.

Foxfire_
Nov 8, 2010

Rust is fine for no OS. It's not a runtime thing, it's a language specifically designed to allow a compiler to reason strongly about program behavior and statically prove stuff about its behavior. In exchange you pay long compile times* and having to be more explicit about a bunch of stuff (e.g. a function with a pointer parameter has to say whether thing pointed at is still valid when it returns).

Some of the stuff it allows proving aren't as useful with no/minimal OS, but some are. You might not care about being able to prove there's no use-after-free bugs if you never free to begin with, but you might still care about being able to prove two tasks never write to the same piece of memory simultaneously.


*Long compile times compared to well-designed languages, not compared to C/C++ that spend forever reparsing includes/templates
.

Splode
Jun 18, 2013

put some clothes on you little freak
Honestly you guys are starting to sell it to me as a replacement for C++ on embedded systems. If I can get a rust-based RTOS that I can guarantee won't hardfault no matter what, and I can still use all the worst-code-ever-written manufacturer supplied libraries using C or C++, that sounds like it's just objectively better.

There'd even be biomedical applications (and other industries, but biomed has some strict standards) where this would be a god send. For example, you can't actually use standard FreeRTOS as it's based around dynamic memory, you must use the explicitly biomedical allowed version where you have to statically define everything (which sucks because of how FreeRTOS is structured). I think. I've never been forced to do it. But just getting FreeRTOS to not occasionally hardfault is an exercise in throwing memory at it, testing the poo poo out of it, and prayer.

Adbot
ADBOT LOVES YOU

KnifeWrench
May 25, 2007

Practical and safe.

Bleak Gremlin

Splode posted:

Honestly you guys are starting to sell it to me as a replacement for C++ on embedded systems.

Hey, kudos to you for keeping an open mind. I don't have any horse in this race, but this is just really nice to see on the internet.

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