This is mainly modified from this answer.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,patterns}
\usetikzlibrary{calc,patterns,decorations.markings}
\usetikzlibrary{positioning}
%
\newcommand{\myfig}[4]{%
\tikzstyle{spring}=[thick,decorate,decoration={aspect=0.5, segment length=#1, amplitude=2mm,coil}]
\tikzstyle{platform}=[fill,pattern=north east lines,draw=none,minimum width=2cm,minimum height=0.3cm]
%
\coordinate (g) at (0,0);
\coordinate (topspring) at (0,-1cm);
\coordinate (bottomspring) at (0,{#2}); %%changing the values (5cm) here will compress or expand the spring
\coordinate (pt2) at ($(bottomspring) + (0,-.5cm)$); %% this is relative.
\coordinate (pt3) at ($(pt2) + (0,#3)$); %% this is relative.
%
\node [platform,anchor=south] at (g) {};
\draw[very thick] (-1,0) -- (1,0);
\draw [thick](topspring)--(g);
\draw [spring] (bottomspring) -- (topspring);
\draw [thick] (bottomspring) -- (pt2.north);
\draw [fill=black] (pt3) circle (#3) node[draw=none,inner sep = 0,scale=#4,text=white]{$m$};
}
\begin{document}
%
\begin{tikzpicture}[yshift=0cm,every node/.style={draw,outer sep=0pt,thick}]
\begin{scope}[xshift=-2.5cm]
\myfig{1mm}{-3cm}{-0.1cm}{0}
\node[draw=none,right=.1cm] at (pt3)(a) {$A$};
\draw [thick,dashed] ($(pt3) + (0.8,0)$) -- +(1.2,0)node[draw=none,inner sep = 0,pos=.5](a1){};
\draw [thick,dashed,] ($(pt3) + (3.3,0)$) -- +(1.2,0)node[draw=none,inner sep = 0,pos=.5](a2){};
\end{scope}
%
\begin{scope}
\myfig{2mm}{-4.8cm}{-0.35cm}{1.5}
\node[draw=none,right=.25cm] at (pt3)(b) {$B$};
\draw [thick,dashed] ($(pt3) + (-1.7,0)$) -- +(1.2,0)node[draw=none,inner sep = 0,pos=.5](b1){};
\draw[thick,latex-latex] (a1) -- (b1)node[draw=none,inner sep = 0,pos=.5,right=0.1cm]{$\delta l_1$};
\end{scope}
%
\begin{scope}[xshift=2.5cm]
\myfig{3mm}{-6.6cm}{-0.4cm}{1.8}
\node[draw=none,right=.3cm] at (pt3)(b) {$C$};
\draw [thick,dashed] ($(pt3) + (-1.7,0)$) -- +(1.2,0)node[draw=none,inner sep = 0,pos=.5](c1){};
\draw[thick,latex-latex] (a2) -- (c1)node[draw=none,inner sep = 0,pos=.5,right=0.1cm]{$\delta l_2$};
\end{scope}
%
\end{tikzpicture}
%
\end{document}

Kindly excuse me if the code is cluttered a bit. It can be simplified further by inserting extra lines inside the scope, into the macro \myfig
itself.
Let us have some fun in this episode of having some free time and getting bored:
\documentclass{article}
\usepackage{filecontents}%
\begin{filecontents*}{beam.tex}
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,patterns}
\usetikzlibrary{calc,patterns,decorations.markings}
\usetikzlibrary{positioning}
%
\newcommand{\myfig}[4]{%
\tikzstyle{spring}=[thick,decorate,decoration={aspect=0.5, segment length=#1, amplitude=2mm,coil}]
\tikzstyle{platform}=[fill,pattern=north east lines,draw=none,minimum width=2cm,minimum height=0.3cm]
%
\coordinate (g) at (0,0);
\coordinate (topspring) at (0,-.2cm);
\coordinate (bottomspring) at (0,{#2}); %%changing the values (5cm) here will compress or expand the spring
\coordinate (pt2) at ($(bottomspring) + (0,-1cm)$); %% this is relative.
\coordinate (pt3) at ($(pt2) + (0,#3)$); %% this is relative.
%
\node [platform,anchor=south] at (g) {};
\draw[very thick] (-1,0) -- (1,0);
\draw [thick](topspring)--(g);
\draw [spring] (bottomspring) -- (topspring);
\draw [thick] (bottomspring) -- (pt2.north);
\draw [fill=black] (pt3) circle (#3) node[draw=none,inner sep = 0,scale=#4,text=white]{$m$};
}
\begin{document}
%
\foreach \x/\y/\r/\s in {1/19/1/.3,1.4/24.8/2/.5,1.8/30.5/3/.7,2.2/36.3/4/.9,2.6/42/5/1.1,3/47.8/6/1.4,3.4/53.6/7/1.8,3.8/59.4/8/2.3,
4.2/65.2/9/2.7,4.4/68/10/3.2}{
\begin{tikzpicture}[scale=1,yshift=0cm,every node/.style={draw,outer sep=0pt,thick}]
\myfig{\x mm}{-\y mm}{-\r mm}{\s}
\path (-1,0) rectangle (1,-10);
\end{tikzpicture}
}
\end{document}
\end{filecontents*}
%create the beam.pdf.
\immediate\write18{pdflatex beam}
% convert to GIF animation
\immediate\write18{convert -delay 10 -loop 0 -density 200 -alpha remove beam.pdf beam.gif}
\begin{document}
This is empty
\end{document}
