Dear Sirs

I need to draw some simple eletrical circuits. I try metapost (mpcirc.mp) and cicruitikz, but i found error messages in both.

Is there a way to draw eletrical circuits in ConTeXt?


Thanks in advance  for your support.

Jorge

ConTeXt  ver: 2014.02.14 17:07 MKIV beta  fmt: 2014.2.15  int: english/english
######### with mpcirc.mp ######

With this code:



\startMPinclusions 
input mpcirc;

\stopMPinclusions



\starttext
 

%\forceMPTEXgraphictrue %%% command don't work

\startMPcode
u:=10bp; % unit of length
prepare(L,C,Vac); % mention your elements
z0=(10u,10u); % lower right node
ht:=6u; % height of circuit
z1=z0+(0,ht); % upper right node
C=.5[z0,z1]; % location of capacitor
L.t=T.r; % use default orientation
C.t=Vac.t=T.u; % components rotated 90 degrees
% set the distance between Voltage and Capacitor
equally_spaced(5u,0) Vac, C;
L=z1-0.5(C-Vac); % location of spool
edraw; % draw components of the circuit
% draw wires connecting components
% the first ones rotated 90 degrees
wire.v(Vac.a,z0);
wire.v(Vac.b,L.a);
wire.v(L.b,z1);
wire(C.a,z0);
wire(C.b,z1);

\stopMPcode
 
\stoptext


I found this error message:

metapost        > error: 
(mpcirc.mp (ttex.mp) (circlib.mp
>> circlib.mp
>> circlib.mpx
! ! Unable to make mpx file.
l.39 def Eplus_ = btex
                      $+$etex enddef;
                      
                      
############ With Circuitikz #######

If i try use Circuitikz with this test code:

\usemodule[circuitikz]

\starttext
 
A simple example to test the installation.

\startcircuitikz[scale=1.2]
\draw 
  (0,2) to[I=1\milli\ampere] (2,2)
        to[R, l_=2\kilo\ohm, *-*] (0,0)
        to[R, l_=2\kilo\ohm] (2,0)
        to[V, v_=2\volt] (2,2)
        to[cspst, l=$t_0$] (4,2) -- (4,1.5)
        to [generic, i=$i_1$, v=$v_1$] (4,-.5) -- (4,-1.5)
  (0,2) -- (0,-1.5) to[V, v_=4\volt] (2,-1.5)
        to [R, l=1\kilo\ohm] (4,-1.5);
\stopcircuitikz
 
\stoptext 

The error message is:

 (/Applications/Context/tex/texmf-modules/tex/generic/circuitikz/pgfcircquadpoles.sty) (/Applications/Context/tex/texmf-modules/tex/generic/circuitikz/pgfcirclabel.sty) (/Applications/Context/tex/texmf-modules/tex/generic/circuitikz/pgfcircvoltage.sty) (/Applications/Context/tex/texmf-modules/tex/generic/circuitikz/pgfcirccurrent.sty))
! Missing \endcsname inserted.

system          > tex > error on line 16 in file /Applications/Context/tex/texmf-modules/tex/generic/circuitikz/t-circuitikz.tex: Missing \endcsname inserted ...

 6     \usepgflibrary[decorations.pathmorphing]
 7     \usetikzlibrary[calc]
 8     
 9     \unprotect
10     
11     \input circuitikz.code.tex
12     
13     % defaults
14     
15     \setupmodule[current=european, voltage=european,  resistor=american,  inductor=cute, logic=american, siunitx=true, arrowmos=false]
16 >>  
17     \processaction[\currentmoduleparameter{voltage}]
18        [    european=>\ctikzset{voltage=european},
19             american=>\ctikzset{voltage=american}
20        ]

#################