Serial communication

Lliam20789

New Member
I have recently been experimenting with the SFR005, which works great! anyway, i designed and built a circuit that contains an 08-M which outputs the distance from pin0 as serout N2400. When I use another 08-M I have found that the variables read from serin are random and not accurate at all. Both circuits shared the same power supply and the SRF005 circuit i made runs fine alone...
What could be the problem?

 
 

Lliam20789

New Member
Yes I can but unfortunately not now, sorry. I'm using a mac now. When I get to school on Thursday I will copy it. Basicly is the the simple SRF program,
and a serin loop.
for memory...
*****************************************************
symbol trig = 1 ‘ Define output pin for Trigger pulse
symbol range = w1 ‘ Define range

main:
pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)
pulsin trig,1,range ‘ measures the range in 10uS steps
‘ now convert range to cm (divide by
5.8) or inches (divide by 14.8)
‘ as picaxe cannot use 5.8, multiply by
10 then divide by 62 instead
let range = range * 10 / 58 ‘ multiply by 10 then divide by
58
debug range
serout 0,N2400,(w1)
pasue 50
goto main

***** Then a simple serin loop: *****

main:
serin 1,N2400,w1
debug w1
pause 50
goto main

**** From memory thats about it...

 
 

manuka

Senior Member
Great recall! Suspect you may have a word/byte problem - recall w1 made up of b0 & b1 etc. Perhaps try doing away with that DEBUG too as it's a known "slow me down " & considered almost redundant beside the superior SERTXD. Also keep in mind random Picaxe values usually relate to floating Pins. Even consider data rate slow downs to 300bps too.

Picaxe serial datacomms is usually very robust- we've managed links even using wet string & a ground return. Stan

Edited by - manuka on 24/04/2007 02:49:25
 

hippy

Ex-Staff (retired)
There probably is a word/byte problem as manuka suggests. SERIN, SEROUT and SERTXD can only deal with bytes; try to send a word value and it will send the lower 8-bits but the top 8-bits are simply discarded.

To send w0 from one to another, send it as its two component byte variables ...

SEROUT 0,N2400,(b1,b0)
SERIN 1,N2400,b1,b0
 

manuka

Senior Member
Wet string- peanuts! Our best serial data party trick involved a whole line of young kids holding hands (with a suitable adult "connector" at each end) thru' which a SEROUT easily passed. Picaxe serial port impedances are super high as you no doubt know, so a few 10's of Meg Ohms with clammy hands is trivial.

Have just in fact watched a Mythbusters TV show where they tried to replicate Ben Franklins famous kite flying thunderstrom trick. Using twine typical of that era, a 400kV strike readily passed down the damp string to zap their modelled "Ben"s heart with a fatal ~10mA.

Hence string R = V/I = ~ 400kV/.01A =~ 40M Ohms & that included air gap R at the key end too.
 
I see a debug there... which will be throwing out weird data on pin 0.

B.T.W. you can Tx and Rx whole words quite well between 08M's using #w0 followed by a text formatter like a space, comma, LFCR etc.

- Andrew
 

demonicpicaxeguy

Senior Member
string, young kids holding hand for a serial link...try this one

get a magnet and hook it up to your serial out pin then have a piece of wire coming off the serial in on your recieving chip and hold it 2 to 3 cm from the magnet

i've seen it used once in an experimental keyboard at the st george bank for a vandal proof atm

ironically three weeks after it was installed someone attempted to raid it and failed hence vandal proof so they came back a week later with a tilt tray truck reversed into it winched it onto the tray and stole it.
 
Here is the original Wet String communications test bed... Note the original PICAXE “Bed of Nails” Boards. This was quite a rustic system and had the advantage of being large, easy to use and easy on the eyes after a day of close focus work.

The LDR top left is being read and sent as serial data to control the pitch of the sound on the speaker bottom light via two damp cotton threads.
[link]http://picaxe08.orcon.net.nz/Photos/PICAXE/Proto/Data/Wet_String_Serial.jpg[/link]
 

Lliam20789

New Member
After trying the code again only using b2, the 2nd PICAXE doesn't respond. The 2nd chip had something like this program:

*******************

main:
serin 1,N2400,b1
pause 10
if b1 > 20 then main
high 2
pause 200
low 2
goto main

***********************

The 1st chip, attached to the SRF05 is defiantly outputting the data but I am having a lot of trouble reading it.
I did not use 'debug' so that rules out that.

I have since tried controlling the robot and SRF05 with a single 08-M and this seems to work ok.
It would be really helpful if anyone can give me some tips...
Thanks.
 

hippy

Ex-Staff (retired)
Firstly you need to establish that the 1st PICAXE is sending data, then you need to establish the 2nd is receiving it.

It is easier to use simple test programs than something which uses the SFR05. Once you've got the serial working you can add the SFR05 code in the 1st, check its data is still being received by the 2nd, then update the code in the 2nd to do what you want.

In the 1st ...<code><pre><font size=2 face='Courier'> Do
SerOut 0,N2400,(b0)
b0 = b0+1
Pause 1000
Loop </font></pre></code> In the 2nd ...<code><pre><font size=2 face='Courier'> Do
Serin 1,N2400,b0
SerTxd (#b0,CR,LF)
Loop </font></pre></code> or something like that.
 

Lliam20789

New Member
Thanks guys,
Works fine now... turns out the motors I was sing created too much noise, a couple of capacitors fixed that.
Now I have 2 08-M communicating, one as the driver and one that operates the SRF05.
 
Top