mamalala I changed the inductors by iron powder toroids, no heat and no heatsinks.
I installed a 16x2 LCD controlled with a psoc and a reset button.
(The position of the HF connector and the reset button is limited by internal space of the box)
The way it works will tell it to you the source code.
Chip: CY8C29466 from Cypress.
Developed in Psoc Designer 5.4 Cypress free software.
This is the main.c
//----------------------------------------------------------------------------
// C main line
//----------------------------------------------------------------------------
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include "stdlib.h"
#include "string.h"
// you must use this lines if you used ljmp instruction at the interrupt .asm files for each module
// in this case PSoCGPIOINT.asm and IDLETIMERINT.asm
#pragma interrupt_handler TipDetectionISR
#pragma interrupt_handler TimeoutISR
unsigned int vforward;
unsigned int vreflect;
unsigned int vregulator;
float vf;
float vx;
float vr;
BYTE barvr;
BYTE idle;
int Statusf;
int Statusx;
int Statusr;
// tip detection interrupt service routine
void TipDetectionISR(void)
{
if (Tipdetector_Data_ADDR & Tipdetector_MASK) RF_EN_On();
else RF_EN_Off();
}
// gets 3 digital values of three conversions made at the same time
void Adc(void)
{
while(TRIADC_1_fIsDataAvailable() == 0){}; // Wait for data to be ready
vforward = TRIADC_1_iGetData1(); // Get Data from ADC Input1
vreflect = TRIADC_1_iGetData2(); // Get Data from ADC Input2
vregulator = TRIADC_1_iGetData3ClearFlag(); // Get Data from ADC Input3
// and clear data ready flag
}
// timeout interrupt service routine
void TimeoutISR(void )
{
RF_EN_Off();
IDLETIMER_Stop();
idle=2;
}
// sets the active status
void Isidle(void )
{
if (RF_EN_GetState())
{
//if regulator voltage does not reach 9.6V you are not soldering, you must change this value for other tips.
//or make a tip menu, as I only use 1 this is my threshold.
if (vr<9.6)
{
IDLETIMER_WritePeriod(5493); // timeout period.
IDLETIMER_WriteCompareValue(0);
IDLETIMER_EnableInt();
IDLETIMER_Start(); // stats timeout timer.
idle=1;
}
// if you are soldering automatically changes active status.
else
{
IDLETIMER_DisableInt();
IDLETIMER_Stop();
idle=0;
}
}
else if (idle<2)
{
idle=3;
}
}
// numerical conversions
void Traduce(void)
{
vf=5.00*((float)vforward)/1023.00; // do the conversion you like here
vx=5.00*((float)vreflect)/1023.00;
vr=29.1644172*((float)vregulator)/1023.00; // 29.1644172 constant adjusts value to match true rms voltage of the regulator
barvr=(BYTE)((int)(40.00*(((float)vregulator)/772.00))); //772.00 for 21V max, 1023 for 28V max.
}
//manages the LCD
void Actualizar(void)
{
if (idle==2) // timeout reached, press reset
{
LCD_1_Position(0,0);
LCD_1_PrCString("Apagado ");
LCD_1_Position(1,0);
LCD_1_PrCString("pulsa reset ");
}
else if (idle==3) // no tip detected, insert it
{
LCD_1_Position(0,0);
LCD_1_PrCString("Cartucho ");
LCD_1_Position(1,0);
LCD_1_PrCString("desconectado ");
}
else
{
LCD_1_DrawBG(1,0,8,barvr);
// "0123456789abcdef"
// "On f=1.23 x=1.23"
LCD_1_Position(1,10);
LCD_1_PrCString("V=");
LCD_1_PrString(ftoa(vr,&Statusr)); //prints a float to string conversion
LCD_1_Position(0,3);
LCD_1_PrCString("f=");
LCD_1_PrString(ftoa(vf,&Statusf));
LCD_1_Position(0,9);
LCD_1_PrCString(" x=");
LCD_1_PrString(ftoa(vx,&Statusx));
LCD_1_Position(0,0);
// prints the active status
if (idle==0)
{
LCD_1_PrCString("On ");
}
else if (idle==1)
{
LCD_1_PrCString("Id ");
}
}
}
void main(void)
{
//adc temp variables
vforward=0;
vreflect=0;
vregulator=0;
//float adc converted variables
vf=0.0;
vx=0.0;
vr=0.0;
//active status 0 ON, 1 IDLE, 2 OFF, 3 tip disconnected so OFF too.
idle=0;
//power bar filler
barvr=0;
//ensures timeout timer is off
IDLETIMER_Stop();
RF_EN_Start();
// first test, if tip connected rfON else rfOFF
if (Tipdetector_Data_ADDR & Tipdetector_MASK) RF_EN_On();
else RF_EN_Off();
M8C_EnableIntMask(INT_MSK0, INT_MSK0_GPIO); //enable interrupt for GPIO pins
M8C_EnableGInt; // Enable global interrupts CAMBIAR
LCD_1_Start();
//bar graph on lcd, only ram configuration, this line does not show a bar by itself
LCD_1_InitBG(LCD_1_SOLID_BG);
//set the power status of the gain amplifiers/buffers
PGA_1_SetGain(PGA_1_G1_00);
PGA_1_Start(PGA_1_HIGHPOWER);
PGA_2_SetGain(PGA_2_G1_00);
PGA_2_Start(PGA_2_HIGHPOWER);
PGA_3_SetGain(PGA_3_G1_00);
PGA_3_Start(PGA_3_HIGHPOWER);
TRIADC_1_Start(TRIADC_1_HIGHPOWER); // Turn on Analog section
TRIADC_1_SetResolution(10); // Set resolution to 10 Bits
TRIADC_1_GetSamples(0); // Start ADC to read continuously
//let's start
for(;;)
{
Adc(); // triple analog digital converter 3 inputs at the same time
Traduce(); // numerical conversions
Isidle(); // configures active status
Actualizar(); // screen information
}
}
This is PSoCGPIOINT.asm
; Generated by PSoC Designer 5.4.2946
;
;;*****************************************************************************
;;*****************************************************************************
;; FILENAME: PSoCGPIOINT.asm
;; Version: 2.0.0.20, Updated on 2003/07/17 at 12:10:35
;; @PSOC_VERSION
;;
;; DESCRIPTION: PSoC GPIO Interrupt Service Routine
;;-----------------------------------------------------------------------------
;; Copyright (c) Cypress Semiconductor 2013. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************
include "m8c.inc"
include "PSoCGPIOINT.inc"
;-----------------------------------------------
; Global Symbols
;-----------------------------------------------
export PSoC_GPIO_ISR
;-----------------------------------------------
; Constant Definitions
;-----------------------------------------------
;-----------------------------------------------
; Variable Allocation
;-----------------------------------------------
;@PSoC_UserCode_INIT@ (Do not change this line.)
;---------------------------------------------------
; Insert your custom declarations below this banner
;---------------------------------------------------
;---------------------------------------------------
; Insert your custom declarations above this banner
;---------------------------------------------------
;@PSoC_UserCode_END@ (Do not change this line.)
;-----------------------------------------------------------------------------
; FUNCTION NAME: PSoC_GPIO_ISR
;
; DESCRIPTION: Unless modified, this implements only a null handler stub.
;
;-----------------------------------------------------------------------------
;
PSoC_GPIO_ISR:
;@PSoC_UserCode_BODY@ (Do not change this line.)
;---------------------------------------------------
; Insert your custom code below this banner
;---------------------------------------------------
ljmp _TipDetectionISR
;---------------------------------------------------
; Insert your custom code above this banner
;---------------------------------------------------
;@PSoC_UserCode_END@ (Do not change this line.)
reti
; end of file PSoCGPIOINT.asm
This is IDLETIMERINT.asm
;;*****************************************************************************
;;*****************************************************************************
;; FILENAME: IDLETIMERINT.asm
;; Version: 2.6, Updated on 2013/5/19 at 10:44:39
;; Generated by PSoC Designer 5.4.2946
;;
;; DESCRIPTION: Timer16 Interrupt Service Routine
;;-----------------------------------------------------------------------------
;; Copyright (c) Cypress Semiconductor 2013. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************
include "m8c.inc"
include "memory.inc"
include "IDLETIMER.inc"
;-----------------------------------------------
; Global Symbols
;-----------------------------------------------
export _IDLETIMER_ISR
AREA InterruptRAM (RAM,REL,CON)
;@PSoC_UserCode_INIT@ (Do not change this line.)
;---------------------------------------------------
; Insert your custom declarations below this banner
;---------------------------------------------------
;------------------------
; Includes
;------------------------
;------------------------
; Constant Definitions
;------------------------
;------------------------
; Variable Allocation
;------------------------
;---------------------------------------------------
; Insert your custom declarations above this banner
;---------------------------------------------------
;@PSoC_UserCode_END@ (Do not change this line.)
AREA UserModules (ROM, REL)
;-----------------------------------------------------------------------------
; FUNCTION NAME: _IDLETIMER_ISR
;
; DESCRIPTION: Unless modified, this implements only a null handler stub.
;
;-----------------------------------------------------------------------------
;
_IDLETIMER_ISR:
;@PSoC_UserCode_BODY@ (Do not change this line.)
;---------------------------------------------------
; Insert your custom assembly code below this banner
;---------------------------------------------------
; NOTE: interrupt service routines must preserve
; the values of the A and X CPU registers.
;---------------------------------------------------
; Insert your custom assembly code above this banner
;---------------------------------------------------
;---------------------------------------------------
; Insert a lcall to a C function below this banner
; and un-comment the lines between these banners
;---------------------------------------------------
ljmp _TimeoutISR
;---------------------------------------------------
; Insert a lcall to a C function above this banner
; and un-comment the lines between these banners
;---------------------------------------------------
;@PSoC_UserCode_END@ (Do not change this line.)
reti
; end of file IDLETIMERINT.asm