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
babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Neat project.

I accidentally bought some I2S microphones a little bit ago. Those are nontrivial to get working on tiny micros, as I2S is a pretty speedy protocol, all things considered.

Because I like to be pedantic, going from 8-bit to 16-bit on your digital audio doesn't do anything for the fidelity, it just lowers the noise floor. If you're using the same sample rate, then you get all your information in the same number of samples, but you get more quantization noise with a lower bit depth. CD players use a 1-bit DAC running at 16x sampling frequency, so it "acts like" a 16-bit (really 14-bit because of math) DAC.

Can't wait until you get into your buttons and switches. Charlieplexing and diodes, aplenty, right?

Adbot
ADBOT LOVES YOU

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

Oh gently caress, I'm spreading misinformation. :saddowns:

Just so I get this clear, do you mean that the fidelity isn't affected because the audio signal is already in digital form so the quality is the same no matter what speaker I use? And that the 16-bit output will have less quantization noise, and this does translate to slightly better perceived sound? I realized that I never looked up the definition of fidelity and the best I could find is "accuracy with respect to the original recorded sound". Is there a more technical definition? I don't remember what I learned in school. :sweatdrop:

The audio is converted by the DAC into a band-limited signal. Everything above samplefreq/2 cannot be represented (as per Nyquist). Therefore, if your sample rate is the same, you get precisely one waveform of your sample points, whether or they're 8 bits or 16 bits or whatever. The 16-bit signal is "closer" to the original, but there isn't any more frequency information in it. Because an arbitrary analog signal falls in a random spot between sampling points, the average difference at a single sample point when summed across all the points is white noise. If you only have 8 bits of depth, then you're looking at a larger signal-to-noise ratio, as each point has a larger distance away it can be.

This is called "quantization noise" and if your digitizer is any good (audio ones are) then this noise is exactly equivalent to tape hiss. 4 bits gives more "hiss" than 8, which is more than 16, etc. So if you're playing on a crappy low-fidelity speaker anyway, your sound and tones (especially if they're small numbers of sine waves added together) will sound the same at 8 bits and 16, but you will probably be able to hear the difference in a voice sample or a drum hit or something that's got a lot of complex frequency stuff in it.

quote:

I never got why they called it "charlieplexing" and not just "key matrix" but I think so? I've been using the buttons directly hooked up to GPIO, but now that I need like 16 of them, I need to switch to the matrix'd approach. I'm using this page as a reference. The key matrix and charlieplexing look basically the same to me, but I also never done charlieplexing before so I'm not sure if they're the same thing or if I'm missing some nuances.

Normal switch matrix takes n pins to drive n2/2 pins, but charlieplexing uses n pins to drive n2-n pins. So a charlieplex 4x4 matrix only needs to use 6 pins, instead of 8. By being clever about which of your inputs are high, which are low, and which are input, you can get all your input with fewer pins, as long as you can sacrifice refresh rate.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Looks pretty good. I used UnoJoy back in 2014 to make my two-axis-and-a-bunch-of-buttons. I think it used an Arduino Nano; it's buried back in the base of the joystick. Anyway, there are two chips onboard the device, an atmega8u2 which does all the USB stuff, and a standard atmega328p (normal arduino) that reads all the buttons and axes and stuff.

Switching pin modes from INPUT to OUTPUT may take some time to stabilize; be mindful of switch debouncing and pullups/pulldowns/slew rate.

When I did my joystick, I had to do the USB HID controller from scratch.

My arduino code was very simple,
code:
 pinMode(SEL1,OUTPUT);
  digitalWrite(SEL1,0);
  delayMicroseconds(10);
/*read all the switches in this bank */
  pinMode(SEL1,INPUT);
 pinMode(SEL2,OUTPUT);
  digitalWrite(SEL2,0);
  delayMicroseconds(10);
/*read all the switches in this bank */
  pinMode(SEL2,INPUT);
 pinMode(SEL3,OUTPUT);
  digitalWrite(SEL3,0);
  delayMicroseconds(10);
/*read all the switches in this bank */
  pinMode(SEL3,INPUT);
controllerData.axis_1=analogRead(A0)>>2;
controllerData.axis_2=analogRead(A1)>>2;

return controllerData;
This basically just polls all the switches and axes as fast as possible and atomically updates a data structure in memory. Periodically, it spits that data structure out over the serial port to the 8u2.

Then in the 8u2 code, it reads in the controller switch data and converts all the d-pads to actual d-pad values like such:
code:
	switch((btnList.dpad_1_dn<<3)+(btnList.dpad_1_rt<<2)+(btnList.dpad_1_lt<<1)+btnList.dpad_1_up)
	{
		case  1: dpad_1=0;break; // up
		case  5: dpad_1=1;break; // up right
		case  4: dpad_1=2;break; // right
		case 12: dpad_1=3;break; //down right
		case  8: dpad_1=4;break; // down
		case 10: dpad_1=5;break; // down left
		case  2: dpad_1=6;break; // left
		case  3: dpad_1=7;break; //up left
		default: dpad_1=8; //neutral
	}

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Good on you for making it this far.

The reason the d-pads are their own part of the report instead of extra buttons is: I wanted a pair of d-pads so I could just tell my app to "use this axis" and not have to map four buttons to 8+1 directions.

This device had four analog axes, two d-pads, a 3-position selector, a couple of rockers, and six individual buttons, one of which was a two-stage. The USB spec handles all of these nicely, so they got their own breakouts in the report.

If you say "this group of inputs is a D-pad" in the USB descriptor, then Windows Just Knows and it works; you don't have to worry at all about whether or not your software can do what you need it to do based on discrete buttons.

I'll dig it out of the closet and plug it in and see what the windows "joystick button input" screen looks like, maybe.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

I love what you're doing here with conductive ink and first principles.

How are you debouncing your switches in code? I've implemented https://hackaday.com/2015/12/10/embed-with-elliot-debounce-your-noisy-buttons-part-ii/ a few times and it has been "pretty good" for what I'm doing; but super-low-latency is typically king for gamepad stuff, so maybe actual schmitt triggers would be worth it.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

You are doing wonderful things. Your CAD is the best Cardboard Aided Design I've seen since Project Binky.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Just to be 100% clear: the cardboard is for prototype only, and the final version is going to be out of something rigid? Or is the final design going to be cardboard for aesthetic purposes?

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

Cardboard is for prototyping only. I want to make the final version by using kiCAD to make PCBs and then creating the case from a 3D printer. The prototype looks like it's going to turn out to be quite unpleasant to use. The cardboard is too squishy for pressing buttons fast and that's going to make playing games really un-fun.

Ok. In that case, 400% do not agonize about things. 3d printer (or a LED laser cutter + acrylic) means all of these problems with height are a down-the-road problem. You just need the outlines and dimensions. Z-axis is for rev. 2, when you can print a stack of shims in .2mm thicknesses and then go with the height that works.

In other words, you're solving a problem that you don't need to solve. I'm here to kindly tell you not to go down the path that so many of us have: trying to make THIS ONE absolutely perfect before moving to the next step. Remember: perfect is the enemy of good.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

Thanks. I've only made two thicknesses of padding and faceplate and I stopped there. I'm working on the wiring now. The more problems like this that crop up during cardboarding make me want to get to the actual designing that much faster...

Just think of all the cardboard as "placeholder." It's good to have the placeholders, amm, in place. The conductive ink on paper is BRILLIANT prototyping as opposed to the rats' nest on a breadboard approach, and I sincerely hope it works for you; I'm watching with anticipation.

Just think of your prototype as having things you learn from and things you ignore. What you learn from is placing and reach and stuff, not SPECIFIC, to-the-thousandth thicknesses. If you think "this cardboard is doing something the final plastic won't do" then just move on. For 3d-printed stuff, 6mm of thickness is PLENTY.

At this point, I think your design looks great, and do not ascribe the weaknesses of your current medium to weaknesses in design nor execution.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

You'll never make any money selling tchotchkies with your 3d printer, but getting the Prusa means it'll Just Work (r) (tm) straight out of the box.

Get away from GIMP for your scale drawings. Get Inkscape. It's a vector drawing program that outputs .svg, but more importantly, it natively works in real-world units. If you set your drawing units and page units to mm, then if the measurement tool says something is 9mm wide, then it's 9mm wide when it prints out.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

Is this from experience? :smith: What were some of the barriers to profitability?

Everybody and their brother has a printer now. Unless you're selling directly to people you know for cheap, there's no market that's not already served.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

Also I'm going to have to apologize in advance because I wanna give the paper circuit the ole college try. I want that sweet cardboard game console street cred. I promise that this will become a proper PCB at some point.

"The old college try" appears to be drinking and smoking weed instead of paying attention, so let's give that one a miss. :dadjoke:

<soapbox>The thing I love about projects like this is that there is A Goal, but not every step has to be laser-focused on achieving that goal. This cardboard version is a thing you want to do, even though it doesn't strictly get you closer to your goal, and may move you further from it. It has become its own thing to do in the larger project. I certainly don't want anyone to deter you from doing things you want to do, even though they are not tightly concerned with your stated overarching purpose.</soapbox>

That said, let's look at your bus layout. Some lines need diodes, some do not. Try to figure out a way so you can use the diodes as your jumpers and move your bus lines so that the stuff that doesn't need jumpers stays planar. This may mean having pin assignments that look completely whacky in code, but make sense in the physical world. That's fine, the code doesn't have to make sense, it just has to produce the output. If having all the D buttons in one group, all the U buttons in another group makes the wiring make sense, then that's a valid plan, instead of forcing the layout to be a specific way because it makes the software look nice or easy.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

Yeah, I don't think you could call me a "real" 3D printing fan seeing as I got into this rear end backwards. I like it when things just work. I only have the attention span to hyper focus on one set of problems at a time.

The prusa will serve you well.

Back to button matrix, eh? That will massively lower your parts count, since you can use the internal pullups for all your buttons now, and don't need any more diodes. The insulating tape under the foil tape is pro-level stuff, man. Keep up the great work.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

So your friend Charlie turned out to be a psycho...

So this is how the Arduino thinks 3 buttons are pressed when in reality only 2 are pressed. It’s hard to predict, but if you write out all the 20 combinations and spend an hour or two working it all out, you’ll find that this situation ends up being very common due to how many combinations of buttons cause ghosting.

Thanks for coming to my TED talk.

Great talk. Good presentation.

Are you running out of digital IO pins on your controller for all the buttons you have? If so, an I2C port expander is probably what you need. One of those means you use two pins to control the port expander and get 16 more inputs.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

Legend of Cory

PS: guess what TV show I just finished watching on Netflix

This is a good update. Keep at it. You are learning many disciplines at once and (unlike SO MANY OTHERS) paying attention to advice and doing things as close to the right way as the hivemind can steer you.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

Me neither, actually. I'm mostly just speculating.

I mean I could do 1 board and cut it into 3 myself, but if I separate the design into 3 boards it won't be as dense so the total area will go up. That makes it a tiny bit more expensive. I think adding flex cables makes it more expensive, but I never tried getting a quote for that. It looked more expensive to me because the one manufacturer I was looking at offered different pricing tiers and split it up as "solid 2 layer", "solid 4 layer", "solid 2/4 layer + flex" but, again, I never actually got a quote. I could opt to not ask them to make flex cables and instead use regular solid core wires to hook up the boards with through-hole pads. 99% I think this is doable, but I could run into space issues.

Really all this means is that I'm thinking too far ahead to the point where I total all the materials together and having this be part of the difference between something that's $400 or something that's $75 - $100. It would probably be easier to just make one thing through any means possible and then iterate by swapping out components and simplifying parts of the design to bring the cost down afterwards.

I'm missing something fundamental. The point of having three boards is so they're all reasonably dense, right? It is a common thing to "panelize" your boards yourself and submit them to the fab house as one "board." So you could have e.g. four copies of your d-pads and two copies of your mainboard in one footprint that meets the fab house's minimum dimensions. You get three or four of those by default, so you'd end up with six to eight bare boards for you to populate. Adding drill holes and stuff is pretty easy; a line of drill holes makes a decent perforation, but there are also guides on how to create edge-routing layouts to make actual 'mouse bites' breakoff tabs.

https://www.pcbway.com/blog/PCB_Design_Layout/Manual_panelizing_of_PCBs_with_tabs_and_mouse_bites_in_Kicad.html

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Looking good so far. I have quite a bit of experience doing stuff in KiCad it wasn't really for.

Global labels and sheet labels are your friends, as are net labels. The net labels carry over to the PCB. This helps a lot when you're ratsnest routing. You'll have a line that's marked "audio_left_trimmed" instead of NET_RV1-2_U6-3.

In the "place power port" series of symbols, there are some quasi-magic power and ground rails; use the ground symbols to give global-net grounds. This means instead of having a bunch of individual wires labelled "agnd" you can have a ground symbol named "agnd" that connects all the "agnd" pins to the "agnd" net by default. Works for power stuff, too. In the schematic editor, it's the button under the "add symbol" button that looks like a ground connection.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

Does this still work if agnd is being driven by the decoder output pin? I'm using the "AGND" output of the Adafruit decoder and connecting the speaker grounds to that. Adafruit says the analog ground is useful for separating analog circuits from digital circuits that might introduce noise if they use the same ground. I suppose that helps, but if it doesn't really make a difference or if I'm misunderstanding my own design then it would be easier just to use the power pins.

The name of the net is "agnd". What that means in your circuit is up to you. It could mean "analog ground" or "audio ground" or "-7VAC connected to the A pin of the UC-G". It's just a net label. It has no "real world" meaning other than what you give it, regardless of what the person who put the symbol in the library typed into the description box.

I like to have sheet labels and net labels to make everything nice, and a couple of different ground/power nets means you can just drop a GND or CHASSIS or GNDREF or VCC/VDD/V+/+12V whatever symbol makes you happy. This schematic is for you, and if the nets are logically named and don't make a huge tangle of lines on your page, that's helpful.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

Kidding with KiCADirus
For example, this power source connected to a fuse going into the decoder's VIN:

This throws an ERC error because it thinks VIN is not being driven. But it is, you see, except that KiCAD is loving stupid like that.

I had forgotten all about that. The Fuse and Circuit Breaker symbols I use I customized and put in my custom library so their pins are both type "power output." It doesn't appear as though there's any way to tell KiCad that "this pin is internally connected to this other pin" in a symbol, other than having the same pin number; that leads to its own set of issues.

Cory Parsnipson posted:

Also, this means that AGND is now a global label that may be connected to other sheets that happen to use AGND? I think that should be okay no matter what, right?

Yes, precisely.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

csammis posted:

If you do need PWR_FLAGs then I find it convenient to keep them tucked away in a dedicated corner of the schematic that is only concerned with power sourcing. That way I don't need to search through the whole drat thing to find them.


This is much nicer and more elegant than having custom symbols for normal things. I dread what will happen if KiCad ever updates its symbol library sufficiently that my library of "fuse" and "breaker" and whatnot stop working.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

All this work just to make a stu-PIIIIIIIIIIIIIID--g'drat gameboyyy~

This shows that you are a poster with superior performance, exceptional ability, personal initiative and total dedication. You reflect credit upon yourself and uphold the highest traditions of DIY service.

Really great job. Post some gerbers and stuff before submitting to manufacturers; we'd love to take first crack at them.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:


Viola.

I also needed to search for how to make a via in a footprint (you can’t in KiCAD) and how to make the solder mask layer a different shape to completely follow the recommendations in the snaptron datasheet.

Via for venting in dome switch trace

I mentioned before that they recommend you put a small hole in each of the center pads of every button. This helps actuation because when you press down on the metal dome, it compresses the air that may be trapped inside and if there’s nowhere for it to go, the air pressure could interfere with the button press.

According to the KiCAD forum, you can’t make vias in a footprint because that requires the footprint to be aware of the PCB type (how many layers, what material, etc). If you don’t need a buried via (one that doesn’t go all the way through the board), you can hack one in by using a plated through hole pad with a hole radius that’s the same as the size. You can see that I put those in and they appear as small grey circles on the center pads in the footprint screenshot above.

Making a custom solder mask


I think the KiCAD forums get a bit full of themselves. You personally know that you're using a 2-layer board for this d-pad, so you can just make your plated through-hole in the center of your pad. I don't see how this isn't a via? Nomenclature?

Will having a solid solder mask on the back cover the vent holes in your fake-vias? Obviously not a problem for any real board vias, but these are supposed to be vent holes too, right? Seems like that PTH pad you place could have the bottom soldermask drawn as well. Like, if you're using .3mm via hole, you'd place a .4mm pad with .3mm hole, soldermasked both sides. Won't matter at all on top, because of the larger footprint pad up there, but the bottom will be clear of mask just in case.


Cory Parsnipson posted:

My headache screams in a shrill howl that fills the room, piercing my vision with red pulsing spears. I clench my hands against my head even harder. The room blurs and undulates and I fall through the floor.

:ohdear:

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

You are using a 3d printer in a way that makes me very happy. Your designs look great and are wonderfully functional.


This is pro AF; it took me a few seconds of HARD looking to determine it wasn't a factory part. Amazing work.

As far as supports go, see how good your slicer is at supporting stuff before you worry about throwing them into your design.

Tapping into plastic: Don't worry about it too much. It's plenty strong if your screw is long enough. Especially M1.6. If you put a 1.5mm hole in your design then you'll get a nice solid wall to thread into. If you have one, you can drill and tap with an actual tap kit. Above M6, you can model the threads into the part directly.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

https://www.mcmaster.com/inserts/heat-set-inserts-for-plastic-7/

Plastic inserts. Either drill or print your hole a nominal diameter, then press these in with a soldering iron and you have a permanent brass thread.

https://hackaday.com/2019/02/28/threading-3d-printed-parts-how-to-use-heat-set-inserts/

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

I love everything you've done! The gray plastic looks so Nintendo; it's perfect.

Cory Parsnipson posted:

Good enough

The select button holder is in place. It's... not my best work. The tiny superfluous piece is flimsy as hell and a pain in the rear end to screw in. It's not going to survive a second revision.

There are two "extra" pins on those switches. Could you just fold those flat for mechanical retention for the switch instead of trying to secure it (flimsily) from the front?

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

I think it's a neat idea. Unfortunately I didn't quite have the length from the pins to securely fasten the top in place. I also broke one of them off accidentally :sigh: Unless you mean fold them to hold the tactile switch itself in place? Holding the switch in place is no problem but the front fastener is more to hold the button cover and flexible silicon membrane in place.

Ah. I meant to hold the switch.

Though, looking at that picture, maybe some thin wire to hold the membrane and button cover in place would work. There's going to be a case over top, right? Could something like blue tack or tape or a zip tie or silicone or... just hold the membrane and button cover in rough location until the front of the case goes on?

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Love all the progress! It's great to have something working in-hand. Great job!

Cory Parsnipson posted:

I poked around with my multimeter and looking through a teardown of the thumbstick I realized that the button wire seems to be left floating and then shorted to ground when the button is pressed down. This would explain why I'm seeing the weird behavior where the button just ends up flickering. Why didn't this show up in the breadboard version? I have no idea. I don't think circuits is turning out to be my strong suit. :(

I decided to fix this by hooking the button wire (the same one going into the gate of the MOSFET) to a pullup resistor off a GPIO that I wasn't using. I don't know if this is a good solution, but it works and I just wanna clicky some buttons. :sigh:

I haven't seen a wiring diagram of how you hooked it up this time, and seem to have missed the MOSFET stuff somewhere. Would you mind sharing your wiring setup (or kicad files) just so we can see what decisions you made? It's always fascinating how many ways there are to solve problems.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Ahh. I get it. So the button floats, but connects to ground when pushed? Makes sense.

Since you're already using the GPIO's pullups, why not just take the thumb buttons out of the row/column stuff and just use those GPIOs to sense the thumb buttons? It takes the MOSFETs and their diodes off the board. Lowers the part count for your PCB, too.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

Oops, all buttons!
Please stick around!

GREAT WORK! I love it when a plan comes together.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

I just want to say that the revelation in the electronics thread is exceptionally surprising to me.

For those not in both threads, Cory Parsnipson found out that the joycons are driven at 1.7V in the actual hardware, but the arduino drives them at 5V. This means that at their minimum range, it is theorized the current can get high enough to smoke the little resistive pots that make the joycons work.

This is news to me, and some amazing examples of value engineering from Nintendo.

Cory, what are the resistance values at min and max on one of your still-working joycons? I think we should calculate power dissipation and see if this is a feasible failure mode.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

but in the future, I'd work around it by avoiding it entirely
:hmmyes:

quote:

or going to OSH park
:hmmyes:

quote:

or just buying a dremel tool instead...
:siren:

DON'T CHEAP OUT HERE. This is where tiny mistakes mean layer splits and broken vias and absolutely impossible-to-detect intermittent faults.

Broken vias are terrible things. I had a via too close to an edge and I split the boards with scissors instead of a sharp cutter. On the bench, all the test points checked good. In the field, one of my signals would get lost. On the bench, fine. Probed? fine. The via was split and when the board heated above 90°F, the layer would split apart and continuity was lost. Drilled and filled the via with solder and saved the board, but what a pain.

Your designs look great, and $25 is a reasonable price. If you keep your boards to 2-layer, I can maybe swing something to help you out. Hit me up in PMs if you want more information.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Just caught up on this thread. Wonderful work; this battery stuff is nontrivial. I'm glad you're learning a lot so that revision (whatever this one is + however many it takes) will be to your liking. I experienced sublime joy when Iclicked back to the subforum screen to find that there was a new post! Excellent!

I looked at the soft power switch pretty hard; I'm not sure it's what you need. That soft power switch still requires the device on the far side to enable/disable the power line. So you'd need some kind of tiny MCU attached to the soft power switch to actually enable/disable the power line and also be talking to the RasPi. Since you can't just have the raspi idling waiting for the power button to get pressed.

If I'm reading the code right, every time the power button is tapped, the device on the far side of "system power" gets full system voltage. It's then up to it to determine what it wants to do. The example sketch has it turning system power off if the button was pressed for <100ms. I don't think a pi will come out of sleep in enough time for this thing to work standalone.

You have another mcu onboard, right? One that could be super-fast-boot and low-power sleep (with a wake on pinchange interrupt) that could also do your power stuff?

edit: didn't say the important stuff first.

babyeatingpsychopath fucked around with this message at 00:48 on Aug 15, 2021

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

These last three posts have been solid awesome.

Myself, I love poring through datasheets and doing esoteric i2c stuff.

I wonder if the [.1 Hr rate] is the 10C rate for the battery, or if it's the .1C rate.... The example makes it seem like it's 1/10 of the 1C rate, but who knows!

To expand a bit: Say you have a "1AH" battery pack. The 1C rate would be 1 amp for 1 hour for the battery to go from full to empty. The 10C rate would be how many amp-hours you could get out of the battery at 10A. It may be more or less than 1AH depending on chemistry. The .1C rate works the same; how many AH you get from the battery at 100mA. This is very frequently more than the 1C capacity, but not always. Some chemistries love dumping power and don't trickle it out well. Some chemistries like giving a little juice for a long time.

babyeatingpsychopath fucked around with this message at 08:09 on Sep 4, 2021

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

This is a valuable use of your time, and I'm happy to continue to watch your progress.

What's in the box?

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

It's the latching power switch! Now I won't have to hurt my fingers pulling the battery out of the socket.

After ripping a thumbnail nearly off trying to get an 18650 out of my battery holder, I installed a commercial snap-action 120V 15A switch in-line. Yeah, just a straight wall switch from the project box. Overkill, maybe, but prototypes are designed to have kludges.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

I've been thinking about your soft power switch A LOT, and I think using the buttons arduino to control it is a simpler path than trying to get the raspi to do it. The two controllers are already talking to each other, so signalling intent shouldn't be too difficult. Since almost all of the soft-power-on stuff can be in the setup() routine and the power-off can be in the raspi with hard clamping help from the arduino, that can also help narrow down where problems are happening and give a little bit of redundancy.

Also, great work on the overlay! Why is the emulator on layer 10,000? That's silly.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

GPIO6 and GPIO16 are not used or connected to anything.

Hmm, I suppose this will work. Feels kind of bad throwing all the gpio-poweroff stuff away though... And I need to figure out what protocol to pass messages between the Arduino and the RPi over USB, but this might be "cleaner" if I can get it all to work. :thunk:

For absolute simplicity, GPIO?? to the arduino for the power-off command and only ever pass USB one direction. Bidirectional USB can be irritating. Unless you're already sending stuff bidirectional, in which case n/m. I seem to remember you had 3 or 4 "spare" GPIOs available.

Alternatively, have GPIO?? tied to the NMOS GPIO and, after the arduino powers the NMOS on, sometime later it just makes that an input. That way, when the pi pulls the NMOS low or de-asserts it, the arduino gets that signal by default. Seems a little bit more fail-safe as long as you trust the power protection and pullups/pulldowns (if enabled, probably not necessary).

I'm not sure if you can use GPIO6 or if you have to use 16, honestly. The GPIO-overlay stuff is a bit esoteric.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

Holy shiiiit pisss!! The piece fits perfectly! Assemblies are my new best friend.

WOOHOO! Great job! The iterations on this have been fascinating to watch. You're an inspiration.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

Cory Parsnipson posted:

It's time to add on all the power supply components and wire them together and then turn it on and cross my fingers and see what happens.

Bummer about the bracket being too short. Thankfully you're not getting these milled from billet aluminum and they take two weeks to show up.

Good luck with the power-on and don't let the smoke out!

Adbot
ADBOT LOVES YOU

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

That's great, man. Great video! I thought you were taking it outside to put next to a literal brick for scale.

Is it possible to get code into the arduino from its current assembly state and have it push ultra-verbose messages about what signals it's getting so you don't have to vivisect it and get in with the logic probe?

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