Controling solenoid, communication with PC and getting data from mass flow meter

Thread Starter


Joined Jan 11, 2012
Hi, I have a small project with main target of controlling external solenoid. Functionality of the main board can be described as follows:

(i) retrieve data from simple keyboard (4+4 pins, 16 keys). Keyboard is for entering a password

(ii) control external solenoid (230 VAC, 10 W) when external authorization is approved

(iii) retrieve data from mass flow meter through RS485

(iv) communicate with PC through RS232: sending string entered on the small keyboard, listen for password authorization and signal that transaction is allowed to be started, sending data from the flow meter.
There will be also a bootlader installed at ATMEGA644PA thus the program can be easily changed without touching the board.

Input voltage available is stabilized 24 VDC which is planned to be transformed linearly via 7805 to 5 V. Power lost will be about 1 W.

Draft of the control board scheme is attached.

Could I ask you for checking this scheme a little bit and discussing about this project in general. My job is software developer and my knowledge of electronics is a little bit limited yet.

Thank you,

Martin Halama



Joined Jul 9, 2011
Had just a quick look. I wouldn't let T1IN of the MAX232 open. (I just don't like it, it probably does nothing bad here)
CTLX is usually HIGH, right. When pulling it low the uC will reset. When CTLX goes high again the voltage at the RESET pin can exceed VCC. I suggest put a small signal diode from reset to VCC.

For D3 and D2 I would rather take UF4004 instead of 1N. This has nothing to do with the reverse recovery time. There was another thread some time ago where we saw that for 1Ns it could take too much time to start to conduct which could be fatal, since it then doesn't clamp the voltage spike.

What's the relay current?

In this document: they suggest 1uF for the MAX232, 0.uF for the MAX232A.

Thread Starter


Joined Jan 11, 2012
Thank you for valuable comments. I have tried to adapt the schematic to the advices given.

The relays current is up to 10 mA.

I am now facing another problem with "auto reset" feature. There are two states in which the board could be in:

(A) working but ready to be reprogrammed through RS232
(B) working and communicates with PC over RS232 in both directions (half duplex)

The last version does not allow (B) state I think because any attempt to send the data from PC to the control board will result in reseting ATMEGA and wait to be reprogrammed (there will be a bootloader on the chip allowing that).

In general:

Specific input message / command send from PC should change state (B) to state (A).

ATMEGA will change state (A) to state (B) by a program instructions - after running the program.

I have maybe found a few ways how to deal with this issue:

(i) reset will be driven by a pin on ATMEGA chip which cause reset to be activated. This "soft reset" will be programmaticaly activated after reset command will be retrieved via serial line. As I understand this is not recommended way of reseting the chip.

(ii) using watchdog timer and adapt bootloader to switch watchdog off immediately preventing infinite reset cycle.

(iii) adapt existing ckt adding an OR gate as an enabling switch (ESW) for CTLX signal as follows.

When ESW is LOW then CTLX is enabled meaning it behaves as original ckt. When ESW is HIGH (set by the program), OUTPUT from the OR Gate is always 1 meaning RESET is disabled no matter what is the state of CTLX.

Does it make sense to solve the issue in this way?