DANSE is now open-source

Since we no longer use it for teaching here, there seems no reason not to open-source the network simulator DANSE.  So I’ve just done this: it’s now available here:


It’s not in a very friendly format; I’ll wait to see if anyone is interested before investing any more time in this.

(I’m still rather busy with the JavaScript version of the analogue simulator, which is coming along… latest version for review can be found here: https://www-users.york.ac.uk/~dajp1/Temp/dasim.html.)

Posted in Uncategorized | Comments Off on DANSE is now open-source

The site is not dead…

I know it’s been almost two years since my last post… but the site is still active, I am still updating things, and I do have hopes for it in the future.  This is just a quick note to let anyone interested know what’s going on.

While this site isn’t dead, Silverlight is.  This is a huge pity for me, since I have a lot of demos that I found really useful written in it.  I live in hope that someone will produce a good, easy-to-use Silverlight -> Javascript/svg translator, up until now I haven’t found one (despite some really promising-looking work at http://fayde.io/).

What I have been doing is learning Javascript.  It’s a rather strange language, and it’s taking me some time to get my head around it.  However, the first result of my dabblings is now available for testing.

It’s a translation (and expansion) of the analogue simulator; the Silverlight application that I used the most.  You can find the current pre-release version here:


Comments and ideas very welcome (although due to the ridiculous number of spambots out there I’ll have to ask people to email me with the comments.)

Posted in Uncategorized | Comments Off on The site is not dead…

Spam, spam, spam….

For some reason the amount of spam comments getting through onto this site has dramatically increased recently.  Annoying.  I’ve had to respond by shutting down comments on most pages… sorry about this – but you can always email / tweet me to get in touch.

If I could find a spam filter that would automatically delete anything which has a question mark in the middle of a word that would get rid of most of the problem… amazing how often spammers put question marks in curious places.  Or perhaps they are using some accented characters which I can’t display to avoid detection as spam… but I don’t know of anything that detects this either.  If anyone knows of such a thing, please get in touch.

Posted in Uncategorized | Comments Off on Spam, spam, spam….

Debugging the analogue simulator and quiz app news

After all this time – someone reported a bug in the analogue simulator, and it’s a stupid one.  Connect two terminals of a potentiometer together, and the simulator can’t cope, it gets the currents entirely wrong.  Fixed now, but I do wonder why it’s taken so long for someone to find and report it.

What else is new?  Well, I’ve finished importing the analogue and digital simulation engines into the circuit theory / quiz application, so it is now possible to set students a problem like “design an amplifier with a gain of 3 using only the components shown”, leave them to wire them up, and then test whether whatever they produce does have the right gain.  On the digital side, I can give them a random truth table, and ask them to wire up some gates to implement it.  Should result in some rather harder, but more engaging, problems.  Perhaps I might need to implement a level four?

The paper about this quiz app is currently with the referees for REES 2015 conference in Dublin.  I’ve got my fingers crossed; with more publicity I might get more people interested in using it.  We teachers don’t get as much chance to travel as the researchers, a trip would be nice; and I’ve never been to Ireland.

Posted in Uncategorized | Comments Off on Debugging the analogue simulator and quiz app news

DANSE has been cited!

This is quite exciting.  I’ve just heard (thanks to ResearchGate) that “An Introduction to DANSE” has been cited!  Ivan Minakov and Roberto Passerone have discussed it in their paper “PASES: An energy-aware design space exploration framework for wireless sensor networks”.  They do a review of other energy-aware simulators out there, and mention DANSE as a particularly user-friendly simulator.  Thanks guys!

Just one point about their paper: it is possible to extend DANSE by adding new protocols.  In fact the way we use it here it students are required to design and implement their own protocols to pass the module.

It is true that you need the full source code to add protocols, and this isn’t on the web-site for free download yet, you have to contact me and ask.  (Complicated reasons to do with the licensing and students confidentiality which I really must get sorted out.)

But it’s nice to know that someone else has noticed it, and if anyone sees this paper and comes across this blog post, they might want to evaluate it, and we can extend the DANSEing family.

Posted in Uncategorized | Comments Off on DANSE has been cited!

Circuit Theory app now complete?

I think I’ve got all the types of questions I want to have into the circuit theory app now, and sorted out what problems I know of in the calculator. It would be really helpful if a few people could test this before it goes live to the students in October.

Try it out at http://demos.gswce.net/CircuitTheory/CircuitTheoryTestPage.html.

Comments most welcome…

Posted in Uncategorized | Comments Off on Circuit Theory app now complete?

Introducting something that isn’t MathPad

OK… so I’ve been working on this new thing. I was going to call it “MathPad” until I googled it and realised that there was already a MathPad. However, the names of solutions in Visual Studio are really hard to change, so it’ll have to stay MathPad to me for now, even though to the external world it’ll have to be called something else. You can have a go at it here: New Math Thing Demo. At first sight it might look a little boring, since it’s just a blank white screen (apart from the logo, of course).

However, if you double-click somewhere, a textbox will appear. Try typing “3^2-3” into the textbox and pressing return. Open another textbox, and try “x^2-3 = 4”. Open a third and try “y = x^2 – 3”. Double-clicking on a textbox closes it.

This was written to help me make videos – I wanted something that could do maths quickly with the minimum of fuss, so I could get on with explaining the electronics.

It uses the same core as the maths solver in the theory quiz demo, although I’ve had to make a few changes in that. I hope I haven’t broken anything…

Posted in Uncategorized | Comments Off on Introducting something that isn’t MathPad

Almost end of spring break

Just a check of things in progress and things coming up.

1) The circuit theory test app is almost complete now… although I’d like to add a few more questions (one set about how to read oscilloscopes, and another about Thevenin equivalent circuits), however it’s comparatively easy to add new sets of questions. Submitting the responses automatically has hit a brick wall: you can’t send email from Silverlight client apps (not surprising really, it would be heaven for spammers) and I can’t use any server-side techniques since I’m hosting this on an Apache server. So the score (along with a few other details) is all wrapped up into a encrypted string, and people will have to copy this into an email and send it to me. (The fact that .NET has a crypto library built in was very useful.) Might be something for a student project at some stage: automating this, with a web-page which keeps the high-scores, or something?

2) The digital circuit simulator has a problem: wires would sometimes get confused about which way round they were (in the digital simulator (unlike the analogue simulator) wires have a direction: from the output to the input). So I thought – how hard could it be to detect this was happening, and then automatically change the direction of all the wires so the run from the outputs to the inputs? Shouldn’t take more than an hour or two, I thought? How wrong can you be… it took days. I still can’t quite believe how it took that long… I guess I must have missed a simple algorithm and done it a really complex way. Anyway it’s done now, so that should make the simulator even easier to use.

3) I’m starting to write a series of “Short Introductions To…” for my new first-year module in basic electronics for those without a strong maths/physics background. This is proving interesting, so I’ll start to put them up here for comments and feedback from anyone who happens across them. I know I’m cutting corners a bit in some of them, and leaving some things out in the effort to make them accessible; I just hope I’m not going too far. They’re designed to be simpler than just about any textbook I’ve come across (which is the whole point of writing them really), they’re for a course that leads to a technician qualification, rather than a full design engineering career. I’ll add these to the reorganized “Chapters” section of the web-site as I finish them. I’m planning on one a week from now until October; that way I’ll have enough to hopefully replace all of the lectures on the new module, and try out a “flipped classroom” model.

That’s it for now… I’ll just go and reorganise the Chapters section…

Posted in Uncategorized | Comments Off on Almost end of spring break

Updating Digital One

Just in case anyone notices – I’ve just released a new version of the digital simulator. This one attempts to automatically fix wires that appear to be connected the wrong way round (in this simulator wires have a direction, and go from outputs to inputs, and get unhappy if they are connected the wrong way round). That really shouldn’t have been hard to do, but it took days… anyway, it’s done now.

There are a few other minor changes as well, but nothing that should affect the operation. If anyone notices it doing anything odd, please let me know.

Posted in Uncategorized | Comments Off on Updating Digital One

printf in C#

I’ve been wondering about making DANSE open-source for a while now (after all if anyone else wants to start using it seriously they will need the source code), but up until recently (well, yesterday) I’ve had a problem: DANSE uses a version of printf written in C# by Richard Prinz which is only available under the Code Project Open License, and this does not allow me to release the code under any other license. I can’t use the CPOL since there is other code also in DANSE released under the GPL.

I can’t use the built-in printf since I want to target Silverlight as well, and I can’t just use the C# print routines since the students taking the module where this software is used haven’t learned C#, all they know is C.

So I figured… how hard can it be to write my own version of printf? Perhaps not implementing all the features, but at least being good enough for my purposes here?

Turns out it’s not that hard, only took a couple of hours. Not very well tested yet, but if anyone else would like to give the following a spin and let me know how they get on, I’d be very interested.

internal enum eTStype { _int, _float, _exponential, _string, _char, _pointer, _hex, _octal, _gtype, _error }
internal class TS
internal int start; internal int end; internal int width; internal int precision; internal eTStype type;
internal TS(int A, int B, int C, int D, eTStype what)
{ start = A; end = B; width = C; precision = D; type = what; }

internal static string sprintf(string format, params Object[] parameters)
// Starts from a copy of the string format, then replaces the type specifiers.
string result = String.Copy(format);

// Keep a list of the type-specifiers as I go through...
List myTS = new List();

// The first type specifier will start with a % which is not preceeded by
// an escape character '\', include an option precision field (".X")
// and then a length and specifier, both of which are ignored to be
// friendly. The specifier is assumed to end at the first occurrance
// of any one of the following specifiers: i, d, u, o, x, X, f, F, e, E,
// g, G, c, s, or p. (C# knows what these variables are.)

// Go through the format string, counting how many type specifiers there
// are, and making a note of what they are:
for (int loop = 0; loop < format.Length; loop++) { if (format[loop] == '%' && (loop == 0 || format[loop - 1] != '\\')) { // Found the start of a format string. int startTS = loop; int precision = 0; int width = 0; Boolean precisionValid = false; eTStype what = eTStype._error; // Now I need to find the end of it and work out what it is: while (loop < format.Length && what == eTStype._error) { char c = format[loop]; if (c == '.') precisionValid = true; if (c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9') { string TryThis = format[loop].ToString(); int whatIsThis = 0; int.TryParse(TryThis, out whatIsThis); if (precisionValid == true) precision = precision * 10 + whatIsThis; else width = width * 10 + whatIsThis; } if (c == 'i' || c == 'd' || c == 'u') what = eTStype._int; else if (c == 'o') what = eTStype._octal; else if (c == 'x' || c == 'X') what = eTStype._hex; else if (c == 'f' || c == 'F') what = eTStype._float; else if (c == 'e' || c == 'E') what = eTStype._exponential; else if (c == 'g' || c == 'G') what = eTStype._gtype; else if (c == 'c') what = eTStype._char; else if (c == 's') what = eTStype._string; else if (c == 'p') what = eTStype._pointer; loop++; } if (what != eTStype._error) { // Must have found the end of a format string, so add this to the list: if (precisionValid == false) precision = -1; TS ts = new TS(startTS, loop, width, precision, what); myTS.Add(ts); } } } // Right - now just go through and make a new string from the // non-type specifier parts of the format string, and the // replacements for the type-specifiers from the parameters list: StringBuilder sb = new StringBuilder(format.Length + 20 * myTS.Count); int lastFinishes = 0; for (int loop = 0; loop < myTS.Count; loop++) { int includeUpToHere = myTS[loop].start; sb.Append(format.Substring(lastFinishes, includeUpToHere - lastFinishes)); if (parameters.Length > loop) sb.Append(makeString(myTS[loop], parameters[loop]));
else sb.Append(" ERROR - Insufficient Parameters ");
lastFinishes = myTS[loop].end;
// Then add on the bit after all type specifiers:
sb.Append(format.Substring(lastFinishes, format.Length - lastFinishes));

return sb.ToString();
static private string makeString(TS ts, Object parameter)
if (ts.type == eTStype._error) return "*Error: Unrecognised type specifier*";

// For pointers, characters and strings all that's required is:
string q = parameter.ToString();

// Then if this is an integer, there are some special cases to include the
// precision, and deal with hex and octal numbers:
if (ts.type == eTStype._int)
long d;
if (long.TryParse(q, out d))
int prec = ts.precision;
if (ts.type == eTStype._hex)
q = d.ToString("X" + ((prec < 0) ? "" : ts.precision.ToString())); } else if (ts.type == eTStype._octal) { // Precision not implemented for octal yet. Does anyone care? string qq = Convert.ToString(d, 8); } else { q = d.ToString("D" + ((prec < 0) ? "" : ts.precision.ToString())); } } else { q = "*Error: Unrecognised type specifier*"; } } if (ts.type == eTStype._exponential || ts.type == eTStype._float || ts.type == eTStype._gtype) { char s = ts.type == eTStype._exponential ? 'e' : ts.type == eTStype._float ? 'f' : 'g'; double d; int prec = ts.precision; if (double.TryParse(q, out d)) q = d.ToString(s + ((prec < 0) ? "" : ts.precision.ToString())); else q = "*Error: Unrecognised type specifier*"; } // Then pad (or truncate) to fit the width required: if (ts.width > 0)
while (q.Length < ts.width) q = " " + q; if (q.Length > ts.width) return q.Substring(0, ts.width);
return q;
return q;

Posted in Uncategorized | Comments Off on printf in C#