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
bawfuls
Oct 28, 2009

a 5V board would be preferable tho because the gauge is 0-5V

Adbot
ADBOT LOVES YOU

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
I dunno if you have a multimeter or scope, or even an Arduino Uno with an analog pin available, but definitely double check that your BMS is using 5V serial.

If it is, yeah, gopher it, use an Arduino Mega or something 5V with multiple UARTs. You seem to be barking up the right tree.


If it's 3.3v, I guess that's still the best route if you need the 5V output, but you'll need a level shifter to get from 5V to 3.3V logic so you don't blow up your BMS's RX pin. Lots of those available on AliExpress for a few pennies. It's just a couple transistors.

mod sassinator
Dec 13, 2006
I came here to Kick Ass and Chew Bubblegum,
and I'm All out of Ass
Or if you need a 3.3 volt serial port (I have a strong feeling your BMS does, but definitely check the specs) just use an Arduino zero / SAMD21 board. It's all 3.3v logic on the pins, and it has plenty of memory and flash space. It's overkill for your needs to just drive a gauge, but it's easy to get going and available.

Sagebrush
Feb 26, 2012

peepsalot posted:

Arduino UNO has a single UART so I don't think you could easily connect a computer and your BMS simultaneously. The bigger arduinos(like Mega or Due) have more UARTs but all the other IO they provide is overkill for what you need.

If it's only running at 9600bps he can use a regular UNO and the SoftwareSerial library to create a virtual port on any two pins, leaving the built-in UART for computer communication.

bawfuls
Oct 28, 2009

Sagebrush posted:

If it's only running at 9600bps he can use a regular UNO and the SoftwareSerial library to create a virtual port on any two pins, leaving the built-in UART for computer communication.
this sounds promising. Next step is figuring out the voltage of the BMS serial connection

evil_bunnY
Apr 2, 2003

Sagebrush posted:

If it's only running at 9600bps he can use a regular UNO and the SoftwareSerial library to create a virtual port on any two pins, leaving the built-in UART for computer communication.
This. You can softserial 9600bps with p much anything.

kumba
Nov 8, 2003

I posted my food for USPOL Thanksgiving!

enjoy the ride

Lipstick Apathy
I've recently purchased an uno to tinker about with it - I design puzzle type things as a hobby and I was hoping to be able to incorporate some arduino tech into some of my designs. Think escape room type stuff, just very low budget as I just do this kind of thing for fun

I was wondering if someone might have a suggestion as to a particular resource to learn this kind of thing from the ground up? I've built my own PCs before in the past but I've never had to think much about circuits and voltages and what not. I see there's resources in the OP but as this thread is 7 years old I just wanted to find out if those are still the best starting points. Thanks in advance :)

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

kumba posted:

I've recently purchased an uno to tinker about with it - I design puzzle type things as a hobby and I was hoping to be able to incorporate some arduino tech into some of my designs. Think escape room type stuff, just very low budget as I just do this kind of thing for fun

I was wondering if someone might have a suggestion as to a particular resource to learn this kind of thing from the ground up? I've built my own PCs before in the past but I've never had to think much about circuits and voltages and what not. I see there's resources in the OP but as this thread is 7 years old I just wanted to find out if those are still the best starting points. Thanks in advance :)

I'd look for a getting started with Arduino type of guide, i.e. something that runs through about a dozen projects to show you different features like digital inputs, digital outputs, analog inputs, interfacing with servos, etc. Check out something like this and its 10 parts: https://learn.adafruit.com/lesson-0-getting-started/overview

bawfuls
Oct 28, 2009

Emailed the BMS maker and got confirmation the serial connection is 5V so I should be good to go with the Uno. Thanks for the help, I’ll likely return when parts show up and I get stuck trying to hack it all together.

Ambrose Burnside
Aug 30, 2007

pensive

kumba posted:

I've recently purchased an uno to tinker about with it - I design puzzle type things as a hobby and I was hoping to be able to incorporate some arduino tech into some of my designs. Think escape room type stuff, just very low budget as I just do this kind of thing for fun

I was wondering if someone might have a suggestion as to a particular resource to learn this kind of thing from the ground up? I've built my own PCs before in the past but I've never had to think much about circuits and voltages and what not. I see there's resources in the OP but as this thread is 7 years old I just wanted to find out if those are still the best starting points. Thanks in advance :)

No better way to learn than by doing, so start by doing very simple things and work from there. Look up some starter tutorials, start with a blink program- nothing more than successfully powering and flashing a sketch to the Uno, with the onboard LED blinking to indicate success. The program is provided as an example in the software. After that, start building basic circuits that experiment with basic components and get a taste for how they work and how the example sketches control everything. Buying a starter kit of some sort is a good idea, you'll get a modest spread of hobbyist components to play around with.
Eventually you'll start thinking of actual applications for your skills and components- workshopping these and getting them from a pile of parts to a working proof-of-concept is where stuff gets fun, and is where you can start focusing on exactly what tickles your interest.


That said, I find it useful to divide "tinkering with arduino" knowledge into three distinct subjects:
1) electrical + circuit fundamentals, which includes core theory, what passive and basic active components do, the nuts and bolts of knowing how to put a basic DC circuit together successfully. call this 'analog stuff'
2) How a microcontroller like an Arduino Uno functions and what people use them for, the difference between digital and analog signals + between inputting and outputting said signals, and the various peripherals (sensors, displays, buttons etc) that both send and receive those signals to hopefully perform useful work. call this "digital stuff"
3) How to write simple programs for your microcontroller using the arduino IDE that tells your Uno how to respond to various inputs from its peripherals to do something practical or entertaining. this is "programming", albeit with training wheels on.

i draw the distinction because all three have various non-Arduino applications, and accordingly you can learn about them- and eventually transfer your knowledge to them- through other means and in other settings. If you figure out you really like writing sketches but aren't much into circuits, for example, learning C instead of Arduino's stripped-down training-wheels version of it might be your next move.

Splode
Jun 18, 2013

put some clothes on you little freak
Or skip C and go straight into C++, which is far closer to Arduino anyway

Ambrose Burnside
Aug 30, 2007

pensive
whoops yeah (guess which of those three sub-disciplines i have the least patience for)

Parts Kit
Jun 9, 2006

durr
i have a hole in my head
durr

bawfuls posted:

this sounds promising. Next step is figuring out the voltage of the BMS serial connection
If it's not directly compatible you'll want to look into a level shifter, of which there are tons out there.

Some are made for RS232 spec voltages though so if you're not seeing +/-12V on the pins you'll want to skip that for something else. I think there are some simple ones that are just basic transistor dealies where you put in your inputs and the voltage you want it to be shifted to on a power rail and go to town.

Splode
Jun 18, 2013

put some clothes on you little freak

Ambrose Burnside posted:

whoops yeah (guess which of those three sub-disciplines i have the least patience for)

C++ is a horrible language anyway so you were right to recommend C.

Rad-daddio
Apr 25, 2017
I was gonna ask what the best coding language is for embedded systems. It's come down to C and C++, but it seems like everyone who uses C thinks it's the best due to it's ability to be used on more microcontrollers and it's lower use of resources. But everyone else says C++ is the way to go since C is old and obsoleted.

Currently, I'm prototyping stuff with Arduino using codes that I find online and modify. But, that can only take me so far so I was figuring to just learn the most applicable language for hardware level stuff and go from there.

taqueso
Mar 8, 2004


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

:pirate::hf::tinfoil:

You can use either, or a few other options like python or rust. Depends on the size of your target system, if you want certain language features, if a compiler toolchain exists targeting your hardware, etc.

mewse
May 2, 2006

Rad-daddio posted:

I was gonna ask what the best coding language is for embedded systems. It's come down to C and C++, but it seems like everyone who uses C thinks it's the best due to it's ability to be used on more microcontrollers and it's lower use of resources. But everyone else says C++ is the way to go since C is old and obsoleted.

Currently, I'm prototyping stuff with Arduino using codes that I find online and modify. But, that can only take me so far so I was figuring to just learn the most applicable language for hardware level stuff and go from there.

The C language book is less than 300 pages. You can start there and then plow ahead into C++. The C++ book is 1376 pages

e: Since the languages are so closely related it's sort of a false dichotomy to say you should only learn one of them.

Rad-daddio
Apr 25, 2017
Holy cow, I guess it's C for me then!

I'll mostly be programming lower level microcontrollers to drive sensor feedback and sensor displays on an oled or lcd display. My current boondoggle is a sensor feedback surgical prototype that calculates a strain gauge value and then sends that data via Bluetooth to be read on a remote tablet running a custom Android app. I've been able to cobble all of this together by watching YouTube videos and stealing code from middle school kids, but like I said that can only take me so far.

Hadlock
Nov 9, 2004

Rust is what the cool kids are using these days

But the tooling and the libraries are moderately primitive in comparison to C/C++

Probably worth running through a Rust hello world tutorial just so you have passing knowledge of it down the road, but you'll probably run into roadblocks pretty quick with libraries and want to switch to C/C++

Splode
Jun 18, 2013

put some clothes on you little freak

Rad-daddio posted:

I was gonna ask what the best coding language is for embedded systems. It's come down to C and C++, but it seems like everyone who uses C thinks it's the best due to it's ability to be used on more microcontrollers and it's lower use of resources. But everyone else says C++ is the way to go since C is old and obsoleted.

Currently, I'm prototyping stuff with Arduino using codes that I find online and modify. But, that can only take me so far so I was figuring to just learn the most applicable language for hardware level stuff and go from there.

Short answer, is there is currently a holy war over this question.

My personal opinion is C forever.
C++ is horrific for embedded systems and nobody really writes modular code anyway so you never get the promised advantages. If you're going to use C++ in a commercial environment I'd argue you should just use arduino or mbed if you're so terrified of registers.

mewse
May 2, 2006

Splode posted:

Short answer, is there is currently a holy war over this question.

Yeah I was worried about getting flamed with my previous post but C foreverrrrr

Rad-daddio
Apr 25, 2017
Yeah, that's where I'm at now. I know gcode from programming cnc mills , but C is slow going for my ageing brain. I'm just working through some free classes I found online.

Splode
Jun 18, 2013

put some clothes on you little freak

Rad-daddio posted:

Yeah, that's where I'm at now. I know gcode from programming cnc mills , but C is slow going for my ageing brain. I'm just working through some free classes I found online.

it's not too bad, just put off learning pointers for as long as you can and I'd go so far as to say it's pretty easy. it's a lot more readable than gcode

mewse posted:

Yeah I was worried about getting flamed with my previous post but C foreverrrrr

I got forced into using C++ for a work project and it has absolutely torpedoed the project, I am never using it again.

mewse
May 2, 2006

Splode posted:

it's not too bad, just put off learning pointers for as long as you can and I'd go so far as to say it's pretty easy. it's a lot more readable than gcode

Pointers really aren't that bad after everyone warns you they're hard to understand

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Splode posted:

Short answer, is there is currently a holy war over this question.

My personal opinion is C forever.
C++ is horrific for embedded systems and nobody really writes modular code anyway so you never get the promised advantages. If you're going to use C++ in a commercial environment I'd argue you should just use arduino or mbed if you're so terrified of registers.

Rust is a nice balance.

C is just too easy to do wrong especially if you have anything security related on the line

Splode
Jun 18, 2013

put some clothes on you little freak

mewse posted:

Pointers really aren't that bad after everyone warns you they're hard to understand

Yeah they're just the hardest part. If you're down with pointers you're finished.

That said, trying to find hard faults with the Arduino IDE with its lack of a debugger sounds like nightmare fuel

Fanged Lawn Wormy
Jan 4, 2008

SQUEAK! SQUEAK! SQUEAK!
I’m sure it’s been mentioned in here before but if you want to do some higher level stuff without going full skilled programmer, the VisualMicro plugin for VisualStudio is very good. It’s paid only now but it’s worth every cent

Fanged Lawn Wormy fucked around with this message at 05:10 on Aug 11, 2019

Sagebrush
Feb 26, 2012

It's full-featured nagware, as far as I can tell. As long as you can deal with a popup once every time you open VS, it's got no limitations.

It's definitely worth the $30 or whatever though

Rad-daddio
Apr 25, 2017

Splode posted:

Yeah they're just the hardest part. If you're down with pointers you're finished.

That said, trying to find hard faults with the Arduino IDE with its lack of a debugger sounds like nightmare fuel

It seems like a lot of the stuff related to Arduino is really didactic. Even going on their forums to ask a quick question can lead to them giving you cryptic responses for the sake of "learning". Feels like the lack of a debugger kind of jives with that so it forces you to stare at you code line by line.

Splode
Jun 18, 2013

put some clothes on you little freak
Yeah, which is dumb, because debuggers teach you a shitload about what's really going on.

They just don't want you to see how ugly the Arduino backend code is :tinfoil:

Wibla
Feb 16, 2011

Splode posted:

They just don't want you to see how ugly the Arduino backend code is :tinfoil:

This is probably pretty accurate :v:

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
Uhh paid software?

PlatformIO is free / OS, built into VS Code, owns bones, and can "import" Arduino projects and there is literally no reason to even download the Arduino IDE anymore, seriously. Drop that hot garbage.

PIO even just opened up their previously paid debugger.

Also it comes preloaded with a million different Arduino clones configs so it can sort through their peculiarities, and automagically does the toolchain stuff for Arduino / Espressif stuff / STM stuff and some others.

Splode
Jun 18, 2013

put some clothes on you little freak
PlatformIO forced an update on me and then stopped being able to compile my project, I've never bothered since. The Arduino IDE is severely limited but it's infinitely more reliable than any other IDE I've ever used

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
Tbh my advocacy of PIO goes way beyond personal preference, and there have been several breaking changes in libraries that would have sunk my projects, had I been using the Arduino IDE.
PIO allows you to fix your libraries and frameworks to specific versions if you like, and use a config file that tells anyone that has your project how to install it automatically, without the version/incompatibility hell that is the Arduino ecosystem.

There are many other reasons to use it over the official stuff, it's just that that one seems relevant to your issue. It's worth the minimal learning curve to figure out how the config file works, to help with future robustness and ease of sharing, and all sorts of customisation

Splode
Jun 18, 2013

put some clothes on you little freak
I just found the entire thing very flakey. I could see how everything was supposed to work, it just didn't.

Sagebrush
Feb 26, 2012

I have found that platformIO...kind of works. Once you get it configured it's fine, but the process is kind of a mess. The Arduino editor is literally just install, double-click, plug in, go, which makes it ideal for beginners; and if you are a more advanced user, visual studio with visual micro is significantly better than platformIO for most Arduino-compatible microcontrollers.

Maybe if you're doing it on a Mac and don't have visual studio available platformIO might be the best choice.

My Rhythmic Crotch
Jan 13, 2011

Another Platformio user here. In fact I like it so much that I cobbled my installation into being able to build code for the newly released Teensy 4, which is not officially supported yet. That was fun.

Foxfire_
Nov 8, 2010

bawfuls posted:

Emailed the BMS maker and got confirmation the serial connection is 5V so I should be good to go with the Uno. Thanks for the help, I’ll likely return when parts show up and I get stuck trying to hack it all together.

A 0V/5V (TTL) serial interface out on a connector would be very strange. Those kinds of logic levels come out of a microcontroller UART, but are pretty much only used within a PCB and then get shifted for an external interface. Also, because it was working with some form of generic USB-to-serial converter, it is almost certainly RS232 (more common than RS422/RS485). I have literally never seen a TTL one of those.

RS232 uses these logic levels:

+3V to +15V = 0
-3V to -15V = 1
with a common ground wire.

A transmitter can use anything in that range and +/-3.3V and +/-5V are common choices. For a usb-to-RS232 converter, it will typically use +/-5V with an internal charge pump generating -5V from the +5V USB power.

A receiver must in general accept anything in that range, though if you know the BMS only uses +/-5V and never injects any bad transients you could allow less (standard requires surviving indefinite shorts to +/-25V on either TX or RX)

The UART on the Uno isn't going to be able to talk to it since it will be using 0V as 0 and the RS232 side will treat that as an invalid/transitional level. It will need a transceiver IC stuck in front of it.

Splode
Jun 18, 2013

put some clothes on you little freak
It's not that unusual for 0 to 5 V logic level uart to be exposed these days

Adbot
ADBOT LOVES YOU

bawfuls
Oct 28, 2009

Foxfire_ posted:

A 0V/5V (TTL) serial interface out on a connector would be very strange. Those kinds of logic levels come out of a microcontroller UART, but are pretty much only used within a PCB and then get shifted for an external interface. Also, because it was working with some form of generic USB-to-serial converter, it is almost certainly RS232 (more common than RS422/RS485). I have literally never seen a TTL one of those.

RS232 uses these logic levels:

+3V to +15V = 0
-3V to -15V = 1
with a common ground wire.

A transmitter can use anything in that range and +/-3.3V and +/-5V are common choices. For a usb-to-RS232 converter, it will typically use +/-5V with an internal charge pump generating -5V from the +5V USB power.

A receiver must in general accept anything in that range, though if you know the BMS only uses +/-5V and never injects any bad transients you could allow less (standard requires surviving indefinite shorts to +/-25V on either TX or RX)

The UART on the Uno isn't going to be able to talk to it since it will be using 0V as 0 and the RS232 side will treat that as an invalid/transitional level. It will need a transceiver IC stuck in front of it.
Update:

It works, with one caveat.

I've got the BMS connected to D0 and D1 on the Uno, and I've got the gauge signal on pin 5 for analog output. I've wired the 12v (ignition keyed) from the car to the Vin on the Uno, and have chassis ground to the input GND.

With all this going, it appears to be working. Key on powers the Uno and the gauge (gauge also requires +12v power from the car), and the program is working as intended giving me the same temperature output on the gauge as I read off the BMS via laptop connection moments earlier.

The caveat is that when I power the Uno from the car's 12v source (actually showing ~13.4v at present on my multimeter), the Uno emits a sustained tone/beep. This is not the case when powered via the USB port (but that interferes with the pin0/1 serial connection), nor when I earlier tested things with a makeshift 12v battery (9v + 2x AAA in series).

I presume this sustained tone/beep/sound is bad, indicative of an error of some kind, relating to the car's 12v feed. What could be going on here?

edit: unrelated followup, what is a good robust way to make these connections to the Uno for the long term? Right now I have trimmed a few generic breadboard jumpers, stripped one end, and soldered that to other wires I can then connect to the gauge wires and the BMS serial wires. But these jumpers seem like they could pop out of the Uno easily, particularly once the car is in motion. Is there something more robust that would secure to the Uno with a clip of some kind?

bawfuls fucked around with this message at 01:08 on Aug 19, 2019

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