Multiple Interrupt-driven Serial Input

rodnet

New Member
Hello,

Please bear with me, this is my first posting here.
Also, I have not yet had any practical experience
with Picaxe, but am seriously interested in using
same in a project that I'm currently trying to work
up a design for.

I would like to ask about a particular issue in the
context of Interrupt-driven Serial Input.

I have in particular studied Hippy's website page:
http://www.hippy.freeserve.co.uk/picaxesi.htm
and also search the form for threads that reference
it and followed up other pointers in these.

I can see that it is feasible to have a 'ring' of Picaxes
each sending data to the next in the ring via a
uni-directional asynch serial connection between each
Picaxe and the immediate next Picaxe in the ring,
employing the Interrupt technique that Hippy describes.

Now for the question.
I would also like to have an additional Picaxe gathering
input data (*) that can communicate into one of the
Picaxes that are in the aforementioned ring.
This would seem to need the receiving Picaxe to be set
up with Interrupt handling for TWO different serial input
pins, one for input from the preceding Picaxe in the ring
plus one for input from the out-of-ring Picaxe.
Is this a workable construct?

I'm trying to think through what would happen if two
interrupts occur, one for each input pin, "at the same time"
or very close together in time.

The only postings that I can find that come near to touching
upon this matter are:
1.
http://www.picaxeforum.co.uk/showthread.php?t=10333
Diode Mixing circuit for multiple interrupts
This touches upon multiple inputs into one Picaxe but also speaks
of 'mixing' from several input pins thus presumably using only one interrupt
routine? What are the pros and cons of this technique?
2.
http://www.picaxeforum.co.uk/showthread.php?t=8268
which cites:
http://www.users.on.net/~alw1746/electronics/serin/SerialInterrupt.htm
a sample master/slave setup.

(*) - I'm thinking of having the out-of-ring Picaxe sitting waiting most of the
time on PS2-keyboard input and sending a data message to one of the in-ring
Pixaxes each time that data entry is made on the keyboard.

I have tried to focus on the specfic design query that I need help with rather
that general details about my project, but am happy to explain it further if
required.

Thanking you in anticipation.

Regards, Rodney
 

hippy

Technical Support
Staff member
This would seem to need the receiving Picaxe to be set up with Interrupt handling for TWO different serial input pins, one for input from the preceding Picaxe in the ring plus one for input from the out-of-ring Picaxe. Is this a workable construct?
There's the rub ... getting a PICAXE to do two things at once.

It is possible to do it by polling in a similar way to interrupts; the sender asks to send, the receiver checks if anyone is asking and grants the right to send and it can do this for one or more who wish to send to it. It in turn seeks permission to send to the next in the ring. A sender only sends when its recipient acknowledges it can.

The senders will not actually interrupt the one it wishes to talk to but as long as the receiver polls often enough that should not be a problem. Having the handshaking anyway is a good idea because there's no guarantee otherwise the receiver saw the interrupt and is ready to receive ( it could be sending to the next in the ring for example and not be interruptible ).

While this is a blocking system, as long as there are no deadlock states ( everyone wanting to communicate with someone and no one being granted the right to ) it should be 'self-clocking' and always sort itself out.

Unless it were a simple master plus multiple slave networking I think I would choose a ring-based design with this type of handshaking. It's a simple system and easy to visualise -

I'd think of it as a circular railway track with trains being messages trying to get into stations where they may be abducted by aliens and disappear, repainted a different colour and passed out towards the next station, and whole new trains may be placed on the line and sent out. Trains get into stations when they sound their horn and the signal turns green, or they must wait ( they can do something else until the light turns green ). Where two or more feeds come to a single station it's exactly the same, one of the feeds gets the green light while the rest must wait.

The beauty there is that it's easy to understand and predict what will happen next from every perspective using an analogy which most recognise. As soon as genuine interrupts are involved it all gets much more complicated; trains trying to get into stations while another has a green light, pile-ups as both reach a single set of points together, drivers not obeying red lights.

The simplest token-ring system is a single train which takes a message from A to B then once it has delivered its message to B raises its "for hire" flag and circles until someone has a message to deliver. A slightly more complicated system can have multiple trains all carrying messages or not which can improve throughput ( just as it does on a real circular transport system ). If getting stuck at signals is a bandwidth problem there's always an option to build tracks which skip one or more stations, so when busy the drive turns right tries that route and so on.

This may not exactly suit what you are hoping to achieve but the main thing to bear in mind is that simple is usually best when it comes to networks and getting them to work.
 
Last edited:

rodnet

New Member
Hippy,

I'm most obliged to you for your speedy and comprehensive response.

I am in the process of absorbing your suggestions and studying Picaxe
documentation and examples further, whereafter, in due course, I likely
will come back with further questions.

Thanks again for taking the time to reply to my posting.

Regards, Rodney
 
Top