Posted on Could 21, 2017 in atmega, {hardware}, PC, course of management

In my earlier article I mentioned how I supposed to transform an outdated PC right into a controller that I may use to automate the temperature management required to ferment and conditional beer. For those who haven’t already learn that introduction then I’d encourage you to do this so you realize what it’s that I’m attempting to realize.

This text will give full particulars of the primary board that I’ve constructed, designed to suit contained in the PC and management relays and triacs.

Design

The warmers, fridge and followers that management the temperature in my brew fridge must be switched on and off and that’s what this board is designed to realize.

Course of automation: relays and triacs

As you’ll be able to see from the diagram the principle options of the board are:

  • Three relays for fundamental on/off switching. To resolve one of many points with the STC-1000 controller I’ll use 16A, title model relays for optimum reliability.
  • A triac. This may give me the flexibility to do phase-angle ‘dimming’ management and might be used for proportional heater or fan management.
  • USB connectivity to the host PC through a USB-to-UART IC.

I count on that lots of my readers will need to construct this board so I’ll design it to be all through-hole utilizing simple to search out elements so that you could construct it with only a fundamental soldering iron. Fancy reflow ovens (a lot as I like mine) and scorching air weapons might be not required for this construct!

With the design standards in thoughts I set about producing a schematic for the board.

Course of automation: relays and triacs

Click on on the thumbnail to obtain a PDF

Let’s do a fast overview of the assorted useful blocks inside the schematic.

Relays

Course of automation: relays and triacs

The relay block is repeated thrice within the schematic, labelled Warmth, Chill and AUX1. There’s no purpose why they need to really be controlling warmth and chill however I most popular these labels to the extra boring 1, 2, Three and many others.

The relays are the RZ03-1A4-D005 by TE Connectivity. They’re 16A rated with a 5V coil and a rated contact voltage of 250VAC. These might be greater than sufficient for my necessities and may final for a few years.

The microcontroller prompts the relay by driving the bottom of the MOSFET Q1 and so long as the bottom is held excessive then the relay will stay switched on. This is named a non-latching relay and it’s vital as a result of we wish the system to fail-safe, i.e. off, if there’s a system energy failure. R5 pulls the MOSFET base right down to floor in order that the relay stays off throughout system power-up when the driving sign is in an indeterminate state.

The sign that drives Q1 additionally drives This autumn to gentle an indicator LED that may give a visible indication that the relay is on. With the board contained in the case I gained’t have the ability to see this however when you’re constructing it and have a kind of instances with a window on the aspect then you will note it.

D4 is the safety diode and I’m utilizing the 1N4007 as a result of I’ve received numerous them. In apply any of the 1N400x sequence will work advantageous. P1 is a two-terminal connection block that may have an acceptable present ranking for this board.

I’ve created a web class for the high-voltage elements of the circuit in order that with regards to the PCB structure I can apply design guidelines corresponding to minimal hint width and clearance to only these elements of the circuit.

The triac and its controller

The triac provides me the flexibility to do phase-angle ‘dimming’ management of the mains AC sine wave. For those who’re coming to this from a microcontroller background the place the provision is each DC and low voltage you then’re most likely acquainted with the widespread Pulse Width Modulation (PWM) approach that’s used to offer the looks of dimming, typically with LEDs, by quickly switching the DC provide on and off and counting on our human persistence of imaginative and prescient to offer the notion of a continuing gentle stage.

Course of automation: relays and triacs

This works properly for DC provides however can the identical approach be utilized to the mains AC provide the place the sign is a dangerously excessive voltage and a sine wave? The straight reply is that no you’ll be able to’t, however you’ll be able to obtain the identical end result with what we name Part Angle Management.

Course of automation: relays and triacs

Right here’s what the mains provide sine wave seems to be like within the UK the place I dwell. Now we have a nominal provide voltage of 240V RMS at a frequency of 50Hz though the precise RMS voltage delivered to the home will differ relying on all types of issues corresponding to your distance from the native substation and the demand within the space on the time. As I write this on a Sunday lunchtime I’m seeing 238V and I’ve seen it as much as the total 240V at different instances.

To provide the looks of dimming a load we depend on the identical fundamental fast on/off switching of the provision as we do with the PWM approach however we should observe a further constraint. We can not select any frequency we like, as an alternative we should use the identical frequency because the mains provide and we should keep in sync with it. Within the UK meaning we’ll be working our dimmer at 100Hz (as soon as for the constructive half of the 50Hz sign and once more for the unfavourable half).

So, we’d like a way for detecting when the sine wave passes by way of the zero level on the X-axis in order that we will keep in sync with it and we additionally want a tool that may quickly change a load on and off whatever the polarity of the sign.

Let’s cope with the switching machine first. Probably the most generally used part is the triac as a result of it’s small, low cost and may be made to deal with giant currents and voltages. A triac is a sort of bi-directional thyristor that solely conducts when triggered by a present at its gate.

Course of automation: relays and triacs

Triac’s have three terminals. Two of them are intuitively labelled MT1 and MT2 for ‘Main Terminal’ one and two. Your load present flows between these two terminals, however solely when the triac has been triggered by a present at its gate. In conventional dimming circuits the place the mains is the one provide obtainable a part known as a diac is commonly used to drive the gate of a triac.

As of late with low voltage DC logic circuits so standard ‘logic level’ triacs have change into obtainable which are simply triggered by a low gate present and they’re typically accompanied by a devoted triac optocoupler to offer isolation between the high and low voltage sides. The Fairchild MOC30x0 sequence may be very standard and that’s the one I’ll be utilizing in my circuit.

Course of automation: relays and triacs

As soon as activated by a pulse of ample length and magnitude at its gate then a triac will latch ‘on’ till the zero crossing present level when it is going to try to show itself off.

Triggering in a Triac is defined by dividing up the relative polarities of the three terminals into quadrants. You may examine these within the Wiki article so I gained’t go into it once more in depth right here. One vital takeaway from the Wiki article is the observe about three quadrant, or snubberless triacs.

When driving masses with a major reactive part the triac is especially weak to false triggering in quadrant 4. By disabling triggering on this quadrant this vulnerability is decreased a lot that the everyday RC snubber circuit that you just typically see is probably not required. I often drive masses which are virtually purely resistive corresponding to heating and lighting however I nonetheless solely use 3Q triacs as a result of they price the identical as 4Q triacs and I don’t want the RC snubber elements.

Now we all know how we’re going to show the mains on and off we have to look at after we’re going to do it.

Zero crossing detection

There are numerous methods to do that. Typically you don’t even have to design a selected sub-circuit for it as a result of it is going to be naturally obtainable at a specific node in your design, as was the case in my reflow oven power-supply circuit. Some designs are doubtlessly unsafe as a result of they don’t isolate the mains voltage from the low voltage detection circuit.

Course of automation: relays and triacs

The design I’ve chosen is each protected and low cost however does come at the price of about 0.5W of energy consumption. It’s protected as a result of it optically isolates the mains from the low voltage aspect and it’s low cost as a result of it makes use of simply three resistors, an AC optocoupler and a MOSFET.

This circuit will present a falling edge pulse on the zero present crossing level. R8 limits the present flowing by way of the optocoupler to the smallest worth that we will get away with in order that the facility dissipated inside R8 is minimised. The optocoupler gives protected isolation between the mains and the low voltage aspect of the circuit.

When present is out there from the mains to gentle the LEDs contained in the optocoupler then the opposing phototransistor will conduct present from 5V by way of R2 and so to floor. A microcontroller enter pin connected to the ZSENSE level will sense 5V by way of the resistor R21 and skim a excessive stage. It doesn’t matter whether or not the load has inductive or reactive elements as a result of the LEDs within the optocoupler are lit by present, not voltage.

At or very close to the purpose of the zero crossing the phototransistor will cease conducting. The 5V voltage will then activate the gate of the MOSFET inflicting present to stream by way of R21 and throughout the MOSFET to floor. Our microcontroller will now sense a low stage and we’ve a falling fringe of a logic sign that we will use to set off an interrupt and begin our work.

The values for R21 and R13 are vital to the accuracy of the zero crossing detection and had been derived empirically with assistance from a check circuit and an oscilloscope.

Now we’re in full possession of all of the pre-requisites for controlling the mains provide we will illustrate what we’re going to do with a easy stream chart.

Course of automation: relays and triacs

If we put that into motion then our ‘dimmed’ mains sign would possibly seem like this.

Course of automation: relays and triacs

The orange strains point out the place we activate the triac and change on the load. The triac robotically switches off on the subsequent zero crossing and we begin our timing cycle once more. The chopped waveform is sufficent to offer the looks of dimming in masses that may help it.

To finish the design R12 is a MOV to guard the triac from voltage spikes and C7 is for interference suppression.

The microcontroller

Course of automation: relays and triacs

Sure it’s the venerable outdated ATMega328P as popularised by the Arduino and its clone military, chosen for this design as a result of its huge availability, simple programming mannequin, through-hole packaging and 5V voltage compatibility. I’ve opted to incorporate an 8MHz crystal on the board in case I resolve that the firmware ought to have the flexibility to run a timed program over the course of a number of days even when the principle host laptop has crashed. Exterior crystal’s are nearly correct sufficient to do this whereas the interior RC oscillator will not be.

The USB controller

Course of automation: relays and triacs

There are numerous USB-to-UART bridge chips round however when my design standards for through-hole units is taken into consideration that listing drops down to at least one, the MCP2221 from Microchip. It’s trivial to make use of in that you just simply hook one aspect as much as your MCU, the opposite aspect to the USB port and you’ll instantly begin speaking to it at 9600 baud. Hearsay has it that it’s really a hard-wired PIC inside that bundle.

I’ve related up the I2C bus regardless that I most likely gained’t use it and I’ve additionally added the three LEDs that point out exercise. These might be normally-on, flashing briefly off when there’s exercise.

Now we’ve seen the design, it’s time to maneuver on to the PCB structure.

PCB Design

There are two fundamental constraints that I have to work with when laying out the board. Firstly, the mounting holes should match the footprint of a 2.5″ onerous drive in order that the board may be mounted in a PC drive bay. Secondly the general measurement of the board ought to match inside the 10x10cm format that’s so low cost to have manufactured in China.

With the board define outlined and the screw holes positioned I then positioned the relays and the triac in order that their related terminal blocks would all face in a single path off the board. The USB ‘B’ connector was positioned on the different finish of the board in order that we’ve information coming in at one aspect and the excessive voltage part all on the different aspect.

Now it was merely a matter of inserting all the opposite elements in as a lot of a logical place as potential and routing all of them up. The board structure is finalised with prime and backside floor pours within the low-voltage areas and teardrop connections to all of the pads for higher connection integrity.

Course of automation: relays and triacs

Course of automation: relays and triacs

I added a silkscreen border and a few textual content to make it clear the place the excessive voltage areas are positioned on this board.

One other helpful step within the verification course of is to view the board in 3D mode the place I can verify the heights of all of the elements that I’ve fashions for and simply see widespread errors corresponding to silkscreen overlapping pads.

Course of automation: relays and triacs

All the elements can be found at Farnell so I put in an order for these and in addition for 10 copies of the PCB from Seeed Studio in China since they had been having a loopy provide of US$4.90 for 10 earlier than postage.

Invoice of Supplies

Right here’s the invoice of supplies for this design displaying part values for a 220-240V mains provide. Consult with the schematic for prompt values for a 120V provide.

Designator Worth Amount Description Footprint Farnell code Notes
C1, C2, C3, C5, C8, C9 100n 6 Ceramic capacitor 2.54mm 2309020
C4 10n 1 Ceramic capacitor 2.54mm 2309024
C6, C11 10µ 2 Electrolytic capacitor 5x11mm 1902913
C7 100n 1 Panasonic ECQU2A104KLA X2 Movie Capacitor 1673308
C10 1 Ceramic capacitor 5.08mm 2112910 [1]
C12, C13 22p 2 Ceramic capacitor 2.54mm 1100369
D1, D2, D3 White 3 LED 3mm [3]
D4, D5, D6 1N4007 3 Diode DO-41 2317417 [2]
D7 Inexperienced 1 LED 3mm [3]
D8, D9, D10 Amber 3 LED 3mm [3]
FB1 BLM18PG221SN1D 1 Ferrite bead AXIAL-0.3 2292304
K1, K2, K3 RZ03-1A4-D005 3 Single-Pole Single-Throw Relay 2325624
P1, P2, P3, P5, P6 PM5.08/2/90 3 WEIDMULLER PM5.08/2/90 PCB terminal block – 5.08 1131855
P4 USB B 1 USB B RECEPTACLE 1177885
P7 2×5 header 1 ISP connector 2.54mm [4]
Q1, Q2, Q3, This autumn, Q5, Q6, Q9 BS170 7 N-Channel MOSFET TO-92 1017687
Q7 2N5551 1 NPN Bipolar Transistor TO-92 9846751
Q8 BTA16-600BW 1 Triac TO-220 1175636
R1, R2, R3 680 3 Resistor AXIAL-0.3 2329545
R4, R5, R6, R7, R17 10ok 5 Resistor AXIAL-0.3 2329474
R8 100ok 2W 500v 1 Resistor AXIAL-0.9 2329558
R9, R18, R19, R20 470 4 Resistor AXIAL-0.3 2329531
R10 360 1 Resistor AXIAL-0.5 2329779
R11 1k 1 Resistor AXIAL-0.3 2329486
R12 275VRMS 1 MOV Varistor 20D sequence 1856919
R13, R21 6.8k 2 Resistor AXIAL-0.3 1700247
R14 100 1 Resistor AXIAL-0.3 2329473
R15, R16 2.2k 2 Resistor AXIAL-0.3 2329584
U1 MCP2221-I/P 1 Microchip USB-Serial DIP-14 2434892
U2 FOD814A 1 Optocoupler DIP-4 2322510
U3 MOC3020M 1 Opto-Triac DIP-6 1471017
U4 ATMega328p 1 8-bit AVR Microcontroller DIP-28 1715487
Y1 8MHz 1 Crystal Oscillator HC49 through gap 2063945
Ohmite FA-T220-38E 1 Triac heatsink 2097690

Notes

Among the elements have observe numbers towards them. The next numbered paragraphs correspond to a numbered observe within the invoice of supplies desk.

  1. 2.54mm elements can be used when you fastidiously bend the leads outwards to suit the broader 5.08mm pitch.
  2. Any of the 1N400x sequence might be advantageous. All of them price about the identical so I are likely to preserve a inventory of the most important one, the 1N4007 round.
  3. Any color of 3mm LED will work and so they’re least expensive on ebay.
  4. These 2.54mm headers are least expensive on ebay.

Meeting

The boards arrived in about Three weeks and so they look excellent. It’s simply ridiculous how cheaply these may be produced as of late.

Course of automation: relays and triacs

Course of automation: relays and triacs

Assembling a purely through-hole board is so simple as sitting down with my soldering iron, a pair of snips and simply getting on with it. You may make life simpler for your self by doing the elements in ascending top order. Which means beginning with the resistors and transferring up by way of the diodes, capacitors and many others.

I select to make use of sockets for all my DIP ICs although you don’t should when you’re assured that your design goes to work first time.

An vital factor to notice is that you could solder the triac in order that when the heatsink is connected there’s at the very least a millimetre or two of air clearance between the heatsink and the board as a result of there are excessive voltage traces working underneath the heatsink and also you wouldn’t need to be relying on the soldermask and the heatsink’s personal coating for insulation.

Course of automation: relays and triacs

Wanting good with all these chunky through-hole elements on board. Right here’s one other shot displaying it mounted on a tough disk caddy.

Course of automation: relays and triacs

As you’ll be able to see it matches properly into the footprint of the onerous disk caddy the place the screw holes within the board mate up with the footprint for a 2.5″ onerous disk.

Testing

Firstly I have to plug it in and see what occurs. The MCP2221 must be utterly autonomous and enumerate as a USB machine with none firmware even being flashed on to the ATmega328p. For the reason that goal working system for the pc internet hosting this machine is Linux I’ll be doing all my testing on a Ubuntu VM working underneath the free VMware participant. My fundamental PC runs Home windows 10 because the host OS as a result of practically all of the purposes that I exploit every day are for Home windows however since I’ve 48Gb of RAM it’s no drawback in any respect to have at the very least one Linux server VM working for these processes that simply run higher on Linux.

I plugged it in. There was a chime from the PC, VMware discovered the machine and I advised it to ship it to the visitor OS. Time to see if it’s there.

$ ls -l /dev/usb* /dev/ttyACM*
crw-rw-rw- 1 andy dialout 166, Zero Could 27 14:28 /dev/ttyACM0

/dev/usb:
complete 0
crw——- 1 root root 180, Zero Could 27 14:28 hiddev0

Cool, seems to be like I’ve new CDC and HID units. Let’s get some information on it.

$ lsusb
Bus 001 System 001: ID 1d6b:0002 Linux Basis 2.Zero root hub
Bus 002 System 004: ID 04d8:00dd Microchip Expertise, Inc.
Bus 002 System 003: ID 0e0f:0002 VMware, Inc. Digital USB Hub
Bus 002 System 002: ID 0e0f:0003 VMware, Inc. Digital Mouse
Bus 002 System 001: ID 1d6b:0001 Linux Basis 1.1 root hub

There it’s on the second row. All of the descriptors retrieved throughout machine enumeration are retrievable by passing the -v flag to lsusb

$ lsusb -vd 04d8:00dd

Bus 002 System 004: ID 04d8:00dd Microchip Expertise, Inc.
Couldn’t open machine, some data might be lacking
System Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous System
bDeviceSubClass 2 ?
bDeviceProtocol 1 Interface Affiliation
bMaxPacketSize0 8
idVendor 0x04d8 Microchip Expertise, Inc.
idProduct 0x00dd
bcdDevice 1.00
iManufacturer 1
iProduct 2
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 107
bNumInterfaces 3
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 100mA
Interface Affiliation:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 2 Communications
bFunctionSubClass 2 Summary (modem)
bFunctionProtocol 1 AT-commands (v.25ter)
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 2 Communications
bInterfaceSubClass 2 Summary (modem)
bInterfaceProtocol 1 AT-commands (v.25ter)
iInterface 0
CDC Header:
bcdCDC 1.10
CDC ACM:
bmCapabilities 0x02
line coding and serial state
CDC Union:
bMasterInterface 0
bSlaveInterface 1
CDC Name Administration:
bmCapabilities 0x00
bDataInterface 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Switch Kind Interrupt
Synch Kind None
Utilization Kind Information
wMaxPacketSize 0x0008 1x Eight bytes
bInterval 2
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 10 CDC Information
bInterfaceSubClass Zero Unused
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Switch Kind Bulk
Synch Kind None
Utilization Kind Information
wMaxPacketSize 0x0010 1x 16 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Switch Kind Bulk
Synch Kind None
Utilization Kind Information
wMaxPacketSize 0x0010 1x 16 bytes
bInterval 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass Three Human Interface System
bInterfaceSubClass Zero No Subclass
bInterfaceProtocol Zero None
iInterface 0
HID System Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.11
bCountryCode Zero Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 28
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP Three IN
bmAttributes 3
Switch Kind Interrupt
Synch Kind None
Utilization Kind Information
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP Three OUT
bmAttributes 3
Switch Kind Interrupt
Synch Kind None
Utilization Kind Information
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1

Endpoints are seen for the CDC and HID units in that listing. I don’t care in regards to the HID machine and can simply be addressing the ATMega328p’s UART by way of the CDC interface on the default pace of 9600 baud.

In its default state Linux will solely permit root to speak to a /dev/ttyACM machine. I would like to alter that so my atypical unprivileged consumer can use it and fortunately Linux gives a approach. Including the next udev guidelines file did the trick.

$ cat /and many others/usdev/guidelines.d/20-brewery-controllers.guidelines
SUBSYSTEM==”tty” ATTRS{producer}==”Microchip Expertise Inc.” SYMLINK+=”Andypercentn” MODE=”0666″, OWNER=”andy”

With this in place I’ll get user-accessible symlinks robotically created and eliminated that time to the actual units.

$ ls -l /dev/Andy*
lrwxrwxrwx 1 root root 7 Could 27 14:28 /dev/Andy0 -> ttyACM0

Subsequent I wanted to check that the MCU is alive so I related up my USBASP programmer and skim out the fuses utilizing avrdude. I had to do that from Home windows as a result of for causes I by no means received to the underside of the USBASP programmer is not going to with Avrdude when the Linux host is working in a digital machine. Which means I’m growing in a split-personality system the place the MCP2221 is related to the Linux visitor and the USBASP is related to the Home windows host with the methods sharing supply code utilizing a VM mount on to the host filesystem. Enjoyable instances.

There have been no issues. The MCU was up and working so now it’s time for me to create some firmware.

The firmware operates in a easy command/response mode over the UART. You may see the supply code right here on github. Every command have to be terminated by a CRLF pair and the one line response will even be terminated the identical approach. The accepted command set is:

Instructions Anticipated response Description
HEAT ON
HEAT OFF
OK Turns the HEAT relay on or off
CHILL ON
CHILL OFF
OK Turns the CHILL relay on or off
AUX1 ON
AUX1 OFF
OK Turns the AUX1 relay on or off
AUX2 OK Units the AUX2 triac ‘dimmer’ stage to the desired share
ID JSON textual content Returns the board identifier string as JSON
COPY plain textual content Returns a copyright assertion legitimate for this board
VER JSON textual content Returns the {hardware} and firmware variations of the board
CAPS JSON textual content Returns the capabilities (variety of relays and many others) of this board
UPTIME OK: Milliseconds
VALID warmth chill aux1 aux2 OK Units the ‘legitimate masks’ of permitted change combos

A lot of the instructions are apparent in what they do and the rationale for a few of them returning JSON is in order that they are often simply parsed by the linux server course of that I’ll create to handle the communication between the consumer interface and the {hardware}.

The VALID command is a security characteristic that units which switches are permitted to be on on the identical time, so for instance if the consumer asks for the heater and chiller to be switched on on the identical time the firmware is not going to allow it. The default setting within the firmware is for all of the controls to be remoted from one another. That’s, no relay or triac could also be on similtaneously any of the others. The documentation for learn how to specify the 4 parameters may be discovered within the supply code right here on github.

For those who don’t need to construct the firmware from supply then yow will discover a pre-built hex file within the bin listing of the github repo. Constructing from supply requires an area set up of avr-gcc that helps C++11, I used 4.9.2, and in addition an set up of the scons construct system.

To construct from supply and concurrently add utilizing the USBASP programmer the command is:

$ scons mains=50 add
scons: Studying SConscript recordsdata …
scons: performed studying SConscript recordsdata.
scons: Constructing targets …
avrdude -c usbasp -p m328p -e -U flash:w:brewery-relays.hex

avrdude.exe: warning: can not set sck interval. please verify for usbasp firmware replace.
avrdude.exe: AVR machine initialized and able to settle for directions

Studying | ################################################## | 100% 0.00s

avrdude.exe: System signature = 0x1e950f
avrdude.exe: erasing chip
avrdude.exe: warning: can not set sck interval. please verify for usbasp firmware replace.
avrdude.exe: studying enter file “brewery-relays.hex”
avrdude.exe: enter file brewery-relays.hex auto detected as Intel Hex
avrdude.exe: writing flash (4196 bytes):

Writing | ################################################## | 100% 2.85s

avrdude.exe: 4196 bytes of flash written
avrdude.exe: verifying flash reminiscence towards brewery-relays.hex:
avrdude.exe: load information flash information from enter file brewery-relays.hex:
avrdude.exe: enter file brewery-relays.hex auto detected as Intel Hex
avrdude.exe: enter file brewery-relays.hex incorporates 4196 bytes
avrdude.exe: studying on-chip flash information:

Studying | ################################################## | 100% 2.16s

avrdude.exe: verifying …
avrdude.exe: 4196 bytes of flash verified

avrdude.exe performed. Thanks.

For those who dwell in a rustic the place the mains provide is 60Hz then merely change mains=50 to mains=60.

The primary time you construct, you could additionally set the fuses in order that the MCU makes use of the exterior 8MHz crystal. The command for that’s:

$ scons mains=50 fuse

Linux gives a spread of serial comms applications that I can use for testing. I briefly tried display screen, cu and minicom and couldn’t get them to work properly in cheap time as a result of their defaults are arrange for actual terminals on the ‘other end’. Python got here to the rescue with the miniterm utility inbuilt to the PySerial bundle. Right here’s an instance of me utilizing it.

$ python -m serial.instruments.miniterm /dev/Andy0
— Miniterm on /dev/Andy0 9600,8,N,1 —
— Stop: Ctrl+]| Menu: Ctrl+T | Assist: Ctrl+T adopted by Ctrl+H —
“Andy’s Workshop Brewery switching controller”␀
{“type”:”switching”,”relays”:[“HEAT”,”CHILL”,”AUX1″],”triacs”:[“AUX2”]}␀
{“hardware”:1,”firmware”:1}␀

My firmware doesn’t echo again the characters that you just kind as a result of it could be pointless in an automatic system. You must take it on belief that the machine is definitely receiving what you kind, or when you stare intently on the center of the three indicator LEDs you then’ll see it briefly flash on and off once more every time you press a key. Within the above session I typed id, caps and ver.

Now let’s change a relay on and see the end result. The command to enter is warmth on

— Miniterm on /dev/Andy0 9600,8,N,1 —
— Stop: Ctrl+]| Menu: Ctrl+T | Assist: Ctrl+T adopted by Ctrl+H —
OK␀

The firmware responded with OK, there was a strong sounding clunk from the relay and the white indicator LED switched on.

Course of automation: relays and triacs

The relays have an marketed most switching frequency of 360 instances per hour when loaded, or as soon as each 10 seconds. The applying software program that I write is not going to permit something like this charge however one ought to by no means depend on software program to at all times do the suitable factor so the firmware is coded to stop anybody relay being switched on twice in a 10s interval. For those who strive, this occurs.

— Miniterm on /dev/Andy0 9600,8,N,1 —
— Stop: Ctrl+]| Menu: Ctrl+T | Assist: Ctrl+T adopted by Ctrl+H —
ERROR:05:Relay 10s blackout lively␀

The opposite two relays all checked out good so now I would like to check the triac earlier than I can name it a day. This isn’t so simple as testing the relays as a result of I’ll have to hook up the mains enter and a check load to the AUX2 output. I’ll use a conveyable worklight for the load. Let’s give it a go.

Course of automation: relays and triacs

My ‘Quick Test’ field by Cliff Electronics provides me a fast technique to hook up the mains provide safely to the board. I examined the triac utilizing the AUX2 command with share values from Zero to 100 in steps of 10. The sunshine responded appropriately which indicated that the mains dimming logic and all of the timers related to that had been working as designed.

That’s sufficient testing for immediately. I now have a working board and may transfer on to the following section of the venture which I believe would be the RTD temperature sensors board.

Video

I made a YouTube video displaying the board in operation. You may watch it right here utilizing the embedded video however a lot better high quality may be had by visiting YouTube and watching it there.

Construct your individual

Though I’ve a selected use for this board the final idea of an inside PC board that can be utilized to modify and dim mains masses might have wider enchantment. Go to my downloads web page to get the Gerber recordsdata for this venture. You may add these to one of many low cost on-line providers corresponding to Seeed, ITead, PCBWay and get some copies manufactured for your self.

You construct and use this board at your individual threat. Please be extraordinarily cautious when dealing with mains wiring. By no means contact any a part of the board whereas the provision is related and at all times safe cabling inside a housing in such a approach that it can not transfer. If unsure, get a professional electrician to do it or at the very least have one evaluate your work.

All of the firmware and utility supply code is right here on github.

Clean boards on the market

I’ve received some spare boards remaining from the batch of ten in my unique order. For those who’d choose to purchase one reasonably than have your individual set manufactured then you need to use the PayPal kind under to make an order.

Remaining phrases

That is the primary concrete implementation of a board for my course of controller and I’m very proud of the outcomes to this point, particularly since I’ve no earlier expertise with the MCP2221 USB controller and but it labored first time. I’ll be transferring on now to the following stage of the venture which might be to construct a temperature sensor board primarily based on RTD probes.

For those who’d like to depart a remark then you are able to do so down under within the feedback part or when you’d like so as to add to the dialogue over within the discussion board then please additionally be at liberty.

You May Also Like

Calculation Number of Days Between Two Dates

Topic: Delphi Language charlene44 wrote: 18/08/2006 at 15h08 calculation of number of…

World of Warcraft Classic: Some Players Use Illegal Tools to Stay Connected

Earlier this week, Blizzard released World of Warcraft Classic. The launch was,…

Crash Team Racing Bientt Back on Ps4!

Activision seems not to have finished with the remastering of the Playstation…

Top Benefits of Social Media Marketing

We cannot deny the fact that when it comes to marketing, social…