Hallo !!!
Please Help me correctly set up the configuration of ZCD detection, Interrupts and firing impulse in creating program code for PIC16F1709.
This is a continuation of topic "triac firing angle using PIC12F1840."
Used information from http://microchip.wikidot.com/tip:13).
Places where I am waiting for reply and I do not understand , in comments is a question mark.
Thank you all !!!
dir PORTxxx out '' how to configure the PWM output to a any free pin to work hpwm1 ?????
''==========================================
InitTimer0 Osc,PS0_128
On Interrupt Timer0Overflow Call impuls_on
''===================================
'' Zero Cross Detection Initialization Code - RA2 pin (from Microchip Developer Help page http://microchip.wikidot.com/tip:13)
ZCD1EN = 1 '' Turn on the ZCD peripheral
ZCD1INTN = 1 '' Turn on the negative edge polarity detect
ZCD1INTP = 1 '' Turn on the positive edge polarity detect
ZCDIF = 0 '' Clear the interrupt flag
ZCDIE = 1 '' Turn on the ZCD interrupt
PEIE = 1 '' Enable peripheral interrupt
GIE = 1 '' Enable global interrupt
''Are there all for ZCD RA2 configuration???
''===========================
on Interrupt ExtInt0 call impuls_off '' Is this correct?
main:
'' code for alpha_ref and 7-segment display Operation
goto main
''========================== open triac
sub impuls_on
set alpha on
end sub
''=========================== close triac
sub impuls_off
if ZCDIF then '' ZCD interrupt flag bit , Is this correct?
set alpha off
cleartimer 0
timer0=alpha_ref
ZCDIF=0
end if
end sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have looked at the code. Let us simplify. See attached. One interrupt routine - check this now checks the flags to understand what event fired.
I have let a few [todo] in the file as I do not know from my quick look this morning. You will have to study the datasheet or others may know the answer.
Thank Anobium!
This chip is is very complex ... I will find it difficult to understand and correctly configured. Anobium, maybe later when you have time, look at the datasheet and correct the code to the end? I'll try soon (today or tomorrow) to buy the PIC16F1709 and make experimental board .
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have requested a sample from Microchip today. It will take a few days to get here.
As a workaround, you have two options.
Use - IPE-Pusher this is included within your install. The automizes programming PIC microprocessors with Microchips
"Integrated Programming Einvironment" IPE.
Tested with IPE 3.10 & 3.15 and PicKit3 (China-Clone).
IPE-Pusher works only, if
IPE is running,
a programmer and
a PIC is connected.
IPE-Pusher reads two commandline parameters, edit the FLASHPIC.BAT within your IDE to get this working.
Use MPLAB. You use MPLAB only to program the chip. The hex is generated in GCB and you simply import the HEX into MPLAB and then write the file out.
@All. Anyone got a PK2DeviceFile.dat with this device installed and working? It would save me a few hours. :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hallo !!!
Please Help me correctly set up the configuration of ZCD detection, Interrupts and firing impulse in creating program code for PIC16F1709.
This is a continuation of topic "triac firing angle using PIC12F1840."
Used information from http://microchip.wikidot.com/tip:13).
Places where I am waiting for reply and I do not understand , in comments is a question mark.
Thank you all !!!
/#chip 16f1709, 4
/#config osc=int
'' portC used for 7seg LED
/#define DISP_SEG_A PORTC.1
/#define DISP_SEG_C PORTC.2
/#define DISP_SEG_D PORTC.3
/#define DISP_SEG_E PORTC.4
/#define DISP_SEG_F PORTC.5
/#define DISP_SEG_G PORTC.6
/#define dot PORTC.7
/#define 7Seg_CommonAnode
dir portc out
''====================
/#define alpha PORTA.3
/#define button PORTA.4
dir button in
dir alpha out '' triac firing signal
''=============================
'' PWM for pulse trafo
hpwm 1,5, 127 ''HPWM channel, frequency, duty cycle 50%
dir PORTxxx out '' how to configure the PWM output to a any free pin to work hpwm1 ?????
''==========================================
InitTimer0 Osc,PS0_128
On Interrupt Timer0Overflow Call impuls_on
''===================================
'' Zero Cross Detection Initialization Code - RA2 pin (from Microchip Developer Help page http://microchip.wikidot.com/tip:13)
ZCD1EN = 1 '' Turn on the ZCD peripheral
ZCD1INTN = 1 '' Turn on the negative edge polarity detect
ZCD1INTP = 1 '' Turn on the positive edge polarity detect
ZCDIF = 0 '' Clear the interrupt flag
ZCDIE = 1 '' Turn on the ZCD interrupt
PEIE = 1 '' Enable peripheral interrupt
GIE = 1 '' Enable global interrupt
''Are there all for ZCD RA2 configuration???
''===========================
on Interrupt ExtInt0 call impuls_off '' Is this correct?
main:
'' code for alpha_ref and 7-segment display Operation
goto main
''========================== open triac
sub impuls_on
set alpha on
end sub
''=========================== close triac
sub impuls_off
if ZCDIF then '' ZCD interrupt flag bit , Is this correct?
set alpha off
cleartimer 0
timer0=alpha_ref
ZCDIF=0
end if
end sub
I have looked at the code. Let us simplify. See attached. One interrupt routine - check this now checks the flags to understand what event fired.
I have let a few [todo] in the file as I do not know from my quick look this morning. You will have to study the datasheet or others may know the answer.
Thank Anobium!
This chip is is very complex ... I will find it difficult to understand and correctly configured. Anobium, maybe later when you have time, look at the datasheet and correct the code to the end? I'll try soon (today or tomorrow) to buy the PIC16F1709 and make experimental board .
Finally I've bought 16f1709 with ZCD. But there is a big problem - PICkit 3 do not support this microcontroller ...
Is it possible get the latest PICkit 3 firmware version?
I think device file version.
I have requested a sample from Microchip today. It will take a few days to get here.
As a workaround, you have two options.
"Integrated Programming Einvironment" IPE.
IPE-Pusher reads two commandline parameters, edit the FLASHPIC.BAT within your IDE to get this working.
Use MPLAB. You use MPLAB only to program the chip. The hex is generated in GCB and you simply import the HEX into MPLAB and then write the file out.
@All. Anyone got a PK2DeviceFile.dat with this device installed and working? It would save me a few hours. :-)