Jump to content

acisre

Members
  • Posts

    18
  • Joined

  • Last visited

Everything posted by acisre

  1. Aha ok, now I understand. Yes I have tested a code without timers, and it worked fine. I have added a little program with some subroutines from the complete program. This is all tested and works. I don't know If I will keep the subroutines like this. Here they were intended as reusable code but they are not called all the time. Probably will change that as Flex727 recommended. Sven example_for_forum.vlp
  2. Hi Joe, Thank you for the time you took to create that program. I don't think that the timers you added are of much added value. If the timers or to long I will loose a lot of time (my program is more then 100 rungs and almost all of them send SDO instructions or read info from the motors via SDO upload). The machine needs to go as fast as possible (current cycle time is 7.5 seconds, I want it to be 6.5 seconds or less. And in that time approximately 30 actions are done. That gives me an average of 0.2 s for each movement. Having timers of 100ms will make it impossible to achieve that. However If I make the timers very short like 10ms then basically you can then just leave them out and simply check for the bit SB242. If not ok it will probably be ok in the next scan or the scan after that. About the "call all the subroutines all the time". Isn't it an advantage to just call the subroutine only when you need it, to make the PLC just read the rungs that if needs to read at that time an not slow it down unnecessarily? Just asking, not planning on adding conditional subroutines at the moment but that seemed like an advantage of having conditional subroutines. Sven
  3. Thanks Flex727 for all the advice so far. I am here to follow the advice of professionals, not to ignore it :-) I think I do know what I have to do now. Im going to create more subroutines to keep everything more readable, but all of the subroutines will be read one after another and they will all share the same state counter. That way I don't need the conditional triggers you are referring to. You are right that I try to program it to much like a computer (it's the only other programming experience that I have)
  4. But then you are basically telling me that, if I can't find a way to make that subroutine evaluate everything in every scan, it should not be a subroutine at all? I just don't see a way around the SB242 without skipping motor messages I added the subroutine to provide more clarity. MotorToPosition.vlx
  5. Hi Joe, I think I did something similar to jour state machine code. I hope my code will be finished in one week from now... will post it then. It is getting quite complex. I think i need to find a trade off between readability of the code vs not making things to difficult... for example: i have a subroutine called « MoterToPosition » , so in my main routine I just store speed, acceleration and position into some bytes and then call that subroutine. That way, the code gets shorter and more readable. However, things also get more complex now: For one, it is possible to call the subroutine but only one rung in that subroutine gets executed. This is because all the rungs check the SB242 (SDO in progress). So now i need to make sure that in the next scan, the remaining rungs in the subroutine get executed. So i need to remember where I stopped using again a counter etc.... I also need to make sure that my main routine keeps calling that subroutine untill it is finished. So now i need a « I am finished » bit that the subroutine sets high when the last rung is executed. In the main routine I can then check that bit to see if I can go into the next state Also, it is possible that in my main program i will call subroutine « <MoterToPosition » twice in one scan, so now i need to implement a « I am busy » bit to indicate that the second call should not start if the first call is not yet finished... I am starting to think that it might be better to just throw this subroutine away and place all the rungs in the main routine again, at the cost of having a much longer and less readable program. Thx for all the help sven
  6. Ofcourse! I should have seen that .. Well, the problem is that each subroutine will take numerous scans before it is finished. This is because each subroutine will contain rungs where I am waiting for a motor to be in position. So I cannot just let subroutine 2 start if something in subroutine 1 is not finished... edit: I should probably have mentioned that I am using a counter and compares at the start of each rung in the subroutines to see if I can execute that rung (sequential program). Now that I think about it, I could use values for that counter from 0 to 100 for subroutine 1, from 100 to 200 for subroutine 2, and so on, and then I would no longer need the "sub 1 done" bits to trigger the start of sub 2. Just need to make sure that the counter at the end of sub1 is 100 so sub 2 will continue after that...
  7. Hello all, I am a beginning plc programmer and I have to program a small machine. Since the machine is a prototype, it is not needed to have a perfect program with good fault messages or the ability to run slow or anything like that. I just like to have a simple yet safe program to prove that our prototype will do what it's supposed to do. The machine has a start and stop button and it needs to home before it can run in automatic mode. I would also like to split up the automatic cycle in some subroutines. I made some example code that I would use for the main routine. Would this be good code to start from? Or am I missing something rather important? Thanks for anyone who can offer some advice!
  8. Thanks for explaining. So the first rung will not work as expected but rung 2+3 will ? I have seen things like this in a program so I will pay attention to this.
  9. Hi Phil, I find this interesting. What exactly do you mean with “a single network”? in de second figure do you mean that the second rung is in a subroutine? I dont really see the difference between the first and the second picture right now.. thank you
  10. Hi Kratmel, The code that you posted, do you call it as a subroutine every time you need it? small update: I have rewritten some of the code with a "CANopen SDO Download STR" block in every rung, and this does seem to work without problems (and the machine is quicker to). But the code becomes messy kind of quickly, so I will probably try to make it into a subroutine Sven
  11. I don't understand this... If you say that all outputs are changed/written only at the end of the PLC scan, then I would think it goes like this: first scan, 0 is stored in MI 1 end of first scan --> 0 written to MI 1 second scan, second rung gets executed and MI 1 is increased by 1 end of second scan --> 1 written to MI 1 third scan, third rung gets executed and MI 1 is increased by 1 end of third scan --> 2 written to MI 1 So I would not expect MI 1 to be 2 in just 1 scan?
  12. @kratmel I looked at the code and it does look good. I like how the counter is at the top row, so its not needed to put the increment block in every rung. I will see if I can use it in my program. I do have another question though: if I would leave out the timers in my program, I wonder what happens. Is every rung executed in one PLC scan? Or does he do the increment function at the end of every scan? In other words, if I would have 50 rungs, would all these rungs be executed in a single scan, or would it take 50 scans before every rung is executed? (thsi was also what Isakovic was thinking I guess) Because if it would be the first case (everyting in one scan) then it's probably normal I'm using instructions. However, if it takes multiple scans, then in theory it should work I think. Or same question with a simple program (see attached screenshot): at the end of one PLC scan, what is the value of MI 1? (I would test it but cannot do the online test right now)
  13. Thank you very much I will definitely take a look at it! No when rung 6 is executed, this rung also resets the timer. The next rung 7 will not be executed because the PLC is so fast that by that time the timer is still running and the timer bit is still zero... Only after a minimum of (in the screenshot) 20 ms rung 7 will be executed.
  14. Hi all, Right now, I am working on a program where I need to write instructions via canopen to several different motors and pneumatic cylinders. Please see attached image for better explanation. at the start of each rung, I am using a comparator (see green circle). Only if my variable has the correct value, the rung can be accessed. Then everything in that rung gets executed, and the counter now is increased by 1 (blue circle), so on the next plc scan I can access the next rung. This works well, but its here where the problems start. During 1 plc scan, several instructions are written to the motors and drivers (mac95 motor from JVL, MIS234 motor from JVL, SMC75 drivers...) It seems that these instructions are written so fast, that some instructions get ignored by the motors. Thus nothing works as it should. This is why a timer and system bit was added (orange circle), to give the motor some time at the start of each rung. It now works, as long as I keep the timer around 40 ms. Any value lower than that and the motors seem to miss instructions from time to time. The problem with this is that I loose some time when writing several instructions like new motor speed, new motor position, motor mode, etc... For example 5 instuctions like that costs me 200 ms of time that the machine is doing nothing. That isn't much, but cycle time is of crucial importance so I'm looking for ways to avoid the use of these delay timers. What I can say is that, using only system bits without the timers (to check if the motor buffer isn't full) doesn't work as well. I seem to loose instructions even when the motor buffer isn't full yet). I also contacted JVL about this issue, they basically told me to (quote): This is a lot of work for me and so I was wondering If anyone on this forum has some tips or a similar experience on how to avoid the use of timers without losing instructions when writing to the motor. Thank you Sven
  15. Hi Kratmel Thanks for the reply and added attachment, I will take a look at it. Also sorry for the late reply. I will see if I can post an image of the wiring, but I must be careful because an NDA is involved here. The other part of your post is difficult for me to follow.. but thank you very much for all the effort! Sven
  16. For the steppers I am using the SMC75 driver from JVL motors. We also have a MAC motor and MIS motor with integrated driver, also from JVL. I don't know if this driver can prepare the signal. If I understand you well, you mean that I can choose what exactly the PDO signal is? So I can change it to be "in position" instead of the actual position? Can you also tell me that if I want to read the status bits, I need a special ladder block to update the status? Or is this done automatically? About the system bits, I have a program with more then 100 rungs. Each of the rungs also has a step counter, so I can only do one rung at a time.. Do you recommend reading that system bit as a NO contact at the beginning of each rung, so I skip it if the bit is low? thanks for the response! (sorry about the many questions)
  17. Hello all, First off, I am a total beginner in plc. Unfortunatly my first project is a little bit on the difficult side, a small machine containing motors and pneumatic cylinders. All communication to the motor is done with CANBUS. Now, I would like to check if a motor is in position. The way I do it now is by reading the position by reading pdo1 every 60ms. Then in my ladder program, I use a compare block to check if the position retrieved is equal to the commanded position. I think this is kind of inefficient because now my program does a pdo rtr constantly every 60ms (to avoid canbus overflow), which is sometimes unnecessary because I only need to know the position sometimes. so my question is, is there a better way to know when the motor is in position? I was thinking about using the 4th bit from the status byte which turns to 1 when the motor is in position? But how to exactly implement this? Do I use a test bit to extract the bit and check it? But is this really better then checking the position via pdo1 and if so why? And how to prevent the CANOPEN buffer to overflow? Right now there are timers in my program which only allow to read or write an instruction every 10ms... is there a better way to do this? Thank you for everyone who can give some tips here. Sven
×
×
  • Create New...