Tuesday 8 October 2013

Time to Propose a Protocol

At the moment I have a 3 wire serial system. 1 GND, one marked TX and one RX. I need to solidify this idea in text, write some code and test it in real hardware. If things don't go well the next option is to add another wire, which I still have space for if I stick to three peristaltic pumps. Which is no problem for this project. L293D's are under £2 each.

After a couple of days cogitating I have made a decision. I considered a variable length with the msb marking another byte like in UTF-8. However this is over complicated for this little job so I have decided on a fixed length scheme.

One possibility.

The minimum number size bound the amount of liquid in millilitres.
1111 1111 1111 1111 is 65535 which is 65.535 litres. This fits the bill for the 30 litres in the specification.
So the protocol, at the moment, is three bytes long
aaaa aaaP - action and parity bit
bbbb bbbb - lower bits of value
cccc cccc - upper bits of value

The next idea

I realised that it is unlikely that a pump will get a 1.01L instruction. They will usually get 10ml or 10L. However there may be the possibility that the controller has a small and large pump on the same L239D. So let's encode the magnitude in the action, I have plenty of those to go round and the amount can just be a single byte.
aaaa aaaP - action and parity bit
vvvv vvvv - value
This is the most satisfying to me. A message will then fit into a 16 bits.

The Protocol v0.1

ActionValueDescription
0000 00001010 1010All Off
0000 0001vvvv vvvvPump 1, v ml
0000 0010vvvv vvvvPump 2, v ml
0000 0100vvvv vvvvPump 3, v ml
0000 1000vvvv vvvvPump 4, v ml
0001 0000vvvv vvvvPump 1, v L
0010 0000vvvv vvvvPump 2, v L
0100 0000vvvv vvvvPump 3, v L
1000 0000vvvv vvvvPump 4, v L
1111 11111010 1010All on until further notice

The values in the All On and All Off are to make sure that a signal is being sent and not just some line noise.

No comments:

Post a Comment