Home > Net >  C # how to continuously monitor the external signal?
C # how to continuously monitor the external signal?

Time:02-11

I'm in the PLC development, mainly control hardware, for example, the X axis motor, sensor SB1, just stop, the SB1 must be in a state of continuous monitoring, program can't read in the form of cycle the SB1, otherwise, at the end of a read SB1's behavior, the next read SB1 behavior are yet to come, SB1 is triggered, and the program is don't know, the X axis motor will be blunt past, machine damage,
PLC itself can continuously monitoring sensor, do not need additional programming, the user as long as the SB1 and X axis motor associated; SB1 is triggered, the X axis motor will stop,
PLC and PC is c # monitoring in a bit, such as M100.0, M100.0 relate with SB1, SB1 from 1 to 0, M100.0 will be from 1 to 0; Conversely, SB1 from 0 to 1, M100.0 also can be from 0 to 1,
Therefore, as long as the c # M100.0 can monitor PLC, this monitoring is persistent, as long as M100.0 have change, can know c #, and respond to,
Excuse me, this continuous monitoring to do?
Ps: would you like to use While (true), don't feel very well

CodePudding user response:

What kind of communication, serial port? USB? Network?
Do a PC program, data caching threads to receive and the subcontract, event pushed to the interface or handler,

Standard PC software development, so many don't understand why you put the PLC software to use tools don't, don't want to use c # to write, and you seem to be less likely to write, or outsourced to I forget it

CodePudding user response:

reference 1/f, rabbit party at large response:
what kind of communication, serial port? USB? Network?
Do a PC program, data caching threads to receive and the subcontract, event pushed to the interface or handler,

Standard PC software development, so many don't understand why you put the PLC software to use tools don't, don't want to use c # to write, and you seem to be less likely to write, or outsourced to I calculate


I am learning, touch screen will, of course, but also several kinds

CodePudding user response:

Before send a movement command to detect the motion state of current motor, if in the stop state is sent, if moving, don't send, give the user returns to a tip at the same time,

CodePudding user response:

reference X - I - n reply: 3/f
before send a movement command to detect the motion state of current motor, if in the stop state is sent, if moving, don't send, give the user returns to a tip at the same time, the

Motor is the first movement, just meet halfway sensor SB1, then SB1 is inspired to the PLC a signal, then the PLC and the signal to the c #,

CodePudding user response:

This problem should not rely on the c #, but should rely on limit to solve,

CodePudding user response:

refer to fifth floor X - I - n reply:
this problem should not rely on the c #, but should rely on limit to solve,

To solve by PLC,
However, also need to know c #, c # have to continue to know the status of the sensor SB1, is to use c # to keep monitoring the status of PLC in M100.0

CodePudding user response:

Or business logic design is not reasonable, safe and reasonable design should be to hit the limit switch directly to stop, even with less than PLC, everything is motion controller at work, c # shouldn't dig in more,
PC software to realize motor state, can ah, polling, on-demand detection,
PC you want to send command, can ah, hair before you take the M100 approximately, motor tell users are now moving in the movement, etc. Will try again, the motor in a stopped state directly send movement commands,

CodePudding user response:

refer to 7th floor X - I - n reply:
or business logic design is not reasonable, safe and reasonable design should hit the limit switch is directly stop, even with less than PLC, everything is motion controller at work, c # shouldn't dig in more,
PC software to realize motor state, can ah, polling, on-demand detection,
PC you want to send command, can ah, hair before you take the M100 approximately, motor tell users are now moving in the movement, etc. Will try again, the motor in a stopped state directly send movement commands,


Is not necessarily the sensor stops, I said stop just for example; It could also be met sensor is reversed, there are many types of actual situation, sensor signals have to tap into the PLC,

CodePudding user response:

Is with or without bias, are one thing, do limit related functions, PLC only at the time of searching zero, or to limit other action when applied to future, PC is absolutely should not be used,

CodePudding user response:

If simply monitoring signals, either polling, either with interrupt (depending on the controller of the SDK), in any scene, all want to use PC software as an unreliable objects to consider, it would crash, complains, will be abnormal exit, even never running, the more the underlying control demand, the more it with controller or PLC to deal with,

CodePudding user response:

You into a kind of erroneous zone
Signal collection and signal acquisition and language-neutral
Do you also do not need to tangle while (true) not while (true)

Itself push-pull two types of signal transmission, the following will push to you, you don't need, just standard serial port, TCP communication
The following is not to push, not let you pull, is, of course, timing, you wound not past,

Even if you use a hardware acquisition card, in fact, as the upstairs said, that or interruption of polling +

Should do what, don't need to follow the garden,

If you really want to with what I am not an infinite loop, and that's fine,
1. In c + + write drive, directly under the timer interrupt
2. Use hardware acquisition card, let do acquisition acquisition card hardware directly to (give you says the cycle of struggle to hardware to play)
3. The indirect opc, put your sampling to opc

CodePudding user response:

First of all the people shall say, the.net now already is "classic" asynchronous programming tool, you can write asynchronous and active "dead" cycle of code, such as
 public async void to start monitoring the SB1 () 
{
While (stopFlag)
{
Reads the status and treatment ();
Await Task. Delay (150);
}
}
don't understand the async void the need to learn grammar, otherwise couldn't keep up with the pace of development,

Secondly, from the bottom, good "monitor" requires two-way communication protocol design, also is the PC to send one or more specific meaning call command, and then the machine feedback message, if you don't design the appropriate signaling message, so don't do roadside stands out the work of the craftsman's porcelain,

CodePudding user response:

.net (including vb.net and so on, as well as Blazor Assembly c # programs to run on a web page) are now support the.net programming tasks (Task) asynchronous micro, can easily write high performance of (quasi) asynchronous algorithm of real-time systems, the need of early knowledge upgrading, we interview c # programmers are rarely just this traditional data structures, algorithms, look more similar Linq, Task, the Actor the use of design model and so on knowledge,

From the communication perspective, the blind spot of many more, programming to personally design signaling, oneself start work design message specification, and personally parsing code, debug message interaction process, the test application client performance improvement after the use of communication interface, raised their children really will take up the communication layer design not good for the application of interference,

CodePudding user response:

General PLC communications, follow some more better industrial agreement, PC first sends a "monitor" command, such as a machine delivered some address data, the next bit machine will the value of these addresses change when the initiative to send a message to PC, this is a two-way agreement, in the basic programming grammar, it is a matter of design idea, said "architecture" is a bit too "big", this kind of thing don't what the architect, worked in control design of professional programmers can,
  •  Tags:  
  • C#
  • Related