Picaxe Slaves to Picaxe Masters

Starting to get to grips with these little things and my project is coming along quite well until now. The problem I have is that I have a lot more code than 600 lines - at lot lot more. I just have enough inputs and outputs using the 40x chip but no way for it to run my code.

So I have been toying around with a couple of ideas.

The first idea. Splitting of the task among four picaxe slaves and collect the data from them onto the 40x chip and display the results on a 4x20 LCD.

The questions I have are as follows. (I have read the manuals and forums - but the right thing arn't in my head quite yet.)

Can i define more than one input as a serial port - and access the individual picaxe slave by polling? - ie 40x Pins set 16 & 17 also 24 to 26 and read into W1, W2, W3, etc

Will I have to clear the old port before moving onto the next one?

Second idea is that i use memory to store the subroutines in. load them - get the result and display - wipe the memory and load the next one. (Not sure about the speed of that - application is real time sensor readings from several types of sensor.

I have the first two sensor units working (well sort of) and they are using 18x chips.

Oh just remembered that there is another module that outputs TTL serial so thats four inputs.

Sorry about that getting all excited
 

eclectic

Moderator
Very first simple idea.

Use a 40X1?
4096 : 2048 or 1000 lines : 600 lines.

About a fiver?

e
 
Last edited:

hippy

Ex-Staff (retired)
You can have multiple serial inputs into a PICAXE but you can only read from one at a time and you'd have to handle it so only the one being listened to was sending. Anything sent when you weren't listening for would be lost, while you're listening to one you cannot do anything else until it has sent its data.

The best way round to do this may be designate the LCD controller as the master then have it ask each PICAXE in turn if they have anything to send and, if they have, read it, move on to the next. This can get more complex than it sounds.

It sounds entirely possible to do what you want, but how a system is best split across multiple PICAXE's depends upon what the complete system is doing, what information needs to be passed around and processed, and how quickly it all needs to be done. What tasks can be stopped and then continued, which need to be running most of the time.
 
The LCD is the master .

When i said realtime I meant to say poll the each line every second.
So just to get this clear I can only listen to one channel at a time even if I give the lines a label and memory variable address?
 

MPep

Senior Member
An idea only, not implemented by me, but... Each slave has its own transmit line to the 40X, or whatever, & the master uses only 1 transmit line so that all slaves are listening to the same message.

In case you are wondering, each slave would have to be coded with an identity number, so that the correct slave would respond to a message such as "number3, sent data".

In fact I guess that all the slaves could also be paralleled together, and therefore only a single pair of comms lines would be used.

See how you go.
 

Jeremy Leach

Senior Member
I'd perhaps go for the 'keep things simple' approach, especially if you are new to Picaxes. So look at one of the bigger picaxes that can hold the code, and also look at your code and try to optimise it... there have been lots of examples on this forum where code examples have shrunk dramatically after people's suggestions !

If you really want to go into more complex solutions then another idea is to use external EEPROM memory to store 'code' and write a little 'interpreter' on the picaxe to read and execute this code. All very experimental and people have had goes at this. If you are doing very simple things then it's a possibility.
 
Thanks for the replies.
MP - thats about how i was looking at it, Perhaps they could all transmit at a given time. Use a clock to control. Oh dear Packets and timing issues then. A baby network!!

JL Whats bigger than a 40x1? I have seen ref to 40x2 but I cant find it on the shop site.
The one board i have made uses a 18x chip. The code is 546 lines long. I can reduce this quite a bit, but then i don't get what i want. I want my cake and i want to eat it, as they say.
You are right about coding. There is always someone who can write it neater and smaller.

I have just found a quad thermometer in David Lincoln's book Programming and customizing the Picaxe Microcontroller. This is one of the boards I have just made. . His code is about 230 lines - mines about 300. Shame i didnt find it before. Head and wall would be in better condition.

The point is that the sensors are serial output. Perhaps if i apply the same logic on the master unit and treat my 4 slaves in the same way. Ummmm I think i may have a plan. Anyone see why it would not work?
 

Dippy

Moderator
I'm pretty certain that it would take very little extra effort such that the Slave PICAXE Tx pins could share a single return line to Master Rx. This could be handy if slaves are at any distance just from the wiring point of view (which is unknown to me). Eg. transistors can be used to turn a driven output into an open drain or source.

There would be no data collision problems and , quite frankly, I can't see any timing issues when using the polling ("Oi! Number3 send me some data") method.
 
D - you are right as usual. A single line would be best.

I'm still not sure about the polling - Cant quite get my head around how to setup the chatline for the correct processor and it means a two way chat. If the are on single lines - oh they still need to chat dont they(!) to start transmitting. Could always place a start code so when the master hears the calling ID it places data into memory when it hears the end stop it goes onto the next line.
 

hippy

Ex-Staff (retired)
Whats bigger than a 40x1? I have seen ref to 40x2 but I cant find it on the shop site.
The 28X2 and 40X2 are planned products, not released yet.

I have just found a quad thermometer in David Lincoln's book Programming and customizing the Picaxe Microcontroller. This is one of the boards I have just made. His code is about 230 lines - mines about 300.
That seems to be awful lot of code in either case. I'm not familiar with David's book so I don't know; just seems very high to me. Maybe it's worth posting some details of what your hardware is and what you need to do and people here may be able to suggest ways to get that code down to a bare minimum but still doing all you require.
 

eclectic

Moderator
Clive.
re. your post #7 and Hippy's post #10.
I've looked at my copy of the David Lincoln book.
“Quad Thermometer”, p 290....

Now, have a look at the Picaxe Home page Links for
Peter Anderson.

http://www.phanderson.com/picaxe/ds18b20_08m.html

Three thermometers on 08M. (< 40 lines.)

With an 18X or above, and an AXE033, I'm sure that
four thermometer input and outputs to LCD and computer,
could be achieved in a lot less than 100 lines.

E
 

retepsnikrep

Senior Member
If you look at this thread and my BMS project you will see that's what i am doing with an opto isolated serial bus from many 08M slaves to one 28X1 Master. :)

The threads a bit rambling but the latest posts give my current code and ideas.

http://batteryvehiclesociety.org.uk/forums/viewtopic.php?t=1245

Basically my Master sends out a signal to the first Slave in a string of slaves and this either sends data on a parellel Master Data Bus or passes on the message to the next Slave and so on through the chain.

Each Slave is running the same code and they can be addresed individually without any hardware ID coding but it's not that fast.

Still all mainly untested. But pcb's are on the way from China ;)
 
Thanks for the responses. Enlightenment. As I said before theres always someone who can do smaller and better. Just wish once in a while it was me.

DS18B20 Code has been bined I will use a similar approach. The result is displayed on the lcd in a block of 4 chrs. Which sensor is the hotest glows. So the code will need a bit of voting logic but should be closer to 40 lines than 300!
 
Just finished to 18x slave circuit. Thought people might like to see it. I decided that the power can either be from an external supply or onboard regulation. I will most likes us a link for that. I will post the i/o card asap
 

Attachments

Top