Help with Power Monitor Please !
Moderator: Benj
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Help with Power Monitor Please !
Hi Fellas,
I am just trying to put a little program together that will monitor the power to a mains pump, I have the signal conversion sorted from the pump with an opto isolator which is connected to pin A0, however when I run the simulation nothing happens, I have tried to follow the chart and it should call the fault macro but it does not.
Any help would be appreciated.
thanks in advance
Acestu
I am just trying to put a little program together that will monitor the power to a mains pump, I have the signal conversion sorted from the pump with an opto isolator which is connected to pin A0, however when I run the simulation nothing happens, I have tried to follow the chart and it should call the fault macro but it does not.
Any help would be appreciated.
thanks in advance
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Help with Power Monitor Please !
Hi Acestu,
Problem is with you decision Icon.
Instead of
STATE <= 0
(<= means less or = )
So it will never see logic1
and you cant get less than 0 with bytes.
You can have
STATE > 0
or
STATE
or
STATE =1
When you alter to one of the above your Flowchart should work.
Martin
Problem is with you decision Icon.
Instead of
STATE <= 0
(<= means less or = )
So it will never see logic1
and you cant get less than 0 with bytes.
You can have
STATE > 0
or
STATE
or
STATE =1
When you alter to one of the above your Flowchart should work.
Martin
Martin
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: Help with Power Monitor Please !
Hi Martin,
Thanks for that, I am a bit confused today with all that is going on, I will have another go now.
Cheers
Acestu
Thanks for that, I am a bit confused today with all that is going on, I will have another go now.
Cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: Help with Power Monitor Please !
Hi Martin,
I have tried and it still does not want to work, I am assuming that if my switch is down (on) that it is supplying a value of 1 at the input pin B0, therefore if the switch is switched off then 0 is supplied to the pin B0(power failure) so the calculation must ask if the input pin B0 equals 0, which would be:
if STATE = 0
Or am I wrong
thanks
Acestu
I have tried and it still does not want to work, I am assuming that if my switch is down (on) that it is supplying a value of 1 at the input pin B0, therefore if the switch is switched off then 0 is supplied to the pin B0(power failure) so the calculation must ask if the input pin B0 equals 0, which would be:
if STATE = 0
Or am I wrong
thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Help with Power Monitor Please !
ah sorry you are correct. I misread
I was thinking if logic or voltage at input is high = +5V then go into macro, as that's what i usually do
If the other way around then you are correct the two that will work are:
if STATE = 0
or
if STATE <1
Martin
Attached is a correct Flowchart.
I added an input to monitor within your fault Detection macro.
Note it states A0 on your control panel, but I have let flowchart as B0
Martni
I was thinking if logic or voltage at input is high = +5V then go into macro, as that's what i usually do
If the other way around then you are correct the two that will work are:
if STATE = 0
or
if STATE <1
Martin
Attached is a correct Flowchart.
I added an input to monitor within your fault Detection macro.
Note it states A0 on your control panel, but I have let flowchart as B0
Martni
- Attachments
-
- power_monitor 2.fcf
- (17 KiB) Downloaded 215 times
Martin
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: Help with Power Monitor Please !
Hi Martin,
I still don't know what is happening here because it seems to be back to front, as in when I first start the simulation the switch is down thus providing a signal of 1 which should make the LCD say "Healthy Supply" and when you switch the switch off then that is when the fault macro should be called.... does that make sense..
thanks
Acestu
I still don't know what is happening here because it seems to be back to front, as in when I first start the simulation the switch is down thus providing a signal of 1 which should make the LCD say "Healthy Supply" and when you switch the switch off then that is when the fault macro should be called.... does that make sense..
thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Help with Power Monitor Please !
Hi Acestu,
when the Flowchart is 1st ran, the switch is down = i/p low (or 0V) that is when it reads PSU fault.
When the switch is up = input high (+5) psu is shown as OK If you do not want it as that way around it can be changed.
So if you want to show fault when input is less than 1V the Flowchart is correct way round.
A bit of advice, press F8 to single step and make sure the variables are added to the variables window.
Martin
when the Flowchart is 1st ran, the switch is down = i/p low (or 0V) that is when it reads PSU fault.
When the switch is up = input high (+5) psu is shown as OK If you do not want it as that way around it can be changed.
So if you want to show fault when input is less than 1V the Flowchart is correct way round.
A bit of advice, press F8 to single step and make sure the variables are added to the variables window.
Martin
Martin
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: Help with Power Monitor Please !
Hi Martin,
What I have done is added an LED to the same port as the toggle switch and it appears that when the switch is down it is actually off and not on as you would think.
thanks
Acestu
What I have done is added an LED to the same port as the toggle switch and it appears that when the switch is down it is actually off and not on as you would think.
thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: Help with Power Monitor Please !
Ok Martin,
I understand it now, in the options for the switch you can swap from active high to active low, I thought this meant that you could toggle the output of the switch between 1 or 0, right I have changed it around a bit and it is working ok now except for when you press the mute sounder button and then reapply the power the delay carries on so do i need to have an interupt in there somewhere ?
thanks
Acestu
I understand it now, in the options for the switch you can swap from active high to active low, I thought this meant that you could toggle the output of the switch between 1 or 0, right I have changed it around a bit and it is working ok now except for when you press the mute sounder button and then reapply the power the delay carries on so do i need to have an interupt in there somewhere ?
thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Help with Power Monitor Please !
Edit was typing a reply when a post had be posted. So sorry if repeating?
LED Off when switch is down is correct.
You need to remember that switch is down = 0V = LED off
If switch is up = +5V = LED on
This would be the case if your sourcing LED.
To source LED the output from microcontroller goes via a current limiting resistor to the anode of LED. the cathode of LED is connected to 0V
With Sourcing if ( Active High you can change the switch to from active high to active low via external properties) o/p = +5V = logic1 then current will flow though LED so it will be illuminated.
if o/p = 0V (switch down) then 0v going into LED anode. Since cathode is connected to 0V as well there will be no current flow (anode and cathode are at the same potential) LED will be off.
If your sinking instead (active low) . Then anode of LED will be connected to +5V (via a current limiting resistor). Then if switch is down (0V) the cathode will be pulled down to 0V so LED will be on (there is a potential difference.)
If the switch is up (+5V) , then the cathode will be at the same potential as the anode (+5V) so LED will be off.
I am assuming your sourcing rather than sinking?
If so your flowchart is correct. Switch down = 0v on B0 = power failure.
The flowchart can be changed so if +5 at B0 then power failure is detected.
Martin
LED Off when switch is down is correct.
You need to remember that switch is down = 0V = LED off
If switch is up = +5V = LED on
This would be the case if your sourcing LED.
To source LED the output from microcontroller goes via a current limiting resistor to the anode of LED. the cathode of LED is connected to 0V
With Sourcing if ( Active High you can change the switch to from active high to active low via external properties) o/p = +5V = logic1 then current will flow though LED so it will be illuminated.
if o/p = 0V (switch down) then 0v going into LED anode. Since cathode is connected to 0V as well there will be no current flow (anode and cathode are at the same potential) LED will be off.
If your sinking instead (active low) . Then anode of LED will be connected to +5V (via a current limiting resistor). Then if switch is down (0V) the cathode will be pulled down to 0V so LED will be on (there is a potential difference.)
If the switch is up (+5V) , then the cathode will be at the same potential as the anode (+5V) so LED will be off.
I am assuming your sourcing rather than sinking?
If so your flowchart is correct. Switch down = 0v on B0 = power failure.
The flowchart can be changed so if +5 at B0 then power failure is detected.
Martin
Martin
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Help with Power Monitor Please !
Perhaps this will work better. if not, what would like me to change?
I have altered Flowchart so if you press mute after power has failed and alarm is on, then alarm will switch off.
So just to confirm.
Voltage at B0 i/p:
if +5V then alarm = on and power failure indicated.
If 0V then alarm = off and normal supply is indicated.
Martin
I have altered Flowchart so if you press mute after power has failed and alarm is on, then alarm will switch off.
So just to confirm.
Voltage at B0 i/p:
if +5V then alarm = on and power failure indicated.
If 0V then alarm = off and normal supply is indicated.
Martin
- Attachments
-
- power_monitor 5.fcf
- (15.85 KiB) Downloaded 196 times
Martin
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: Help with Power Monitor Please !
Hi Martin,
Sorry it is the other way round, when there is power at the pump there is +5volts at B0 and NO fault
When power goes down on the pump B0 is then 0 volts and an alarm is caused,
I wanted to mute the sounder for a set amount of time and keep coming back on as long as the alarm condition was still active, because people tend to just mute the alarm and it is forgotten about, is this possible by interrupting the delay and returning to the main part of the program ?
thanks
Acestu
Sorry it is the other way round, when there is power at the pump there is +5volts at B0 and NO fault
When power goes down on the pump B0 is then 0 volts and an alarm is caused,
I wanted to mute the sounder for a set amount of time and keep coming back on as long as the alarm condition was still active, because people tend to just mute the alarm and it is forgotten about, is this possible by interrupting the delay and returning to the main part of the program ?
thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Help with Power Monitor Please !
Hi acestu,
I have altered flowchart so the mute seconds can be set from 0 to 65535.
When power is restored,delay is canceled.
Also if switch is up then that means power is detected on B0.
If switch is down then no power is detected on B0
Simulator is working just fine.
Martin
I have altered flowchart so the mute seconds can be set from 0 to 65535.
When power is restored,delay is canceled.
Also if switch is up then that means power is detected on B0.
If switch is down then no power is detected on B0
Simulator is working just fine.
Martin
- Attachments
-
- power_monitor 5.fcf
- (21.45 KiB) Downloaded 146 times
Martin
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: Help with Power Monitor Please !
Hi Martin,
Sorry for being a pain but I can,t get this simulation to work, when you run the simulation you can toggle the switch as many times as you like and all is ok
But when you cause an alarm, press the mute button, then toggle the power back on and off again the sounder LED does not light, it sort of dosen't reset
after power is restored to B0.
thanks
Acestu
Sorry for being a pain but I can,t get this simulation to work, when you run the simulation you can toggle the switch as many times as you like and all is ok
But when you cause an alarm, press the mute button, then toggle the power back on and off again the sounder LED does not light, it sort of dosen't reset
after power is restored to B0.
thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Help with Power Monitor Please !
Ah sorry I though you meant power supply to microcontroller not B0
I have sorted that out for you as well.
I don't think your a pain at all!
I did say for you to mention if not working the way you would like it to, I would then modify flowchart.
Can you please try attached version.
Martin
I have sorted that out for you as well.
I don't think your a pain at all!
I did say for you to mention if not working the way you would like it to, I would then modify flowchart.
Can you please try attached version.
Martin
- Attachments
-
- power_monitor 6.fcf
- (21.57 KiB) Downloaded 164 times
Martin
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: Help with Power Monitor Please !
Hi Martin,
I have just tried the new code and changed the mute time to 5 seconds for testing purposes but when I try it and press the mute button the sounder light goes off but it never comes back on again..sorry..
thanks
Acestu
I have just tried the new code and changed the mute time to 5 seconds for testing purposes but when I try it and press the mute button the sounder light goes off but it never comes back on again..sorry..
thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Help with Power Monitor Please !
Hi acestu,
Have you taken into account that simulation time for timer interrupts is much much slower than real time (its is dependent on PC speed as well)
Simulator is working for me. On my PC 5 seconds of simulation time takes 1 min & 42 seconds. Slower PC's will take longer.
My advice is change the simulation time to 1 second and see how long it takes for LED to light back up.
When uploaded to real hardware, MuteSeconds = 5 will only take 5 seconds (even though it took nearly 2 mins on the simulator).
Martin
Have you taken into account that simulation time for timer interrupts is much much slower than real time (its is dependent on PC speed as well)
Simulator is working for me. On my PC 5 seconds of simulation time takes 1 min & 42 seconds. Slower PC's will take longer.
My advice is change the simulation time to 1 second and see how long it takes for LED to light back up.
When uploaded to real hardware, MuteSeconds = 5 will only take 5 seconds (even though it took nearly 2 mins on the simulator).
Martin
Martin
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: Help with Power Monitor Please !
Hi Martin,
Thanks for that, I thought about that but I didn't realize it took so long, i set to 5 seconds and counted to to about 130 seconds, I must of just missed it.
That's brilliant, I will try and figure out how you have done it now, it looks quite complicated...
cheers
Acestu
Thanks for that, I thought about that but I didn't realize it took so long, i set to 5 seconds and counted to to about 130 seconds, I must of just missed it.
That's brilliant, I will try and figure out how you have done it now, it looks quite complicated...
cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Help with Power Monitor Please !
Your welcome.
So there maybe a easier way of doing this?
Martin
I was struggling to concentrate as Mrs was talking to me at the same timeacestu wrote:I will try and figure out how you have done it now, it looks quite complicated...
So there maybe a easier way of doing this?
Martin
Martin