Hello, I am new to arduino and this forum. I am wanting to use a arduino board to control a solenoid. I want to switch on power (12VDC) to this solenoid at a specific frequency. Also when power is sent to the board (switch on) I want a short supply of 12VDC to the solenoid. Can anyone give me guidance with this project? I am clueless.
What would a frequency do, that simply on off don't?
Do you know the timing of that solenoid? How much time to retract the armature? How much time to fully restore the armature? The sum of those time will be the shortest time for your frequency.
That depends on your circuit and what frequency the solenoid can do. Also your design is dependent on the voltage and current ratings of the solenoid.
What is the task of the program in real life?
I need a solenoid to control an exhaust valve on a IC engine. A signal from the ignition would trigger the arduino @ 6000 rpm if the rpm were to drop below 6000 then I would want the solenoid to close the valve. The said engine does have a unit to work this but it has developed a fault and I believe it is irreplaceable.
I think my fist post wasn't too clear. I would want to use a signal from an engine ignition system to trigger the arduino to energize or open a solenoid, this would want to happen at an rpm of 6000. If the rpm were to drop below 6000 rpm then I would want the solenoid to close.
Activate a solenoid @ 6000 rpm, below 6000 rpm close the solenoid. A signal would be from an ignition system of a IC engine.
Simply start by coding a frequency counter with an interrupt input signal.
It is recommended to decouple both systems by using an optocoupler for the input signal.
Look at the pulseIn()
function. It should do what you need. Alternately, you could write a frequency count routine, but I think measuring pulsein a few times and taking an average is probably good enough.
Thank you, sorry for being so ignorant but how do I do this? I am brand new to this, I have no previous experience.
Sounds like potential for serious damage to your engine? Why tackle a relatively complex project like this from a cold start?
A solenoid ONLY pulls the armature inward. Some type of spring is needed to return the armature. Solenoids usually have a spring only strong enough to just return the armature to it's rest position. What in your project returns the valve to it's normal position?
Welcome! I think this is what you are trying to build. GP RPM limiter The reason I suggest this is it does not appear you have enough experience in automotive electronics. Here is some reading if you want to keep going.
Arduinos are designed for experimentation and learning, often used with breadboards and loose wires, which can become unreliable if vibrated. They are not built for harsh, dirty, or electrically noisy environments commonly found in industrial, automotive, or other commercial applications, making them unsuitable for such settings.
To ensure we can provide the most accurate assistance, please include detailed information about your setup. Specify the exact board, shield, wiring configuration, and power sources you are using. An annotated schematic is ideal, as it provides a clear overview of your setup, but be sure to also include links to the technical specifications of your hardware components.
Before posting your code, please review the forum guidelines and use code tags for better readability. Also, provide links to the technical information about your hardware, and include a preliminary schematic that shows all power, ground, and connections. For additional guidance, you can refer to this link: Useful Links and Tutorials. Note that in this context, breadboard diagrams are not considered proper schematics.
Valuable Resources for Automotive Electronics:
- STMicroelectronics Application Note AN2689:
This application note provides guidelines on protecting automotive electronics from electrical hazards, focusing on design and component selection. Reading this will greatly enhance your understanding of automotive circuit protection.
Read AN2689 - Analog Devices: Automotive Electronics Design:
This article distills key insights into designing automotive electronics, offering practical advice for engineers.
Read the article - Diodes Incorporated: Transient Voltage Suppression in Automotive:
Learn about techniques to protect automotive circuits from transient voltage, which is critical for ensuring reliable operation in harsh conditions.
Read the article - AEC-100 Standards Webinar:
This webinar from Monolithic Power Systems provides a detailed overview of AEC standards, essential for understanding automotive electronics requirements.
Watch the webinar - Understanding Automotive Electronics, An Engineering Perspective by William B. Ribbens:
This comprehensive book offers an in-depth look into automotive electronics from an engineering perspective, making it an invaluable resource.
Access the book
These resources should provide a strong foundation for anyone involved in automotive electronics design. If you need further help or more resources, feel free to ask!
==> ==============[ CAN ]======================
Setting Up Arduinos with CAN using MCP2515 Modules
I suggest starting with a few Arduinos and setting them up for CAN communication using MCP2515 CAN modules and Cory Fowler's library: MCP_CAN_lib on GitHub. The send and receive examples work great, and you can combine them to send and receive within a single Arduino UNO. Note that the modules cannot acknowledge themselves; CAN communication requires at least two nodes for acknowledgment.
Important Tips for Setting Up Your CAN Bus:
- Connect Grounds: Ensure that the ground from each Arduino UNO is connected to reduce noise.
- Bus Termination: Properly terminate both physical ends of the CAN bus with 120 Ohm resistors. Failing to terminate both ends will cause communication issues. You can measure the resistance across the CAN leads using an ohmmeter; a resistance close to 120 Ohms indicates proper termination. Only two terminators are needed in total—none are required for nodes in the middle of the bus.
- Crystal Configuration: MCP2515 modules may have different crystals; be sure to set the initialization code to match the specific crystal frequency of your module. Check the module’s specifications for guidance.
- CAN Specification: The CAN protocol has two parts:
- Part A (CAN 2.0A): Standard format with an 11-bit identifier.
- Part B (CAN 2.0B): Extended format with a 29-bit identifier.Most devices will likely use CAN 2.0A. The MCP2515 module connects via SPI and is compatible with other SPI devices, but it’s best to start with just the CAN module first.
- Minimum Two Nodes Required: A CAN bus needs at least two active nodes because the protocol requires an acknowledgment within each frame. The receiver must be active during transmission to provide this acknowledgment. If the message isn’t acknowledged, the transmitter will register an error and increment its internal error counter. Once the error count reaches its limit, the transmitter shuts down, a process managed by the CAN controller transparently.
For a more in-depth understanding, refer to this helpful tutorial: Interfacing MCP2515 CAN Bus Module with Arduino.
You have referred to the signal from the ignition several times. What is this signal?
No problem. If you don't have much programming experience, Arduino can seem daunting, but it's designed to be pretty easy.
You'll need to install the Arduino IDE of course and get a board. An Arduino nano (genuine or clone doesn't matter) is more than enough. Install the basic blink.ino sketch and understand how it works.
The first hurdle you need to cross is interfacing the pulse signal to the arduino so you can read it. An SparkFun Opto-isolator Breakout is a generally safe way of doing this.
Next step is to read the pulses. By this point you should be able to read the documentation on PulseIn() and understand how to use it. A good test would be to read the result of pulsein and print it to the serial terminal and observe how the output changes along with RPM.
By that point you should have advanced far enough to be able to figure out the rest. Don't let the people saying that you have to be expert in all things automotive electronics stop you. If we all had to do that, nothing would ever get done. I don't need to be a trained automotive technician to replace a head gasket; I just need to know how to read a repair manual.
Thank you so much for your help. Where on the board would I connect the signal wire? Also the solenoid is 12VDC will the Arduino board handle this? I shall buy a board.
Thank you again.
I only know that it is from a small trigger coil. As N-S poles of the magneto pass this trigger it sends a signal to the CDI and to the box which controls the exhaust valve, this box is no longer working properly, this is why I need something to mimic it.
You need to know a bit more in order to program your Arduino to be able to take information from that signal. You need to know the voltages of that signal and the time properties, such as does the signal have pulse information or is it voltage information.
If it's a pickup coil, it's almost certainly just a pulse signal. My concern would be whether ir not it has enough drive to power an optocoupler.