Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Thursday, September 7, 2017

IEC6113-3 Standard - supported programming languages

IEC6113-3 Standard - supported programming languages :
  • Instruction List (IL)
  • Ladder Diagram (LD)
  • Structured Text (ST)
  • Sequential Function Chart (SFC)
  • Function Block Diagram (FBD)
ABB Control Builder for various ABB products supports all these programming languages.

Saturday, September 1, 2012

Auto formatting the code in Visual Studio


- CTRL-A to select the whole text.
- Ctrl+K- Ctrl + F


 Before Auto Format
Ctrl - A selects the whole text
Ctrl K + Ctrl F, auto formats the whole text

Thursday, May 31, 2012

String to Double issues in C# .NET


If you are simply using 

double test = Double.Parse("12.45");

and it doesn't work due to formating issues, here is the right post for you. Almost certainly you're using the wrong CultureInfo. Try specifying CultureInfo.InvariantCulture to parse in. I suspect it's currently assuming that "." is a thousands separator rather than a decimal point.

CultureInfo Invc = new CultureInfo("");
Invc = CultureInfo.InvariantCulture;

x1 = Double.Parse("12.45", Invc);

alternative:

x1 = Double.Parse("12.45", CultureInfo.InvariantCulture);

Wednesday, May 30, 2012

Tab Order in C# Windows Form - Visual Studio 2010

Setting Tab order in C# (Visual Studio 2010):

1 - Select View - Tab Order. This activates the tab-order selection mode on the form. A number (representing the TabIndex property) appears in the upper-left corner of each control.
2-  Click the controls sequentially to establish the tab order you want.
3 - When you are done, click View - Tab Order to deactivate the indexing.

Source: http://msdn.microsoft.com/en-us/library/bd16a8cw.aspx

Sunday, May 20, 2012

Flame Detector Sensor, Arduino Tutorial


This is a sample code to show how this cheap component from DealExtreme works with Ardunio (2.5$ with free shipping). These are very useful sensors for building [b]firefighting robots[/b]  :D  Look at the sample code for more info.
Sensor detecting match flame


purchase link:
http://www.dealextreme.com/p/arduino-flame-sensor-for-temperature-detection-blue-dc-3-3-5v-118075

OBS1: I assume this component uses Infrared and should be in direct sight to detect flame. This would work easily on big flames but for a match flame (very small), it could miss it.
OBS2: I read the values with analogRead but I guess they are readable with Digital Read as well as differences are quite high.
-------------------------
/*
  FLAME detector connected to Arduino
  http://www.dealextreme.com/p/arduino-flame-sensor-for-temperature-detection-blue-dc-3-3-5v-118075

 Developer:
 Akbar (Shahab) F. Moghaddam
 20.05.12

 Comment : I assume this component uses Infrared and should be in direct sight to detect flame. This would work easily on big flames but for a match flame (very small), it could miss it.

 */

//CONSTANTS
const int pinD0 = 0;
const int pinA0 = 1;

//VARIABLE
int A = -999;
int D = -999;
int readVal = 0;
boolean logging = false;
boolean fire = false;
boolean changed = true;


void setup() {              
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);
  pinMode(0, INPUT);
  pinMode(1, INPUT);
  Serial.begin(19200);
}

void loop() {
  initialAll();
  readValues();
  loggingProcess();
  if (changed)
    printState();
  delay(1000);// wait for a second
}

void initialAll(){
  readVal = 0;
}

void readValues(){
  A = analogRead(pinA0);
  D = analogRead(pinD0);
  fireCheck();
  if (Serial.available()>0){
    readVal = Serial.read();
  }
}

void loggingProcess(){
  if (readVal == 'l'){
    if (logging)
      logging = false;
    else
      logging = true;
  }
 
  if (logging){
    Serial.println("------------");
    Serial.println("SYUMMARY");
    Serial.print("A0:");
    Serial.println(A);
    Serial.print("D0:");
    Serial.println(D);
    Serial.println("------------");
  }
}

void printState(){
  if (fire){
    Serial.println("------------");
    Serial.println("FLAME Detected");
    Serial.println("------------");  
  }
  else{
    Serial.println("------------");
    Serial.println("NO FLAME");
    Serial.println("------------");  
  }
  changed = !changed;
}

void fireCheck(){
  if (A < 350 && D < 350){
    fire = true;
    changed = !changed;
  }
  else{
    fire = false;
    changed = !changed;  
  }
}

Quality Joystick from DealExtreme (very cheap)


Here I am about to write a tutorial about a cheap joystick I came across lately which can be bought for only 3.5$ with free shipping to Norway. It is a PS2 repair kit which can easily be used with Arduino concept as well (the input voltage is 5+). It can detect all 8 directions in 2D dimension and also Clicked feature.

Joystick tutorial

Purchase link:
http://www.dealextreme.com/p/repair-parts-replacement-analog-stick-module-for-ps2-controller-black-121340

Here the outputs from the joystick are only VRx, VRy, SW, GND and +5V.
VRx = x value (see program)
VRy = y value (see program)
SW = if Clicked or Not -> Clicked = 0, NOT clicked = 1

-----------------------

/*
  JOYSTICK Program connected to Arduino
 http://www.dealextreme.com/p/repair-parts-replacement-analog-stick-module-for-ps2-controller-black-121340

 Developer:
 Akbar (Shahab) F. Moghaddam
 20.05.12

 Comment : Front, Back, left, right
 */

//CONSTANTS
const int pinX = 2;
const int pinY = 1;
const int pinSW = 0;

//VARIABLE
int VRx = -999;
int VRy = -999;
int SW = -999;
int readVal = 0;
boolean logging = false;


void setup() {              
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);
  pinMode(0, INPUT);
  pinMode(1, INPUT);
  pinMode(2, INPUT);
  Serial.begin(19200);
}

void loop() {
  initialAll();
  readValues();
  loggingProcess();
  printState();
  delay(1000);// wait for a second
}

void initialAll(){
  readVal = 0;
}

void readValues(){
  VRx = analogRead(pinX);
  VRy = analogRead(pinY);
  SW = analogRead(pinSW);
  if (Serial.available()>0){
    readVal = Serial.read();
  }
}

void loggingProcess(){
  if (readVal == 'l'){
    if (logging)
      logging = false;
    else
      logging = true;
  }

  if (logging){
    Serial.println("------------");
    Serial.println("SYUMMARY");
    Serial.print("X:");
    Serial.println(VRx);
    Serial.print("Y:");
    Serial.println(VRy);
    Serial.print("SW is:");
    Serial.println(SW);    
    Serial.println("------------");
  }
}

void printState(){
  if (SW == 0){
    Serial.println("------------");
    Serial.println("CLICKED");
    Serial.println("------------");  
  }
  else if (VRx > 330 && VRx < 350 && VRy > 325 && VRy < 350){
    Serial.println("------------");
    Serial.println("NORMAL");
    Serial.println("------------");  
  }//NORMAL
  else if (VRx > 660 && VRx < 700 && VRy > 325 && VRy < 350){
    Serial.println("------------");
    Serial.println("FRONT");
    Serial.println("------------");
  }//FRONT
  else if (VRx < 5/*==0*/ && VRy > 325 && VRy < 350){
    Serial.println("------------");
    Serial.println("BACK");
    Serial.println("------------");
  }//BACK
  else if (VRx > 330 && VRx < 350 && VRy < 5 /*==0*/){
    Serial.println("------------");
    Serial.println("LEFT");
    Serial.println("------------");  
  }//LEFT
  else if (VRx > 330 && VRx < 350 && VRy > 665 && VRy < 700){
    Serial.println("------------");
    Serial.println("RIGHT");
    Serial.println("------------");  
  }//RIGHT
  else if (VRx > 350 && VRx < 680 && VRy > 350 && VRy < 670){
    Serial.println("------------");
    Serial.println("FRONT-RIGHT");
    Serial.println("------------");  
  }//FRONT-RIGHT
  else if (VRx >= 0 && VRx < 350 && VRy > 350 && VRy < 680){
    Serial.println("------------");
    Serial.println("BACK-RIGHT");
    Serial.println("------------");  
  }//BACK-RIGHT
  else if (VRx >= 0 && VRx < 330 && VRy >= 0 && VRy < 325){
    Serial.println("------------");
    Serial.println("BACK-LEFT");
    Serial.println("------------");  
  }//BACK-LEFT
  else if (VRx > 350 && VRx < 680 && VRy >= 0 && VRy < 325){
    Serial.println("------------");
    Serial.println("FRONT-LEFT");
    Serial.println("------------");  
  }//FRONT-LEFT
  else{
    Serial.println("------------");
    Serial.println("UNKNOWN");
    Serial.println("------------");  
  }//UNKNOWN
}

Tuesday, March 27, 2012

Reseting program pointer, ABB PC SDK


ResetProgramPointer method
Using ResetProgramPointer you can set the program pointer to the main entry point of the task.
VB:
aTask.ResetProgramPointer()

C#:
aTask.ResetProgramPointer();

Stop [ \NoRegain ], ABB RAPID



MoveL point_1, v1000, z10, tool1;
TPWrite “Jog the robot to the position for pallet corner 1”;
Stop \NoRegain;
p1_read := CRobT();
MoveL point_2, v500, z50, tool1;

Program execution stops with the robot at point_1. The operator jogs the robot to p1_read. For the next program start, the robot does not regain to point_1, so the position p1_read can be stored in the program

Tuesday, January 10, 2012

Printing out with ABB Rapid, TPWrite

TPWrite "The value is now "+ValToStr(pTemp.extax.eax_c);


This command would print out the data on FlexPendant. In robotStduio this would not be written in the output window(!), but you can follow this in Virtual FlexPendant.

For loop in ABB Rapid programming language

FOR index FROM initial_value TO final_value DO
      //Do Following ...
ENDFOR

Saturday, April 30, 2011

Processing and Arrow keys

Although in the Processing API it is mentioned that key returns the value of the pressed key, but when it comes to arrows it just returns question mark !!! The magic is to use keyCode :-)

void keyPressed(){
  //print(keyCode);
  if (keyCode == RIGHT){
    //GO RIGHT
  }
  else if (keyCode == LEFT){
    //GO LEFT
  }

  else if (keyCode == UP){
    //GO UP
  }
  else if (keyCode == DOWN){
    //GO DOWN
  }


}//end of keyPressed

Friday, January 7, 2011

RxTx API, Java

By clicking on the following link you can have access to the full directory of RxTx library API's in Java :