Sunday, March 20, 2022

Learning neural networks 1

1 Simple forward pass of one layer neural network in Python, with numpy

 






# -*- coding: utf-8 -*-
"""
Created on Fri Mar 18 12:39:21 2022

@author: Balaji
"""

import numpy as np
num_neurons = 2;
num_inputs  = 3;
num_dataSets= 1;
print('\n Program for a simple neural network, doing a forward pass with one layer')
print('\n Each row is a data set')
inputs  = np.random.randn(num_dataSets,num_inputs);
weights = np.random.randn(num_neurons ,num_inputs);
bias    = np.random.randn(num_neurons ,1);
results = np.zeros_like(bias)

print('\n Input = ')
print(inputs)

print('\n Weights = ')
print(weights)

print('\n Bias = ')
print(bias)

for input_iter in inputs:
    for weight_iter,bias_iter,result_iter in zip(weights,bias,results):
        print('\n Input data set:')
        print(input_iter);
        print('\n is multiplied with weights')
        print(weight_iter)
        print('\n and added with bias')
        print(bias_iter)
        print('\n to give the result of neuron as')
        result_iter = input_iter.dot(weight_iter) + bias_iter;
        print(result_iter)
 
 

Monday, September 20, 2021

Sheet metal fabrication tips

  •  SS304 is better from rust susceptibility
  • SS202 is normally used for indoor use
  • SS316 is used when chemically corrosive environment is present
  • AL, GI and cold rolled MS sheets are available in market upto 3mm thickness
  • All sheet metal bends upto 2mm should use 0.8mm as inner bend radius.

Wednesday, May 26, 2021

The league, a short story.

 

The league.

 A short story.

Every body in the league has a  role. Not to say that there were no overlaps. Many of our abilities overlapped. There were many who could read minds or at least guess what the other guy was thinking. Guys who could calm down a raving lunatic in to a docile kitten with a caress to the forehead were dime a dozen. The league was flush with people with abilities that were grounded, or dare I say, plebeian.

But I, I am unique. I am a walking, talking AM radio transmitter. I know. It does not get any more plebeian than this. I am not aware of any grandpa who owns a radio receiver around here. Heck, even I haven't opened the FM radio app on my own phone since the day the league gave me one. Nevertheless, I am the only one who can make your speakers buzz and I can broadcast over a small bandwidth over a sizable area.

I still haven't mastered the modulation part yet so I cannot convey any meaning full signal, but I could manage the carrier wave alright. I am sure I can go to binary levels or Morse code if I practice, but practicing the transmission leaves me absolutely starving and thirsty and I like to be comfortable as much as possible. Wider I try to broadcast, faster I drain out. Plus the league commander does not see the value in me or my ability to warrant further training. Not only that, I think he actually detests me training. Once I took it upon myself to train in the league's anechoic chamber. I was being paid handsomely by the league and wanted to show some progress, or at least some activity that my previous bosses took for progress. The chamber was originally built for testing sonic crowd control booms. With no riots predicted by the popular sentiment analysts of the league, nobody bothered to calibrate the power levels of the sonic booms and the facility was in disrepair. As I started humming from the center of the chamber, I could certainly feel that the acoustics were weird in the foam padded hall. It turns out the chamber does not block out my frequency that well and I, after a hearty meal, gave quite a good headache to the lab rats in the nearby league facilities in a couple of seconds.

The league commander was quite annoyed at the news and sent a curt email, addressed only to me, barring my training in any form in future. I was puzzled for a few days how he zeroed in on me as the cause but was also extremely relieved that my stipend was intact. I decided that the powers that be were fine with me being paid handsomely for sitting tight and made myself more comfortable in the league head quarters.

With the abilities being conferred upon us by the almighty "luck", which wielded its influence over us mortals through the mutations in our genes, nobody could know what power or curse was the newborn going to arrive with. All we know was that the mutations became much more wide spread after the bombs went off.Many a times there were cases of "would-have-been" heroes having lived through their entire lives unaware of the powers that they had all along. Many became aware of their abilities only through freak accidents or when being cornered to the wall under a mortal threats. They were the lucky ones, I feel now. One saving grace that Newton still has is that none of the abilities defied known biology or ever-true physics, much to the disappointment of ardent comic fans who expected some one from the league to zip through the skies or at least jump really high.

It is not for want of trying that none of the corporations have yet figured out how to tweak the mutations in a predictable manner. We were all aware that all the big boys and the league itself is spending good money chasing a system that can guarantee both the special ability and the survival of the newborn. Though mothers were willing to be irradiated during pregnancy under quite a many guise, it was difficult to contain the PR disaster when a baby was born disfigured or worse. Soon the corporations found a better way of trial and error that had fewer repercussions during the inevitable error phase. Why irradiate a pregnant woman when a hidden virus could be your DNA vector? Several developing countries did not periodically scan the developing baby with the already stretched health care systems and the companies observed the babies being born from afar after unleashing the viral vectors on to the unsuspecting population.

Now, am not questioning the use of us humans as lab specimens by the league, because I did not know it first hand. Neither did I want to. I needed the uncertainty of it all to let me be with the league. And in the unlikely event that I prove the fact to myself, I did have a good reasonings to convince myself to stay. The league was already having a big group of savants and they were trying to cure some pretty darn in-curable conditions that ail our kind. We need more geniuses and boy wonders on the job. Tests have to be done, methodologies refined and made repeatable.

Anyways, by now you would have guessed where all this is going. As I am recapping all this, the league commander is coming to my dorm. I was quite surprised to see him actually. I expected a more hero looking guy leading league. Instead he was in a sharp all black business suit over a crisp white shirt and I was instantly convinced he had no special abilities whatsoever. He took down his shades and said, "I am good with numbers. I know what you are thinking. But I have no time to humor you right now. Walk with me."

I left my dorm and started walking with him towards the basement parking as he took the longer route rather cut across the garden like everybody else. May be he keeps fit this way. I followed him behind. "Listen to me. I will say this once and this is to be repeated to no one.I know your abilities and the possibility you hold. I am sorry about your curtailed privileges after the anechoic chamber incident. I did not want your abilities becoming more public than they already are. Right now the league thinks you are a novelty and an irritant at best. I would prefer to keep it that way. Your dorm is being vacated now and you will come with me to the airport. You will board a C5 galaxy that awaits you there with your belongings. You will be taken to Nigel where we have a experimental facility".

I was finding it difficult to concentrate on his words with the pace of walking making me breathless and this guy was talking continuously all this while. May be it was me who actually needed the exercise. Anyways, to the point. "Oh my God!! I always feared that it would come to this. You have let lose a virus in your trials haven't you? People are going to die in that country you are talking about? You are doing a cover up now aren't you? Why are you taking me?" I was trying show anger in my accusations, but I was finding it difficult with the labored breathing. "Shut up and listen. I am late for the board of governors meeting. They are going to be quite thrilled with the news I have for them and I don't want their mood fouled with my delay. We were conducting viral trials alright. That's being going on for a decade now. But we're not trying to get whizz kids anymore. We already got that process fine tuned in our irradiation trials. We now have more Nobel grade geneticists than we can employ at our facilities. With their help, we have advanced to the next stage a couple of years back. We were perfecting our gene therapy for ever lasting youth in our trials. Now, the situation is that the last 50 or so kids born in Nigel haven't had a single hospital visit for any vector born diseases and haven't aged a day past puberty. This is in a country where we still lose good men to malaria. Now, we have reached the threshold of repeatability required by our management in our control groups."

"Oh thank God. I was unnecessarily feeling guilty all this time. You are good. I was actually with the good guys all this time. Good God. It feels good to be relieved". I finally caught my breath."

"Shut up. We can't have near immortals in Nigel trudging along with our yet to be patented genes before we monetize. All humanity can have it, in due course, at the right price. Here is where you come in. You need to synchronize your transmission frequency with the resonant frequency of the brain cavities of the people there. Required chamber training will be given onboard the galaxy en-route. There are people of various age groups with different cranial volumes there, so it will take some time as you walk around. There can be no machinery or trace left in that jungle. I expect you to be done before my meeting starts. I would like to declare to the investors that the loose ends are already tied up. It looks professional."

Saturday, April 24, 2021

Tips when starting Python programming V plotter in Raspberry

Two errors I encountered and How I googled them out of existence.

  1.  Initially when importing numpy in python after installing it using python3 -m pip install numpy, i got error that "Importing numpy shared c extensions failed.". It got solved after running "sudo apt-get install libatlas-base-dev". Answer from " https://github.com/numpy/numpy/issues/16012"
  2. While importing serial and running serial.Serial(), i got error that serial has nothing called Serial. Solution was to uninstall serial and install pyserial. Answer from "https://duckduckgo.com/?q=serial+has+no+attribute+serial&t=raspberrypi&ia=web"

pip uninstall serial
pip uninstall pyserial
pip install pyserial 

Working code in Raspbian 32 bit Os on Raspberry 4 B, with arduino cnc shield , 28BYJ motors for V plotter:

import numpy as np
import matplotlib
# ensure pyserial and serial is installed
import serial
import time

ser = serial.Serial("/dev/ttyUSB0")
ser.baudrate = 9600

# Existing steps per mm was 250 for x and y axis. It was found using $$ command.
# Measured actual travel of thread and set the $0 and $1 variable to correct values.
#$0 = 138.8 = 139 steps per mm
#$1 = 138.8 = 139 steps per mm
if (ser.is_open):
    print ("\n Serial port has been opened")
    print("\n Initialising communication with GRBL on the arduino")
    print("\n Using ")
    print(ser.name)
else:
    print("\n Could not open serial port for communicating with GRBL on the arduino")

# Communicating for codes
print("Stripping all end of characters for safety before encoding to byte string.")
ser.write("\r\n\r\n".strip().encode())
time.sleep(2);
ser.flushInput();

print("Using G01 command for a basic move command")
command= "G01X{}Y{}".format(10,10)
ser.write((command.strip()+'\n').encode());
#reading reply
grbl_reply = ser.readline().strip()
print("GRBL replied that")
print(grbl_reply)
time.sleep(4)
ser.flushInput();

print("\n Closing serial port ,finally.")        
ser.close();


Friday, July 17, 2020

Word size and data types part of embedded systems course.(Transcript)

Depending on the type of architecture, these instructions can be extremely complex, like in the case of a CISC machine, or these instructions can be very simple, like in the case of a RISC machine. ARM, or advanced risk machine, contains many different versions of its architecture; however, we often refer to ARM as a 32-bit or a 64-bit architecture. These numbers represent the word size for two different versions of their RISC instruction sets. Physically in hardware, CPU registers and assembly operations will be designed around these sizes. In C programming, you can define operations around a variety of sizes that do not necessarily map to the word size. However, every operation in C utilizes the word size and the instruction set architecture or ISA. Learning about how these two types of data references can help a programmer write more efficient and portable code is what we're going to look at. The fundamental unit of work for a processor is the instruction and the word size. The instructions are assembly operations that perform a small amount of work in a CPU. These instructions are fetched from the code memory, decoded and then executed by the CPU. Operations can range from arithmetic to logical to controlling program flow and load store operations of memory. The word is the size of work that each operation performs. For example, an architecture with a 32-bit word could perform an arithmetic add; these mean that the architecture will able to add two 32-bit numbers in one instruction. The general purpose registers in the CPU will be sized the same size as the word size. This is because these registers are where the operands are stored for each instruction. The Cortex-M0 has 16 general purpose registers, most of which are available for use by the programmer. Some are reserved general purpose registers like the link register, the stack pointer and the program counter. The architecture is built around performing the operations on the size of the word with these registers. However, that does not mean you cannot perform arithmetic or logic operations from C programming with larger or smaller sizes than the word. We often have operations that do 8-bit, 16-bit or even 64-bit math on a 32-bit architecture. The ISA may have specific assembly operations for these smaller size data actions or it may require multiple 32-bit operations to do larger sizes. The word size is often confused with the instruction size or the bus width. The ARM Cortex-M series has a 32-bit instruction size. However, ARM can also be configured so that the CPI core can operate with a 16-bit instruction size. This is referred to as the thumb architecture. Thumb is just a reduced number of ARM instructions at a smaller instruction size. The size of instruction can limit the number of supported operations and different features within each individual operation. These operations are usually referred to as an operation code or an opcode. The bus width for ARM can vary depending on the different bus architectures you're using. You would typically see a bus width at least the size of the word or the instruction. This helps with efficiency because instructions are read from memory just like data is read. You would want to be able to fetch an instruction from memory in one memory fetch. The bus width does not necessarily have to be the word size, but the bus refers to many things. A bus will contain both data bits, address bits and control bits. The data bits can be configured for ARM architecture, but usually for sizes equal to or larger than the word size. The address bits would usually map to the size of the word, as this is the way that we will address our microcontroller components within a memory map. Just like a pointer holds an address for a piece of data, an address must be provided to fetch a specific instruction at a given address. The address is referenced by a program counter and the instruction that is being execute is put into the instruction register. Now you might be asking how does the word size relate to a C program type? When you write C programs, you have utilized a handful of data types and type modifiers for your variable declarations. These have specified size and sign of a type. The types included chars and integers. The modifiers included signed, unsigned, short and long. These types are somewhat ambiguous when it comes to physical sizes and memory. The C standard only guarantees a minimum size that each of these types might be. It's up to the architecture and the compiler to actually sign the sizes at build time. For instance, an integer can be 16-bits or 32-bits, depending on the architecture. The length and size ambiguity does not suffice for software engineers. Instead, we utilize some special types to help provide more insight on what exactly you are reserving in your architecture. These are referred to as the standard integer sizes and are standard practice to use. There are three forms to these standard references. These include types that describe an exact size, a minimum size and a fast execution size. You can find these defined in your stdint.h library file. The standard types have much more clear definition. They start with a u-int or an int, which represent an unsigned integer or a signed integer. Following this is the number of bits this type will occupy. A uint8 will represent a unsigned 8-bit type, while an int32 represent a signed 32-bit integer. The underscore t at the end just indicates that this word represents a type. You will likely see support for 8, 16, 32 and even up to 64-bit standard integer types. And when these are used, they will reserve the exact amount of memory. If you were to look further in the standard int file, you will see two other types declared that look very similar to our u-int and int formats. These include the int_fast types and the int_least types. These are slightly different from the compiler perspective. The least type just requests that the compiler select a storage amount of at least n bits. So int_least8_t would be assigned at least 8-bit type. The fast type indicates that this data should be represented in a way that the access and use of this type occurs as fast as possible in an architecture with at least n bits. So int_fast8 type would be implemented with at least 8-bits. However, it would likely be sized up to the size of the word. These types are set by the compiler or by using the typedef C keyword. The typedef keyword allows us to create our own types and use them in a short form just like we do with ints, chars and floats. These are extremely helpful for defining structures, enumerations, or unions with custom type names. If we were to open an example of the standard int file, you will see these standard types defined and you could see the typedef keyword is used to map the u_int8 type to the unsigned char type. And the int32 type is type-defined as a signed long int. Many of the tenets of good software design were addressed in this video. Understanding the architecture word size can help us choose data types that best utilize the architecture. By selecting smaller data sizes, we might be using less memory; but that can be causing excess overhead in operations. Larger types than the word will cause extra operations to do loads and stores of that data as well as the actual operation on that data. In C programming, the types we select can vary or are architecture and compiler-dependent. By utilizing the standard types, we can create unambiguous code that helps us create and write more portable and efficient software

Monday, June 15, 2020

Vibration measurement and balancing seminar by Bentley Nevada


Major takeaways from vibration and engine balancing seminar by Bentley Nevada

Held at Aeronautical society of India, February 28, 2020

  1. ICP  accelerometers are not rugged. They are sensitive to temperature fluctuations.
  2. Charge type accelerometers are good for field use
  3. The gap in peaks between rotor and stator vibration signals is of the order of 10 microseconds
  4. Techniques to measure rotor angle position in aero engines:
    1. Rolls Royce: One tooth in gear wheel is shorter/taller than others
    2. Pratt and Whitney: Gap between successive gear teeth is smaller for only one pair. 
    3. Pratt and Whitney's method requires a high sampling rate.
  5. PBS 4100 is the Industry standard for vibration analysis.
  6. 32% of fuel in aero engines goes to turning the fan in turbofans
  7. Vibration survey for Aero engines is a plot between the amplitude of vibrations and speed. 2 curves are typically presented: 
    1. N1 signal amplitude (lower).
    2. Broadband (BB) (higher)
  8. BB  is all the vibration measured by the sensor
  9. N1 is the vibration amplitude between 45 and 55 Hz for a 50 Hz shaft.
  10. N1 signal plotting requires a tracking filter.
  11. BB > N1, typically.
  12. If all vibration is caused by N1 alone, N1=BB
  13. PBS 4100: 
    1. Number of channels used is 4 for portable instruments, 20 for test cells
    2. TCP / IP available
    3. Labview drivers available
    4. Online  data retrieving possible
    5. C, C++ API available
    6. Digital output available 
    7. Safety limits & triggers can be configured
  14.  Balancing of the engine requires an influence coefficient matrix of the engine and one set of acceleration vibration surveys.
  15. 4 or 5 points on the vibration survey are taken for calculation of compensating masses.
  16. CFM 56 old TBO 5000 Hours. Now TBO is 7500 hrs. The current target is 12000 hrs. Fan RPM is 500 to 5750 RPM
  17. For balancing, the software can be forced to use standard weights.
  18. PBS4100 can be told to minimize vibration at a particular speed and not to care about other higher speeds.
  19. Imbalance in turbine plane can be corrected by masses in compressor plane
  20. Twin spool rotor (HP spool of CFM56 in 737 airplanes) core balancing is also done in the same fashion using optical pickups in the inspection window using a blade that is painted white in color.
  21. 1500CS calibrator can be used to apply 0 to 10,000 pico coulombs to the cable of the accelerometer. 1500CS has 2 function generators for sine, square voltage waveforms. The phase difference between 2 channels of PBS also needs to be calibrated upto 0.1 degrees using 1500CS.
  22. Simultaneous sampling by PBS has a delay in the order of nanoseconds.
  23. PBS is a rugged system and uses an accelerometer on static casing. Eddy current/proximity probes are not rugged and cannot be targeted on rotating shaft in aircraft engines.
  24. If phase of signal is steady, the mounting of accelerometer is good. If phase signal is jittery, mounting is not good. 
  25. EGT and oil temperature have to be stabilized before collecting data for balancing. The phase of the accelerometer signal can drift due to temperature changes and due to non settled EGT levels.
  26. Shaft runout can be seen in the bode plot.
  27. Journal bearings are difficult to balance with this system. You need to see spectrum of responses to make a decision on feasibility.
  28. Comment by Sanjay Barad GTRE: Typically for journal bearings, we take response at low rpm (1000 RPM) and subtract it from the response at 25000 RPM. Subtraction has to be done vectorially. ADRE has such a provision. Squeeze film damper for bearings also to be done similarly.
  29. The lunch served was very simple.
Few photos:





 





Thursday, August 15, 2019

Notes from public seminar at CMTI, Bangalore on 15th March 2018

Notes on Meet on Machine Tool Industry, Current scenario and the way forward:


Organised by Govt of India, HMT, IMMTA and CMTI.


  1. Jig boring machines are still imported from switzerland
  2. Only spare parts assembly is happening in India
  3. Imported components:
    1. Control system,
    2. drives
    3. ball screws
    4. turrets
  4. Systems in Inida have not reached Shoblin level accuracy
  5. Swiss jig boring machines are not mass produced. They are still hand crafted
  6. Huge market opportunity for
    1.  ceramic manufacturing machines
    2. tape winding and polar winding machines
  7. FADEC controls are still imported
  8.  CMTI is a R&D place for manufacturing of tools

TP Sridhar, ACE designers limited,  Peenya, tps@acedesigners.co.in 

  1. From 1979
  2. Largest turning center manufacturers
  3. 4000 installations per year
  4. 700 crore in turning ceters alone
  5. 1800 crore, 2000 employees 
  6.  Mostly Ex CMTI employees
  7. R&D under progress in
    1. hydrostatic guideways
    2. thermal compensation
    3. synthetic granite bed
    4. CNC controls
    5. sensors
    6. spindle bearings
    7. LM guides and Ball screws
    8. spinner lathe
  8. PSU should not put foreign items specs in RFQ
  9. Give advantages (20% cost) to Indian companies

L S Umesh, ACE manufacturing solutions

  1. Severe man power shortage in Industry
  2. Twin spindle vertical machining centers are exported to Mexico

P M Jadeja, CMD-Jyoti CNC, Rajkot

  1.  1000 crore technology company
  2. recently acquired french company
  3. Ball screws made by PMK
  4. Gives projects to IIT on machine tools
  5. ARCI Hyderabad develops powder for direct metal deposition, DMD
  6. CGCRI makes laser upto 1kW

 ETA technologies

  1. etatechnology.in
  2. Makes friction welding machines

Bhagya Chandra Rao, Kennametal , Tumkur Road

  • Originally Widma group
  • 110 crore/year
  • makes ECO grind machine tools and fixtures
  • specializes in 5 axis CNC
  • 38kW,12000 RPM spindles
  • does vision based machining
  • makes hydrostatic spindles and guide ways
  • does turbine blade manufacturing using grinding process
  • feels IISc doing research only for MNCs
  • developing SV cam software for machining

Pragati Automation

  • deepak@pragatiautomation.com
  • makes tool turrets, automatic tool turrets and CNC machines
  • CHINA is bigges customer
  • uses ethercat real time communication
  • servoand spindle drives of 0.75 to 15 kW
  • makes ball screws

Sendhil Raja, RRCAT , under BARC/Atomic energy

  • Does work on optics
  • has laser and optical instrumentation laboratory
  • does micro maching and liquid jet polishing, femto second laser micro machining
  • optical precision required is 0.1 microns
  • optical precision is usually of the order of wavelength/100
  • grinding machines work on air bearings
  • artificial granite/granitite being used
  • reaction free air bearing spindles reduces forces transmitted to machining bed
  • to reduce reaction force, usually opposing slides accelerating together are used.
  • epoxy granite has similar rigidity compared to granite
  • intra ocular lenses require diamond turning and 4000 diamond turning machines are required per year in India

Praful Shende, Kothari group, Pune

  • Mr Amit Goradia does CNC controls and electropneumatics based CNC
  • develops indigenous EPfast bus to talk between controller and drive

Other companies that came:

  • Anant Jain, Micromatic grinding tech, develops hydrostatic grinding
  •  Vishal Nair, ISGEC, does metal forming press.