Jump to content

Kpotmake

Members
  • Posts

    8
  • Joined

  • Last visited

  • Days Won

    1

Kpotmake last won the day on December 8 2021

Kpotmake had the most liked content!

Kpotmake's Achievements

Newbie

Newbie (1/4)

2

Reputation

  1. Ok thanks for your reply, will keep that in mind
  2. But is there a way to figure out why the CPU crashes? For instance other PLC brands give an error message 'zero division' when dividing by 0 or 'array out of bounds' when accessing an element of an array that doenst exist etc. Does Unitronics also give some sort of explanation to a CPU crash?
  3. I just created a C function in an Unilogic project that looks like this: static void CircleFromCenterCutpos(int Cutpos, int Diameter, int Knifewidth, int Overlap, volatile int* Knifepos) { // User code starts below this comment int totalcuts = (Diameter / 2 / (Knifewidth - Overlap) + 1) * 2; bool FirstHalf = Cutpos <= totalcuts/2; int TempCutPos = 0; if (FirstHalf == true) { TempCutPos = totalcuts/2 - Cutpos; *Knifepos = Diameter / 2 - (Knifewidth - Overlap) * TempCutPos - Knifewidth/2; } else { TempCutPos = abs(totalcuts/2 - Cutpos)-1; *Knifepos = Diameter / 2 + (Knifewidth - Overlap) * TempCutPos +Knifewidth - Knifewidth/2; } // User code ends above this comment } This code crashes the CPU. How can I see what the cause is for the CPU crash in such a case? Because the traditional approach of commenting out lines/ changing code is taking WAAAY to long with Unitronics because of the long reboot time after chrashing the CPU and long compile & download times Edit: I found the problem and it is that in Unilogic in C you are not allowed to divide by using c = a/ b but you have to use ARITHMETIC_DIV(1, a, b, c);. same goes for ABS() function. This makes some C functions close to unreadable unfortunatly. Also, the code compiles fine, but doesnt work if you dont use the arithmetic functions... which can be confusing I'm still interested in a solution how to troubleshoot this next time in a time efficient way
  4. Thanks! to anyone who wishes to create a solid shape: What you need to do is create a loop that runs something like this (in case of a circle, rectangle is somewhat similar): Create a tag lineThickness, init value 10 Creat a tag idx (index for keeping track of the loop count) On the first line the shape radius must be set to: DesiredRadius - LineThickness Then subtract from the radius: idx * linethickness then increment idx and repeat the loop untill the radius < linethickness same applies for rectangle, except you need to apply this to width and height instead of radius
  5. I'm trying to draw a pattern on a screen with the insert shape function, and so far everything is working, but I would like to know where I could find some documentation on these functions? They don't seem to be included in the help file. I did open the example project 'draw_shape', and this has been helpfull in creating the first setup, but there are still a lot of questions left unanswered. For instance: -What is the maximum amount of shapes per group before I receive the error message from the insert shape function block 'maximum shapes reached' (error -8)? -When is the shape inserted in the group? On the rising edge of the input or does it keep adding shapes as long as the input is high? Same question for draw shape group function block -What is the maximum thickness for a line / rectangle before I receive the error message -2? Edit: seems to be 10 -Is it possible to create a solid circle / rectangle instead of just the border lines? Edit: since I haven't received any replies I made a loop that creates an increasingly smaller triangle / circle to fill the shape -Are the available colors defined somewhere? Edit: the color codes seem to be HTML color codes (https://htmlcolorcodes.com/) To anyone who wishes to implement this function, this is what I have found out so far: When you want to draw a grid from a data table (this was the case for me), when you want to loop through the data table to copy the X0 X1 Y0 Y1 coordinates from the data table to the shape line, you must include the status of the clear, insert shape and draw functions as a requirement before inserting a new shape (last insert / clear / draw must be finished before starting a new action), don't insert / clear / draw a new shape if status is <> 0. Also I found it worked flawlessly if I only trigger the function block once, so immediatly reset the starting condition once the insert shape function block is busy (again, you can monitor if it's busy by checking status <> 0). The easiest way to achieve this is with a state machine
  6. I have made a program for a Unitronics PLC to communicate with another PLC (sigmatek) over TCP. Unitronics is the server, the sigmatek PLC is the client. I am sending a big data table over TCP (5120 bytes in total). The way it works is Sigmatek initiates a connection as a client, and unitronics sends the data once a connection is established. I have it working, but I'm not statisfied with the way it is programmed now. Let me try to explain my problem: For some reason I cannot send more then 1024 bytes with one TCP server TX function block, so I have split the data up in 5 seperate buffers, that I send to 5 clients. (I have configured 5 clients in the other PLC), these 5 clients all connect to the same server. This is no problem for me. The problem is, that to send the buffer to the correct client, I need to know the client ID. What I'm doing right now to figure the client ID number out is: In the sigmatek PLC I have made a program that the first client has to connect, and when the first client is connected, connect the second one after a small delay, and so on.. In my Unitronics PLC, if a new Client is connecting, I can check the ID of that client by checking the connection array (it's an array of 16 bits). For example: Sigmatek tries to connect the first client, if the connection is esablished, then bit 4 of my connection array in Unitronics might become high, now I know Client 1 has ID 4, when the second client connects, bit 2 might turn on, so the second client has ID 2, and so on.. and when a connection is lost, I disconnect them all and start the process again This works fine, but is far from elegant... What's the proper way to find out the client ID on the server side of a TCP server / client model?
  7. Is there a way to rearrange struct items within a struct, and also is the same possible for the global tags? I know we can sort the tags by name but if we open Unilogic the default sort is first tag created is first in the row the same would come in handy for function inputs and outputs. I have created several C functions which are verry similar, and my program has become verry confusing because a lot of these function blocks have the same inputs and outputs, but they are not arranged the same and I would like to change this, but haven't found out how to do that yet...
  8. Hello all, I was asked to write some software for a machine using a Unitronics PLC, programming in Unilogic is new to me but I've got the machine up and running quite easily, the software is verry intuitive. However it does lack structured text programming... for the more complex tasks I was told I could write my own C functions. This does however bring some limitations with it, the worst one being not being able to acces the global tags and being limited to 256 bytes of data within the functions. Is there a way to call other functions within the C function? This would be a workaround for these limitation. For example: I need to loop through an array that has 100 items, and then perform a calculation on these items. The looping part would fit in a C function but the calculation combined with the array size would require more then 256 bytes. If I could call another function when looping through the for loop this would solve my problem.
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.