Hello. New here. I have both a Uno R3 and a R4 Minima. Is there a test which will return which board I am running on? I have slightly different behaviour at the moment.
Welcome to the forum
Are you aiming to write a single sketch and have it behave differently depending on the type of board that it is running on, or something else ?
Hello HeliBob,
I want a single sketch to run on both boards. The difference in behaviour is a bit complicated - it is to do with shutting down or resetting when I get voltage dips due to the Arduino operating solenoids. The R4 Minima behaves better and doesn't reset when pulling in the hold winding. The R3 resets every time, to I want to activate the hold winding right at the start when I can override the reset.
This isn't the best solution, - I have to eliminate the resets a better way, but it is a step along the way.
The solenoids operate from a 12V car battery. The Uno is powered with a buck converter which seems just to pass on the voltage dips to the 5V line.
Perhaps I should try a linear regulator?
It's not recommended to power the Uno R3 through the 5V output pin. You can indeed have problems as you describe if you do. It would be much better if you use a good quality buck to 9V and power the board through the Vin pin or barrel jack.
You should also have a 0.1uF capacitor and diode across the solenoid coil, this will help suppress noise and voltage spikes. Also keep the R3 away from the solenoid so it won't pick up the magnetic field of the solenoid.
Thank you Jim. I was thinking about trying the onboard regulator from 12V. But your suggestion of a buck down to 9V sounds like a better idea. Will have to wait till I get back to civilisation. How do I tell if it's good quality?
I have a diode across the solenoid. Will try adding a 0.1uF capacitor as well. R3 / R4 are 1m. away from the solenoid and in a metal enclosure.
I think now is the time to share a schematic, hand drawn and photographed is fine, indeed it's preferable to a Fritzy diagram, and some clear photos of what you have.
I think the hypothesis that there are voltage dips from the solenoids being passed on by the buck converters is unlikely to be correct.
At the risk of entering into a disagreement with @jim-p I don't see a problem with powering at the 5V pin from a buck converter.
I have them on a digital storage scope. Can try to download them if you like.
It doesn't seem to be dips that cause the resetting of the R3. It's oscillations at ~23 - 34 MHz which occur every time the buck converter does a switching. The amplitude starts around 2V p-p and dies down. Every time the buck converter does a switching. Just when it tries to pull in a solenoid, the oscillation amplitude increases to 2V p-p.
Perry, I will try to play a bit more with the scope tomorrow to work out how to download waveforms. Would be interesting to post here. It's my first time looking at things like this.
I will try to draw a schematic, but it might take a bit of effort. The basics is that the R3 is driving an off-the-shelf 5V relay board through an opto-coupler. The 5V relay then drives the solenoid. There is no direct connection to the R3. Only through the power supply rail.
I did not suggest that because depending on the battery, a fully charged 12V lead acid battery could be close to 13V and that out of the specified range of the R3
Thanks for that. I was wondering what the voltage input range would be. The battery is more likely to be at 14 - 15V when the diesel is running. Now I know not to try this.
Buy from a reputable parts distributor like Digi-Key, Mouser, Newark, Farnell, RS. etc.
Don't use a high current regulator. A 10A regulator won't work as well at 200mA as it will at 5A.
So is this a boost or fuel injector project on a deisel vehicle?
The automotive environment is full of EMI and all kinds of noise. When a battery is charging you could get really bad voltage spikes.
It's a controller for a diesel driven water pump on a farm. Yes, there is noise on the supply line. But the controller is fine with that if it can just get over pulling in the fuel shutoff solenoid and the voltage dip from the starter motor.
There is no fuel injection. Just a single-cylinder 16 HP Yanmar diesel.
A 12V battery can go as low as 10V when cranking an engine.
It may be a lot easier to just power the Uno with a separate battery.
If you are seeing oscillation on the MHz range then something is seriously wrong. I've yet to see a buck converter work at those frequencies, although I'm aware of some at 1 to 2MHz. Most are something like 50 to 100kHz.
What do you mean by 'does a switching'?
The buck converter switches in the kHz range. I have to check exactly the frequency. But every one of those kHz switchings initiates an damped oscillation at 23 MHz (R3) or 34 MHz (R4). Why? I will try to get a trace of these.
I finally changed the starter motor today (old one couldn't crank past the first compression) and got a trace of the voltage dip. The 12V went down to 3V! Of course the R3 shut down. How do I get past that?