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
Bistromatic
Oct 3, 2004

And turn the inner eye
To see its path...
I'm contemplating making some overly fancy card game tokens that slowly light up after you flip them to their "on" side and fade back out if you flip them to "off" again. It's keys for the game Keyforge if that means anything to you and a player needs exactly three so i'm not gonna be making a million of these.

Looking into fade-in/fade out circuits for LEDs a bit i happened upon people commonly using ATTiny85s for this. They are far smaller than any analog circuit i could realistically rig up to do the same thing. And they seem to be compatible with the Arduino enviroment which is why i'm asking here.

What i have in mind is an SW-200D tilt switch that closes when the token is right side up and then the ATTiny start fading in three LEDs via PWM output. The LEDs i picked draw 25mA a piece so i can't run more than one from each of the output pins since they are rated for 40mA.

Now where it gets confusing is that i'm finding conflicting information on whether the ATTiny85 can do two or three PWM outputs. The official documentation says pins 5 and 6 function as PWM outputs but some people say you can use pin 3 as well. :confused: If it's only two does anyone have a recommendation for a different microcontroller or an alternate way to hook up three 25mA LEDs without blowing anything? Indiviadual control of the LEDs would be a nice bonus but i care more about having three.

There's a bunch of different ATTiny85 variants too but those seem to mostly refer to the shape of the package and pins, is there anything i should watch out for specifically?

Everything everything would be powered by a 1/2 AA 3.6V battery since it seems to be a good compromise of size and capacity. It seems to be plenty for the microcontroller as well.

Here's a wiring diagram assuming i can get three PWM pins:


And here's a quick mock-up of the whole thing with components loosely thrown in for scale:


One last question would be if anyone can recommend me a power switch that's as tiny as possible? There's plenty of tiny buttons but switches tend to be larger than i'd like.

Adbot
ADBOT LOVES YOU

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib

Bistromatic posted:

One last question would be if anyone can recommend me a power switch that's as tiny as possible? There's plenty of tiny buttons but switches tend to be larger than i'd like.

APEM NK236? 0.1" pin spacing, .4" LOA, 0.1" wide...

Bistromatic
Oct 3, 2004

And turn the inner eye
To see its path...
Thanks, those seem perfect!

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib

Bistromatic posted:

Thanks, those seem perfect!

Always glad to do some DigiKey parametric searches!

CarForumPoster
Jun 26, 2013

⚡POWER⚡

sharkytm posted:

Always glad to do some DigiKey parametric searches!

Snarky sharky

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib

CarForumPoster posted:

Snarky sharky

No snark intended. I really like DigiKey's search. It's almost as good as McMaster Carr.

evil_bunnY
Apr 2, 2003

I need a pair of microcontrollers with:
  • p2p transceiver (let's couple hundred yards so ESPNow, LoRa or something equivalent would be great)
  • OLED screen. Tiny is fine.
  • compass/GPS
  • and ideally (1s) battery management.

Does anyone make such a thing? I could piece it together on top of an ESP32 feather but I'd really like to keep it as small as possible.

Lowen SoDium
Jun 5, 2003

Highen Fiber
Clapping Larry

evil_bunnY posted:

I need a pair of microcontrollers with:
  • p2p transceiver (let's couple hundred yards so ESPNow, LoRa or something equivalent would be great)
  • OLED screen. Tiny is fine.
  • compass/GPS
  • and ideally (1s) battery management.

Does anyone make such a thing? I could piece it together on top of an ESP32 feather but I'd really like to keep it as small as possible.

Something like this?

https://www.aliexpress.com/item/TTGO-T-Beam-ESP32-433-868-915Mhz-WiFi-wireless-Bluetooth-Module-ESP-32-GPS-NEO-6M/32967228739.html

My Rhythmic Crotch
Jan 13, 2011

evil_bunnY posted:

I need a pair of microcontrollers with:
  • p2p transceiver (let's couple hundred yards so ESPNow, LoRa or something equivalent would be great)
  • OLED screen. Tiny is fine.
  • compass/GPS
  • and ideally (1s) battery management.

Does anyone make such a thing? I could piece it together on top of an ESP32 feather but I'd really like to keep it as small as possible.

This plus this, they also make a GPS feather as well, but it would probably be easier to just wire the GPS directly in.

evil_bunnY
Apr 2, 2003

Gonna get one these I think:

evil_bunnY posted:

No but this looks like it'll be perfect for both ends

https://pycom.io/product/pygo1/

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib
I've run into an Atmel micro problem, so it's kinda Arduino-related. I'm reprogramming some boards with ATTiny 45's on them. The code is open source and Arduino-based, I made some changes, and I'm trying to program a bunch of these devices. I've had two of these just up and die, and ten successful programming results. I'm confused as to what could cause the micro to stop communicating.

1. One failure was using a soldered-on header, the other was from a pogo-pin jig. The program uploads, but fails on verification. Once it fails, the micro never talks again. I get "device signature 0x0000" if I use my Arduino as ISP, and a similar device initialization failure using a USBasp. USBasp was run in both normal and slow clock mode to try and get things working. Device runs the micro on 5V, and my programmers both run 5V. I tried 3.3V and no change.

2. Fuses are unchanged, and I've verified power and external clock signal are correct and intact.

3. I could get ahold of a HVPP, but I'm hoping there's something else I can try.

Thoughts?

Splode
Jun 18, 2013

put some clothes on you little freak
Are you programming with jtag, or via the Arduino bootloader?

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib

Splode posted:

Are you programming with jtag, or via the Arduino bootloader?

Bootloader.

Sagebrush
Feb 26, 2012

How? The tiny 45 doesn't have an internal serial port. The only way to program them is through isp (or hv I guess).

Sagebrush fucked around with this message at 14:26 on May 21, 2019

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib

Sagebrush posted:

How? The tiny 45 doesn't have an internal serial port. The only way to program them is through isp (or hv I guess).

There's a programming header on the board, and I'm using an ISP to do the programming, so not using the bootloader. Sorry. I know it's not JTAG.

It's a 6-pin:
MISO, MOSI, SCK, Reset, plus +5V, Gnd.
I'm very much not an AVR person, I mostly run PICs, so the tools are pretty foreign to me.

sharkytm fucked around with this message at 18:10 on May 21, 2019

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib
I tried to program some more of these boards, and captured the output when one fails.
code:
avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -pattiny45 -carduino -PCOM3 -b19200 -Uflash:w:C:\PROGRAM.hex:i 

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, [url]http://www.bdmicro.com/[/url]
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
         AVR Part                      : ATtiny45
         Chip Erase delay              : 4500 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     6     4    0 no        256    4      0  4000  4500 0xff 0xff
           flash         65     6    32    0 yes      4096   64     64  4500  4500 0xff 0xff
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9206 (probably t45)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "C:\PROGRAM.hex"
avrdude: writing flash (3830 bytes):

Writing | ################################################## | 100% 5.41s

avrdude: 3830 bytes of flash written
avrdude: verifying flash memory against C:\PROGRAM.hex:
avrdude: load data flash data from input file C:\PROGRAM.hex:
avrdude: input file C:\PROGRAM.hex contains 3830 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 2.70s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x00 != 0x53
avrdude: verification error; content mismatch

avrdude done.  Thank you.

the selected serial port 
 does not exist or your board is not connected
After this error shows up, I can never talk to the ATTiny45 again, it only returns the device signature of 0x0000 afterwards.

Sagebrush
Feb 26, 2012

So it successfully detects the chip and burns the program, and then the program fails verification from byte zero and the signature disappears?

It sounds like your programmer (or something about the way you've got it set up in the circuit) is frying the chips. Do you have any loose Tiny45s? Can you try burning the same program onto them several times to see if you get the same failure when they're not in the circuit?

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib

Sagebrush posted:

So it successfully detects the chip and burns the program, and then the program fails verification from byte zero and the signature disappears?

It sounds like your programmer (or something about the way you've got it set up in the circuit) is frying the chips. Do you have any loose Tiny45s? Can you try burning the same program onto them several times to see if you get the same failure when they're not in the circuit?
Yes.

I'll order some. If I can program them outside and solder them onto the board, it'll save the $400 in paperweights that I have now. This is what I get for using a COTS product instead of designing from scratch. I talked to their engineering team, and apparently once the full board is assembled, it needs to be powered separately as other components are drawing too much power and can cause glitches. I'll give that a shot today.

sharkytm fucked around with this message at 15:13 on May 23, 2019

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib
Nope, that didn't help. The board (which is part of an LED light) was powered by a 12V bench supply, and being programmed by my Arduino as ISP. The LED flashed very quickly during the programming, which isn't surprising, because the LED driver is connected to Pin 6 of the micro (shared by the MISO connection). I got a the same mismatch error, and this was repeatable (I could keep sending the program and getting the flashes and error). Once I powered the board down, the micro went silent. I've got 25 ATTiny45's on their way, I'll try programming them off-board and installing them. It's really odd that I had a reasonable number of successes, and now I'm at about 25% success rate. I was previously using my desktop, and now I'm on a laptop, but the settings are identical. Any thoughts?

Sagebrush
Feb 26, 2012

I haven't looked at the circuit itself, but I'd almost put money at this point on it being a problem with programming it in circuit. The fact that it's running on 12v and that the MISO pin is connected to the LED driver is skeeving me out. Get the bare chips and some sockets and see how you make out.

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib

Sagebrush posted:

I haven't looked at the circuit itself, but I'd almost put money at this point on it being a problem with programming it in circuit. The fact that it's running on 12v and that the MISO pin is connected to the LED driver is skeeving me out. Get the bare chips and some sockets and see how you make out.

No way to socket them, it's all SMD. And on a MCPCB, to boot, soldering is a royal pain. I just hot-air gunned one out, and it doesn't talk to AtmelStudio. The MFR has some forum posts about programming them in-circuit, which is why I thought it would work (and it did several times).

Bad Munki
Nov 4, 2008

We're all mad here.


sharkytm posted:

No way to socket them, it's all SMD.

Test socket not an option? https://www.adafruit.com/product/1282?gclid=CjwKCAjwiZnnBRBQEiwAcWKfYjLqviSuIiy7AtPv0tpno2pNzkr7lllCfoR0uWkRypLi2honzI9uBRoCJrcQAvD_BwE

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib
Test socket might be an option. I'll think about it.

So... I programmed the last 4 lights with no failures. I went back to my original setup: Arduino as ISP, soldered headers, and flying leads from the Arduino to the header. No problems. I'm wondering if the Pogo Pins are causing a problem, or maybe something else that I missed. Is there a big difference between "Upload" and "Upload using programmer" when using Arduino as ISP? I know you have to use "Upload using programmer" with the USBAsp, but not sure about the Arduino as ISP. all 4 of these latest ones used "Upload as programmer", but I swear I used "Upload" previously.

sharkytm fucked around with this message at 13:10 on May 24, 2019

Hadlock
Nov 9, 2004

My nephew is into toys now and the original plan was to build a wooden car but his dad keeps bringing home these light up toys from China

I was thinking about hollowing out a section of the car and throwing a tiny86 in there, a strip of LEDs and some sort of battery

Since he likes shaking things and banging them around. What kinds of sensors can I hook up to detect a toddler banging it around? I'm thinking detecting forces above 2G? Someone had asked long ago about a very low energy jiggle sensor on a spring, I think. The sensor would change the color of the LEDs, or light pattern, etc.

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
Yeah, just Google spring shock sensor, they'll come right up. I have a little plastic ball, think marble sized, with one of those and some flashy LEDs. It's lasted literally ten years, somehow gets moved with me, keeps turning up in drawers and surprises me when it gets bumped and starts flashing for a minute

evil_bunnY
Apr 2, 2003

a solid state accelerometer (LIS3DH is cheap) will do the same thing.

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
Not as cool and harder to use though

Hadlock
Nov 9, 2004

Yeah the very next day my nephew comes over and his mom has a bouncy ball that lights up when you throw it against the ground. Just gonna get one of those and harvest the guts from it, wire it up to some extra LEDs and maybe maybe a bigger battery. Arduino is absolute overkill for what I need to do. Then I can just epoxy everything in place.

poeticoddity
Jan 14, 2007
"How nice - to feel nothing and still get full credit for being alive." - Kurt Vonnegut Jr. - Slaughterhouse Five
Does anyone know if the soon-to-be-available Arduino Nano 33 BLE will be able to act as an HID?

bawfuls
Oct 28, 2009

So I *think* an Arduino is the right tool to accomplish what I want to do, and I'm here for some help/clarification on that.

I've got a project car (an electric conversion, AI thread here) and I need to add a realtime display of my battery temperature. My batteries already have a total of 10 thermistors in them, which are connected to a Battery Management System (BMS). The BMS continuously monitors these temperatures, and throws an error if they are over the warning limit (illuminates a light on my dash).

There are two ways to interface with the BMS: a CAN-BUS interface, and a serial connection on a 3.5mm TRS jack (looks like a headphone jack). The CAN-BUS is not suitable for my needs (it doesn't output temperatures, headers would be wrong for CAN gauges anyway). The serial connection allows one to connect a laptop to the BMS via a usb-serial cable that comes with it. Using a terminal client like PuTTY, this is how the BMS is configured and how I can query information it's monitoring, like thermistor temperatures. There is a simple text command to query themistor readings, and they are returned in a predictable text format.

But I don't want to drive around with a laptop on the passenger seat, I want a nice gauge in the dash. So, I've got a suitable gauge on order, which takes a simple 0-5V input. I should then be able to set up an Arduino to connect to the BMS serial connection, write a bit of code to periodically query thermistor temps from the BMS, parse the output, and convert that into a 0-5V analog (or likely PWM) output signal for the gauge.

I think I understand how to do nearly all that from what I've researched thus far, except the serial communication. It is not clear to me how easy or difficult that is. Maybe it's a simple as connecting the right pins and then a couple lines of code:
code:
Serial.begin(9600); //baud rate of the BMS serial port
Serial.print("sh th"); //BMS command to query thermistor temperatures
String rawOutput = Serial.readString();
Followed by some parsing of that string and conversion to numerical values. But then I've also read confusing things about compatibility of different serial connections, and every time I google for some combination of "Arduino serial communication" everything is focused on interface between an Arduino and a computer. Is there more to this or is it that simple? What's the most straightforward way to troubleshoot this? Since I want to use the serial connection on the Arduino for BMS communication, how can I monitor the output with a laptop to check my work as I set everything up? Is the Arduino Uno fine for this, or is there another board that'd be better suited for my purposes?

bawfuls fucked around with this message at 23:01 on Aug 5, 2019

evil_bunnY
Apr 2, 2003

It's real simple as long as you can get the duino to physically talk to the BMS.

shame on an IGA
Apr 8, 2005

What make and model BMS do you have? I'd mostly be concerned about verifying the voltage on that serial port before you risk frying a pin, any other configuration needs can be handled in software. RS-232 / 9600 baud / 8 data bits / 1 stop bit / no parity is pretty standard but you never know if you've got an oddball until you check.

bawfuls
Oct 28, 2009

Yeah I guess troubleshooting that is what worries me. Guess I need to get an additional display just to have a way to verify the communication?

bawfuls
Oct 28, 2009

My BMS is this: https://www.thunderstruck-ev.com/bms/

The documentation says 9600 baud, 8 data bits, 1 stop but. It doesn’t mention RS232 or otherwise.

Splode
Jun 18, 2013

put some clothes on you little freak
Nah just work out what voltage is coming out of the serial port from the battery manager. Pray it's 5 volts, anything else will require additional hardware.

Otherwise it's pretty easy, if you can connect with putty you have your serial settings already

taqueso
Mar 8, 2004


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

:pirate::hf::tinfoil:

They mention using a USB-serial converter so that makes it 99.99% chance its RS232.

Hmm, it connects with a 3.5mm jack so maybe lower that to 98%.

bawfuls
Oct 28, 2009

Is an Uno the right board for this? I assume a PWM voltage output will be fine for this, shouldn’t need a true analog voltage output. And I’ll need to power the Arduino separately since it can’t pull power from the BMS. Looks like I should be able to power it with my existing 12V sources in the car.

shame on an IGA
Apr 8, 2005

Based on this documentation filename coming up from googling the driver filename, I'm confident it's 232. Now gotta figure out which wires on the stereo plug are Tx / Rx / GND

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS

taqueso posted:

They mention using a USB-serial converter so that makes it 99.99% chance its RS232.

Hmm, it connects with a 3.5mm jack so maybe lower that to 98%.

RS232 is specifically -15V / +15V, and it's really doubtful that that's it.


A USB-Serial converter, and this BMS, probably, will be UART (which is pretty standard serial), but that still doesn't answer the question of whether it's 5V or 3.3V. Most modern stuff has moved over to 3.3V, and I'd recommend picking up some sort of 3.3V-compatible Arduino-alike. The Teensy is supposed to be good, I guess.

Adbot
ADBOT LOVES YOU

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

ante posted:

RS232 is specifically -15V / +15V, and it's really doubtful that that's it.


A USB-Serial converter, and this BMS, probably, will be UART (which is pretty standard serial), but that still doesn't answer the question of whether it's 5V or 3.3V. Most modern stuff has moved over to 3.3V, and I'd recommend picking up some sort of 3.3V-compatible Arduino-alike. The Teensy is supposed to be good, I guess.
There's diferent revisions of the standard, and afaik rev C switched to 5V. Anyways you can pick up a MAX3232 module on ebay for like $1 to do the level shifting easy peasy.

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.

I would personally go with an ESP32 (3.3V based so still need to be cautious of voltage levels, so get the MAX3232 above), which iirc has 3 UARTs and can also interface with computer over wifi if you want.

edit: forgot to mention ESP32 is compatible with Arduino IDE, so you can keep your code basically the same, except maybe changing some pin #s.

peepsalot fucked around with this message at 02:38 on Aug 6, 2019

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