First off I apologize if this is the wrong category.
This is my first project with the Nano. I started with the UNO... fried that :-).
This device reads a tachometer sensor and kicks a relay on and off at a specified threshold. The device has a Nano, buck for 12v-5v, variable reluctance sensor ic (nvc1124), high-low voltage converter, 2 dip switches, I2C IO expander, and relay. Those are the major components.
I've moved from breadboard to prototype board, and tested the device. What I'd like to do now is move to a PCB. I'm using KiCad. I'm still getting use to KiCad. I've produced a schematic and PCB, and run the ERC, and DRC. The ERC has only a couple of errors for the 5v and Gnd lines of the Nano. I believe that is because it shows those lines as output and the output for the buck conflicts. The DRC is clean.
Have I left something out? The prototype works as expected. I'm more nervous about whether I overlooked something that is harmful in some way or don't have some kind of protection in place.
Driving a relay directly from a pin, even a small 40mA G5Q relay, is bad practice.
You will burn your Nano sooner or later.
Use a transistor with 1k base resistor (470ohm if the coil draws more than 40mA).
And don't forget a kickback diode across the coil.
Why the port expander for the switches. Most of the Nano pins are not used.
Can't you use a 4*4 matrix or resistor ladder for that.
Leo..
Hey thanks! I'll look into that. I had an opto coupler relay on the prototype board, but couldn't find a suitable part in Kicad and came up with that.
Simply put I thought I needed another 8 bit dip for configuration, and it was just simpler to use the expander. I was also considering using an even smaller micro.
I considered a resistor ladder but makes more code bloat (I thought). I don't know what a 4*4 matrix is?
A dipswitch is a closed/open switch, rather than a momentary in an nxn keypad. Totally different thing. You've done the right thing if you really need the dipswitch, but I'd be looking at using EEPROM instead. Store your settings in non-volatile memory, avoid the hardware!
C
Thought of that too. But, I still need the ability to input the settings right?
So are you saying the matrix solution above can not be employed for (if not using expander), the use of 8 pins for a 16bit result. I know I only need 12, so a real savings of 4 pins.
The thing with a dipswitch scan is, any or all switches can be closed or open. The scan utility generally reports only one button, not n of n. So, no, not usually.
As far as the settings, I've gone at this a couple of ways. In one instance, I had a display, so I simply wrote the code so that if you did a certain thing when the Arduino came out of reset, it prompted for the settings, and stored them to EEPROM. In a second instance, the EEPROM content wasn't changeable in-situ, so I wrote a sketch that simply stored the data to the EEPROM, then a loaded the "real" sketch, which simply read the EEPROM. A third technique would be to allow yourself to plug in the computer and reset the unit, then use prompts via serial monitor to set the EEPROM contents.
There are many ways to skin the cat, if you want to investigate any of these further just reply, asking about them. (i hate dip switches, and configuration jumpers)
C
Camsysca,
Thanks. This device is pretty much going to be set once per application, and most likely never changed after that. I don't like dips necessarily either. But, they do have their place. I should really move code to setup(), and only do once at power cycle anyway.
Wawa,
Here's an update of schematic with the transistor driving the relay. I believe this is what you were referring too? Thanks for the input on this.
Sorry, deleted a post, decrypted the diagram too quickly.
Decrypting, because you don't use drawing conventions.
Signal goes from left to right.
Supply pointing to the top, ground towards the bottom.
Don't draw ground and supply wires, they confuse things, use ground and VCC symbols.
Leo..
For this simple of a device, setting a dip switch once or maybe more than once if the user sets it wrong on the first try (or two). I think dips are a good choice. Yes, I've seen many devices with dips. I have a Victron Inverter/Charger with dips.
Not quite, keep components like MOSFETs with D to the top and S to the bottom, imagine the current flowing from the top of the sheet to the bottom, gnd.
Also keep components connected, using NetNames if for PCB manufacture, not trouble shooting.
Good try so far , clear and open schematic.,
As @Wawa has pointed out some conventions you need to learn, and that takes practice and experience.
Tom, Thanks! I applied Leo's advice on dropping all the noise of connected lines. I thought I did connect the components with name tags. Could you point to a specific case? Again, love the feedback. Applied what I think you meant