Help getting Picaxe chips to 'talk' to each other.

Dracion

New Member
Hello,

I'm currently doing an electronic safe project at school which involves a PICAXE 08M and an 18X. My problem is that I need to be able to send 6 different 'messages' from my main 18X which runs the main program, to the 08M which plays the tune; and on the circuit Outputs 0 and 1 on the 18X are connected to inputs 3 and 4 on the 08M. I was recommended at school to use the serin and serout commands for sending messages, and so looked the command up in the manual. Problem is, I still have no idea how the code works, and my attempts at programming it in in the editor always return syntax error :/.

An example of my somewhat crappy code from the 08M is as follows (please don't laugh):

Code:
main:		'Listen for commands
	if pin2=1 then goto alarm
	if serin 4,T300_4,goto fail
	if serin 4,T600_4,goto congrats
	if serin 4,N300_4,goto badbeep
	if serin 4,N600_4,goto goodbeep
	if serin 4,N1200_4,goto normalbeep
	goto main
Can someone please point out what am I doing wrong, and if I using the right command(s)?

Many thanks, Dracion
 

Peter M

Senior Member
Please read Page 138 in picaxe manual_2

The serin command reads data in then stores it in a variable like b1.
Then you need to ask your question If b1=xxx then alarm
Code:
Command - pin No. - baud rate/mode - where its stored when read
    |         |            |                 |
  serin       4         ,T300_4             ,b1
The 18x needs to use the same baud rate/mode as the 08m so that they are both speaking the same language.

Hope this helps
 

Dracion

New Member
Ahh! I see where I was going wrong now, many thanks :)

One final question though, does it matter what baud rate I use?
 

eclectic

Moderator
Read the small print.

Dracion.
If you're using Serin on pin3 of an 08M, there are a few
important lines tucked away on page 140 of Basic Manual 2

Quote:

PICAXE-08/08M/14M - Due to the internal structure of input3 on these chips, a
1N4148 diode is required betwen the pin and V+ for serin to work on this
particular pin (‘bar’ end of diode to V+) with this circuit. All other pins have an
internal diode.

Your teacher should be able to advise on how to fit the diode,
if you need more help.

e.
 

hippy

Ex-Staff (retired)
Ideally choose an Nxxxx baud rate when interfacing to PC's or between PICAXE's. That greatly reduces initialisation and the possibility of corrupt data being seen by the receiver.

While reading the manual, take a look at the SELECT-CASE command. That should really help you out ...

- Do
--- SerIn pin,baud,b0
--- Select Case b0
----- Case 0 : ...
----- :
----- Case N : ...
--- End Select
- Loop
 
Top