Showing posts with label software. Show all posts
Showing posts with label software. Show all posts

Thursday, 6 September 2018

Surface Pro (2018) for Embedded Software Development

Summary
This blog examines the feasibility of using the Surface Pro 2018 'Surface' as an alternative to a Windows based laptop or desktop machine for the purpose of embedded software development.

Consideration was given to targeted metrics which consisted of physical handling, connectivity, storage speed and keyboard solutions. For a performance comparison, two common software packages were used to compile example projects on the Surface and a reference Asus laptop. Metrics dependent on factors which were difficult to verify, such as battery life, were not examined.


Surface Pro i5
Surface Pro i5
Testing was performed on a Surface Pro i5 over the duration four weeks, with the default Windows 10 Professional installation.


Surface Pro Hardware
Surface Pro Hardware

The Surface Pro i5 uses the Intel 7300U processor and was loaded with 8GB of RAM running Windows 10 Professional.


Surface Pro Windows Version
Surface Pro Windows Version

Handling and Portability
As a desktop replacement, without the addition of a keyboard such as the Surface Type, the Surface Pro 'Surface' is a befitting of the name space saver. Notably for small benches or work spaces the footprint of the Surface is very appealing which makes shifting or repositioning the Surface comparably easy moving from a laptop.

Off the bench in general use, the low weight of the Surface results in relative ease of movement. The kickstand was adjusted in the same manner a laptop display would be moved to cater for varying locations or seated positions.


Bluetooth
During point and select operation during code changes, use the Surface Pen was used without any issue. Other Bluetooth devices in the same proximity to the Surface did not cause any interference. 

Wireless
The wireless maintained connection whether at short distances (1m) or longer distances (30m) from a wireless router (BiPac). Only one dropout was noted during the test period.

Wi-Fi Bandwidth testing was performed using a local server, albeit slow. The Surface and Asus devices were both loaded with IPerf 3.1.3, then several tests conducted. Tests were conducted using the bidirectional configuration in IPerf.

SO_SNDBUF is 212992
[  4] local x.x.x.x port 56795 connected to y.y.y.y port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec  18.8 MBytes   157 Mbits/sec
[  4]   1.00-2.00   sec  15.8 MBytes   132 Mbits/sec
[  4]   2.00-3.00   sec  12.8 MBytes   107 Mbits/sec
[  4]   3.00-4.00   sec  11.5 MBytes  96.2 Mbits/sec
[  4]   4.00-5.00   sec  10.8 MBytes  90.4 Mbits/sec
[  4]   5.00-6.00   sec  10.0 MBytes  83.7 Mbits/sec
[  4]   6.00-7.00   sec  11.6 MBytes  97.6 Mbits/sec
[  4]   7.00-8.00   sec  11.0 MBytes  92.3 Mbits/sec

[  4]   8.00-9.00   sec  10.8 MBytes  90.1 Mbits/sec

Shown below are the results of the bandwidth tests conducted.


Surface Pro vs Asus Wi-Fi Bandwidth Results
Surface Pro vs Asus Wi-Fi Bandwidth Results
USB
The Surface's single port USB connection could certainly be considered a limitation for a embedded software or hardware developer who may need two or more USB ports.

During development the single Surface USB port was connected to a USB hub which facilitated a mouse, keyboard and programming adaptor. In some instances a serial adaptor was required. There were no issues relating to the download of drivers, operation of the USB or the performance of the adaptors.


Storage
For copying medium sized (>500Mb) files between computers either, an SD card or USB drive was used. With a meagre 128 Gb internal SSD, the removable SD card was used to store working files and backups.

The USB port was usually broken out to a hub, consequently little commentary on use with insertion of various USB equipment.

Inserting and removing the SD card from the Surface was seamless. The location of the SD slot behind the kickstand resonated with me for typical operation. 

For comparison of copy speeds for the SD card, an Asus i7-77HQ provided results as a reference device.

SD Speed
SD Card testing was performed with a Strontium Nitro 433X Class 10 16 Gb SD using the test software H2testw 1.4. This package was selected because it was capable of testing SD and USB.


Strontium Nitro 433X
Strontium Nitro 433X
Several tests were conducted using the Strontium Nitro on the Surface and Asus with the results displayed below.


Surface Pro vs Asus SD Card Read Speeds
Surface Pro vs Asus SD Card Read Speeds


Surface Pro vs Asus SD Card Write Speeds
Surface Pro vs Asus SD Card Write Speeds
USB Speed
Speed testing was performed with a Silicon Power USB 3 32GB drive using the same test software, H2testw 1.4, that was used with the SD card.


Silicon Power USB 3 Drive
Silicon Power USB 3 Drive
Again several tests were conducted using the Silicon Power USB on the Surface and Asus with the results displayed below.


Surface Pro vs Asus USB Drive Read Speeds
Surface Pro vs Asus USB Drive Read Speeds
Surface Pro vs Asus USB Drive Write Speeds
Surface Pro vs Asus USB Drive Write Speeds
Software Compile Times
The first application used for comparing software compile times was the 'Maker' popular Arduino, version 1.8.6.

Arduino
Three example projects were built on the Surface and an Asus laptop. Timing of the compile process was performed manually therefore some tolerance in timing shall be noted.


Surface Pro vs Asus Arduino Project Compile Times
Surface Pro vs Asus Arduino Project Compile Times
PSoC Creator
Again three example projects provided by Cypress were built on the Surface and an Asus laptop using PSoC Creator 4.2 'IDE'. Timing of the compile process was taken from the start and end times noted in the IDE output window.


Surface Pro vs Asus PSoC Creator Project Compile Times
Surface Pro vs Asus PSoC Creator Project Compile Times
Code Editing
Editing code with an application such as PSoC Creator, utilising the on-screen Surface keyboard was more cumbersome compared to a standard mechanical keyboard. One of the primary reasons was the standard Surface keyboard on-screen layout results in additional key presses to realise straightforward characters. For instance, at worst case, curly, round or square brackets would require three button presses.
A further reason for using a Surface Keyboard or a similar external keyboard solution was the on-screen keyboard does not display when text areas are clicked for editing. The on-screen keyboard had to be invoked manually.


Silicon Labs PSoC Creator Project on Surface Pro
Silicon Labs PSoC Creator Project on Surface Pro
On-Screen Keyboard
There were some initial complications with phantom presses. Applying the Microsoft HotFix for Surface Pro 4 resolved this issue.

Using the Surface Pro in landscape mode was personally the preferred option when writing code because the rear stand was used in the lowest position. Typing with the Surface flat on the desk was achievable although did not suit my office layout. The above image shows typically the ratio of code to keyboard that was used while developing the Silicon Labs blog.

Surface Pen
For specific editing tasks such as selection of text, repositioning selected text or moving on-screen objects the Surface Pen is a handy tool however, a standard external mouse will achieve the same result. People using the Surface Pen for more advanced tasks may have different feedback on its suitability.

Microsoft Surface Cover (Keyboard)
As a keyboard solution, the Surface Cover was more than reasonable with the depth of keystrokes sufficient to provide tactile feedback. The backlight keys on the Surface Cover were handy when typing whilst in low lighting conditions.


Surface Pro with Surface Cover
Surface Pro with Surface Cover
Final Thoughts
For embedded software development the Surface Pro is a worthy competitor to devices with similar specifications and features already in the market. 

In this setting, pro's for the Surface were the lightweight, fan less design, ease in handling and a solid Wi-Fi performance.

Unsurprisingly con's for the Surface related to limited connectivity resulting from the single USB port, throttled processor performance and initial phantom touch screen issues. The latter touch issue being the most obstructive as this phenomenon prevented device useability to the point of preventing logging onto the Operating System.

In a nutshell choosing the most suitable device ultimately depends on the requirements of the end user. Certainly for embedded software development other devices such as the middle to high end Lenovo Yoga, Dell Inspiron 13 or the HP Spectre may be a more suitable solution.


Monday, 12 February 2018

Win 10 Serial Terminal software max baud rate

Summary
This purpose of this blog was to identify the maximum baud rate of several Windows 10 serial port terminal programs when used with an FTDI USB to TTL adaptor which had a specified rate of 3Mbaud.

Addendum: PCTerm 3.7 added to test results for testing 3Mbaud.

Test Setup
A Cypress PSoC development kit CY8CKIT-042 was configured with a UART component to repeatedly send the sequence of capitilised letters A to Z. 


PSoC and FDTI Test Setup
PSoC and FDTI Test Setup
The associated transmit output and 0V reference from the development kit were connected to the receive input and 0V on the FTDI USB to TTL adaptor (TTL-232R-RPi).


FDTI TTL-232R-RPi Adaptor
FDTI TTL-232R-RPi Adaptor
The USB side of the FTDI adaptor was connected to a Windows 10 laptop for the duration of the software testing. Specifications for the laptop are shown below.


Windows 10 Test System Specifications
Windows 10 Test System Specifications

Validation Criteria
There were only two criteria that the software needed to fulfil in order to be accepted as a pass for this test.

1. Display the characters A - Z on the terminal software in either ASCII or HEX and

2. Terminal software should still be useable - meaning not crash, lockup or become unresponsive for the duration of the test


Test Software
Listed below are the ten Windows terminal applications that were tested.

1. Advanced Serial Port Monitor

2. CoolTerm

3. Hype!Terminal

4. Muterm2

5. Putty

6. RealTerm

7. Serial Port Terminal

8. TeraTerm

9. Termite

10. XShell5

11. PC Term 3.7


Test Results
It should be noted that this test was performed under the conditions detailed below.

1. The various Windows terminal applications were used for receiving characters only,

2. Some of the various Windows terminal applications were used in their trial installation mode or the latest Beta of the application,

3. Some Windows terminal applications did have faster baud rates which were not tested,

4. Only standard baud rates such as 115200, 230400, 460800, 921600 and higher were used while determining the maximum receive baud rate of the Windows terminal applications for this specific hardware setup.


Windows Terminal Software Max Data Rate Test Results
Windows Terminal Software Max Data Rate Test Results
PCTerm was added to this blog, post publishing and it was proven to be the fastest in data rate for displaying ASCII text. RealTerm was the fastest in data rate for displaying data in Hex.

Other notable mentions; Putty, Hype!Term and Advanced Serial Port Monitor.

Test Notes
During testing TeraTerm performed without any issues receiving data at 921600 baud.


TeraTerm Receiving Data at 921600
TeraTerm Receiving Data at 921600
Similarly with RealTerm the receive window configured to display in ASCII no issues were noted.

RealTerm Receiving Data at 921600 - ASCII Displayed
RealTerm Receiving Data at 921600 - ASCII Displayed
Changing RealTerm to display in HEX at 921600 resulted in slow performance and issues relating to the onscreen refresh. Reducing the baud rate to 460800 resolved the display issues. Similarly adding a 1us delay between characters at 921600 resolved the onscreen refresh.

RealTerm Receiving Data at 921600 - HEX Displayed
RealTerm Receiving Data at 921600 - HEX Displayed
PCTerm 3.7 performed at 3Mbaud without any issues to display ASCII.


PCTerm Receiving Data at 3Mbaud - ASCII Displayed
PCTerm Receiving Data at 3Mbaud - ASCII Displayed

Test Code
Basic test code with an option to add inter-character delays.

/* ========================================
*
* Example Terminal Speed Test PSoC4
*  
* Revision:    1.00
* Date:        10/02/2018

* 10/02/2018   1.00     Test release
*
* Released as GPL
*
* ======================================== */
#include <project.h>
#include <stdio.h>
#include <stdbool.h>


int main()
{   
    uint8 count_i;                               /* Define for loop counter var */
    uint16 char_delay = 0;                  /* Define intercharacter character delay in ms*/
    
    CyGlobalIntEnable;                      /* Enable global interrupts. */
    UART_Start();
    while (SW1_Read() == true);     /* Wait for button press */
    UART_UartPutString("Start");
    
    for(;;)
    {
        count_i = 65u;
        while (count_i <= 90u) {
            UART_UartPutChar(count_i);
            if (char_delay != 0u) {
                CyDelayUs(char_delay);
            }
            count_i++;
        }
    }
}

/* [] END OF FILE */


PSoC Creator Changes for PCTerm
The default HFClock 'HFClk' for the PSoC Creator UART is 24MHz. As this clock rate results in only 1.5Mbaud, the HFClock was increased to 48MHz.


PSoC Creator HFClk Increase to 48MHz
PSoC Creator HFClk Increase to 48MHz
Using the UART SCB component with an external 48MHz clock resulted in the required 3Mbaud data rate.


PSoC Creator Top Design SCB UART with 24MHz External Clock
PSoC Creator Top Design SCB UART with 24MHz External Clock
The properties of the SCB UART displayed the 3Mbaud UART data rate.


PSoC Creator SCB UART at 3Mbaud
PSoC Creator SCB UART at 3Mbaud

Summary
PCTerm, RealTerm and TeraTerm are noteworthy Windows based serial terminal applications which would serve hobbyists and professionals alike. Personally, i am habitual in installing software such as RealTerm and TeraTerm on computers involved in software or hardware development. Further to the recent addendum testing PCTerm, this application may replace TeraTerm in some instances.

It should be noted that each of the terminal applications mentioned in this blog were tested for the specific purpose of receiving with a high baud rate. When choosing a suitable serial terminal application, each specimen of software should be reviewed under its own merit to ensure its suitability for the intended task.

When a more comprehensive look at data is required then a protocol analyser is usually required. These solutions range from all in one devices such as the Analog Discovery 2 by Digilent to dedicated input only products such as the Saleae Logic devices to high end products from Keysight. From experience, even the low cost Digilent Analog Discovery 2 will efficiently record and display the character test performed in this blog!

Friday, 8 December 2017

Venus Heat Sealer (VHIB) controller module update

Summary
Other than using a resealable shielded plastic bag for protecting electronic components, the humble heat sealer must come in a close second for a more permanent solution when sealing plastic bags. There is however, a reasonable difference in build quality of heat sealers.


Venus Pack - Heat sealer
Venus Pack - Heat sealer
This blog shows how a Venus heat sealer controller could be updated, with a view to improving the robustness of the design.

Heat Sealer
The subject of this blog was a product by Venus Pack which had seen a decade of use with only one trip back to the manufacturer for a repair. The actual model was VHIB200.
Heat sealer model VHIB200
Heat sealer model VHIB200
After transporting the sealer to a new location, the unit heat sealing became intermittent. Evidently this behaviour was similar to the last issue before manufacturer repair. Time for review and rebuild.



Warning and Disclaimer
The voltages present in this design are 240V AC, which can easily kill. Care and steps should be taken to prevent electrocution. Wiring of this nature should only be performed by experienced persons. I take no responsibility whatever for misuse of the information detailed on this blog.

Heat Sealer Controller
Shown below is an image of the damaged controller. The culprit turned out to be a leaded resistor. Note the leftmost resistor in image below, with the lead snapped from the body.


Heat sealer controller damaged resistor
Heat sealer controller damaged resistor
The board was repaired with a smaller wattage resistor as a temporary fix, shown below.


Heat sealer controller
Heat sealer controller
Controller Design
The heat sealer control board design is a simple single sided board using an RC timer to operate a relay which powers the transformer which drives the heater element. Using the potentiometer the heater element operating period is set.

Below is the original heat sealer schematic showing the main components involved in the units operation. This schematic was taken from the original documentation, PDF available here.


Venus Pack Heat Sealer Schematic
Venus Pack Heat Sealer Schematic
A digital current clamp was used to measure the currents on the primary and secondary of the transformer. The primary current peaked at 2.5A and the transformer secondary current peaked at over 10A. With these currents in mind it was decided to switch the transformer primary in a similar manner to the existing design which used a relay.

Controller Redesign
The changes to the controller design were firstly to move away from a relay to a TRIAC. The relay was responsible for switching of the primary of the transformer which powers the heater element. Secondly the new design was primarily made with surface mount components and separated into two circuit boards for isolation.

Similar to other designs in my blogs, a Cypress PSoC (CY8C4245) was used. For a design with relatively simple control requirements, ADC in and digital out almost any controller could be used, should a few dollars need to be shaved off the project.

Schematic Design (TRIAC and Power Supply)
Unlike the factory circuit design with derived non-isolated DC from the mains AC supply, the redesign was fully isolated between AC and DC. The TRIAC and power supply, essentially the high voltage items, were restricted to one of the circuit boards for the design. To achieve the isolation a small brick AC to DC power supply was utilised from Vigortronix, model VTX-214-001-106. With a dielectric isolated over 4kV this was more than sufficient for mains voltages. The 6V DC output was supplied to a 5V linear regulator as shown below.


Impulse Sealer Power Supply
Impulse Sealer Power Supply
An optional voltage divider was included on the output of the AC DC supply as a power supply fail sensing feature for the 6V supply.

For the TRIAC, isolation was achieved using one of the well known OnSemiconductor devices, the MOC3041. The OnSemi part has zero crossing, 400V peak blocking voltage.


Impulse Sealer Isolated TRIAC Drive
Impulse Sealer Isolated TRIAC Drive
The TRIAC itself, ST part T810-600B, is rated at 8A 600V with a 5mA to 50mA gate trigger current range. There are a number of resources available for optically isolated TRIAC designs such as this oldie from Panasonic Industrial - Driving Triacs with Phototriacs. Should that link become extinct, here is a PDF version here on Google Drive, credit to the original author. Another article worth a read, originally from Fairchild, Application Note AN-3004 Applications of Zero Voltage Crossing Optically Isolated Triac Drivers or here on Google Drive.

In order to drive the optical isolator LED, some 15mA of current was required. Certainly 15mA of sourcing current is not possible from a single pin on the PSoC device, although some designers are more than willing to parallel up a handful of spare outputs with current sharing resistors - not a good design principle.


MOC3041 Transfer Characteristics
MOC3041 Transfer Characteristics
Literally for less than a dollar a SN74LVC2G17 Dual Schmitt Trigger and Buffer was used as the device driven by the PSoC to control the MOC3041. The maximum IO current for this device is 50mA which provides a strong drive current for the LED of the opto isolator.

Schematic Design (PSoC and IO)
The second circuit board used in the design contained devices that operated at lower voltages which included the PSoC, buffers, LED and potentiometer.

In the design shown below the PSoC controller shows inputs and outputs (IO) for the TRIAC control, ADC, LED drive, UART debug, option resistors and programming header. Not shown is the power supply decoupling section.


Impulse Sealer PSoC Design
Impulse Sealer PSoC Design
To provide input protection to the PSoC ADC inputs 10R resistors with rail to rail steering diodes were included in the design.


PSoC Basic Input Protection
PSoC Basic Input Protection
Operator control to set the sealer operating time was achieved using a standard wiper based potentiometer and feedback to the operator using a bicolour LED.


Bicolour LED and Potentiometer
Bicolour LED and Potentiometer
Connection of the PSoC controller and peripheral hardware is achieved on an upper level sheet in the design software.


Impulse Sealer Upper Schematic
Impulse Sealer Upper Schematic
PCB Design (Sketch)
After performing a brief disassembly of the original impulse sealer controller, the dimensions of single sided circuit board were recorded. These were used to define the size of the new circuit boards.


Impulse Sealer PCB Dimensions
Impulse Sealer PCB Dimensions
In addition to the overall circuit board dimensions, the original mounting location of the potentiometer, mounting screw and LED were also taken. A hand drawn sketch usually works out to be time saving information for the PCB designer especially when boards contains several or more specifically places components such as connectors, buttons or LED's.
Impulse Sealer Blank Power Supply PCB
Impulse Sealer Blank Power Supply PCB
Also included on the blank circuit board where a pair of M2.5 mounting holes to mechanically hold the pair of circuit boards - TRIAC and Power Supply together.

PCB Layout (TRIAC and Power Supply)
All schematic parts were checked then brought into the PCB design software. The image below shows a draft parts placement separating the high voltage on the left hand of the board and low voltage with TRIAC control on the right side of the board.
Impulse Sealer Power Supply Draft Placement
Impulse Sealer Power Supply Draft Placement
Using Saturn PCB Toolkit to check the voltage creep distance for the left and right sides resulted in a distance of more than 2.5mm. The distance between the low and higher voltage is based on the peak voltage not the usual 240VAC RMS measurement. The circuit board layout was updated, as shown in the image below, to allow for more than 5mm between the high and low voltage sections of the design.


Impulse Sealer Power Supply Final Placement
Impulse Sealer Power Supply Final Placement
At the top right hand corner of the image above is a 4-way through hole inter board connector. This connector provides power to the controller board, control for the optoisolator and a feedback voltage from the output of the 6V power supply.

Routing the board was achieved using a double sided route. A top layer 0VDC polygon was used for the low voltage side of the board.


Impulse Sealer Power Supply Routed PCB
The circuit board power supply bottom side is shown below in 3D.


Impulse Sealer Power Supply 3D
Impulse Sealer Power Supply 3D
PCB Layout (Controller)
The blank circuit board for the microcontroller board keeps the same dimensions as the power supply board. Also included on the board were the pair of M2.5 mounting holes, the location of the potentiometer, LED and central mounting hole.
Impulse Sealer Blank Controller PCB
Impulse Sealer Blank Controller PCB
To ensure the location of the potentiometer, LED and central mounting hole were correct the two related parts were placed on the circuit board.


Impulse Sealer Controller PCB - LED and Potentiometer
Impulse Sealer Controller PCB - LED and Potentiometer
The image below shows a draft parts placement which kept in mind the orientation of the M2.5 mounting holes and the power supply circuit board interconnect.
Impulse Sealer Controller Draft Placement
Impulse Sealer Controller Draft Placement
Some minor changes were made to layout to facilitate a simpler route, final parts placement is shown in the image below.


Impulse Sealer Controller Final Placement
Impulse Sealer Controller Final Placement
Routing the board was achieved using a four layer board. Top and bottom were used for signals, bottom for a 0VDC polygon with the two internal planes used for 5V and 0V power.
Impulse Sealer Controller Routed PCB
Impulse Sealer Controller Routed PCB
The circuit board power supply top side is shown below in 3D.


Impulse Sealer Controller 3D
Impulse Sealer Controller 3D
PCB Population
Both the blank circuit boards were populated then fitted together with M2.5 x 12mm brass bolts and spacers. Nylon spacers would be a better solution for a more permanent solution.


Impulse Sealer Controller PCB Populated
Impulse Sealer Controller PCB Populated
The above image shows the controller circuit board with the PSoC, potentiometer and bi-colour LED visible. Connection between the controller and power supply boards was achieved using a 4-way header as shown above.


Impulse Sealer Power Supply PCB Populated
Impulse Sealer Power Supply PCB Populated
Shown in the above image is the power supply circuit board with the AC to DC power supply module, TRIAC and associated components.


Software PSoC Top Design
At the top schematic sheet of PSoC Creator there are only a few components, some of which are optional. In the image below the pin allocation of inputs and outputs are shown.


Impulse Sealer Pin Allocation
Impulse Sealer Pin Allocation

Shown in the image below are the inputs relating to the operational mode (optional) and outputs driving the bicolour LED and TRIAC.


Impulse Sealer Inputs and Outputs
Impulse Sealer Inputs and Outputs
For control of the TRIAC output a 100msec system 'tick' timer was used as part of the software. As an alternative solution, a Timer component could also have been used in a one shot mode. This has some advantages relating to code and timing accuracy.


Impulse Sealer Internal Tick Timer
Impulse Sealer Internal Tick Timer
To convert the potentiometer voltage the usual ADC component was used in single ended mode and referenced to Vref.


Impulse Sealer ADC
Impulse Sealer ADC
Lastly for debugging during software development, a UART component was added to round off the design.


Impulse Sealer UART
Impulse Sealer UART

Test Code
To test the controller board, operational code was written with some provisions for additional measurements from the PSoC (die) temperature sensor and the output voltage of the AC to DC power supply brick.

The only provision for activation of the TRIAC was to match the Venus 0.2sec ON time and the OFF time was increased to around 3sec.



/*==============================================================================
 *
 * Heat Sealer Project
 *
 * Implements CPU control of a heat sealer design
 *
 * Built with Creator 4.1.0.3210
 *
 * 1/10/2017 - Intial write
 * 
*/

#include <project.h>
#include <stdio.h>

/* Defines */
#define CHANNEL_1           (0u)
#define CHANNEL_2           (1u)
#define CHANNEL_3           (2u)
#define NO_OF_CHANNELS      (3u)

/* ISR Prototypes */
CY_ISR_PROTO(isr_Timer);
CY_ISR_PROTO(isr_ADC);

/* Function Prototypes */
void Initialize();
void LED_Colour(uint8 led_colour, uint8 state);

/* Global Defines */
#define false                           0
#define true                            1
#define red                             1
#define green                           2
#define orange                          3

/* Global Variables */
volatile uint32 windowFlag              = 0;
volatile uint8  dataReady               = 0;
uint16  ADC_Die_Temp                    = 0;        /* Future use */
uint16  ADC_DC_Supply                   = 0;        /* Future use */
uint16  ADC_Run_Pot                     = 0;
uint8 channel                           = CHANNEL_1;
int16 adcVal[4u];

/* Function Prototypes */
void Initialize(void);
void LED_Colour(uint8 led_colour, uint8 state);

//==============================================================================
// Timer Interrupt
//==============================================================================
CY_ISR(isr_Timer)                       
{
    if (ADC_Run_Pot != 0) {
        ADC_Run_Pot--;                              /* Decrement the run timer - 100msec steps */
    }
    isr_Timer_ClearPending();                       /* Reset interrupt */
    Timer_Ticks_ClearInterrupt(Timer_Ticks_INTR_MASK_CC_MATCH);
}

//==============================================================================
// ADC Int
//==============================================================================
CY_ISR(isr_ADC)                        
{
    uint32 intr_status;

    intr_status = ADC_SAR_INTR_MASKED_REG;          /* Read interrupt status registers */
    if((intr_status & ADC_EOS_MASK) != 0u)          /* Check for End of Scan interrupt */
    {
        windowFlag = ADC_SAR_RANGE_INTR_MASKED_REG; /* Read range interrupt status and raise the flag */  
        ADC_SAR_RANGE_INTR_REG = windowFlag;        /* Clear range detect status */
        dataReady = 1u;
    }
    ADC_SAR_INTR_REG = intr_status;                 /* Clear handled interrupt */
    ADC_IRQ_ClearPending();
}

//==============================================================================
// Set LED Colour
// Passed the LED colour and state for driving bicolour LED
//==============================================================================
void LED_Colour(uint8 led_colour, uint8 state)
{
    switch (led_colour)
    {
    case red:
        if (state == true) {
            LED_R_Write(true);
            LED_G_Write(false);
        }
        if (state == false) {
            LED_R_Write(false);
            LED_G_Write(false);
        }
    break;
    case green: 
        if (state == true) {
            LED_R_Write(false);
            LED_G_Write(true);       
        }
        if (state == false) {
            LED_R_Write(false);
            LED_G_Write(false);
        }
    break;
    case orange: 
        if (state == true) {
            LED_R_Write(true);
            LED_G_Write(true);
        }
        if (state == false) {
            LED_R_Write(false);
            LED_G_Write(false);
        }
    break;
    }    
}


//==============================================================================
// Init PSoC 
//==============================================================================
void Initialize()
{
    ADC_SetChanMask(0x1);                                               /* ADC set channel mask - 3 channels */
    ADC_Start();                                                        /* ADC component start */
    ADC_StartConvert();                                                 /* ADC conversion start */
    #if defined DEBUG
        UART_Start();                                                   /* UART start - 115200 8 N 1 */
        UART_UartPutString("Impluse Sealer\r\n");
    #endif
    Timer_Ticks_Start();                                                /* Start 100ms system timer */
    isr_Timer_StartEx(isr_Timer);                                       /* Attach timer handler */
    isr_ADC_StartEx(isr_ADC);                                           /* Attach ADC handler */
}


//==============================================================================
// Main
//==============================================================================
int main()
{
 CyGlobalIntEnable;                                                  /* Enable global interrupts */
    Initialize();
    LED_Colour(orange, true);                                           /* Flash orange LED to verify start */
    CyDelay(250);
    LED_Colour(orange, false);
    while (dataReady == 0u){};                                          /* Read the potentiometer value */
    adcVal[CHANNEL_1] = ADC_GetResult16(CHANNEL_1);
    channel = CHANNEL_1;
    ADC_Run_Pot = 0x138A - ADC_CountsTo_mVolts(channel, adcVal[CHANNEL_1]); /* Invert potentiometer - hardware direction */
    ADC_Run_Pot = (ADC_Run_Pot / 300u) + 2;                             /* Scale the result, 0.2sec min, 3sec max */
    dataReady = 0u;                                                     /* Rearm in case a conversion is required */
    TRIAC_Write(true);
    LED_Colour(green, true);                                            /* Green LED ON to show run cycle */  
    for(;;)                                                             /* Loop here until sealer unpowered */
    {
        if ((ADC_Run_Pot == 0) && (TRIAC_Read() == true)) {             /* Switch OFF only is TRIAC is ON */
            TRIAC_Write(false);
            LED_Colour(green, false);                                   /* Green LED OFF */
        }      
    }  
}
/* [] END OF FILE */


Load Testing TRIAC
To load test the TRIAC on the power supply board an old 2200W 240V AC kettle, partially filled with water, served as the load. In order to keep the circuit AC test voltages low, a step down toroidal transformer was utilised. The transformer used in the test setup shown below had a pair of 18V secondary windings connected in series. Unloaded voltage was 43V AC which was suitably higher than the minimum operating voltage of the TRIAC.


Impulse Sealer PSU Board TRIAC Load Testing
Impulse Sealer Power Supply Board TRIAC Load Testing
During initial setup it was noted that the Vigortronix AC to DC supply was operating with the low 42V AC input voltage providing 6.2V DC and enough current to power the buffer driving the TRIAC. The Vigortronix datasheet states 90V AC minimum for the supply.

To ensure the TRIAC was not conducting when the 42V AC was supplied the control line, usually driven from the PSoC, was connected to 0V as shown in the image below.

Impulse Sealer PSU Board
Impulse Sealer Power Supply Board 
A full load test was not conducted on the PSU board, although the 27R resistance of the kettle provided over 1A of current through the load - enough to heat the TRIAC.


Impulse Sealer PSU Board TRIAC During Load Testing
Impulse Sealer Power Supply Board During Load Testing
When 5V DC was applied to the TRIAC control line the current measured through the load was 1.4A AC, as shown in the image above. The supply voltage dropped to 38V AC when the load was connected.

The input voltage was increased to around 80V AC using a second transformer in series. The waveform seen by the load is seen below. Captured in the waveform is the activation of the impulse sealer, marked by the position of the trigger 'T', then the subsequent voltage supplied to the load as seen by the AC waveform.


Impulse Sealer Load Turn ON
Impulse Sealer Load Turn ON
In addition the minimum (0.216sec) and maximum (1.8sec) run time, based on the extents of the potentiometer position, were captured.


Impulse Sealer Min Run Time
Impulse Sealer Min Run Time


Impulse Sealer Max Run Time
Impulse Sealer Max Run Time

Operational Testing
To perform a full load test and check the operation of the design, the controller and power supply boards were fitted together then wired into the existing unit as a mock-up of the completed design.


Impulse Sealer Removed Transformer
Impulse Sealer Removed Transformer
Shown in the above image is the step down transformer removed from the impulse sealer chassis. The blue and green cables are the 240V AC mains supply and the two red cables are the primary to the transformer.

Below the image shows the updated controller and power supply fitted together. The existing four way connector on the impulse sealer was removed and replaced with crimped ferrules.


Impulse Sealer New Controller and Power Supply
Impulse Sealer New Controller and Power Supply
After the connections were verified the impulse sealer was reassembled, transformer mounted back into the chassis and controller mounted into its original side mounting position.


Impulse Sealer Assembly
Impulse Sealer Assembly
A new brushed black aluminium knob was fitted to the controller, no trimming to the potentiometer shaft was needed. The controller was then mounted with a single bolt and bench testing was then performed.


Impulse Sealer Controller Mounted
Impulse Sealer Controller Mounted
Below is a short capture of the impulse sealer being tested using an antistatic bag (PET).




Using a Fluke 325 true RMS clamp meter, a number of AC current and voltage measurements were taken when the impulse sealer was activated.

Primary Voltage: 240.3V
Primary Current: 1.75A

Secondary Voltage: 13.3V
Secondary Current: 13.8A

Prototype Release
For those wanting to use this project - schematics, Gerbers and PSoC project is available below.

Bug reports or schematic feedback is invited, enjoy!


Impulse Sealer Controller Schematics
Impulse Sealer Controller Schematics

Impulse Sealer PSU Schematics
Impulse Sealer PSU Schematics

Impulse Sealer Controller Gerber
Impulse Sealer Controller Gerber

Impulse Sealer PSU Gerber
Impulse Sealer PSU Gerber

PSoC Creator 4.1 DC Fan Controller
PSoC Creator 4.1 Impulse Sealer
A Note on Improvements
For those looking to update the code, there was additional functionality added to the PCB to allow measurement of the AC DC converter output voltage. A scaled 6V DC output was made available on a PSoC ADC compatible pin.

On the same line of thought relating to code improvements, the internal PSoC die temperature was also made available to the PSoC ADC.