Silicon ChipLow-voltage, high-current DC Motor Speed Controller - October 2018 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Seemingly helpful technology may not be that helpful
  4. Feature: Reusable Rockets by Dr David Maddison
  5. Project: GPS-synched Frequency Reference Pt.1 by Tim Blythman
  6. Project: Arduino-based programmer for DCC Decoders by Tim Blythman
  7. Project: Low-voltage, high-current DC Motor Speed Controller by Nicholas Vinen
  8. Serviceman's Log: I'm on holidays, but not from servicing! by Dave Thompson
  9. Feature: Developing CleverScope's high-performance CS448 by Bart Schroeder
  10. Project: Opto-Isolated Mains Relay by Tim Blythman
  11. Feature: Intro to programming: Cypress' System on a Chip (SoC) by Dennis Smith
  12. PartShop
  13. Product Showcase
  14. Vintage Radio: Emerson 838 hybrid valve/transistor radio by Ian Batty
  15. Subscriptions
  16. Market Centre
  17. Advertising Index
  18. Notes & Errata: Steam Train Whistle/Diesel Horn / Arduino Data Logger
  19. Outer Back Cover

This is only a preview of the October 2018 issue of Silicon Chip.

You can view 40 of the 112 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "GPS-synched Frequency Reference Pt.1":
  • GPS-synched Frequency Reference PCB [04107181] (AUD $7.50)
  • PIC32MX170F256B-50I/SP programmed for the GPS-Synched Frequency Reference [0410718A.hex] (Programmed Microcontroller, AUD $15.00)
  • VK2828U7G5LF TTL GPS/GLONASS/GALILEO module with antenna and cable (Component, AUD $25.00)
  • Micromite LCD BackPack V2 complete kit (Component, AUD $70.00)
  • SMD parts for the GPS-Synched Frequency Reference (Component, AUD $80.00)
  • Firmware (HEX) files and BASIC/C source code for the GPS-Synched Frequency Reference [0410718A.hex] (Software, Free)
  • GPS-Synched Frequency Reference PCB pattern (PDF download) [04107181] (Free)
  • GPS-synched Frequency Reference drilling and cutting diagrams (PDF download) (Panel Artwork, Free)
Articles in this series:
  • GPS-synched Frequency Reference Pt.1 (October 2018)
  • GPS-synched Frequency Reference Pt.1 (October 2018)
  • GPS-synched, lab-quality frequency reference (Part 2) (November 2018)
  • GPS-synched, lab-quality frequency reference (Part 2) (November 2018)
Items relevant to "Arduino-based programmer for DCC Decoders":
  • DCC Decoder Programmer PCB [09107181] (AUD $5.00)
  • DCC Decoder Programmer PCB plus stackable headers [09107181] (AUD $7.50)
  • Small 2A boost step-up regulator module (MT3608) (Component, AUD $3.00)
  • DCC Decoder Programmer sketches (Software, Free)
  • DCC Decoder Programmer PCB pattern (PDF download) [09107181] (Free)
Items relevant to "Low-voltage, high-current DC Motor Speed Controller":
  • Four-channel High-current DC Fan and Pump Controller PCB [05108181] (AUD $5.00)
  • PIC16F1459-I/SO programmed for the Four-channel High-current DC Fan & Pump Controller (0510818A.HEX) (Programmed Microcontroller, AUD $10.00)
  • Firmware for the Four-channel High-current DC Fan & Pump Controller (0510818A.HEX) (Software, Free)
  • Four-channel High-current DC Fan and Pump Controller PCB pattern (PDF download) [05108181] (Free)
Articles in this series:
  • Low-voltage, high-current DC Motor Speed Controller (October 2018)
  • Low-voltage, high-current DC Motor Speed Controller (October 2018)
  • Low voltage DC Motor and Pump Controller (Part 2) (December 2018)
  • Low voltage DC Motor and Pump Controller (Part 2) (December 2018)
Items relevant to "Opto-Isolated Mains Relay":
  • Opto-Isolated Relay PCB plus two extension boards [10107181] (AUD $7.50)
  • Opto-Isolated Relay PCB pattern (PDF download) [10107181] (Free)
Items relevant to "Intro to programming: Cypress' System on a Chip (SoC)":
  • Cypress PSoC4 CY8CKIT demonstration project files (Thermistor/LCD) (Software, Free)
Articles in this series:
  • Intro to programming: Cypress' System on a Chip (SoC) (October 2018)
  • Intro to programming: Cypress' System on a Chip (SoC) (October 2018)
  • Cypress “system on a chip” part 2 (September 2019)
  • Cypress “system on a chip” part 2 (September 2019)

Purchase a printed copy of this issue for $10.00.

Four-channel High-current DC Fan and Pump Controller by Nicholas Vinen We originally designed this multi-channel pump and fan speed controller for automotive (or other vehicle) tasks – but now realise it has a myriad of other applications. It can be used anywhere you need to adjust the speed of low-voltage DC fans or other PWM-controlled devices. It has many options and is easy to set up using an onboard USB interface. J form 20A output channels. ust one look at the specs panel opposite will show just The design also incorporates a comprehensive supply how flexible this project is! If you need to control the voltage monitoring and timer scheme which allows it to speed of a low-voltage DC motor – a fan or pump for consume a tiny amount of power (microamps) when the example – in response to changes in temperature, this is battery voltage is low but quickly comes into operawhat you need. tion once the battery starts charging. The The speed is controlled by varying the duty cycle of timers allow the unit to run for a specithe DC voltage applied to the device (ie, Pulse-Width fied time after the supply voltage drops, Modulation or PWM control) and is calculated eg, to cool down a turbo-charged enbased on either the absolute temperagine after driving for some time. ture of one or two sensors, or During this “cooldown” period, the difference in temperature the fan(s) and pump(s) can be run at between two sensors. a reduced duty cycle, to avoid disUp to four temperature sencharging the battery too quickly. sors can be connected and these And the unit can be programmed can either be analog (NTC thermisto ignore periods of lower battery tors) or digital (Dallas DS18B20)     voltage, as would be the case in devices. Shown here vehicles where the battery is not There are four independent 10A close to life size, the charging while ever the engine output channels which can be used motor/pump controller fits is running. to control four separate fans/pumps, on a single PCB. While it has all SMD The relationship between senor they can be combined in pairs to components, construction is not difficult. 46 Silicon Chip Australia’s electronics magazine siliconchip.com.au Features & specifications • • • • • • • • • • • Supply voltage: .............................. 5-15V DC Outputs:............................................ 4 x 10A or 2 x 20A or 2 x 10A + 1 x 20A Supply protection:......................... can handle typical load dumps and other automotive spikes Quiescent current: ........................ typically <1mA Temperature sensors:................... up to four, each a 10k NTC thermistor or DS18B20 digital sensor Temperature sensor range:......... -55°C to +125°C (DS18B20), -30°C to +105°C (NTC) Temperature sensor accuracy: .. (-10°C to +85°C): ±0.5°C (DS18B20), typically ±1°C (NTC) PWM frequency: ............................ 0.1Hz to 160kHz (configurable; output capabilities vary) PWM duty cycle: ........................... 0% to 100% in 1% steps Configuration interface:............... USB port (serial console) Per-output configuration:........... which temperature sensors control duty cycle, minimum/maximum duty cycle, duty cycle hysteresis, duty cycle ramp speed, supply voltage compensation, motor characteristic compensation • Power supply configuration:....... switch-on voltage, switch-off voltage, switch-off delay, cooldown voltage threshold, cooldown delay and maximum time, cooldown mode duty cycle adjustment • Software features: ........................ status feedback, debugging • Other features:............................... configurable indicator LED on/off-board, shut-down/enable input sor temperature and fan/pump speed is controlled using numerous parameters which make the unit’s set-up very flexible. For example, you can specify both a minimum and maximum duty cycle for each output, along with the corresponding sensor temperature(s). You can also compensate for the fact that the load speed varies with supply voltage and that speed may not be proportional to voltage. For example, fan speed is roughly proportional to the cube root of the voltage applied (see siliconchip.com.au/link/aal6). The unit can linearise this control so that the fan speed doubles when the temperature (difference) doubles. All these various parameters are programmed over a USB interface so that you can avoid fiddling with trimpots or jumpers; depending on how you wire it, you can change its configuration without having to open the case – or possibly even the vehicle bonnet! This same interface can provide real-time feedback on the status of all the temperature sensors and output duty cycles. You can also temporarily override temperature sensor readings and the supply voltage to see whether the unit responds as expected. Circuit description Fig.1 shows the full circuit, which is based on PIC16F1459 microcontroller IC1. We chose this controller for the following properties: a USB interface, a very low sleep current (so it can be powered from a fixed battery supply), multiple hardware PWM outputs, multiple analog inputs plus a number of free digital inputs and outputs and sufficient flash memory and processing speed for a reasonably complex firmware program. This chip has two hardware PWM outputs at pins 5 (RC5/PWM1) and 8 (RC8/AN8/PWM2). These feed two halves of a dual low-side Mosfet driver, IC2 (TC4427A). IC2 is effectively just two high-current buffers; its output pins 7 and 5 follow the state of input pins 2 and 4 but the inputs draw minimal current (ie, have a high impedance) while the outputs can source and sink several amps peak. This high current charges and discharges the gate capacitances of Mosfets Q1a and Q1b quickly, giving rapid on and off transitions. Fast switching avoids the high dissipation which occurs when the Mosfets are in a partial siliconchip.com.au conduction state. These Mosfets are connected between the negative terminal of the fan/pump outputs at CON8 and CON9 and power ground. The positive terminal of each fan/pump output connects directly to the positive terminal of the high-current supply header, CON15. The power ground connection is also made at this connector. So essentially, the positive supply to each fan/pump comes directly from CON15 while the negative supply at CON15 connects to the fan/pump via the Mosfet channel. Hence, the Mosfets switch on power to each fan or pump when their gate is high and off when it is low. Mosfets Q1a and Q1b are in a single 8-pin SMD package and are each rated to handle up to 30V and 40A with a typical on-resistance of 4.34mΩ. This gives a continuous dissipation when conducting 10A of 434mW (10A2 x 4.34mΩ). Thus, the dual package could dissipate up to 868mW. The junction-to-ambient thermal resistance for this device is 95K/W, giving a maximum temperature rise of 82.5K (868mW x 95K), so with an ambient temperature of 55°C, we would expect a junction temperature of up to 137.5°C, which is well below the maximum rating of 175°C. In practice, the heatsinking effect of the PCB results in a lower temperature rise and so these Mosfets should each comfortably handle 10A continuously even, in the hostile environment of an engine bay. (A good rule of thumb is that a single 8-pin SOIC package can handle around 2W without becoming too hot, as long as it is connected to a reasonably-sized copper plane.) The same arrangement is used for driving fan outputs 3 and 4 at CON10 and CON11, using dual Mosfet driver IC3 and dual Mosfet Q2. These are controlled by digital output pins RC3 (pin 7) and RC4 (pin 6) of IC1. Since IC1 only has two hardware PWM pins, these must be software-controlled; they are updated from a timer-controlled interrupt handler routine which means that we can provide reasonably accurate PWM signals up to a moderate frequency (around 2kHz). Note that each output Mosfet (Q1a-Q2b) also has an associated diode to the +12VF supply rail (D1-D4). These are rated at 5A continuous, 200A peak (non-repetitive for 8.3ms) and 400V, and are included to absorb any back-EMF Australia’s electronics magazine October 2018  47 Fig.1: the Fan Controller is built around PIC microcontroller IC1, which provides PWM signals to Mosfet drivers IC2 and IC3. These then control Mosfets Q1a-Q2b to switch on and off and vary the speed of up to four fans or pumps. Up to four digital (DS18B20) or analog (10k NTC thermistor) temperature sensors can be connected via CON4-CON7. Configuration and monitoring are done via the USB interface at CON1 or CON3. from switched inductive loads such as fan motors. The back-EMF current could exceed 10A but would typically average much lower than this, well within the 5A rating. Temperature sensors Between one and four temperature sensors can be wired up to pin headers CON4-CON7. Each of these headers has a 4.7kΩ pull-up resistor from pin 1 to the 3.3V supply while pin 2 connects to ground. Pin 1 also connects to one of the following input pins on IC1: RC1/AN5, RC2/AN6, RB4/ AN10 or RB5/AN11 (pins 15, 14, 13 and 12 respectively). If a 10kΩ NTC thermistor is connected to one of these pin headers, it forms a voltage divider with the 4.7kΩ resistor to the 3.3V rail, so a voltage appears at the micro pin which drops with increasing temperature. In this case, the micro pin is configured as an analog input. The 3.3V rail is fed directly into pin 16 (VREF+) and is 48 Silicon Chip used as the ADC reference voltage. This allows for accurate ratiometric measurements of these voltages so that the temperature readings can be as accurate as the resistor and NTC tolerances allow. If a DS18B20 digital temperature sensor is used, it is configured in 2-wire mode, with its ground pin to pin 2 (ie, circuit ground) and its other two pins tied to pin 1. In this case, the sensor gets its supply voltage from the 3.3V supply via the 4.7kΩ resistor and the sensor and micro also communicate by briefly pulsing this pin low. Thus, the sensor pin is used as a digital I/O for digital sensors. During ADC conversions, the DS18B20 sensor draws more power, so the micro drives the relevant pin high to 5V, to ensure it is supplied with sufficient current. The fact that this is above the normal 3.3V level for this pin is not a problem because the DS18B20 can operate with a varying supply voltage as long as it is in the range of 3.0-5.5V. Australia’s electronics magazine siliconchip.com.au approximate range of -10°C to +105°C. The temperature sensor inputs could also be used as digital inputs under some circumstances, to either inhibit the operation of a fan or pump or to force it on. We’ll explain how to do this later. Essentially, if you leave an input open, you get a very low temperature reading while if you short it out, you get a very high temperature reading. Supply voltage sensing ERRATA PWM frequencies above 1kHz require a 30V+ schottky diode to be connected across the fan/pump, cathode to positive, with a current rating at least half the load’s maximum. Solder it across the unit’s outputs or the fan/pump terminals. We also suggest that you solder 10µF 25V X5R capacitors on top of the 100nF bypass capacitors for IC2 and IC3 and add a 2200µF 25V lowESR electrolytic between the +12VF and 0V (fan power input) terminals on the board. Note that the loads may run briefly when power is first applied; disconnect all loads before making a connection to CON2 (ICSP). Hence, no circuit changes are needed to use either an NTC thermistor or digital temperature sensor. You just have to tell the software which type of sensor you are using on which input, so it knows how to configure the corresponding pin. The measurement range for the DS18B20 is -55°C to +125°C and it has a specified accuracy of ±0.5°C from -10°C to +85°C. There is a precision/update rate trade-off with this type of sensor; at 1.25Hz, you get readings in 0.0625°C steps; at 2.5Hz, the steps are 0.125°C; at 5Hz, 0.25°C and at 10Hz, 0.5°C. The rate is software configurable. For an NTC thermistor, the software calculates readings from -50°C up to around +120°C but a typical thermistor is only be specified to operate from -30°C to +105°C (it may work outside these bounds but accuracy may suffer). We recommend the use of 1% tolerance thermistors which should give readings accurate to within about ±1°C in the siliconchip.com.au The unfiltered supply connection (nominally 12V) is applied to the emitter of high-voltage PNP transistor Q3. When IC1 brings its RB7 digital output (pin 10) high, this switches on small signal Mosfet Q4, as its gate voltage is then 5V above its source, which is connected to ground (0V). Q4 then sinks current from the base of Q3, via the 100kΩ series resistor, switching on Q3. The supply voltage is then applied to the 22kΩ/10kΩ resistive divider, resulting in a voltage at pin 9 of IC1 (analog input AN9) which is approximately one-third of that of the supply voltage. IC1 uses its 5V supply as the ADC reference voltage for this measurement, allowing it to measure a supply voltage of up to 16V (5V x 3.2). This is then used to decide whether IC1 should be active or go into low-power sleep mode and is also used to compensate the PWM output duty cycles for supply variations if that option is enabled. When IC1 is in sleep mode, pin 10 is driven low, switching off Q4 and Q3 and thus minimising the quiescent current. Dual diode D7 (with the two diodes connected in parallel) prevents damage to Q4, should there be a spike in the 12V supply, which could couple through the base-emitter junction of Q3 and across to the collector of Q4. Since the cathodes of D7 connect to the filtered and clamped 12V supply, any excessive voltage is conducted to TVS1 and dissipated within. When IC1 is active and pin 10 is high, this also supplies current to the input of reference regulator REG2, via a low-pass RC filter comprising a 220Ω resistor and 100nF ceramic capacitor. REG2 supplies minimal current – just the current through the four 4.7kΩ temperature sensor pull-up resistors (a maximum of 2.8mA) plus a few microamps to supply the VREF+ analog reference of IC1’s internal ADC (via pin 16). So its input is driven directly by digital output RB7 (pin 10) on IC1. This is the same pin used to control the gate of Q4, so when the supply voltage sensing is active, REG2 is also active, to provide the reference voltage to pin 16, allowing the ADC to make accurate supply and temperature sensor voltage measurements. The 220Ω series resistor from pin 10 to REG2 also limits the initial current spike from charging/discharging REG2’s 100nF input bypass capacitor to 15mA. Its low-pass filter action minimises any supply noise feeding through to the output of REG2. Power supply There are two separate power connectors; CON15 is used to feed power solely to the fans via Mosfets Q1 & Q2 while CON14 powers the rest of the circuitry. The two grounds are connected via a 1kΩ resistor for testing purposes but usually, they will both connect back to the negative terminal of the battery, effectively shorting that resistor out. The reason for the separate connectors is so when the Australia’s electronics magazine October 2018  49 fans/pumps are powered, the voltage automotive systems, so are longer drop along the wires does not affect the spikes at lower voltages. To avoid battery voltage measurement. the 220Ω resistor and TVS1 burning That could cause the unit to continuout in such a case (eg, during jump ally switch on and off if the battery voltstarting), PTC1 has been included. age is close to the cut-out threshold. That If it is conducting more than a few was a problem with our previous design, hundred milliamps, its resistance indespite it having significant built-in hyscreases after a short time. This limits teresis for the cut-out voltage. the long-term current and thus disPower for the board flows through resipation in itself and the other comverse polarity protection diode D6, two ponents. Once the supply voltage resmall schottky diodes within the same turns to normal, its resistance drops package that are connected in parallel to and it no longer has much effect on minimise the voltage drop. The supply We show the blank PCBs mainly circuit operation. current then flows through a small PTC because construction is a little unusual: REG1 is the primary regulator prothermistor and a 220Ω 3W SMD resistor using SMDs, all the components are viding power to the rest of the cirbefore reaching transient voltage sup- mounted on what would normally be cuit and it has a very low quiescent regarded as the “underside” of the pressor TVS1. current of just a few microamps. These components protect the cir- double-sided board. The large holes This means that when IC1 is in sleep along the edge allow large terminals for cuitry from the voltage spikes which are mode, the whole circuit normally connecting heavy-current motors, etc. common in automotive supplies. TVS1 draws less than 1mA and so has virclamps the voltage at input pin 8 of REG1 to a maximum tually no effect on battery life. of about +18V and -1V while conducting around 1A; this We’re using the high-voltage version of this regulator, value is based on an expected maximum spike voltage of rated to survive with an input in the range of -50V to +60V, around ±200V with current limiting due to the 220Ω se- for maximum robustness, even though the input protecries resistor. tion circuitry should prevent its supply voltage from ever While brief (~1ms), high-voltage spikes are common in coming close to those extremes. Fig.2: this web-based software (which can be run on the local PC if necessary) provides a simple interface for setting all the configuration parameters for the DC Fan Speed Controller. The text at the bottom is automatically updated and if sent to the unit’s USB serial console, will set the new configuration automatically. You can also read the configuration back out of the unit using the reverse procedure. 50 Silicon Chip Australia’s electronics magazine siliconchip.com.au This regulator requires an output filter capacitor with an ESR in a specific range for stability, so we have carefully chosen a 22µF 16V tantalum capacitor with a suitable ESR over a wide temperature range, to ensure it works well in the hostile environment of an engine bay. There is no onboard fuse for the fan supplies but a fuse is required. If you don’t have a suitable spare fuse in your fuse box, you need to add an inline fuse between the battery positive terminal and pin 1 of CON15 with a sufficiently high rating to handle the full load current. Shut down/enable input CON12 provides a method to shut down the unit’s outputs when they are not needed. For example, it could be wired to a switch in the cabin to enable or disable the extra fans or to an ECU or another computer which may decide to shut them down for some reason. By default, pulling the RA4 digital input (pin 3) on IC1 low shuts down all the outputs and this pin is held high using a software-enabled internal pull-up current. Pin 3 can be pulled low by making a connection between the pins of CON12. But the software settings can also be changed to invert the operation of this pin so that it must be pulled low to enable the outputs. USB interface The signal pins on USB socket CON1 (D- and D+) connect directly to the USB pins on microcontroller IC1 (pins 18 and 19). The micro has all the internal circuitry required for USB communication. The USB 5V pin is wired to IC1’s digital input RB6 (pin 11) via a 100kΩ resistor, so that pin is pulled high when a USB host is connected. Dual schottky diode D5 (again paralleled) allows current to flow to the micro’s 5V supply from the USB socket, so the unit can be programmed without needing an external power supply wired up to CON14. If there is already power at CON14, D5 does not conduct unless the USB 5V rail is significantly higher than 5V. D5 also prevents current from being fed back into the USB port if the USB 5V rail is a bit low. When powered from the USB supply, Mosfet drivers IC2 and IC3 have no supply voltage, so we avoid driving their inputs. Microcontroller IC1 detects this condition and disable all the PWM outputs unless the supply rail which feeds these chips is above 5V, to avoid current flowing through their input clamp diodes. IC1 needs to know when a USB connection is made so it can initiate communications with the host. If power is coming from the USB connector, then this happens immediately at power-up but if power has already been applied externally, then the only way to know when to initiate communication is by monitoring the state of pin 11. But this is a little tricky since we haven’t provided any pull-down resistor on that pin to ensure its level is low when the USB cable is not connected (this was done to save space). The trick is that we briefly set pin 11 as a digital output and pull it actively low, then set it as an input again and check the voltage. The small pin capacitance ensures that the voltage is still close to 0V when we read its state unless the USB supply is present and pulling it up to 5V. So this allows us to avoid needing the extra component; the 100kΩ series resistor is necessary to ensure that excessive current does not flow siliconchip.com.au Parts list – DC Fan/Pump Controller (main board) 1 double-sided PCB, code 05108181, 68 x 34.5mm 1 MINIASMDC014F PTC thermistor, 4832/1812 SMD package (PTC1) 1 SMD mini type B USB connector (CON1) 1 5-pin header (CON2) 1 4-pin header (CON3) 6 2-pin polarised headers with matching plugs (CON4-CON7,CON12,CON13) Semiconductors 1 PIC16F1459-I/SO microcontroller programmed with 0510818A.HEX (IC1) 2 TC4427AEOA dual low-side Mosfet drivers, SOIC-8 (IC2,IC3) 1 LM2936HVMAX-5.0 LDO regulator, SOIC-8 (REG1) 1 MCP1700-3.3 3.LDO regulator, SOT-23 (REG2) 2 BUK7K5R1-30E dual N-channel Mosfets (Q1,Q2) 1 MMBTA92 high-voltage PNP transistor, SOT-23 (Q3) 1 2N7002 N-channel Mosfet, SOT-23 (Q4) 1 blue high-brightness SMD LED, SMA package (LED1) 1 TPSMD14A transient voltage suppressor, SMC case (TVS1) 4 SD2114S040S8 5A 400V schottky diodes, SMB case (D1-D4) 3 BAT54C dual schottky diodes, SOT-23 (D5-D7) Capacitors (all SMD 3216/1206 size, 50V X7R unless otherwise stated) 1 22µF 16V SMB case tantalum [Vishay/Sprague 293D226X0016B2T] 1 10µF 16V X7R 1 1µF 25V X7R 1 470nF 50V X7R 4 100nF 50V X7R 1 1nF 50V X7R Resistors (all SMD 3216/1206 size, 1% unless otherwise stated) 2 100kΩ 1 39kΩ 2 10kΩ 4 4.7kΩ 3 1kΩ 2 220Ω 1 220Ω 5% 3W SMD 6331/2512 Other parts (case, wiring, sensors etc) 1 IP65-rated case large enough for the PCB 1-4 waterproof 10kΩ NTC thermistors with cables (TS1-TS4) and/or 1-4 waterproof DS18B20 temperature sensors (TS1-TS4) 1 USB cable with Type-A connector or chassis-mount Type-B USB socket (optional) 1 inline blade fuse holder rated at 40A or higher 1 40A blade fuse various lengths of heavy duty automotive wire (10A and 40A, red and black) through the clamp diode on that pin while the 5V bypass capacitors are charging immediately upon power-up. The unit automatically comes out of sleep mode if a USB cable is connected, so that you can communicate with it, and stays out of sleep mode as long as the USB cable is attached. But it still shuts down the outputs based on the supply voltage, so the fan/pump behaviour is not affected by using the connection state of the USB interface. In addition to the onboard micro USB connector, the USB connections are broken out to a 4-pin header, so that a USB cable or waterproof socket can be soldered directly Australia’s electronics magazine October 2018  51 to the board and either fed through a grommet in the case or mounted on the case respectively. LED feedback and programming LED1 is provided as a means to determine what the unit is doing. It can be programmed to light up when the unit has power, or light up when the unit is active (ie, not in sleep mode). Or it can be set to change brightness depending on the maximum output duty cycle. It is driven from digital output RA5 (pin 2), using software PWM to control brightness, as all the hardware PWM pins are used for the fan/pump outputs. Five-pin header CON2 allows microcontroller IC1 to be programmed once it has been soldered to the board. We expect most constructors would purchase a pre-programmed micro but if there is a software update, or if you want to program it yourself, this is possible using a PICkit 3 or PICkit 4 plugged into CON2. CON2 is designed so that it does not need to be soldered to the board; the pin header is a friction fit so it can be inserted when needed and then removed when programming is complete. High-current connections Note that while CON8-CON11, CON14 and CON15 are labelled as connectors, in each case, they are actually a pair of pads on the PCB. This is because, to save space and because of the high currents involved, and for reliability reasons, we decided it was best to make these connections by soldering wires directly onto the PCB. As you can see from the photo, the pads are large enough for thick copper wire, to ensure it can handle the high currents without excessive voltage drops or wire heating. The wires are clamped or glued to holes in the case so that the solder joints do not fatigue and fail from vibration. Set-up and software Initially, the plan was for the unit to be completely configured and controlled using the USB port, via a serial (text) interface. You would send it commands and it would display a response. This would let you set and view all the parameters, see the status and send testing commands to check that it’s operating as expected. Unfortunately, although we are using the version of this chip with the maximum amout of flash memory (16384 bytes), it was simply impossible to fit all these functions into the space available. So what we have done instead is created a separate piece of software that you run on a computer, which allows you to set all the various configuration parameters. This then produces a code which you “copy and paste” into the serial terminal to update the configuration programmed into the chip. To simplify the software, this code is a text representation of the bytes to write into the chip’s configuration memory. This interface is shown in Fig.2. The various parameters have been chosen at the top and the long configuration string is shown at the bottom. This updates as soon as you make any changes to a parameter and there’s a convenient button to copy it, ready for pasting. The USB interface provides a method to dump the unit’s configuration in the same format, and if you copy and paste this back into the setup software shown in Fig.2, all the configuration data at the top of the page is updated with the values you chose last time. So the process of making small changes to the unit’s configuration is quick and easy. You just dump the configuration in the text console, copy it, paste it into the app, make the changes, then copy the new string and paste it back into the text console. You can skip the first few steps when making subsequent changes since you will already have the app open. Status monitoring and debugging The monitoring/debugging interface lets you easily “peer inside the black box” of the Fan Controller to see what it is doing. This is done by issuing commands over the USB text console. For example, if you type “show status” then you get a listing of the current supply voltage, the temperature readings of all the connected sensors and the PWM duty cycle and frequency of each output (see Fig.3). Once you have set the unit up, so that you don’t have to manipulate the battery voltage and sensor temperatures to verify that it’s doing its job correctly, you can also issue commands to override the battery voltage and/or the temperature readings. For example, if you issue the command “override TS2 57C”, the unit behaves as if temperature sensor TS2 is giving a reading of 57°C. You can verify that the fans/pumps respond as expected, then issue another command so that the reading goes back to normal. Overriding the supply voltage works similarly. The operation of the USB interface does not interfere with the unit’s other functions, so if you can route the USB cable to allow it, it would be possible to drive around and have someone in the passenger seat monitor the temperatures, fan speeds etc, to see how they respond. Coming next month Next month we will have the full construction and wiring details of the new DC Fan Speed Controller as well as more details on how the software works, the various settings, the SC control commands and other helpful instructions. Fig.3: the text-based USB serial console interface allows you to monitor the unit’s status in real time, read and update its configuration dynamically and also perform debugging/testing actions which allow you to see how the unit responds to changes in sensor temperatures and/or supply voltage variations. 52 Silicon Chip Australia’s electronics magazine siliconchip.com.au