vinny

MrPLC Member
  • Content count

    11
  • Joined

  • Last visited

Everything posted by vinny

  1. Hi I just given a swanky new laptop at work, which is lovely and everything, but does not have an ethernet port. Unfazed by this, I just got hold of a USB to LAN adapter and got to work. My primary development environment is Beckhoff TwinCAT, and was rather gutted to find there are no real-time ethernet devices on the machine(attached image for reference). I was wondering if there was any adapter that I could use for real-time ethernet device. I am aware of latency issues and this would only be used to test communication and make sure everything talk to each other. Cheers
  2. In your parameter tab, there is a setting for Monitoring, this gives the window of error (Target position of the axis and actual position of axis). You should be able to adjust this to avoid this error, and it is something you would change based on the acceleration which the axis undergoes. At high acceleration, it is natural for the axis to go past the following error window. If my memory serves me right, you should be able to change your Motion Monitoring under Monitoring to allow a slightly loose control. hope it helps
  3. Using time as a variable in TwinCAT 2 PLC

    Okay, you 177744 is a following error - Meaning your target position is outside the range of the estimated position. First check on you TwinCAT System Manager by clicking on axis to see what size of window is set. Adjusting that window should help a little bit. Also you can set your Jerk (m/s2/s) to have a smoother movement.
  4. Am I correct in assuming you have enough position points for each axis so that the curve fits to your required curve? If you have the points, 1. Create an array with the positions 2. Run a loop where, the motor performs a FB_MoveAbsolute for every position. I think you are having trouble is, you set FBMove.Start= TRUE, then it doesn't move to the second position? Is that correct?
  5. TWINCAT Structure to CSV

    Hi All I have a Structure consisting of different datatypes and want to read/write values for this struct using a csv. i tried using the CSV_Examples, but I am not able to get my around to using a structure to write the csv rather than an array of values. Thank you for the help
  6. TwinCat chronometer

    Hi Joan True the value is not parametrised, i could not find the get cycle tick fb.. i know i have seen it, couldnt figure out where, but i wasnt aware of the issue of task being surpassed... thanks for that! Using TON has an issue of not being able to continue from the previous value and is limited to 999hrs (on a scheme of a machine, it not too long,is it?) Cheers
  7. TWINCAT Structure to CSV

    Hi Thanks for the reply In the example given, in P_TextModeWrite, Step 3 (attached below), the array is converted to a string and is incremented to next value based on index. However when I use a Structure, there isnt a fixed increment size (different data types = different sizes), which is where I have hit a wall. I have attached the Struct as an export too, and am trying to create a csv file which holds the var name with its value and read back the values to fill the structure (* Convert one PLC record to CSV format *) sCSVLine := ''; fbWriter.eCmd := eEnumCmd_First;(* Write first field value *) IF nRow <= MAX_CSV_ROWS THEN FOR nColumn := 0 TO MAX_CSV_COLUMNS BY 1 DO sCSVField := STRING_TO_CSVFIELD( database[ nRow, nColumn ], FALSE );(* TODO: Get field value from your application *) (* Add new field to the record buffer *) fbWriter( pBuffer := ADR( sCSVLine ), cbBuffer := SIZEOF( sCSVLine ) - 1, putValue := sCSVField, pValue := 0, cbValue := 0, bCRLF := ( nColumn = MAX_CSV_COLUMNS ) );(* bCRLF == TRUE => Write CRLF after the last field value *) IF fbWriter.bOk THEN fbWriter.eCmd := eEnumCmd_Next;(* Write next field value *) ELSE(* Error *) step := 100; RETURN; END_IF END_FOR(* FOR nColumn := 0... *) (* FB_FilePuts adds allready CR (carriage return) to the written line. We have to replace the $R$L characters with $L character to avoid double CR. *) IF RIGHT( sCSVLine, 2 ) = '$R$L' THEN sCSVLine := REPLACE( sCSVLine, '$L', 2, LEN( sCSVLine ) - 1 ); END_IF nRow := nRow + 1;(* Increment number of created records (rows) *) step := 4;(* Write record to the file *) ELSE(* All rows written => Close file *) step := 10; END_IF
  8. CRC 8 Calculator

    You Sir are a Gentleman and a Scholar! Yeah that code was provided in a fairly useless manual and I couldn't get my head around the source but thank you so much for doing what you have! In ST I can at least make sense of what is happening and try to solve the issue.. And yes I do have a few commands and their predefined crc8 values which i can refer against. If you are ever in England, I owe you a pint of beer! Thanks again!
  9. CRC 8 Calculator

    Hi I am fairly new to TWINCAT and am trying to translate a bit of code for a checksum CRC8 calculator. I have the following code, which I think is in C# (which I have no experience in whatsoever) unsigned char CalcCRC8(unsigned char *Data) { unsigned char LoopCntr; unsigned char A; unsigned char B; unsigned char CRC8 = 0; B = 0; while (*(Data + B)){ A = *(Data + B); for (LoopCntr = 0; LoopCntr < 8; LoopCntr++, A >>= 1){ // 8 bit loop if ((A ^ CRC8) & 0x01){ // test bit 0 of (Data XOR CRC8) CRC8 ^= 0x18; // toggle bits 3 and 4 of CRC8 CRC8 >>= 1; // rotate right CRC8, 1 time CRC8 |= 0x80; // set bit 7 of CRC8 } else { CRC8 >>= 1; // rotate right CRC8, 1 time } } B++; } return CRC8; // return CRC8 } I would be most grateful if someone could translate it for me! Thank you very much
  10. TwinCat chronometer

    Are you looking for just a timer? or are you trying to have something like a time machine has been running? for a normal timer you could use TON... otherwise you have to make your own FunctionBlock