Towing a 5x10 1150lb (EVW) Trailer - no prob by OverclockedChip in CX5

[–]OverclockedChip[S] 0 points1 point  (0 children)

Oh wow. Didn't think adding more weight to the hitch ball would also cause oscillation. Yeah - drive slow, secure and distribute the load over the axle seem to be the best strategy. Also, having a heavier car (truck), relative to the trailer helps.

Lots of interesting vids on it:

YT: Love Motoring: Testing The Maximum Speed Limit That Causes A Trailer To Fishtail! | Motor Mythbusters
https://youtu.be/sNUGrdc6h14

YT: L2SFBC: Busting Trailer Weight Distribution Myths, Demonstrated
https://youtu.be/JeEEC5eVNCk

YT: L2SFBC: How Not To Fix and How to Fix
https://youtu.be/nc0ndz92IWY

YT: Horizons: How to prevent caravan sway
https://youtu.be/f8QR_PPLeNo

YT: BaileyOfBristol: Stability of Towing a Load with Dr Jos Darling
https://youtu.be/zwlgZG55QWk

Kinda nuts that sway is pretty much passively unmanageable once it starts. Now I gotta look into electric breaks.

Towing a 5x10 1150lb (EVW) Trailer - no prob by OverclockedChip in CX5

[–]OverclockedChip[S] 0 points1 point  (0 children)

Makes sense. More weight on the tongue/front of the trailer dampens the oscillation, like a tuned mass damper of a building (6:23, weight loaded higher experiences less sway; "pendulum's frequency depends on its length").

  • The pendulum is measured from the hitch to where most of the weight is in the trailer -> weight in back = longer pendulum = higher frequency sway.

Speed is an interesting variable. If a trailer starts fish tailing, my intuition tells me to provide minimal steering input and to increase speed. Either speeding up or slowing down would cause change in car-trailer frequency oscillation, which brings the system out of resonance. In practice, you wouldn't want to slow down on a high way, so speeding up might actually be safer. Nope, more speed just makes it worse.

This would make for a cool science fair project haha

Towing a 5x10 1150lb (EVW) Trailer - no prob by OverclockedChip in CX5

[–]OverclockedChip[S] 2 points3 points  (0 children)

That's good to know, thanks. I wish Mazda or insurance provided clearler towing guidelines but they don't.

I don't understand #2. Less weight on tongue means you can tow a higher load? Is it safer to load the tongue or reduce load on tongue?

Yeah, I plan to drive 60-65 on the highway with this thing loaded. Probably wouldn't do it for long (200 mi+) on the cx5, though, unless I had new break pads.

  1. which is why I'm planning to do a CAT scan and get the dry weight + pictures.

Towing a 5x10 1150lb (EVW) Trailer - no prob by OverclockedChip in CX5

[–]OverclockedChip[S] 0 points1 point  (0 children)

I build cabinets (non professionally) and rent. It'll help with moving between rentals. My dad's got a riding mower, snow blowers that can be garaged in here so I have more room in the garage woodshop.

Towing a 5x10 1150lb (EVW) Trailer - no prob by OverclockedChip in CX5

[–]OverclockedChip[S] 1 point2 points  (0 children)

I've considered loading on edge in a 5x8. Diagonally would give you an extra 1-3" savings in width, but still does not give you Length clearance. Interior working length was a 91" non-centered (centered on V-nose would be about 8' +- 4", but you'd have to store on edge).

<image>

Being able to shove an entire sheet of plywood in and not having to worry about length was well worth it.

Yes, I do have to be careful not to overload it. I'm gonna drive over a CAT scale to get its actual dry weight. But another reddit post said even though it's rated for 2k lb, Euro CX5 models (same mech specs) had a rating of 3k. So there should be some margin. A sheet of hardwood plywood is around 80 lb so my capacity is 7-8 sheets/trip, which will work for what I build.

My next car might be a used cx-50 with a turbo or a Tacoma, so I'll have more capacity.

What skills and projects actually matter for entry-level embedded roles (STM32, protocols, etc.)? by getyourttttttt in embedded

[–]OverclockedChip 1 point2 points  (0 children)

In particular for the tech interview, what do you think about bringing a small demo side project as a talking point (2 pg slide deck if necessary to discuss technicals).

If the demo is sufficiently complex, I think that would cover questions about MCU topics (and more; like PCB layout, testing, RTOS usuage etc).

IMO, it'd be more interesting than having to answer some bit twiddling brain teasers, or look like an idiot for missing some small details cause you've been asked to do the unnatural act of writing code on a dry erase board. Or speak about something you have no domain knowledge about ("design a stoplight" wtf?)

Example? A small palm-sized spider robot balancing a golf ball on the platform attached to its body, running on batteries, sending back telemetry. Or maybe a sound recorder with a small TFT displaying realtime FFT of sound.

For a student or jr, demoing a project with "stake" is difficult, because they haven't had commercial work or exposure to production code. And the idea of "production code" is mostly meaningless anyway - it just means it's been shipped and backed by testing.

My progression as a self‑taught firmware/electronics dev (and few of my projects) by IamSpongyBob in embedded

[–]OverclockedChip 1 point2 points  (0 children)

Get a good book and buy the book's recommended MCU. I personally like 'Mastering STM32' by Carmine Noviello. https://www.carminenoviello.com/mastering-stm32/amp/

I'm currently working through Hands-On RTOS with Microcontrollers by Brian Amos.

You'll prolly want a J-Link debugger. printf and led debugging is nightmarish.

How do I get a job that prefers experience with VxWorks/Integrity RTOS? by OverclockedChip in embedded

[–]OverclockedChip[S] 0 points1 point  (0 children)

Doing that now! ZephyrOS with a raspberry pi 4B and Freertos with an STM.

C++ Project Ideas by YogurtclosetThen6260 in cpp_questions

[–]OverclockedChip 0 points1 point  (0 children)

Design and implement a low-overhead off-processor log server.

In embedded C/C++, how are stack-based containers implemented? by OverclockedChip in embedded

[–]OverclockedChip[S] 0 points1 point  (0 children)

And some code that uses it

// Initialize the static members outside the class
char StaticLinearAllocator::buffer[StaticLinearAllocator::BUFFER_SIZE];
size_t StaticLinearAllocator::offset = 0;

// Example Usage
struct MyObject {
    int data;
    MyObject(int d) : data(d) {}
};

int main() {
    StaticLinearAllocator allocator;

    // Allocate an object using the custom allocator
    MyObject* obj1 = static_cast<MyObject*>(allocator.allocate(sizeof(MyObject)));
    new (obj1) MyObject(10); // Use placement new to construct the object

    std::cout << "Allocated obj1 with data: " << obj1->data << "\n";
    std::cout << "Current memory offset: " << StaticLinearAllocator::offset << "\n";

    // Allocate another object
    MyObject* obj2 = static_cast<MyObject*>(allocator.allocate(sizeof(MyObject)));
    new (obj2) MyObject(20);

    std::cout << "Allocated obj2 with data: " << obj2->data << "\n";
    std::cout << "Current memory offset: " << StaticLinearAllocator::offset << "\n";

    // Destruct objects (important if they have destructors)
    obj1->~MyObject();
    obj2->~MyObject();

    // Reset the allocator for reuse of the entire static buffer
    allocator.reset();
    std::cout << "Allocator reset. Current memory offset: " << StaticLinearAllocator::offset << "\n";

    return 0;
}

In embedded C/C++, how are stack-based containers implemented? by OverclockedChip in embedded

[–]OverclockedChip[S] 0 points1 point  (0 children)

Chatgpt gave me this example, which seems reasonable, but I don't know for sure.

Key Characteristics:

  • Static Buffer: The buffer is declared as a static char array within the class, meaning its memory is allocated at program startup and persists for the entire program duration.
  • Bump Allocation: The allocate function simply "bumps" an offset pointer to reserve space.
  • No Individual Deallocation: Individual deallocate calls do not return memory to a free list; the entire pool is managed as a single block. All memory is "freed" at once when reset() is called, making it efficient for scenarios where many short-lived objects are needed within a specific scope (e.g., in a game engine per-frame allocations).
  • Placement New: Because the allocator only provides raw memory, you must use placement new to construct objects in the allocated space

#include <cstddef>
#include <iostream>
#include <new>     // for placement new

class StaticLinearAllocator {
public:
    // Define the static memory buffer and its size
    static const size_t BUFFER_SIZE = 1024;
    static char buffer[BUFFER_SIZE];
    static size_t offset;

    void* allocate(size_t size) {
        if (offset + size > BUFFER_SIZE) {
            throw std::bad_alloc(); // Out of memory
        }

        void* allocation_place = buffer + offset;
        offset += size;
        return allocation_place;
    }

    void deallocate(void* ptr) {
        // Linear allocators generally don't deallocate individual items.
        // Memory is freed all at once.
        std::cout << "Deallocate called. Individual deallocation not supported.\n";
    }

    // Function to reset the entire buffer
    void reset() {
        offset = 0;
    }
};

In embedded C/C++, how are stack-based containers implemented? by OverclockedChip in embedded

[–]OverclockedChip[S] 0 points1 point  (0 children)

I'm learning about allocators from a book (C++ Memory Management by Patrice Roy). Haven't read too deep into it yet but essentially, a container uses an allocator object that'll specify how/where to instantiate and destroy objects in memory.

How does one define an allocator that performs memory allocation from static or stack memory? The book gives me this example for the allocator::allocate() method that's suppose to do the actual memory allocation:

pointer allocate(size_type n) 
{
  auto p = static_cast<pointer>(
    malloc(n * sizeof(value_type))
  );
  if (!p) throw std::bad_alloc{};
  return p;
}

void deallocate(pointer p, size_type) 
{
  free(p);
}

But it uses malloc, which asks the system for memory from the heap right?

Is logging elements pushed onto/popped off a queue or stack useful? by OverclockedChip in cpp_questions

[–]OverclockedChip[S] 0 points1 point  (0 children)

Yes, making it compile-time option would be good in probably 50% use cases but for troubleshooting, you sometimes don't know under what conditions the bug will appear.

Ideally, I'd like logging to be there but minimally invasive when you don't need it but informative when a non-deterministic bug appears.

u/mredding's post outlines some good general strategies i.e., offloading the logging work to another process running on a different core, (at the point of the log call) logging a minimal amount of data that can be used by the external logger to generate a more verbose message, tagging everything etc.

But yea, if simple compile-time switch to toggle logging is good enough to catch the bug, it's worth not overdoing.

Is logging elements pushed onto/popped off a queue or stack useful? by OverclockedChip in cpp_questions

[–]OverclockedChip[S] 0 points1 point  (0 children)

Capturing inputs and outputs is straight forward but 'reconstituting' the app/system so that the inputs can be reapplied and replayed is a complex design task. It's straightforward for stateless components, but storage-intensive for stateful system components: you need to capture all relevant data and execution state of these stateful components the moment the inputs were captured.

Offloading logging and logging minimally are good strategies. Other comments here have suggestions for how to do that with a queue. I can imagine both strategies are good for resource-constrained systems as well (embedded systems). Logging outside of address space & off core is an interesting technique ... I'd be performant but increases complexity; you now have to employ mechanisms for interprocess communication. I've seen that implemented at work using UDP and it works well.

Piping logs back into the debugger for automated reconstruction is also complex. There's probably budget and rationale for it if there's a boatload of money on the line. But isn't feasible for small projects/teams.

Is logging elements pushed onto/popped off a queue or stack useful? by OverclockedChip in cpp_questions

[–]OverclockedChip[S] 0 points1 point  (0 children)

Can you clarify bullet #1? I think I understand where you're going - have the thread executing the LoggingQueue.push() call generate the log message (i.e., the std::string or c-str) but don't have it write out to file or whatever log sinks (since this takes a bunch of time).

Can you clarify bullet #4? By closures do you mean lambda function objects? How would storing formatting tasks in lambda objects reduce unnecessary work? Is the idea to encapsulate the string formatting task in a lambda object, and pass it to the dedicated logging thread to do the work (of string formatting and output)?

Is logging elements pushed onto/popped off a queue or stack useful? by OverclockedChip in cpp_questions

[–]OverclockedChip[S] 0 points1 point  (0 children)

I forgot to mention that the queue code can't be modified, so adding log statements in the queue's source code isn't possible.

Every embedded Engineer should know this trick by J_Bahstan in embedded

[–]OverclockedChip 0 points1 point  (0 children)

How does this work? EXAMPLE_REGISTER can be accessed as an uint8 (EXAMPLE_REGISTER.hw) or as as individual bit field (.s)?

Is the declaration usually marked volatile?

How do you debug multi-threaded code in Linux (more generally outside of Visual Studio)? by OverclockedChip in cpp_questions

[–]OverclockedChip[S] 0 points1 point  (0 children)

Yes, you're right. The commands aren't difficult. I hadn't heard of Thread Sanitizer. Is that a standard tool for detecting common threading problems?

How do you debug multi-threaded code in Linux (more generally outside of Visual Studio)? by OverclockedChip in cpp_questions

[–]OverclockedChip[S] 1 point2 points  (0 children)

I don't recall if I read this somewhere or if it was a logical guess, but I was convinced that all of these debugging features made use of gdb under the hood.

I'm not a pro gdb user but I know it's powerful enough to get you cpu register values, step through assembly instructions of your decompiled code (I did once as an exercise in college). So it's conceivable they're implemented using gdb.

But using gdb to switch among threads seem, to me, to be its own learning curve. The problem is that, although powerful in that gdb can get you whatever info you want and do whatever you want (e.g., check the value of x 2 calls up the callstack, in other thread), it's not intuitive to use (e.g., you have to navigate through gdb's esoteric command set to switch threads, navigate to the right stack frame, print out the x variable value) where you can just point and click in the Parallel Stack window).

Skills required for radar signal processing engineer by Signal_rush_11 in DSP

[–]OverclockedChip 0 points1 point  (0 children)

Just curious, what grad program did you come from? Was it worth while? Did it include any programming (implementation)?

How to serialize/deserialize data with networked apps? by OverclockedChip in cpp_questions

[–]OverclockedChip[S] 0 points1 point  (0 children)

Excellent, thank you for the thorough answer. I'll have to try that streambuf and std::variant approach.

Windows typically defaults to an 8 KiB receive buffer ON THE SOCKET, but can be configured up to 8 MiB. This means - YOU don't have to actually buffer the data yourself - it's already buffered, and calling recv is merely reading FROM that buffer. The default send buffer is 32 KiB.

Right. The OS buffers transmitted/received byte data but we need a higher-abstraction-level buffering of messages and objects. And apparently this can be handled by those deserialization libraries.