PDM for Race car

Hey everyone,

Please forgive my lack of knowledge in regards to programming. I am very very fresh to Arduino and coding.

I am in the final stages of building a rally car and instead of spending hundreds on a power distribution module (PDM) Ive decided to build one.

I am able to code very basic things such as neonpixel displays and a few relay options.

However this build is bigger than what I'd normally undertake. I have 15 switches (momentary push button), 16 relays, 1 servo and one 8x8 led matrix.

I am wanting to make 12 push buttons latching for the 12 relays, 1 button pulse 1 relay every 250ms when button is held, Move servo when 2 switches are pressed (1 button moves servo up X degrees and 1 button moves servo down X degrees) and finally display either "P,R,N,1,2,3,4" on the display depending on the servo angle.

I am running this all off a Mega and I'm just hoping someone could please help me code this. I'm happy to pay someone to help code. I can do it for a single button to relay but I can't for the life of me combine it all together.

Regards

Nick

Start by using the built in IDE examples for buttons. When You master that look for servo etc.
Develope the project step by step, adding a new item when the previous thing works.

Don't wire all up and start coding. That is making debugging as difficult as possible.

1 Like

Quick question - you mean on the 8x8 LED matrix?

And the relays + servo are the entire output otherwise?

Do you have 16 or 12 relays?

This is all fairly easy programming, and using the Mega means you could be quite literal about the outputs and inputs as there are plenty of pins.

The section for buying software is here

but I think you might be able to do this youself with a bit of help.

Post any sketch that you have written (or even largely stolen borrowed) that works and does what you had in mind when you began. That will give us an idea of the kind of stuff you are already familiar with.

Srsly, this can be done with just the basic features of the language, stuff you'd probably want to know even if you purchased a solution. So you could make your own minor adjustments without keeping someone else in business. :expressionless:

a7

1 Like

+1.

In fact, you could build the project in the wokwi simulator and use LEDs as proxies for the relays, and serial printing instead of the LED matrix and so forth.

Build in sections that can work independently, those sketches can be kept around for testing when there is a fault of some kind.

I can often get the logic of a small project 100 percent functional before I ever touch real circuitry.

The drawback is sitting on my arm for too long at a stretch, no need to jump,up for parts and stuff. :expressionless:

a7

Thank you for the rapid responses guys.

I am not Infront of my PC at the moment as I'm at work currently.

I have a 16 relay module wired to the mega.

I have 13 buttons that I'd like to control the relays

2 buttons I'd like to control the servo and when I say "display" I mean the 8x8 led matrix.

Ti be brutally honest I tend to use chat gpt for most of my code as I have 0 idea how to do it myself as I'm still teaching myself.

I'm not so sure if a relay will like that.

Maybe you should describe what all those relays are going to control.

The project linked below isn't hitting your specs, I just post the link so you can see the wokwi simulator.

It is a switcher for effects, it has multiple banks of presets, but shows buttons controlling relays.

a7

say when chatgpt fails.

Every button is a Momentary 2 pin switch but I have written how i'd like the button to function.

Relay module

Relay 1 - Starter Trigger (D22)
Button - Momentary
Wiring - Normally Open
Function - Trigger relay Closed while button is held

Relay 2 - ECU Power (D23)
Button - Latching
Wiring - Normally Closed
Function - Trigger relay Open when button is pressed

Relay 3 - Front window wash (D24)
Button - momentary
Wiring - Normally open
Function - Trigger relay Closed while button is held

Relay 4 - Rear window wash (D25)
Button - momentary
Wiring - Normally open
Function - Trigger relay Closed while button is held

Relay 5 - Intercooler Spray (D26)
Button - Latching
Wiring - Normally open
Function - Trigger relay closed for 30 seconds. wait 2 mins and repeat until button is pressed again

Relay 6 - Drivers spotlight (D27)
Button - latching
Wiring - normally open
Function - trigger relay closed when button is pressed

Relay 7 - passengers spotlight (D28)
Button - latching
Wiring - normally open
Function - trigger relay closed when button is pressed

Both spotlights are wired to one switch.

Relay 8 - Rain Light (D29)
Button - Latching
Wiring - Normally Open
Function - trigger relay closed for 1 second then open for 1 second until button is pressed again

Relay 9 - Ignition cut (D30)
Button - momentary
Wiring - normally closed
Function - trigger relay open for 500ms and closed for 500ms while button is held

Relay 10 - Nitrous Spray (D31)
Button - momentary
Wiring - normally open
Function - trigger relay closed while button is held

Relay 11 - Overdrive gear (D32)
Button - latching
Wiring - normally closed
Function - trigger relay open when button is pressed.

Relay 12 - drivers low beam (D33)
Button - latching
Wiring - normally closed
Function - trigger relay open when button is pressed

Relay 13 - passengers low beam (D34)
Button - latching
Wiring - normally closed
Function - trigger relay open when button is pressed

Both low beams are wired to one switch

Relay 14 - Engine bay lights (D35)
Button - Latching
Wiring - Normally open
Function - Trigger relay closed when button is pressed

Relay 15 - spare currently (D36)
Button -
Wiring -
Function -

Relay 16 - spare currently (D37)
Button -
Wiring -
Function -

Shifter Set Up

Servo starts at 5 degrees when arduino is powered on and displays "P" on the 8X8 MAX7219 Matrix.

Switch 1 - D38
Switch 2 - D39

When switch 1 is pressed servo moves +15 degrees and displays "R" on the matrix

When switch 1 is pressed servo moves +15 degrees and displays "N" on the matrix

When switch 1 is pressed servo moves +15 degrees and displays "3" on the matrix

When switch 1 is pressed servo moves +15 degrees and displays "2" on the matrix

When switch 1 is pressed servo moves +15 degrees and displays "1" on the matrix

I also have a neutral switch that I would like to move the servo to 35 degrees when held and then move back to the position it was in prior to the switch being pressed.

and same in reverse. I am using a sim sequential to move a servo hooked up to my auto trans shifter and would like to see what gear I'm in.

Button Box

Engine Start - D40
ECU Power - D41
Ignition Cut - D42
Front Wash - D43
Overdrive - D44
Intercooler spray - D45
Nitrous - D46
Rear Wash - D47
Neutral - D48
Spotlights - D49
Rain Light - D50
Party - D51
Flash - D52

I have a "Party" button that I would like to trigger relays for the low beams and spot lights to flash. So when I push the button the drivers low beam and passengers spot light trigger at the same time and then trigger the passengers low beam and the drivers spotlight to flash like police lights. This is purely for show aesthetics. Hence why the low beams and the spotlights are wired to their own relay.

The "Flash" Button is to flash the spotlights every 500ms to signal that i intend to pass while on a push lap.

ALL PWM pins are free besides the servo in D7

I currently have no code for this project. all my code is for other projects on my nano (Neopixel strips for the house)

It's handy for small basic as projects but for something like this I thought maybe someone who knows what I'm trying to do would be better before I even wasted my time with CHATGPT and all its possible issues

This seems new. You've listed a buncha inputs (?) , labeled with some things that otherwise do not appear in your description, at least that is what I make of it.

And anyone, chatGPT included, will need more than

Relay 2 - ECU Power (D23)
Button - Latching
Wiring - Normally Closed
Function - Trigger relay Open when button is pressed

This means toggle the relay when the button becomes pressed, amIRight? To code a momentary push button to act like a push on, push off type?

a7

Sorry, yes when button is pressed toggle the relay. I should have made that clear. When I say "function" that is the desired outcome of what I'd like to happen when the button is pressed.

i meant when you not happy with results from other sources, then call me, i write sketch for you.

1 Like

And here an equivalent statement would be

the relay is closed if the switch is down

that is the relay just follows the pushbutton. Same same the others except open whilst pressed.

I'm still wondering about the Button Box. Lotsa inputs, what do they do?

I'd just let @kolaha write something to starpt with, it will be way closer than you'd get with chatGPT in any reasonable time. :- |

a7

1 Like

What is the best way to contact you directly? Thank you so much for your time so far.

write just here.
a schematic will be good, do you have one?

Nor currently no but I will be able to design one this weekend for you and I'll put it here.

Hey Kolaha,

Sorry for the delay in replying. Have been away for a track event.

I have created a schematic diagram but I am only able to save it as a picture. Do you have an email I can forward it to?

place here.