PLC ladder logic sequence - logic

I've spent hours and a trees worth of paper sketching and I haven't been able to stumble upon anything to get me past this problem. I'm able to switch back and forth between two motors but I can't figure out how to turn the motors off while switching between them, while still following the criteria below.
Using ladder logic:
Use only one start stop station consisting of only one NC contact and one NO contact, two motor starters and three control relays create the following cycle. (No timers or counters)
When the start button is pressed motor 1 will start and run until stopped by pressing the stop button.
When the start button is pressed again motor 2 will run until stopped by pressing the stop button.
When the start button is pressed again motors 1 & 2 will run until stopped by pressing the stop button.
Pressing the start button again will now start the cycle over.
Any help is very appreciated.
Thank you

Ira Baxter is right. You should use a state machine. I have set-up one below. Normally you would draw such a state machine using circles and arrows, but this will do for now I guess...
Although you talk about having 3 different steps (states) I actually see 6 states:
State0: Both motors are switched off (If start button pressed goto state 1)
State1: Motor 1 running (If stop button pressed goto state 2)
State2: Both motors are switched off (If start button pressed goto state 3)
State3: Motor 2 running (If stop button pressed goto state 4)
State4: Both motors are switched off (If start button pressed goto state 5)
State5: Both motors are running (If stop button pressed goto state 0)
What you should do is have one block determine the state (0..5) and have the motor-control blocks react to that state.

If you are limited on relays and don't want state machine you can do it with only 2 relays. Use logic flags to solve it. This example assumes you have rising edge contacts and set+reset coils as starters. I can't write ladder code here so I do what I can:
START is NO button and STOP is NC button. M1+M2 are motors F1+F2 are relays
START M1 M2 F1 F2 M1
-|P|--|/|--|/|--|/|--|/|--(S)
STOP M1 M2 M1 F1
-|N|--| |--|/|--(R)--(S)
START M1 M2 F1 F2 M2
-|P|--|/|--|/|--| |--|/|--(S)
STOP M1 M2 M1 F2 F1
-|N|--|/|--| |--(R)--(S)--(R)
START M1 M2 F1 F2 M1 M2 F2
-|P|--|/|--|/|--|/|--| |--(S)--(S)--(R)
STOP M1 M2 M1 M2
-|N|--| |--| |--(R)--(R)-

Related

Logic Audio: How do I create a latching toggle switch from sustain pedal data

Well, my problem was this, but I solved it!
I'm posting this in case this can help someone else.
I'm using Logic Pro.
I wanted to use sustain pedal midi data to toggle (latch) a button, such that I press the pedal once, and the button goes to 'ON' position. Press again and it goes 'OFF'. I wanted to use this to mute/unmute a talkback mic.
Here is my solution. If anyone can improve, go ahead!
Basic Logic ENV :
Logic ENV
Filter 0: (Filter out 0 values)
Alt Split: (alternate pedal down instructions between 2 outputs)
Rev Pol: This generates sus pedal value 0 for every other pedal down
The object 'TALK' is just to display current state, but could be patched to anything.
See the above images for mu own solution

How can I have a button trigger a function to move the mouse cursor on a timer in C#/visual studio?

I'm building an automatic timer system as a fun silly project for some office chums. It's end user goal is to allow end users to be away from keyboard while still simulating activity to prevent timed applications from changing their statuses to away.
I have the front end of a windows form with two buttons. ON and OFF. When I press on, I want it to begin moving the mouse in 1 minute intervals for a moment. (or click maybe.) and when I select off it stops the action.
I've never really coded much before (I've done basic python stuff so I know what an if statement is, a function, how to declare a variable etc but I've never done anything with a GUI or in c# so this is all new.)
Lastly, I would want to save/export it as an exe for distribution for slackers I mean end users to run and use.
Thanks so much for the help!
Looks like someone is trying to hack their way out to keep their PC active when away from desk :D
//programmatically move the mouse example
PointConverter pc = new PointConverter();
Point pt = new Point();
pt = (Point)pc.ConvertFromString("0, 768");
Cursor.Position = pt;
Ref

Is there a way in AutoHotkey to know between a mouse click and touchscreen click

I have two monitors one of them is a touchscreen. do somebody now a simple code in autohotkey. that you received a value, between a mouse click and a touchscreen click
I use for example Photoshop application on my main monitor 1
And I have a virtual keyboard with my (favorite keystroke combos) on my touchscreen monitor 2
I want if I do with my left hand a touchscreen click on my virtual keyboard monitor 2.
That the mouse pointer stays on my main monitor 1
So that I can proceed with PhotoShop without interrupting to move my mouse pointer back to my main monitor 1.
This is the script so far a alternative idea.
::^d ;push ctrl + d to disable the mouse pointer movement
BlockInput MouseMove
return
::^e ;push ctrl + e to enable the mouse pointer movement
BlockInput MouseMoveOff
return
Distinguishing between input devices is not a trivial task with AHK. It can be done, but it's quite complicated.
If you'd be okay with interpreting every click on the touchscreen as a touch click then you could do something like this:
When the mouse moves on the normal screen
store it's position in a variable.
When a left click is executed on the touch screen do the click
move the mouse back to the last know position on the normal monitor.
You'll need:
SysGet
RegisterCallback or SetTimer+MouseGetPos
Hotkeys
I do not have a second monitor to fully test this code but I have tested on my main monitor which is a touchscreen. This code should do the trick :)
; Screen pixel split between monitors
; You should change this values according to the desired region of interest
screen_split_min := 0
screen_split_max := 200
; To get absolute monitor coordinates
CoordMode, Mouse, Screen
MouseGetPos, pre_mx, pre_my
While 1
{
MouseGetPos, tmp_mx, tmp_my
If tmp_mx > %screen_split_max%
{
pre_mx := tmp_mx
pre_my := tmp_my
}
}
~LButton::
MouseGetPos, mx, my
If mx <= %screen_split_max% and mx >= %screen_split_min%
{
MouseMove, pre_mx, pre_my, 0
}
return
HTH ;)

Autohotkey: multiple / contingent uses for one command

I'm working on a game design / UI project to redesign an existing game's control scheme (in this case, Trine) to use minimalistic input. I am trying to map lateral movement and the jump function to a Win8 tablet's volume buttons. Here is the basic code I am using:
Volume_Up::
Loop 5
{
Send {right down}
Sleep 50
}
Send {right up}
Return
Volume_Down::
Loop 5
{
Send {left down}
Sleep 50
}
Send {left up}
Return
This is working fairly well and is pretty responsive for moving left and right. However, the desired behavior that I want is to trigger jump (i.e. up) when BOTH buttons are depressed. For instance:
Player holds VolumeUp to move right.
Player comes to an obstacle.
Player continues to hold VolumeUp to queue right-bound movement and;
Player taps VolumeDown momentarily
Player jumps, movement continues up-and-over obstacle toward the right.
I have tried various permutations on using another script with the (Volume_Up & Volume_Down::) syntax to trigger this interaction, but that always seems to interfere with the movement commands. I think this may call for a nested If statement inside the move-left / move-right commands, to check if both buttons are depressed, but the Autohotkey documentation is not very clear and I'm unsure how to code that (I'm more of a game designer than I am a programmer). Any help would be really appreciated!
First of all, give attention to the comment from MCL. Pressing a button down 5 times and never releasing it in between does not seem to do much.
I think that you want multiple threads to be able to run at the same time.
Look up threads, but be aware about the following:
"Although AutoHotkey doesn't actually use multiple threads, it simulates some of that behavior: If a second thread is started -- such as by pressing another hotkey while the previous is still running -- the current thread will be interrupted (temporarily halted) to allow the new thread to become current. If a third thread is started while the second is still running, both the second and first will be in a dormant state, and so on."

R: How to fix perpetual "Click or hit ENTER for next page" on plot()?

I'm using Windows 7x64 and R v2.14.2, with revolution R as the GUI.
For some reason, every time I make a plot, the console states:
Waiting to confirm page change...
...and the plot states:
Click or hit ENTER for next page
I have to click somewhere in the plot to allow it to complete its plot.
I'm wondering what I'm doing wrong, and is there any way to fix this without reinstalling R in its entirety?
Update 1
I've tried:
devAskNewPage(FALSE)
options(device.ask.default = FALSE)
grDevices::devAskNewPage(ask=FALSE)
Here is my list of windows:
> dev.list()
windows
2
I think this problem started after I used plot.new() to create a new graphics window. My machine was also shut down non-gracefully last night. On another odd note, the graphics work (albeit oddly) in Revolution R, but don't display at all in RStudio, even though this uses a different core R version (v2.15.2).
Update 2
I'm wondering if there is a way to set par() to its installation defaults?
Update 3
Rebooted machine; problem still exists.
I think that you need to close the graphics device and open a new one before changes to devAskNewPage or getOption("device.ask.default") take effect.
At a guess, you are calling some code where asking for to change the plot is turned on, and then trying to create more plots in the same device.
This one was definitely user error; both Windows and R are working perfectly.
The problem was with the plot command in a sub-function:
plot(y ~ a + b)
This command does not plot two series on one graph; it plots them separately on two graphs, with the message "Click or hit ENTER for next page” between them. All of the other precursors/symptoms were simple coincidence.

Resources