' {$STAMP BS2}
'{Stamp2}
' {$PBASIC 2.5}
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
Scale CON 300 ' to ms for 2 us per unit
#CASE BS2SX, BS2P, BS2PX
Scale CON 1250 ' to ms for 0.8 us per unit
#ENDSELECT
AA VAR Word
Mode VAR Word
Chg VAR Word 'charge var pulse out to load cap bank
GasPurge VAR Word 'Gas purge length
HfPuls VAR Word ' Hi freq pulse length, cap in circuit to delay off
IgbtDuty VAR Word ' PWM duty cycle
IgbtPuls VAR Word ' PWM MSec out
PostPurge VAR Word 'time to hold gas on after pulse
Charge PIN 0 'assign pin 0 to SSR charge relay
GasSol PIN 1
HiFreq PIN 2
IGBT PIN 3
FootSw PIN 7
IncrA PIN 4
IncrB PIN 5
PrgSw PIN 6
ProgramPin PIN 6 'switch selector to enter values via encoder input
Baudrate CON 32+$4000
Rate CON 10
LCD PIN 15
A CON 65
Setup:
HIGH Charge 'make P0 high (LED off)
HIGH GasSol 'make P1 high
HIGH HiFreq 'Make P2 high
HIGH IGBT 'make P3 high
INPUT 4 'Plus button
INPUT 5 'Minus button
INPUT 6 'Program button
INPUT 7 'Foot pedal
Setvalues:
Mode = 1 'Tiny Tig weld
Chg = 1601
HfPuls =500
IgbtDuty = 125 'pwm duty cycles..
IgbtPuls = 255 '
GasPurge = 1501
GOSUB LcdPrint
Main:
IF mode = 1 THEN GOSUB TinyTig
IF mode = 2 THEN GOSUB Capweld
IF Mode = 3 THEN GOSUB EDM
IF Mode = 4 THEN GOSUB Plasma
GOTO Main
TinyTig: 'this is the capacitive discharge welder subroutine.
GOSUB changeheat
IF Mode <> 1 THEN RETURN 'send back to the main loop
IF PrgSw = 0 THEN GOSUB program
IF CHARGE=0 THEN HIGH CHARGE 'TURN It back off.
IF Hifreq=0 THEN HIGH HiFreq 'turn it back off
IF GasSol=0 THEN HIGH GasSol 'turn the gas back off
IF HiFreq=0 THEN HIGH HiFreq 'turn the hi freq back off.
IF FootSw = 1 THEN GOTO TinyTig 'loop back up, looking for foot activation
LOW GasSol 'turn on the gas solonoid
LOW Charge 'turn on the charge SSR
IF FOOTSW = 1 THEN GOTO TinyTig 'loop back up, looking for foot activation
LOW GasSol 'turn on the gas solonoid
PAUSE GasPurge 'delay this long
IF FootSw = 1 THEN GOTO TinyTig 'loop back up, looking for foot activation
LOW HiFreq 'turn it on
IF FootSw = 1 THEN GOTO TinyTig 'loop back up, looking for foot activation
PWM IGBT,IgbtDuty,HFPuls ' PWM duty, HFpuls msecs..
HIGH HiFreq 'turn it off
FootStillDown:
PWM IGBT,IgbtDuty,IgbtPuls 'output this amount of PWM to the transistor..
IF IncrA=1 THEN IgbtDuty=IgbtDuty+10
IF IncrB=1 THEN IgbtDuty=IgbtDuty-10
IF Igbtduty>255 THEN Igbtduty=255
IF Igbtduty<10 THEN IgbtDuty=10
IF footsw=0 THEN GOTO FootStillDown
HIGH Charge 'turn off the charge SSR
PAUSE PostPurge 'wait this long to post purge gas on hot metal
HIGH GasSol 'turn the gas back off
GOSUB PrintVar4 'print the varibles to the screen..
GOTO TinyTig
CapWeld: 'this is the capacitive discharge welder subroutine.
GOSUB Changeheat
IF PrgSw = 0 THEN GOSUB program
IF Mode <>2 THEN RETURN 'send back to Main loop
IF CHARGE=0 THEN HIGH CHARGE 'TURN It back off.
IF Hifreq=0 THEN HIGH HiFreq 'turn it back off
IF GasSol=0 THEN HIGH GasSol 'turn the gas back off
IF HiFreq=0 THEN HIGH HiFreq 'turn the hi freq back off.
IF FootSw = 1 THEN GOTO CapWeld 'loop back up, looking for foot activation
LOW GasSol 'turn on the gas solonoid
LOW Charge 'turn on the charge SSR
PAUSE chg 'Delay this long and charge the capacitor bank
IF FootSw = 1 THEN GOTO CapWeld 'loop back up, looking for foot activation
LOW GasSol 'turn on the gas solonoid
HIGH charge 'it back off now loaded capacitors
PAUSE GasPurge 'delay this long
IF FootSw = 1 THEN GOTO CapWeld 'loop back up, looking for foot activation
LOW HiFreq 'turn it on
PAUSE HfPuls 'delay this long
IF FootSw = 1 THEN GOTO CapWeld 'loop back up, looking for foot activation
PWM IGBT,IgbtDuty,IgbtPuls 'output this amount of PWM to the transistor..
HIGH HiFreq 'turn it back off
PAUSE PostPurge 'wait this long to post purge gas on hot metal
HIGH GasSol 'turn the gas back off
LiftFoot2:
IF FootSw=0 THEN GOTO LiftFoot2
GOTO Capweld
Edm: 'this is the spark discharge subroutine.
GOSUB ChangeHeat
IF mode <> 3 THEN RETURN 'send back to main loop
IF PrgSw = 0 THEN GOSUB program
IF CHARGE=0 THEN HIGH CHARGE 'TURN It back off.
IF Hifreq=0 THEN HIGH HiFreq 'turn it back off
IF GasSol=0 THEN HIGH GasSol 'turn the gas back off
IF HiFreq=0 THEN HIGH HiFreq 'turn the hi freq back off.
IF FootSw = 1 THEN GOTO EDM 'loop back up, looking for foot activation
LOW GasSol 'turn on the solonoid
LOW Charge 'turn on the charge SSR
PAUSE chg 'Delay this long and charge the capacitor bank
IF FootSw = 1 THEN GOTO EDM 'loop back up, looking for foot activation
LOW HiFreq 'turn it on
PAUSE hfpuls 'build plasma ball in handle..
LOW GasSol 'turn on the solonoid and blow plasma ball
IF FOOTSW = 1 THEN GOTO EDM 'loop back up, looking for foot activation
LiftFoot3:
PWM IGBT,IgbtDuty,IgbtPuls 'output this amount of PWM to the transistor..
IF FootSw=0 THEN GOTO LiftFoot3
HIGH HiFreq 'turn it back off
PAUSE PostPurge 'wait this long to post purge gas on hot metal
HIGH GasSol 'turn the gas back off
GOTO Edm
Plasma: 'Plasma subroutine
IF Mode <> 4 THEN RETURN 'send back to Main loop
IF PrgSw = 0 THEN GOSUB program
IF CHARGE=0 THEN HIGH CHARGE 'TURN It back off.
IF Hifreq=0 THEN HIGH HiFreq 'turn it back off
IF GasSol=0 THEN HIGH GasSol 'turn the gas back off
IF HiFreq=0 THEN HIGH HiFreq 'turn the hi freq back off.
IF FootSw = 1 THEN GOTO Plasma 'loop back up, looking for foot activation
LOW Charge 'turn on the charge SSR
PAUSE chg 'Delay this long and charge the capacitor bank
IF FootSw = 1 THEN GOTO plasma 'loop back up, looking for foot activation
LOW HiFreq 'turn on the air solonoid
PAUSE Hfpuls
IF FootSw = 1 THEN GOTO Plasma 'loop back up, looking for foot activation
LOW GasSol 'turn it on
IF FootSw = 1 THEN GOTO Plasma 'loop back up, looking for foot activation
FootStillDown4:
PWM IGBT,IgbtDuty,IgbtPuls 'output this amount of PWM to the transistor..
IF footSw=0 THEN FootStilldown4
GOTO Plasma
LcdPrint:
SEROUT LCD,BAUDRATE, RATE,[92,66,32,32]
FOR AA = 1 TO 255
SEROUT Lcd,Baudrate,Rate,[92,91,32] 'Print the space character TO wipe..
NEXT
SEROUT Lcd,Baudrate,Rate,[92,66,32,32] 'locate 1stth line down..
SEROUT LCD,Baudrate,Rate,[92,91,67,79,70,69,82,45,69,78,71,73,78,69,82,73,78 ,71,82,79,66,79,84,73,67,83]
'Cofer-Engineering-Robotics
SEROUT Lcd,Baudrate,Rate,[92,66,32,33] 'locate 2nd line down..
SEROUT LCD,Baudrate,Rate,[92,91,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61 ,61,61,61,61,61,61,61,61,62] ' SEND THE LCD SIGnal
SEROUT Lcd,Baudrate,Rate,[92,66,32,34] 'locate 3rd line this line
SEROUT LCD,Baudrate,Rate,[92,91,67,72,65,82,71,69] ' Charge time
SEROUT Lcd,Baudrate,Rate,[92,66,32,35] 'locate 4th line down..
SEROUT LCD,Baudrate,Rate,[92,91,80,85,82,71,69] ' Purge
SEROUT Lcd,Baudrate,Rate,[92,66,32,36] 'locate 5th line down..
SEROUT LCD,Baudrate,Rate,[92,91,72,73,70,82,69,81] ' HiFreq
SEROUT Lcd,Baudrate,Rate,[92,66,32,37] 'locate 6th line down..
SEROUT LCD,Baudrate,Rate,[92,91,80,87,77,32,68,85,84,89] ' PWM Duty
SEROUT Lcd,Baudrate,Rate,[92,66,32,38] 'locate 7th line 4th line down..
SEROUT LCD,Baudrate,Rate,[92,91,80,87,77,32,80,85,76,83,69] ' PWM pulse
SEROUT Lcd,Baudrate,Rate,[92,66,32,39] 'locate 8th line down..
SEROUT LCD,Baudrate,Rate,[92,91,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 ] ' SEND THE LCD SIgnal
GOSUB printVar1 'charge time varible
GOSUB printvar2 'Gas purge time
GOSUB printvar3 'HF pulse duration
GOSUB printvar4 'PWM duty cycle
GOSUB printvar5 'pwm Msec
GOSUB printvar6 'mode of operation
RETURN
PrintVar1:
SEROUT Lcd,Baudrate,Rate,[92,66,42,34] 'locate 3rd x 10 over
SEROUT LCD,Baudrate,Rate,[92,91,32,32,32,32,32,32,32,32] ' diplay Charge time
SEROUT Lcd,Baudrate,Rate,[92,66,42,34] 'locate 3rd x 10 over
SEROUT Lcd,Baudrate,Rate,[92,66,42,34] 'locate 3rd x 10 over
SEROUT LCD,Baudrate,Rate,[92,91,48+(chg DIG 3),48+(chg DIG 2),48+(chg DIG 1),48+(chg DIG 4)] ' diplay Charge time
RETURN
PrintVar2:
SEROUT Lcd,Baudrate,Rate,[92,66,42,35] 'locate 4th x 10 over
SEROUT LCD,Baudrate,Rate,[92,91,32,32,32,32,32,32,32,32] ' diplay
SEROUT Lcd,Baudrate,Rate,[92,66,42,35] 'locate 4th x 10 over
SEROUT LCD,Baudrate,Rate,[92,91,48+(GasPurge DIG 3),48+(GasPurge DIG 2),48+(GasPurge DIG 1),48+(GasPurge DIG 4)] ' Purge msec
RETURN
PrintVar3:
SEROUT Lcd,Baudrate,Rate,[92,66,42,36] 'locate 5th line down..
SEROUT LCD,Baudrate,Rate,[92,91,32,32,32,32,32,32,32,32] ' diplay
SEROUT Lcd,Baudrate,Rate,[92,66,42,36] 'locate 5th line down..
SEROUT LCD,Baudrate,Rate,[92,91,48+(HfPuls DIG 1),48+(HfPuls DIG 2),48+(HfPuls DIG 3),48+(HfPuls DIG 4)] ' HiFreq msec
RETURN