Custom microprocessor (Arduino, Pi, etc) Jeep project thread

I am now convinced in my own view , why this is the correct answer for my cooling needs. :)

001.jpg
 
The one time I looked into programmable logic controls, I realized that they weren't what I expected. You're right, some of the knowledge and experience crosses over, but not as much as I thought.

A lot of them are done with ladder logic or function block diagrams, and I have colleagues that will spend their entire career using nothing but those. They're great for people that don't have computer programming experience but I find them to be very limited in what you can do. When my company was on the hunt for a new control supplier in 2010 I looked far and wide to make sure the new one had a text programming capability because the previous one didn't. HVAC has locked into an IEC standard that has a standardized text language they call "Structured Text". From what I understand it's based on Pascal which is kind of an odd choice but if you can understand C, Java, basic, etc it's an easy jump once you get used to the syntax differences. The key is it already has standard libraries full of most of the functions I need to use like reading a temp sensor, communicating over a serial port, etc. The use of PWM is fairly rare and the frequency is standardized so I've never had occasion to mess with the clock. 🤣
 
  • Like
Reactions: sab
A lot of them are done with ladder logic ... 🤣

I haven't thought about ladder logic in decades - had a brief flirtation with same. Being used to procedural languages, LL didn't make a whole lot of sense - seemed crude by comparison, but it had its uses.

I've written a fair amount of Pascal code, which I'll take any day over C, but both share ALGOL's horrid syntax.
 
I haven't thought about ladder logic in decades - had a brief flirtation with same. Being used to procedural languages, LL didn't make a whole lot of sense - seemed crude by comparison, but it had its uses.

I've written a fair amount of Pascal code, which I'll take any day over C, but both share ALGOL's horrid syntax.

Ladder logic is really common in industrial automation, like an automated factory with conveyer belts, etc. I've only used it in an industrial controls class.

Thanks to all the functions I have at my disposal, I could write this entire fan controller program in about 8 lines with the controller I use at work because the input filter is built in, converting resistance to a temperature is already there, all I have to do is provide the intensity and identify the sensor. I don't even have to declare variables in the code, as it's in a separate area where I also populate about a dozen other properties.


But just for anybody who's curious about the differences between IEC 61131-3 Structured Text vs Arduino's flavor of C++ (I don't actually need any of the stuff before line 20 since the filters are already implemented when I read the .Val property from the input, but coded it just to demonstrate the minor differences in syntax for If-then and for-next loops).

1730162706496.png



1730153432274.png


Differences that trip me up the most when i switch back and forth:

1. having a colon in the assignment operator
2. C++ is less picky about data types - it'll let me mix int and float and anything else in an expression, while ST won't let me do that without a conversion, to the point that even a value has to have a decimal point if it's a float and if I want a function to do the same thing with a single and a double and a float, I have to have copies of the function for each one, for both inputs and outputs.
3. ST declares arrays like LCTsamples[0..29] or LCTsamples[1..30] or you could even do [5..23] if you woke up and chose violence...as odd as it sounds I do have situations where it makes sense to start an array with a nonzero index, but I get pretty used to the second number in the declaration being the last valid index in the array. In C++ I declare LCTsamples[30] which is the same thing as saying [0..29]. Even though I used a 30 in the declaration, there's no index 30, and if I call it, it'll be outside of the array and return some nonsense number but keep running, whereas ST will kill the program with a fatal error and tell me what index I tried to call, what the actual array dimensions are, and what function the error happened in (in hex, in order of execution).
 
Last edited:
Ladder logic is really common in industrial automation, like an automated factory with conveyer belts, etc. I've only used it in an industrial controls class.
The industrial computer company I worked for in the 80s and early 90s had a LL product. They had used it to control our wave solder machine, and tried to stick me with supporting it. I got out of that ASAFP...

Fun tuning PID loops in LL...

Your ST example does look a lot like Pascal, I find it far easier to comprehend than C - but I could do without the ALGOL syntax of either - everything uses that syntax now, and it just isn't comprehensible to this old hack. But most of my programming was done in assembly.
 
next challenge is packaging. For reasons like water, dust, heat, vibration, shock, electrical noise, etc, having a naked Arduino board hanging around in an offroad vehicle just won't do.

The most common way to address most of these issues is potting. That will stop further access to wiring, etc so I need to make sure it's fully tested out and all wiring is 100% done before I do that. I'll bring all the wires out through a single penetration and connect with butt connectors, and leave a USB pigtail for software updates.

I've never potted anything before, so if anybody has any suggestions I'm happy to listen.

1. Must effectively conduct heat away from the board so it doesn't soak and destroy itself. Must have a melting point higher than the max operating temp of the board. Nano ESP32 is rated for up to 105C.
2. Must be flexible enough to not break solder joints when things heat up and expand.
3. Transparent is a bonus so I could still see the LED's on the board.

Thinking I could mount it inside the grill near the (absent) OE ambient sensor, and just have a short whip for the fan control ambient sensor.

Electrically, I've come across some things suggesting that an automotive charging system is prone to significant voltage spikes that can smoke sensitive electronics. The Nano ESP32 is supposed to be able to accept up to 28V so I was initially thinking of wiring it directly to switched 12V but I can't have my fan quitting on me over a random transient electrical spike, so I'm considering disassembling a small cigarette lighter-USB power supply and building that into it as well. I'm sure I could figure out how to build something but it won't be as efficient (from a time standpoint) as buying something that already exists.

For the external circuitry I have some a small PCB board...2" x 1.5"..which is more than double the size of the Arduino Nano itself. :ROFLMAO: Should be plenty of room for a few resistors and some transistors. Here they are with a microSD card for scale.

PXL_20241031_182352509.jpg


Don't have much free time left today so hope to be able to draw up a rough draft wiring schematic and maybe get some of it wired up tomorrow.
 
If you're not crunched for space with where you're planning to locate it, getting an enclosure with a gasket would be simpler and less permanent than fully potting it. Probably more tolerant with thermals, too. Can even get transparent options or windows for the LED visibility!
 
  • Like
Reactions: hear
If you're not crunched for space with where you're planning to locate it, getting an enclosure with a gasket would be simpler and less permanent than fully potting it. Probably more tolerant with thermals, too. Can even get transparent options or windows for the LED visibility!

I agree with it being more simple and less permanent. In my research I found a lot of folks cautioning against that because of the propensity for trapped humidity to condense on the inside of the enclosure and then drip onto the board. The suggested mitigation was a weephole in the bottom - I would have no worries with that in a stationary application at home, but for whatever reason I'm nervous doing that in an operation-critical automotive application.

I still don't have the fan itself so I have plenty of time to figure this out as well as to be convinced of the right way to do it. I only thought of potting because that seems to be how the vast majority of automotive electronics are protected. I will say I see a lot more people doing it your way than via potting, but most of them are using it for car audio or reading OBD2 live data, not something that will cripple the vehicle if it fails.

The more I think about this the more I think maybe I should build 2 of these so I have a spare. :ROFLMAO: And on that note, I think what I'll do for the connection pigtail(s) is Weatherpack connectors. I think I have 8 pins total, and I think weatherpack goes up to 6, so I'll group them in a logical fashion, like one connector consisting of things that tie into the vehicle harness and another connector of things that don't.

1730402667887.png
 
Ladder logic is really common in industrial automation, like an automated factory with conveyer belts, etc. I've only used it in an industrial controls class.

Thanks to all the functions I have at my disposal, I could write this entire fan controller program in about 8 lines with the controller I use at work because the input filter is built in, converting resistance to a temperature is already there, all I have to do is provide the intensity and identify the sensor. I don't even have to declare variables in the code, as it's in a separate area where I also populate about a dozen other properties.


But just for anybody who's curious about the differences between IEC 61131-3 Structured Text vs Arduino's flavor of C++ (I don't actually need any of the stuff before line 20 since the filters are already implemented when I read the .Val property from the input, but coded it just to demonstrate the minor differences in syntax for If-then and for-next loops).

View attachment 568606


View attachment 568564
Structured text looks a lot like PL/SQL or Ada
 
  • Like
Reactions: freedom_in_4low
Potting: I haven't done it. But check this page at Mouser for ideas. Conformal coatings, Epoxy compounds, Potting compounds:
https://www.mouser.com/c/tools-supplies/chemicals/?q=potting
The actual potting compounds page price will scare you. But conformal coatings (same thing, pretty much) is much more reasonable, and the description gives it away: flexible epoxy. As long as it's not electrically conductive, perhaps any old epoxy would do. And you could mount the controller under the dash in a box, at least until you've got it 100% perfect.

I wouldn't put 12V into a microcontroller board, even if it says it can take it. They have itty-bitty voltage regulators which will run HOT. It might be best to regulate the 12V down to 5 to 8 volts to feed the Nano. And that gives an additional layer of protection.

Spike protection: I would just add a TVS (Transient Voltage Suppression) Diode to the circuit. A 1.5KE18A should be about right for a 12V circuit, before a voltage regulator down to 5V for the Arduino / Nano ESP32.
https://www.mouser.com/ProductDetail/STMicroelectronics/1.5KE18A?qs=f9uBznyCLha8iICfeZroYQ==
Here's a clip from an old automotive project of mine: Schottky diode for reverse polarity protection, TVS for spike suppression, and overkill inductor for more spike suppression (which I would leave out).

1730405955956.png
 
Potting: I haven't done it. But check this page at Mouser for ideas. Conformal coatings, Epoxy compounds, Potting compounds:
https://www.mouser.com/c/tools-supplies/chemicals/?q=potting
The actual potting compounds page price will scare you. But conformal coatings (same thing, pretty much) is much more reasonable, and the description gives it away: flexible epoxy. As long as it's not electrically conductive, perhaps any old epoxy would do. And you could mount the controller under the dash in a box, at least until you've got it 100% perfect.

thanks for that link. Epoxy is probably the most common I'm coming across, but I'm also seeing polyurethane products that tend to be more flexible. MG Chemicals makes a clear epoxy, which would be cool, but it's $100 for a 375mL bottle vs about $60 for their black epoxy or flexible polyurethane.

I wouldn't put 12V into a microcontroller board, even if it says it can take it. They have itty-bitty voltage regulators which will run HOT. It might be best to regulate the 12V down to 5 to 8 volts to feed the Nano. And that gives an additional layer of protection.

Spike protection: I would just add a TVS (Transient Voltage Suppression) Diode to the circuit. A 1.5KE18A should be about right for a 12V circuit, before a voltage regulator down to 5V for the Arduino / Nano ESP32.
https://www.mouser.com/ProductDetail/STMicroelectronics/1.5KE18A?qs=f9uBznyCLha8iICfeZroYQ==
Here's a clip from an old automotive project of mine: Schottky diode for reverse polarity protection, TVS for spike suppression, and overkill inductor for more spike suppression (which I would leave out).

View attachment 569085

that's not bad at all. I'll definitely think about making my own before I take one apart. Would be nice to fit it all on one PCB.

Is that basically what's inside one of these?

1730410571520.png
 
thanks for that link. Epoxy is probably the most common I'm coming across, but I'm also seeing polyurethane products that tend to be more flexible. MG Chemicals makes a clear epoxy, which would be cool, but it's $100 for a 375mL bottle vs about $60 for their black epoxy or flexible polyurethane.



that's not bad at all. I'll definitely think about making my own before I take one apart. Would be nice to fit it all on one PCB.

Is that basically what's inside one of these?

View attachment 569097

I've gotten some MG conformal coating stuff for a lot cheaper than that before, I'll have to go dig up my digikey order history and see if it might be suitable for you.
As a note of caution for using other various epoxies that aren't explicitly for electronics, some of them will emit some corrosives while curing that will ruin your board. Something to watch out for!
 
Is that basically what's inside one of these?

I think the better ones will have a TVS, the cheapo ones might have an MOV (if any protection at all) which will break down over time. And a 12V-to-5V step-down regulator, of course.

Epoxy is probably the most common ...

The epoxies I've used (not very many) have been soft enough to mark with a fingernail. I suspect that's flexible enough for potting. The wires and components aren't expanding/contracting very far with temperature.

I just checked some cured J-B Weld Steel Reinforced Epoxy. Not the slightest bit electrically conductive. I may try it on something someday.
 
  • Like
Reactions: freedom_in_4low
I agree with it being more simple and less permanent. In my research I found a lot of folks cautioning against that because of the propensity for trapped humidity to condense on the inside of the enclosure and then drip onto the board.
This is getting into my area of expertise. There's a couple of ways to handle this. First, in a small enclosure, toss a desiccant pack in, close it up and forget it. Just make sure its really, truly sealed, and make sure the desiccant is actually dry before you use it.

If you're anal and/or the enclosure is larger, you can flush it out with dry nitrogen - but this takes the addition of suitable fittings and check valves to do it right. Still, blasting dry nitrogen at the thing while you seal it up beats a poke in the eye with a mascara brush. I used to do basically "all of the above", and we had sensors to tell us if there was a containment breach. A humidity sensor, a water sensor at the lowest point, and a pressure sensor as we'd pressurize the thing to 5 PSIG with the nitrogen so we'd know if we had a leak.

All that is overkill for this use case, use a desiccant pack and seal it. As far as potting compounds go, there are "re-entrant" types - messy but doable. We mostly used 3M "Scotchcast" - very permanent - but it was mostly on cable splices and occasionally on small electronics boards that didn't dissipate any heat.
 
This is getting into my area of expertise. There's a couple of ways to handle this. First, in a small enclosure, toss a desiccant pack in, close it up and forget it. Just make sure its really, truly sealed, and make sure the desiccant is actually dry before you use it.

If you're anal and/or the enclosure is larger, you can flush it out with dry nitrogen - but this takes the addition of suitable fittings and check valves to do it right. Still, blasting dry nitrogen at the thing while you seal it up beats a poke in the eye with a mascara brush. I used to do basically "all of the above", and we had sensors to tell us if there was a containment breach. A humidity sensor, a water sensor at the lowest point, and a pressure sensor as we'd pressurize the thing to 5 PSIG with the nitrogen so we'd know if we had a leak.

All that is overkill for this use case, use a desiccant pack and seal it. As far as potting compounds go, there are "re-entrant" types - messy but doable. We mostly used 3M "Scotchcast" - very permanent - but it was mostly on cable splices and occasionally on small electronics boards that didn't dissipate any heat.

I was hoping you'd chime in here. The desiccant pack sounds promising. I could do a conformal coating as well just to be sure.

What are your thoughts on shock/vibration?
 
I was hoping you'd chime in here. The desiccant pack sounds promising. I could do a conformal coating as well just to be sure.

What are your thoughts on shock/vibration?

Conformal coating certainly wouldn't hurt, although we never bothered.

Shock/Vibration is relatively easy - secure everything. In another life I pre-qualified - I think it was eight - identical systems for NASA. The through hole components had to be staked in place with some kind of glue.

In general, bolt down or otherwise secure connectors if you're worried about them coming apart - that's why Jeep used those annoying little latches everywhere. Don't rely on PC grade connectors to stay in place without help. Blah, blah, blah.
 
  • Like
Reactions: freedom_in_4low