I will give its a go later. I will try each piece on each sensor as both are TX and RX.
I have the sensors communicating correctly with each other, but there are power issues when I moved to developing the updates for the controller. the batteries are a little low (sensors where developed with a wall wart type PSU), but a single sensor and I can get a qualifier pass (but not reading variable for some reason), but with 2 sensors no joy. the voltage drop post regulator (about 0.1v drop), but not pre regulator. Its looking like I am going have to step up the development programme
I think it maybe helpful if I try and give a description of what the sensor code does.
The controller must send the contin line high so that the sensor know that a controller is connected - the sensor defaults if it unconnected.
if the contin line is low, it assumes it the second or greater sensor in the chain, and sets the flag to show that. Then listens for an address from the previous sensor, once received it sends an address on, and a qualifier to show present to the previous sensor
if the contin line is high, it is the first sensor in the chain, and sets the flag to 0 and sends an address to the next sensor
these 2 action are under a single if statement at the start of the programme
the programme then listens for the qualifier to come back from the next sensor, if nothing is heard it times out and assume its the last in the chain and sets the flag to 2
if the flag is 2 (the last sensor in the chain) its address is sent to the previous sensor,
the previous sensor is waiting for the signal, when its received it send it on until the first sensor receives it, where it will be held until the controller request the information.
this is done in the second if statement
as a result each sensor is identical until the addresses are established which means there is no order the attach them, they self address and could in theory make a chain of 256 sensors. this makes the code look more complex than it is as it contains the code for both "master" and "slave". In this system that is no true master and slave, just simply a chain that information is passed along and modified were needed. Due to the fact that there is three line. 2 for power and ground, and one for data means that information has to be passed in both directions meaning one has to ensure that each sensor sets its pins correctly at the any given time.
Code:
[color=Black]init:
[/color][color=Green]'debug
'###Sensor Startup Squence###
[/color][color=Blue]pause [/color][color=Navy]200 [/color][color=Green]'allow controller start up
[/color][color=Blue]let [/color][color=Purple]dirsc [/color][color=DarkCyan]= [/color][color=Navy]%000110
[/color][color=Blue]setfreq M16
let [/color][color=Black]qual [/color][color=DarkCyan]= [/color][color=Red]"U" [/color][color=Green]'set serin qualifier
[/color][color=Blue]let [/color][color=Black]address [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Green]'set defualt address
[/color][color=Blue]let [/color][color=Black]instruct [/color][color=DarkCyan]= [/color][color=Navy]$01 [/color][color=Green]'set defualt instruction - and on all sensors
[/color][color=Blue]if [/color][color=Black]contin [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Blue]then [/color][color=Green]'check for controller signal
'wait for address information from other sensors
'if controller signal is not recieved
[/color][color=Blue]let [/color][color=Black]flag [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Green]'set not first sensor flag
[/color][color=Blue]serin [PLAIN][[/PLAIN][/color][color=Navy]2000[/color][color=Black],start_laser[/color][color=Blue][PLAIN]][/PLAIN][/color][color=Black], sercon, baud, [/color][color=Blue]([/color][color=Black]qual[/color][color=Blue])[/color][color=Black],address
[/color][color=Green]'if no controller detected, presume standalone sensor and skip ahead
[/color][color=Blue]inc [/color][color=Black]address [/color][color=Green]'increment address from previous sensor
[/color][color=Blue]serout [/color][color=Black]sercas, baud, [/color][color=Blue]([/color][color=Black]qual[/color][color=Blue]) [/color][color=Green]'send out next address
[/color][color=Blue]pause [/color][color=Navy]4
[/color][color=Blue]serout [/color][color=Black]sercas, baud, [/color][color=Blue]([/color][color=Black]address[/color][color=Blue]) [/color][color=Green]'send out next address
[/color][color=Blue]let [/color][color=Purple]dirsc [/color][color=DarkCyan]= [/color][color=Navy]%010010
[/color][color=Blue]serout [/color][color=Black]sercon, baud, [/color][color=Blue]([/color][color=Black]qual[/color][color=Blue]) [/color][color=Green]'send qualifier to previous to show attatched
'debug
[/color][color=Blue]else [/color][color=Green]'other wise fist sensor, send address to next sensor
[/color][color=Blue]let [/color][color=Black]flag [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Green]'set first sensor flag
[/color][color=Blue]pause [/color][color=Navy]1000
[/color][color=Blue]serout [/color][color=Black]sercas, baud, [/color][color=Blue]([/color][color=Black]qual[/color][color=Blue])
pause [/color][color=Navy]4
[/color][color=Blue]serout [/color][color=Black]sercas, baud, [/color][color=Blue]([/color][color=Black]address[/color][color=Blue])
end if
let [/color][color=Purple]dirsc [/color][color=DarkCyan]= [/color][color=Navy]%010010
[/color][color=Blue]serin [PLAIN][[/PLAIN][/color][color=Navy]500[/color][color=Black],last_sens[/color][color=Blue][PLAIN]][/PLAIN][/color][color=Black], sercas, baud, [/color][color=Blue]([/color][color=Black]qual[/color][color=Blue])[/color]
[color=Black]last_sens_return:
[/color][color=Green]'debug
[/color][color=Blue]if [/color][color=Black]flag [/color][color=DarkCyan]= [/color][color=Navy]2 [/color][color=Blue]then [/color][color=Green]'flag 2 indicates last sensor
[/color][color=Blue]pause [/color][color=Navy]1000
[/color][color=Blue]serout [/color][color=Black]sercon, baud, [/color][color=Blue]([/color][color=Black]qual[/color][color=Blue])
pause [/color][color=Navy]4
[/color][color=Blue]serout [/color][color=Black]sercon, baud, [/color][color=Blue]([/color][color=Black]address[/color][color=Blue]) [/color][color=Green]'send address to previous sensor
[/color][color=Blue]low [/color][color=Black]cascout
[/color][color=Blue]else
serin [/color][color=Black]sercas, baud,[/color][color=Blue]([/color][color=Black]qual[/color][color=Blue])[/color][color=Black], number [/color][color=Green]'receive
[/color][color=Blue]if [/color][color=Black]flag [/color][color=DarkCyan]> [/color][color=Navy]0 [/color][color=Blue]then
serout [/color][color=Black]sercon, baud, [/color][color=Blue]([/color][color=Black]qual[/color][color=Blue])
pause [/color][color=Navy]4
[/color][color=Blue]serout [/color][color=Black]sercon, baud, [/color][color=Blue]([/color][color=Black]number[/color][color=Blue])
end if
[/color][color=Green]'debug
[/color][color=Blue]end if[/color]
this works for comms between 2 sensor, I haven't tried more as yet.