Timing with a clock
Neily03
✭✭✭
I've got a clock setup to time when the conveyor on our plant is stop, it's working off a trap routine using the output C1NullSpeed as a trigger, the trouble we're having is if we stop the conveyor and Reset PP to Main then restart the conveyor the timer reads as 0 seconds irrespective of how long it's stopped for.
Does PP to Main reset all clocks?
Here's the code we're using:
connect irConvStop with tpConvStop;
ISignalDI c1NullSpeed, 1, irConvStop;
connect irConvStart with tpConvStart;
ISignalDI c1NullSpeed, 0, irConvStart;
trap tpConvStop
log_stop;
if DOutput(sdoCycleOn) = 1 then
if bCTSyncInfo
ErrWrite \I, "Conveyor Stopped", "Conveyor Stopped";
endif
ClkReset clkConv2;
ClkStart clkConv2;
endtrap
trap tpConvStart
if DOutput(sdoCycleOn) = 1 then
ClkStop clkConv2;
nStopTime := nStopTime + ClkRead(clkConv2) + nConvRamping;
!writes downtime to logfile.
log_start;
if bCTSyncInfo
ErrWrite \I , "Conveyor Started", "StopTime: " + ValToStr(nStopTime);
endif
endtrap
Does PP to Main reset all clocks?
Here's the code we're using:
connect irConvStop with tpConvStop;
ISignalDI c1NullSpeed, 1, irConvStop;
connect irConvStart with tpConvStart;
ISignalDI c1NullSpeed, 0, irConvStart;
trap tpConvStop
log_stop;
if DOutput(sdoCycleOn) = 1 then
if bCTSyncInfo
ErrWrite \I, "Conveyor Stopped", "Conveyor Stopped";
endif
ClkReset clkConv2;
ClkStart clkConv2;
endtrap
trap tpConvStart
if DOutput(sdoCycleOn) = 1 then
ClkStop clkConv2;
nStopTime := nStopTime + ClkRead(clkConv2) + nConvRamping;
!writes downtime to logfile.
log_start;
if bCTSyncInfo
ErrWrite \I , "Conveyor Started", "StopTime: " + ValToStr(nStopTime);
endif
endtrap
0
Comments
-
I am sure that you have solved this by now but I want to just check by adding some comments.
As long as your nStopTime is declared as a global variable and is PERS type then your code will work even if the clock is reset by the PP to Main (which it will be because clocks are VAR type and
not PERS). I don't remember if the clock will start running again when the PP to Main happens, but if it doesn't then you can just declare a PERS bool bClockRunning and set it true when the clock
starts that way when the PP to main happens you will know that the clock was running and you can start it again.
�0 -
Thanks David,
We ended getting round the problem by moving the trap into a background task so PP to main has no effect.
0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 800 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings