Sunday 23 August 2020

Troubleshooting Siemens step 7 200 cpu226

I got into trouble the other day. I was modifying a client's machine. The machine runs a simatic step 7 200 cpu 226.





Initially the device was detected quickly. I simulated the existing program and figured that I would do the modification after production is over. 

So when I resumed, the device failed to be detected, it also froze and nothing was responding.

 I feared for the worst. I feared that the firmware could be bricked and that I may have to replace the PLC or figure out how to reset the thing to factory defaults! My head was racing with everybody looking up to me for a solution. 

There is nothing as traumatizing as bricking a machine that was running before it is touched. With a thousand eyes and high expectation weogjing heavily on my shoulders, I compose myself and consult a few friends. It's a Saturday night and some are already Sanitizing their throats. No solution comes through. 

I give up and rest for the day hoping to resolve the matter by Sunday morning. I retire to bed hoping the Chinese supplier would offer some insight. The only thing he said is that I should restart the machine which I had already done a thousand times.

At exactly 5am,the client calls me. I fumble from my sleep and get ready to head to the factory by 6am. Before I left the bed, 


I do a quick YouTube search and find a video without audio by a Pakistani where the same problem I was facing was solved.  Luckily he had left his email and phone number. I quickly write him an email. I shoot some whatsapp messages and call frantically! The rest is history! 


Name:Nasir Hussain
Phone +92 323 5007170
YouTube :  https://www.youtube.com/channel/UC2z25mBoq_yDFtTUeKgLDVA

I now feel guilty for not publishing enough on this blog and my YouTube channel. We're it not for Nasir's work, I would have been stuck a long time! 


Monday 1 December 2014

LED LIT RIDING JACKET



 It has been quite a while since I posted anything here and am feeling a little guilty. But this does not mean that I have not been tinkering. I recently bought a tiny 150cc bike to navigate the crazy Nairobi traffic and when I ventured on the road I felt like a small grain sand in a sea of crazy PSVs and other motorists. After Purchasing my riding gear and using it for a while I decided to make it more visible by adding some wearable tech onto it using an LED strip arduino uno and a transistor TIP122. 


Posing with the bike



Riding jacket with LED strip on it, notice it at the elbow, waistline and back

How the jacket looks in the light, maybe it is too bright

And in the dark, amazing!

Arduino Uno thrown in the mix to add different lighting effects


The code that runs this jacket is simply a combination of the fading example and the blinking example that comes with the arduino IDE.
/*
 Fade
 
 This example shows how to fade an LED on pin 9
 using the analogWrite() function.
 
 This example code is in the public domain.
 */

int led = 3;           // the pin that the LED is attached to
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup()  { 
  // declare pin 9 to be an output:
  pinMode(led, OUTPUT);
} 

// the loop routine runs over and over again forever:
void loop()  { 
  int x=0;
  for(x=0;x<255;x++){
  // set the brightness of pin 9:
  analogWrite(led, brightness);    

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade: 
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ; 
  }     
  // wait for 30 milliseconds to see the dimming effect    
  delay(30); 
  }  
  
  for(x=0;x<5;x++){
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
  }
  
  for(x=0;x<10;x++){
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);              // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(500);              // wait for a second
  }
} 
 
 
Enjoy! 

Thursday 24 July 2014

Fabricating a Temperature data Logger Using Arduino in two days


Recently friends  approached me requiring a data logger for a refrigeration system they were building for cooling harvested agricultural produce. I quickly put together a prototype using an Arduino Uno  and data logger shield. I demonstrated and they were overjoyed. At this point I could see the relief in their eyes with the automation in data collection so they do not have to bear the pressure of  reading and recording the temperature from  four thermometers every few seconds. The initial contraption is pictured below.


So after making a good first impression, I set out to create a device that will be cheaper than the off the shelf proof of concept device. I have been down this road before and the worry is the bugs that delay an otherwise smooth process. After about an hour of design time I converted the contraption to one file ready for Fabrication using Toner Transfer Method. Then parts were sourced and soldered and soldered after drilling and cutting PCB down to size. For code and circuits checkout the repository on bitbucket. Otherwise below are pictures of the quick and dirty prototype. 

Completed device showing the makeshift probes and the nice plastic housing


Complete device showing SLA backup battery and wall adaptor for charging

For a two day Fabrication exersise I feel good about this. To make it better a friend is smiling all the way to the Lab.



Tuesday 1 April 2014

making infrared intruder counter / alarm


Introduction

This is a gadget for counting the number of times an infrared beam of light is interrupted. It is arduino based and implemented with an atmega328 chip on a veroboard. This is an easy project and may take a day to put together.

The counter working

Parts required

  • 220 ohms resistors
  • 10k resistors 
  • 4 digit 7 segment display
  • atmega328p/ arduino uno
  • infrared photo transistor
  • infrared diode
  • 7805 voltage regulator
  • power source: 7.5Vdc to 15Vdc
  • buzzer

Connecting it together

I use the pin mapping of the atmega328p from the arduino site and is also shown below. To protect the microcontroller pins from being destroyed by large currents that may flow, add 220 ohms resistors on the common cathodes or anodes of your display. 

For connecting the 4 digit  7 segment display use the assignment shown in the picture below. Just in case you have the same display I had, otherwise find the display pin assignment in the datasheet.



Connect the 4digit 7-segment display using pin assignement in the code and load the code to the MCU using a programmer. For me I use UsbTinyISP.

Code


/*Written by Dean Reading, 2012.  deanreading@hotmail.com
/Edited by Peter Mbari to Count number of Intruders using Infrared
 

 */

#include "SevSeg.h"

//Create an instance of the object.
SevSeg sevseg;

int sPin=12;
int buzzer=13;
int people=0;
//Create global variables
unsigned long timer;
int CentSec=0;

void setup() {
  //I am using a common anode display, with the digit pins connected
  //from 0-3 and the segment pins connected from 4-11
  sevseg.Begin(1,0,1,2,3,4,5,6,7,8,9,10,11);
  //Set the desired brightness (0 to 100);
  sevseg.Brightness(50);
  
  pinMode(sPin, INPUT);// Setup the Infared sensor pin as input
  
  pinMode(buzzer, OUTPUT);// Set Buzzer pin as output
  timer=millis();
}

void loop() {
  //Produce an output on the display
  sevseg.PrintOutput();
  
 if(digitalRead(sPin)==LOW)
 {
   people++;
  while(digitalRead(sPin)==LOW)sevseg.PrintOutput();
  digitalWrite(13,HIGH);  
  delay(500);
  digitalWrite(13, LOW);
 }
 
  
    //Update the number to be displayed, with a decimal
    //place in the correct position.
    sevseg.NewNum(people,(byte) 0);
  
}


Finaly after the board is assembled and working you get a nice display like the one shown in the video below.




Happy making








Thursday 9 January 2014

Home-made UV exposure box for PCB prototyping

Earliest last year I wrote this  post on how to make printed circuit boards using the method of toner transfer. Since before then I have known that the method is not consistent in the results obtained. Sometime the toner does not stick evenly on the copper clad especially for bigger designs.

During the same period I made several PCB at the University of  Nairobi Electrical Engineering department and the boards were much more superior to the ones I had made before using the toner transfer method.


good pcb made using pre-sensitized copper clad  


double sided pcb exposure box 

controls for the pcb exposure box
The department has a double sided PCB exposure box that is proven to give very good results over the many years it has been in service. Problem is I can't access this machine at my  leisure and therefore I decided to make my own machine.

First I sourced for the UV bulbs that were available in Nairobi and then enlisted the help of a colleague to get the box designed. A press fit design was quickly put together and cut from left over mdf using a cnc router we have at the fablab and some pictures are shown below!

Cutting the parts on the Shopbot
Some of the cut parts ready for assembly




Filing the edges for a nice fit

The we put together the box by press fitting as shown in the pictures below.

Press fit Box for the top cover
The bottom was also cut and assembled in the same way. The UV bulbs were then fitted and the fun began. . . TESTING!


Putting the bulb holders in place



fitting the bulbs after fitting the reflective foil(kitchen foil works fine)

the complete assembly

fitting a paper cover for a quick and dirty testing session(Just couldn't wait to fix the plexi glass cover)
 After all this hard work, it was now time to test this baby! Having recently bought a can of UV curable solder mask paint I decided to see if it will cure in this UV light.
After several failed attempts mostly due to underexposure, the results were messy.

the messy results


At the point whre I almost gave up and almost  threw the box in the dustbin, I had some of the  solder mask cured on one of the samples and my hope was rekindled! With this burst of energy and enthusiasm I experimented with different timings for the exposure and got some impressive results
pcb with solder mask after curing and cleaning with acetone

first encouraging results using an actual pcb
At this point I could predict the results and my money did not go to waste after all.

 One more experiment though PCB exposure for etching!
This is the primary reason for this box and it had to be tried as well with the following great results!

pcb  after exposure and development

pcb after etching!

pcb with Solder mask applied to it!

 Now that the machine is useful, a Plexiglas cover will be perfect for the top. Using a laser cutter this was cut and fitted and now the box is complete at least for single sided boards.



For double sided exposures I will have to finish the top, but I am impressed with the results I have got already!



THE QUEST CONTINUES!




Wednesday 13 November 2013

Make the Easiest AVRISP for your hardware hacking expeditions

I have always found my self in the chicken egg situation when making electronics using microcontrollers. Many open source programmers are based on microcontrollers which require specific firmware to be uploaded before they become useful or they require specific hardware. There are quite a number of open source designs of avr ISPs namely

USBASP

USBasp is a USB in-circuit programmer for Atmel AVR controllers. It simply consists of an ATMega88 or an ATMega8 and a couple of passive components. The programmer uses a firmware-only USB driver, no special USB controller is needed.
This is a great programmer but you must have another programmer to make the circuit useful.

Parallel Port programmer 

Serial Port Programmer

These are  great ones since they do not require any firmware on them but the down side is that a parallel port or the Serial port, which are absent in most new computers, is required to upload firmware to the mcu.

AVR Development boards 
There are quite a large flavour of these platforms offered by various vendors and they are great. They offer many features and support many chips but they are far out of reach for newbies especially in Kenya. 

To avoid all these problems then I used a design that programmes itself. This ISP has been used to upload bootloaders and burn fuses on new ATMEGA chips using the arduino IDE. What many people do not know is that with avrdude, you can upload firmware to any avr chip.
 In the Arduino examples there is an arduino ISP sketch that when uploaded turns an Arduino board into a programmer as seen in this Youtube video.

I had an arduino proto shield left over from previous and I went ahead and converted it into my isp following this design and below are pictures of what I made.




After the programmer is made see an avrdude tutorial here to upload firmware or use the arduino ide with the programmer for uploading firmware.

Snapshot of command line window with avrdude in action

 Feel free to ask any questions in the comments.

Happy hacking 




Monday 15 July 2013

Unlock your potential with open source hardware


For long many have been scared of starting off in embedded systems and programming because of the fallacy that they it is hard. Times have changed and today there exists open source tools and platforms like that make the entry level requirements have gone qiute low. It is amazing the kind of projects that have been powerded by these platforms from blinking an led to going to space with ardusat.
 Just to mention a few platforms;

1. arduino is based on 8 bit avr microcontrollers with the new arduino Due for 32 bit microcontrollers.
"Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments." by Arduino Team
Arduino Due

Mbed : Based powerful 32 bit ARM microcontrollers.
"The mbed rapid prototyping platform is the fastest way to design products based on ARM microcontrollers.
The project is being developed by ARM, its Partners and the contributions of the global mbed Developer Community" by the mbed team.

mbed FRDM KL25Z

pinguino :Based on ©Microchip microcontrollers
"Pinguino is an Arduino-like board based on a PIC Microcontroller. The goal of this project is to build an integrated IDE easy to use on LINUX, WINDOWS and MAC OS X. Arduino is a powerful tool with some defaults. One of its inconveniences are a no native USB interface on the chip and its code length." by the Pinguino team.



Many other projects are featured on wikipedia and are interesting to look at.

With all these project one the greatest emphasis is on getting people to do the projects without worrying too much about about the complexity of  writing the underlying complex routines. They make you design your application easily without spending hours learning pragma, configuration bit or command line compilers. Most provides USB Bootloaders. This means that there is small program running inside the microcontroller is responsible for transferring your user program to the program memory and handing over the control to this program afterwards. No programmer is needed, the microcontrollers can be reprogrammed over USB with a PC.
These platforms come with plenty of examples and libraries which come in handy for both the advanced users as well as the beginners. Not to forget the numerous support from users all over the world. With only a few hours of study you could well have finished some nice projects.

Sites like instructables have numerous projects with step by step directions on how to work with these nice little toys. From my childhood days, I learnt that playing with toys is most enjoyable if the toy is mine. for this reason head to  nerokas electronics shop, get your toy and let the fun begin.