Picaxe to picaxe communication

marzan

Senior Member
Hello everyone. I have 2 linear threaded shafts that need to move in unison (or close to) to 6 pre defined positions. what I was thinking of doing is have one Picaxe acting as the master that decides what position they need to go to by sending a serial command to a second picaxe controlling the other shaft. what I want to do is have the master send the command to the slave, and for the slave to send the command back so the master knows it was received. I want the master to wait until it receives the reply before moving. The bit I am trying to work out is if both picaxes can be alerted via serial input if either detects their particular shaft isn't moving.
In essence what I am asking is, can you have a serial port wait for a command and then after run in the background waiting for a possible fault message?
I am using a 20x2 as a master and possibly an 08m2 as a slave. to make it tougher I would rather not use wires, although I realise that would create a whole set of new problems. Failing that, as few wires as possible.

Thanks in advance.

Marz
 

hippy

Technical Support
Staff member
You can use HSERIN to receive data in the background while doing something else.
 

StefanST

New Member
... what I want to do is have the master send the command to the slave, and for the slave to send the command back so the master knows it was received. ...
See https://en.wikipedia.org/wiki/Handshaking

... The bit I am trying to work out is if both picaxes can be alerted via serial input if either detects their particular shaft isn't moving. ...
* It is not good idea to wait for message about slave's problems. If the communication slave to master fails somewhere (and the master will not receive any message), the master will not know about the problems with slave's shaft.

* I think, when you need to watch the slave's shaft, you shoult continually communicate with slave and ask slave whether shaft is moving or not. Or compare slave's shaft position with the master's one.

* A more detailed example of simple communication between two processors:
- No1 will send a message to No2.
- No2 will receive the message and send it back to No1.
- No1 will receive a message. If both messages are identical, then No1 considers this message as transferred.
- If not, communication can be repeated. After the timeout has expired, the communication is considered as failed.
 
Last edited:

rq3

Senior Member
Hello everyone. I have 2 linear threaded shafts that need to move in unison (or close to) to 6 pre defined positions. what I was thinking of doing is have one Picaxe acting as the master that decides what position they need to go to by sending a serial command to a second picaxe controlling the other shaft. what I want to do is have the master send the command to the slave, and for the slave to send the command back so the master knows it was received. I want the master to wait until it receives the reply before moving. The bit I am trying to work out is if both picaxes can be alerted via serial input if either detects their particular shaft isn't moving.
In essence what I am asking is, can you have a serial port wait for a command and then after run in the background waiting for a possible fault message?
I am using a 20x2 as a master and possibly an 08m2 as a slave. to make it tougher I would rather not use wires, although I realise that would create a whole set of new problems. Failing that, as few wires as possible.

Thanks in advance.

Marz
Do they "need to move in unison", or do you need to shift the phase between them? If they need to move in unison, why not gear them together?
 

hippy

Technical Support
Staff member
You might be able to simplify and improve things by having two slaves, one for each actuator. Have the master tell the slaves where to move to, then it only has to check they are both moving, if not, stop both.
 

darb1972

Senior Member
And don't add any wireless comms until you know the prototype (in whatever form that might take) works without issue. Speaking from experience, ALWAYS get your design working via a cable/physical solution first (where possible).

I like the idea of two small slaves with one larger master.
 

marzan

Senior Member
Sorry folks. New job is taking far too much of my time :( I have however done the mechanical side of things:20645709_2022409577784612_577509894_n.jpg20646027_2022409551117948_2071063610_n.jpg
@hippy I do like the idea of a master and 2 slaves. makes sense.
@Stephanst I like the idea of comparing the shaft position values.

It is a complicated device if I dont want to connect them both mechanically. Still trying to decide which way to go. Thanks for all the suggestions.
Marz.
 

marzan

Senior Member
I had some time today to write some basic code to get it moving. I am using older 20M chips as I have quite a few of them.
Code:
symbol motoron = b.0    	;start motor
symbol up = b.1   		;activate relay when going up
symbol hcheck = w5		;adc value of 10 turn pot
symbol hval = w6  		;remote triggered value
symbol come_up = w4




Main:
      let b1 = pinsc & %01111110                ;input trigger value masking ADC value and c.0
		select case b1
			case 0 goto main  	      ; wait for trigger from remote
			case 2 hval = 591   		;POT values for different heights
			case 4 hval = 441`  		;"    				"
			case 8 hval = 288   		;"    				"
			case 16 hval = 134        	;"    				" 
			case 32 hval = 892  		;"    				"
			case 64 hval = 747  		;"    				"
		endselect
	readADC10 7,hcheck				; read POT value to dtermine either up or down
	      if hcheck < 100 then fault_height   ;check power to POT
		if hcheck > 950 then fault_height   ;check POT earth
		if hcheck < hval then go_up   	;go to move up or continue on to move down
	come_up = hval - 13     			;to eliminate backlash always go past mark and then
								;come back up    
	high motoron					
		do
			readADC10 7,hcheck
		loop until hcheck <= come_up  	; go low to reversing point
	low motoron
	pause 150   					;let motor stop before reversing
	goto go_up    
go_up:
	high up
	pause 50
	high motoron
		do
			readADC10 7,hcheck		;go high to position
		loop until hcheck >= hval
	low up
	low motoron
	goto main   					; go back and wait for new trigger

fault_height:
		do
			toggle b.5
			pause 500
		loop
		
up_led:
	for b6 = 1 to 10
		toggle b.5
		pause 250
	next
	low b.5
	goto main
	
down_led:
	for b6 = 1 to 10
		toggle b.5
		wait 1
	next
		low b.5
	goto main
can anyone see any improvements I could make?
Thanks.
Marz
 
Last edited:

BESQUEUT

Senior Member
Hello everyone. I have 2 linear threaded shafts that need to move in unison (or close to) to 6 pre defined positions. what I was thinking of doing is have one Picaxe acting as the master that decides what position they need to go to by sending a serial command to a second picaxe controlling the other shaft. what I want to do is have the master send the command to the slave, and for the slave to send the command back so the master knows it was received. I want the master to wait until it receives the reply before moving. The bit I am trying to work out is if both picaxes can be alerted via serial input if either detects their particular shaft isn't moving.
In essence what I am asking is, can you have a serial port wait for a command and then after run in the background waiting for a possible fault message?
I am using a 20x2 as a master and possibly an 08m2 as a slave. to make it tougher I would rather not use wires, although I realise that would create a whole set of new problems. Failing that, as few wires as possible.

Thanks in advance.

Marz
If you only need 6 pre defined positions, no need for serial communication.
Simply use 3 wires for parallele communication IE 8 possibles states.
The 8m2 Picaxe only have to read 3 IN pins and set position accordlngly...
 

marzan

Senior Member
If you only need 6 pre defined positions, no need for serial communication.
Simply use 3 wires for parallele communication IE 8 possibles states.
The 8m2 Picaxe only have to read 3 IN pins and set position accordlngly...
the problem that I face is that dogs and wires don`t mix ;) I am trying to figure out if it is worth the extra trouble to have some sort of wireless of infrared communication, or weather I need to redesign the tyre jump to accomodate wires or a mechanical linkage. the question is how do I do that and still have the jump within the specifications.
Marz
 

BESQUEUT

Senior Member
I would rather not use wires, although I realise that would create a whole set of new problems.
For sure, no wire = whole set of new problems...
If wires are possibles, IHMO use them.
If 2 wires are possibles for unidirectional serial communication, I suppose 4 are also possibles for // communication...
and far simplers programs...
 

hippy

Technical Support
Staff member
Most of the dog tyre jumps I looked at on Google Images seem to have a separating bar at the base to hold the legs a fixed distance apart, and presumably to give stability, rigidity and to stop the lifting legs from rotating. You could run your wires through that if you have one. Or even use a hollow separating bar to pass IR through.

I would be tempted to go for IR. If it's not a real rubber tyre then you could possibly create a fibre optic cable path from one side to the other.
 

marzan

Senior Member
Fibre optic!! Now its getting interesting!! The hard part of going through the bar at the bottom is getting it past the mechanical bit that is under the electronic bit. I did think of putting the electronics under the mechanics, but then I would still have to get the antennae past the mechanism. Maybe the best solution is just to build two autonomous units and test the jump to see if that causes any issues. I just know in the past occasionally one of the sides on the normal jumps doesn't receive a signal and causes the bar to not be set correctly.
I do appreciate all the suggestions though. It gives me a few more options to ponder
Marz.
 
Last edited:

BESQUEUT

Senior Member
Maybe the best solution is just to build two autonomous units and test the jump to see if that causes any issues.
1) Do you also have two separate power supply ? If not, you already have 2 wires between poles, so 3 more is not a big deal...

2) What will you do if test fail ?

3) Will there be only 2 poles, or maybe few on the same site ?

4) Looking at #10, it appear that position is only defined by a 10 turns pot. So Why not using only one Picaxe and 3 wires between poles : ground and V+ for the motor and one for the ADC in ?
==> no communication problems between Picaxes...
 
Last edited:

marzan

Senior Member
@ Besquet I have made other ordinary jumps that are independent poles. The trouble with the tyre jump is it uses 2 poles and a fairly solid doughnut in the middle. On the normal jumps it dosen`t matter if for some reason they don't move. The tyre jump is a lot more solid and could be badly damaged if one side moves without the other.
I am waiting for my circuit boards to arrive. When they do I will do a bit more work on the tyre jump and post some pictures to show what it actually looks like.
Marz.
 
Top