New to serial

wardbob

Member
I have never done any programming of serial communication between Picaxes or anything else, for that matter. There is a lot of info around but it is not organized, so I'm not sure where to start. I've looked around for a beginner tutorial to serial coms on Picaxe with a number of well-explained examples, but haven't found that. The posts in the forum seem to be by people who know a bit about what they are doing already.

Here's the outline of a project I want to build. I will have a main program on a 14M2 talking to upwards of ten or more 08m2 Picaxes spaced up to several feet away from each other. Each of those, ID numbered 1 to 10 in their program, will be able to control several things such as an LED, a motor, a servo, music, AC lighting through a Solid State Relay, etc.

(This is for a proposed Christmas display for next year involving various lights and moving characters and objects all sequenced/choreographed by the 14M2 or modified by observers pushing interactive buttons. Dozens of things might be running at any time.)

Let's say I want to tell 08M2 chip #6 to turn on an LED. I want to send a signal to all ten chips that would contain the chip ID number 6 and another number to tell the appropriate chip which function it should control at that time. The others, of course, would ignore the instruction. Then, at a later time, I want to tell chip #9 to turn its motor off. Then chip #3 to play a tune. Etc, etc. This way I can control numerous devices with minimal wiring from the 14m2 to each 08M2.

First, I imagine this can be done? Second, what serin, serout, or other statements do I need to make it happen? I can't imagine it to be too complicated since the 14M2 will just keep sending different pairs of numbers the exact same way for each action. All I need are those few serial code lines to get me going. Third, are there any input or output pins to be avoided?

Finally, will interrupts from the buttons (to the 14M2) interfere with the serial coms?

This year's small, simple display is up and running, but needs some tuning up in terms of what is on at what time. I might even be able to rewire it if I can figure out how to run it by serial. I will get a video up soon on this thread.

Thanks for any help you can give me.

wardbob
 

Kecked

Member
I have never done any programming of serial communication between Picaxes or anything else, for that matter. There is a lot of info around but it is not organized, so I'm not sure where to start. I've looked around for a beginner tutorial to serial coms on Picaxe with a number of well-explained examples, but haven't found that. The posts in the forum seem to be by people who know a bit about what they are doing already.

Here's the outline of a project I want to build. I will have a main program on a 14M2 talking to upwards of ten or more 08m2 Picaxes spaced up to several feet away from each other. Each of those, ID numbered 1 to 10 in their program, will be able to control several things such as an LED, a motor, a servo, music, AC lighting through a Solid State Relay, etc.

(This is for a proposed Christmas display for next year involving various lights and moving characters and objects all sequenced/choreographed by the 14M2 or modified by observers pushing interactive buttons. Dozens of things might be running at any time.)

Let's say I want to tell 08M2 chip #6 to turn on an LED. I want to send a signal to all ten chips that would contain the chip ID number 6 and another number to tell the appropriate chip which function it should control at that time. The others, of course, would ignore the instruction. Then, at a later time, I want to tell chip #9 to turn its motor off. Then chip #3 to play a tune. Etc, etc. This way I can control numerous devices with minimal wiring from the 14m2 to each 08M2.

First, I imagine this can be done? Second, what serin, serout, or other statements do I need to make it happen? I can't imagine it to be too complicated since the 14M2 will just keep sending different pairs of numbers the exact same way for each action. All I need are those few serial code lines to get me going. Third, are there any input or output pins to be avoided?

Finally, will interrupts from the buttons (to the 14M2) interfere with the serial coms?

This year's small, simple display is up and running, but needs some tuning up in terms of what is on at what time. I might even be able to rewire it if I can figure out how to run it by serial. I will get a video up soon on this thread.

Thanks for any help you can give me.

wardbob
Lookup DMX. There is zero reason to build that stuff. Buy it off the shelf. Why reinvent the wheel.
 

tony_g

Senior Member
Lookup DMX. There is zero reason to build that stuff. Buy it off the shelf. Why reinvent the wheel.
but isnt that half of the reason why we do these things with the picaxe or other microcontrollers, the learning curve, the experience gained and the satisfaction when it is finished and works as we intended it to.
 

wardbob

Member
Lookup DMX. There is zero reason to build that stuff. Buy it off the shelf. Why reinvent the wheel.
Thank you tony_g for beating me to it.

Kecked, why run a marathon when you could drive 26 miles in a car? Why climb a mountain when someone could drop you off with a helicopter? Why spend months crafting a piece of furniture when you could just buy it at a store? Why use Picaxes to do anything when you could just hire someone to do it for you?

Yours is one of the stranger replies I have seen on this forum.

I looked up DMX and the best I could find was this: http://www.youtube.com/watch?v=AXca4WcCzlo
 

hippy

Technical Support
Staff member
What's needed sounds fairly simple, say an ID to say who's to do what, a command to say what to do, and maybe an argument to say how to do that what, Turn LED on for destination with ID 6 ...

Code:
b0 = 6 ' ID
b1 = 2 ' Command : Set LED
b2 = 1 ' Action : 0=Off,1=On
SerOut pin, baud, ( "DO", b0, b1, b2 )
The receiver can be something like ..

Code:
Do
  Do
    SerIn pin, baud, ( "DO" ), b0, b1, b2
  Loop Until b0 = 6
  Select Case b1
    Case 2 : Select Case b2
               Case 0 : Low  led
               Case 1 : High led
             End Select
  End Select
Loop
 

wardbob

Member
Hippy and eclectic, thanks for some great info. I didn't find either in my search, so I'll have to search better next time.

w
 

Paix

Senior Member
With communication from one master to a number of slaves, RS485 transceiver chips might be considered to allow reliable serial connection between a large number of PICAXE systems.

In it's simplest form the transmit output from the master connects to DI and the DE and -RE pins held high with a pull up resistor ( 10k ). This would enable the transmitter in the RS485 transceiver and disable the receiver

On slaves the serial input data connects the RO pin and the DI and -RE pins would be connected to 0V to disable the RS485 transmitter and disable the receivers. The two wire bus would be connected to A and B pins on each chip. Job done and good for at least 1km at pretty modest data rates of at least 9600 Baud on Cat5 UTP cable.

The Master transceiver chip could both transmit and receive at the same time by enabling the transmit ( DI high) and the reciever (-RO low) and the data would be put onto the bus by the transmitter and taken back off by the receiver in the same chip. Simples . . . :)

A 100 ohm resistor is required to terminate the bus correctly, to stop ringing/reflections in the cable. As standard 32 nodes can be connected to the bus, although devices are available to increase this number from the original specification to 64, 127 or even 256 nodes. 32 and 64 node capable chips are made by more than 20 manufacturers and each manufacturer probably has four different variants on their books. Each trying to make their product the one that will be chosen by manufacturers, on either price or features.

Keep it simple and buy the cheapest, probably at around 84p to £1.20 depending upon where you look. They are used heavily in industry.
rs485.png
http://www.lammertbies.nl/comm/info/RS-485.html
RS components online £0.44 each in a packet of 10 soic package.

http://uk.rs-online.com/web/c/semiconductors/interface-ics/line-transceivers/?searchTerm=rs485&sort-by=P_breakPrice1&sort-order=asc&view-type=List&sort-option=Price
 

wardbob

Member
RS485 transceiver chips might be considered to allow reliable serial connection between a large number of PICAXE systems.
Thanks. That looks like a very strong and easy solution. Probably too good for my simple app, where I can afford occasional glitches, but something to keep for the future.
 

Paix

Senior Member
People do split RS232 connections to things like two printers and it works very well, despite it being "far from being recommended". Unfortunately trying to stretch that philosophy to anything more than two receivers begins to require a bit more thought. The beauty of the RS485 solution is that each transceiver chip sits at each PICAXE node and drives and accepts the TTL serial signals. So it can most probably be retrofitted.

I look forward to your video so that we can get a fuller idea of what you are planning.
 
Top