I am trying to implement a toggle switch. On the rising edge of "Change", it should toggle "ToggleThis".
I thought the first ladder logic diagram would work. Let's say we start with all the variables turned off, so "Change" = 0, "ChangePrevious"=0 and therefore it doesn't toggle "ToggleThis". When "Change" becomes 1, "ChangePrevious" is still 0 for the first iteration, therefore it toggles "ToggleThis" once and "ChangePrevious" becomes 1 and stays at 1 for the rest of the iterations while "Change" is 1.
Well, it didn't work as I thought it would and I cannot figure out why.
When I add two latches in parallel as shown in the second ladder logic diagram, it magically works as desired. And I have no idea why. I don't see how it changes anything. Can someone please explain? Sorry if this is a dumb question, I've only just started learning about ladder logic.