For the CT circuit, its link is previously posted, of 10A/5mA has 4 legs, two for input two for output.
We have agreed to shunt a 200 ohm resistors to its output legs, then enter it to comparator biased circuit same as VT one; the problem is, even in its datasheet no statings were found to define the input from output terminals, so using a DVM, i made a resistivity check for both two sides: on the front two legs, the resistance was too high (O.L) on the rear two legs, the resistance was of 150 ohms, doens't this mean that the front legs must be connected in series with the fan, and the rear legs must be shunted with the burden and connected to LM358 circuit?
Something does not look right. For the current transformer, the input side should be having a very low resistance because that will take a high current. The resistance should be less than 1R because at 10A it will dissipate 100W. The output side (secondary side) resistance will be of the order of 10-100R (can be even 1K) because it will be loaded with a resistor to convert the current into a voltage. If one winding is showing very high resistance (OL), the winding is perhaps open. Can you please post a picture of the CT you are using?
- - - Updated - - -
I think you need to pass the current carrying conductor through the hole in the transformer and use the output from the winding showing 150R. Leave the two legs without continuity open.
Here it is:
**broken link removed**
ASM: org 0x800
Define LCD_LINES = 4
Define LCD_CHARS = 16
Define LCD_BITS = 8 'allowed values are 4 and 8 - the number of data interface lines
Define LCD_DREG = PORTB
Define LCD_DBIT = 0 '0 or 4 for 4-bit interface, ignored for 8-bit interface
Define LCD_RSREG = PORTD
Define LCD_RSBIT = 0
Define LCD_EREG = PORTD
Define LCD_EBIT = 2
Define LCD_RWREG = PORTD 'set to 0 if not used, 0 is default
Define LCD_RWBIT = 1 'set to 0 if not used, 0 is default
Define LCD_COMMANDUS = 2000 'delay after LCDCMDOUT, default value is 5000
Define LCD_DATAUS = 100 'delay after LCDOUT, default value is 100
Define LCD_INITMS = 100 'delay used by LCDINIT, default value is 100
'the last three Define directives set the values suitable for simulation; they should be omitted for a real device
Lcdinit 0 'initialize LCD module; cursor is blinking
Dim volt As Word
Dim current As Word
Dim x As Single
Dim timer As Word
timer = 0
main:
WaitMs 800
Lcdcmdout LcdClear
Adcin 2, current
Adcin 1, volt
Lcdout "", #volt
Lcdcmdout LcdLine2Home
Lcdout "", #current
start:
If current = 0 Then
timer = timer + 1
If volt = 0 Then
Goto stop
Else
Goto start
Endif
Endif
stop:
Lcdcmdout LcdLine3Home
Lcdout "T = ", #timer
WaitMs 800
Goto main
End
Why don't you try two antiparallel zener diodes, about 3V, put at the input of the comparator for the V detector circuit?
I think you may have a hardware problem and possibly software as well.
The ZCD circuits may well have overloaded inputs, particularly the voltage detector. This could lead to latch-up or even damage to the LM358s.
A 6V RMS transformer with little load is probably producing aound 7V (the rated voltage is specified under load) so peak to peak it will reach (2 * SQRT(2) * 7) ~20V. That is within the maximum differential range of the LM358 but the absolute input voltage should not exceed the supply voltage (ON Semi data sheet, page 3). The resistors in series with the inputs will help to protect the IC but such excesive voltages applied across the inputs probably causes them to alternately clamp and measure on each half cycle. This may still work but I would be concerned about long term reliability.
You will get more consistent results if you further reduce the voltage from the 6V transformer, possibly clamping it so it stays within ground/5V levels. Even better is to remove the transformer completely and use an opto-coupler. It would be smaller, still give isolation and the output would already be at logic levels and maybe give better noise immunity. Remember that a fixed phase shift in the voltage sensor is not important because that will be your reference 'zero' anyway, what is important is that the reference is stable or the timing will be inaccurate.
The phase angle is simply a measure of the time delay between voltage and current zero crossings, presented as a proportion of one cycle. It can be mathematically calculated once you know the exact AC frequency, tables are not needed.
For highest precision, you want a hardware timer to reset at voltage zero crossing and reach it's maximum count (255, 65535...) at the end of one AC cycle. That means that if you stop the timer as the current passes zero, it will hold the most accurate measurment of elapsed time. Take into consideration the AC frequency when working out the timer counting rate, for example tdo you have to cater for 50Hz or 60Hz AC and if it will be used on a generator supply, should it be able to work if the engine is slightly over or under speed. I would recommend you use either TMR1 in TMR3 in this application.
Which compiler are you using to write your code?
Brian.
You can do it many ways. All of the above are valid methods but I would suggest there is a better way of using the optocoupler that avoids the high power rated resistor and is also more efficient. What isn't clear is those schematics show a 24V AC input but I'm guessing you really have 220V AC and they do not show how the voltage is dropped to 24V. If you use a reactive circuit, for example another transformer, it will introduce a phase shift of it's own which only complicated things further.
I suggest you do it this way:
Connect the 220V AC input to two 47K 0.5W resistors, one in each wire (for safety, they are electrically in series anyway) then to a bridge rectifier with it's output wired to the LED side of the optocoupler. So its similar to the final schematic in your last post but the bridge rectifier is on the LED side of the resistors. By moving the bridge you no longer have to use high voltage diodes, you can use small signal diodes (1N4148 for example) because the LED clamps the voltage across them to no more than about 2V.
The optocoupler method has almost zero phase shift and is entirely voltage operated so it gives a good reference to reset the delay counter.
Brian.
You really need an oscilloscope to see the waveform but from those readings it is likely to be working properly. The output of the optocoupler will be very short pulses at twice AC line frequency (remember the waveform crosses zero twice per cycle). A DVM on a DC range will not have time to sample the voltage so the reading will be wrong, similarly on the AC range it will be calibrated for a sine waveform so with pulses the reading will be wrong. The fact that there is a reading other than 5V means there is signal present so it is probably good.
I would like to make a suggstion that makes the software easier: connect the ZCD signals to RB0, RB1 or RB2 on the PIC. The reason I suggest this is because those three pins can be used as interrupt inputs. Ideally, you want to start and stop the timer as rapidly as possible when the zero crossing is detected. If you use the polling method (reading the pins in sequence) there will inevitably be some additional delay as the software steps through the code to the instruction that reads the pin state. If you use interrupts you can get a faster response because the ZCD signal itself can trigger the timer routines in hardware rather than software. It is up to you, the inaccuracy with the polling method is small if you are using a fast clock speed anyway.
Brian.
You don't have to use PORTB but it will give the most accurate measurement.
The program flow is like this:
1. configure the timer so it counts internal clock cycles.
2. turn the timer off so it doesn't count by itself.
3. zero the timer so you have a known starting value.
4. configure the PIC so RB0 and RB1 are interrupt inputs.
5. write an interrupt service routine (ISR) that gets called when RB0 or RB1 have a signal on them.
6. if the interrupt came from RB0, turn the timer on. (voltage ZCD)
7. if the interrupt came from RB1, turn the timer off. (current ZCD)
The value in the timer is then proportional to the delay between the two zero crossings. From that value and how fast the timer was counting, you can calculate the elapsed time and therefore the phase angle between the signals.
Your current ZCD circuit is good. If you want to add extra protection in case of high current spikes (they will translate to high voltage spikes from the CT) you can do it easily with 4 small signal diodes. Wire two to each input pin at the LM358, one diode to ground with it's cathode to the IC, the other to +5V with it's anode to the IC. They will not do anything at all in normal operation because they are reverse biased but if the voltage tries to go below ground or above 5V they will conduct and clamp it to a safe level.
Brian.
No, that's not quite right.
The voltage detection is done with the opto-coupler and the two resistors. It is inherently protected because the LEDs inside the opto-coupler are constant voltage devices, it means the voltage across them can not go above their rated Vf (~1.2V) and any excess voltage will be turned into heat in the resistors. So you do not need to protect the opto-coupler circuit.
That isn't true of the LM358 though. If the voltage at it's input pins is allowed to go higher than its supply voltage or go below the ground potential (=negative in your circuit) it might damage the IC. If you wire the diodes as in my diagram it should protect the IC.
(sorry if the image is rotated in your browser, Edaboard sometimes does that)
The diodes are wired so they never normally conduct so they will have no effect on the zero crossing waveform. If the voltage goes too high or too low, one of the diodes will start to conduct and safely 'dump' the excess power to ground or the supply line. The reason I suggest protection on the current monitoring circuit is that the secondary voltage in the CT is proportional to the current in the primary (the power wire passing through it). With the 60W fan as load there would be no problem but if you accidentally put a heavier load or a short circuit on it, the secondary voltage would be much higher.
I often find people are frightened of using interrupts but they are incredibly useful things. The only difference between a 'normal' subroutine and an ISR is that a subroutine is called from within the software and an ISR is called in response to a hardware condition. In practical terms, that means the ISR may be called at any time because the program may be unaware of what is happening in the world around it and therefore there has to be a method of remembering what the program was doing so it can return to it after the interrupt has been dealt with.
The classic example is you are watching a DVD and your phone rings. You press the pause button on the DVD player, answer the call then cancel the pause and carry on watching the movie. In the example, the movie is the main program and the phone call is the interrupt. When you press pause you are saving the place in the movie so you can return to it when you have finished your conversation.
In PIC software an ISR first saves some of the critical registers so they can be used within the ISR. At the end of the ISR, the contents of those registers is restored and the routine finishes. The main program then continues without knowing the interrupt ever happened.
I will have to have to read the documentation on how Oshonsoft do it. I have a copy of all their compilers but I normally program in C or assembler so I'm 'rusty' at BASIC !
Yes, those are the kind of diode I meant.
Brian.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?