PICAXE on UK to USA robot boat: sound

Robin Lovelock

Senior Member
Hi Folks. Things are progressing well with the small picaxe-controlled robot boat, which I hope will be launched this year from UK to USA. It's still doing 24/7 testing, sailing around Bray Lake, and I'm now looking at the software, testing it with my GPS simulator, and checking the logic to navigate from UK, past the Azores, the Bahamas, Bermuda and to a spot to be decided in the USA :)

All explained on www.gpss.co.uk/autop.htm including video showing our recent sea trial on the UK south coast.

This thread relates to sound output from my picaxe - the little servo driver board. It's been working well, taking GPS data in RS232, wind direction sensor as analogue voltage in, and driving the rudder servo, to steer the boat around waypoints. The software also uses the TUNE command to play tones into a little loudspeaker that is near an FM transmitter - so we receive information on the shore, no more than 100 or 200 yards away. This is only for testing on Bray Lake - but it's just possible we might use it at sea.

I thought I'd posted a thread on this sound stuff, but I couldn't find it. I was probably interested in text to speech.
Now I'm thinking of dedicating another picaxe to sound, driving the loudspeaker, and using whatever is simplest to pass data from one to the other.
e.g. my autopilot picaxe might pass a code to say which sound or tune to play from the "sound picaxe".

There are some side effects which I've lived with: e.g. our tunes and subroutines to play tones, use up valuable memory. We can just about squeeze our new waypoints to the USA in, but if we put this sound stuff into another picaxe or connected chipset, it would release memory. Perhaps more significantly, playing the tones with TUNE causes a slight twitch of the servo - there is obviously interferrence here.

Here is what we use the sound for:
1) range to the next waypoint as tones: e.g. dah-dah-dit = 50+50+10 = 110 metres.
2) inside a waypoint box - we play theme from "Close Encounters" :)
3) starting a new tack at 45 degrees to the wind "Popeye the Sailorman" :)
4) rudder left - low tone "dah"
5) rudder right - higher tone "dit-dah"

Our autopilot picaxe software has a feedback loop lasting about 6 seconds:
1) use SERIN to read data from the GPS including lat/lon, direction, speed.
2) read direction from wind direction sensor and convert to absolute direction.
3) test if lat/lon in a waypoint box, or other values, and change the destination lat/lon if needed.
4) calculate the target heading from GPS lat/lon to the destination lat/lon.
5) modify this target heading if it means sailing too close to the wind.
6) calculate the error in heading between target heading and real GPS heading.
7) move the rudder servo to steer the boat.
go back to step 1 above.

Sounds are generated in several of these stages, using TUNE (via subroutine calls).

Any ideas on a simple way of connecting two picaxe, such as my servo controller, and communicating.
I can then put the sound stuff onto the second picaxe. It will only take a few milliamps - power drain is important.

Or - maybe there is a text-to-speech solution ? :)

Many Thanks in advance for any ideas.
Robin
www.gpss.co.uk/autop.htm
 

hippy

Ex-Staff (retired)
A simple SERIN / HSERIN into a variable then play something depending on what that was would be the easiest. All you need then is a SEROUT and the right value to trigger what want it to do.
 

Robin Lovelock

Senior Member
Thanks Hippy. Sorry for my delay - been doing other things. That looks simple. Let me try here ...

Right now my picaxe servo driver has a little loudspeaker on signal and ov of one servo position
and I get tunes out OK:
Code:
 playpopeye: 'play Popeye The Sailor Man Theme   
  tune 0, 2,($07,$0A,$0A,$0A,$C8,$07,$8A,$0A,$0A,$10,$08,$10,$D3,$10,$8A)
  PAUSE FORP1SEC
  return
So I guess I could replace this subroutine with one that did a SEROUT to another "sound" picaxe servo driver.

"Popeye" is played when I start tacking, so I could use "T", and other tunes could correspond to other letters.
e.g. "L" = turn left, etc.

So would that subroutine in my autopilot picaxe change to something like ?:

Code:
 playpopeye: 'play Popeye The Sailor Man Theme   
  SEROUT 0, N4800_16, "T"
  return
and the one in the "sound" picaxe to:

Code:
top:
 SERIN 0, b1
 if b1 = "T" then gosub playpopeye
 (tests for other letters)
 goto top

 playpopeye: 'play Popeye The Sailor Man Theme   
  tune 0, 2,($07,$0A,$0A,$0A,$C8,$07,$8A,$0A,$0A,$10,$08,$10,$D3,$10,$8A)
  PAUSE FORP1SEC
  return
 
Last edited:

hippy

Ex-Staff (retired)
Yes, that's the sort of thing. SELECT-CASE is an easy way to decide which actual TUNE to play.

Code:
Do
  SerIn pin, baud, b0
  Select Case b0
     Case "T"
        Tune ... popeye ...
    Case ...

  End Select
Loop
 

Robin Lovelock

Senior Member
Thanks Hippy. Sorry for delay again: have been giving priority to 24/7 testing of the total boat system. Have just stripped hull down, rebuilt and re-filled with foam, and tried on Bray Lake - but not enough wind for a few days now !

I did make a bit of progress on the program (below) which I call APSOUND.BAS and, by accident I tested it with the GPS plugged in - and it did play sounds - presumably in response to characters it was looking for :)

I also tried simulation mode, but when I typed in a character like T it gave an error "Try again - illegal serin entry".

This little program is 287 bytes / 2048 in memory, so it looks as if I might save about 10% memory in my Autopilot picaxe
when I take the sound stuff out, since the SEROUT calls will not need much.

But this job is very much an "experiment on the side" because I have to give priority to the other stuff like 24/7 testing of the total boat system and simulating the UK-USA trip.

Please feel free to make suggestions - you save me time spent on the job :)

Robin
www.gpss.co.uk/autop.htm

Code:
'APSOUND.BAS auto pilot sound for robot boat - based on AUTOP1.BAS
'v1a (c) Robin Lovelock www.gpss.co.uk/autop.htm
'v1a 6 Aug12 - first version.
'reads characters from other (Autopilot) picaxe and plays sounds to loudspeaker
 
 #picaxe 08M2  
 setfreq M16
 
 symbol FOR1SEC = 4000 'pause value at 16MHz for 1 sec
 symbol FOR1P5SEC = 6000 'pause value at 16MHz for 1.5 sec
 symbol FOR2SEC = 8000 'pause value at 16MHz for 2 sec
 symbol FOR3SEC = 12000 'pause value at 16MHz for 3 sec
 symbol FOR4SEC = 16000 'pause value at 16MHz for 4 sec
 symbol FORP5SEC = 2000 'pause value at 16MHz for 0.5 sec
 symbol FORP1SEC = 400 'pause value at 16MHz for 0.1 sec
 symbol FORP2SEC = 800 'pause value at 16MHz for 0.2 sec
 
 sertxd ( 10,13,"APSOUND" ) 'trace output
 
 'simple test of the sounds ...

 PAUSE FORP5SEC
 w3=90: w13=1: gosub playright
 w3=90: gosub playright
 w3=90: gosub playright
 PAUSE FOR1SEC 
 call playerror 'error sound Uh-Oh!
 PAUSE FOR1SEC

 gosub playpopeye 'play Popeye to show tacking

 gosub playclose 'play tune - Close Encounters
 
 'wait for character from other picaxe
 'L=left, R=Right, C=Close. E=Error. S=Simpsons. T=Tack (Popeye)
waitforchar: 
  SERIN 3, N4800_16, b0
  Select Case b0
    Case "T"
      gosub playpopeye
    Case "L"
      gosub playleft
    Case "R"
      gosub playright
    Case "C"
      gosub playclose
    Case "E"
      gosub playerror
  End Select
  goto waitforchar
 
playclose:
  tune 0,5,(7,9,5,37,192) 'close encounters
  PAUSE FOR1SEC
  return
  
playsimp:
  tune 0, 4,($00,$04,$06,$49,$07,$04,$00,$69,$66,$66,$66,$E7 ,$6C,$66,$66,$66,$67,$2A,$2B)
  PAUSE FOR1SEC
  return  

  'w3 is degrees of error 0-180  
 playleft:
  'tune 0, 4,($65,$65,$28,$65,$25,$E8,$65,$68,$01,$00,$6A,$2A,$28) 'Lullaby = Left
  w6=w3/8 '1j was 5
  if w3 > 90 then '1h
    w6 = 11 '1j was 18
  endif
  tune 0,w6,(4) 
  return


  'w3 is degrees of error 0-180    
 playright:   
  'tune 0, 4,($68,$6A,$68,$65,$41,$6A,$28,$68,$6A,$68,$6A,$68,$41,$C0) 'Ruldolf = Right
  tune 0,2,(7) 
  w6=w3/8 '1j was 5
  if w3 > 90 then '1h
    w6 = 11 '1j was 18
  endif
  tune 0,w6,(7) 
  return
  
 playerror: 'based on Telly-Tubby Uh-Oh!
  tune 0,2,(11)
  tune 0,11,(10)
  return
  
  'b12 is range of destination in 10m steps 
  'long tones are 50m steps. e.g. 70m = dah dit dit  
 playdist:
  if b12 >= 5 then
    b12 = b12 - 5
    tune 0,6,(10)
    goto playdist
  endif
  for b13=1 to b12
    tune 0,2,(10)
  next  '
  PAUSE FORP5SEC
  return
  
  
 playpopeye: 'play Popeye The Sailor Man Theme   
  tune 0, 2,($07,$0A,$0A,$0A,$C8,$07,$8A,$0A,$0A,$10,$08,$10,$D3,$10,$8A)
  PAUSE FORP1SEC
  return
 

erco

Senior Member
Fabulous project, I'm following with great interest.

The Tune & Sound commands definitely hog PicAxe resources. As long as you're considering adding another Picaxe, why not add a text to speech chip? They use quick-executing serial outout commands. If your main picaxe has the memory, you might not even need another picaxe, just send one line of text (or song) at a time (takes milliseconds) and let the TTS chip deal with storage & timing.

I haven't coded Popeye, but here's my one nautical song for you: http://www.youtube.com/watch?v=J5GMOAIQbJ4

And of course it works with a PicAxe. My next video will have 3 singing together. :)
http://www.youtube.com/watch?v=ufAPg4RkYcc
 

hippy

Ex-Staff (retired)
symbol FOR3SEC = 12000 'pause value at 16MHz for 3 sec

One handy tip for symbols like that, to make the times easier to enter and to read, is to specify the time in two parts ...

symbol FOR3SEC = 3000 * 4

Even specify the multiplier as its own SYMBOL, then you only have one thing to alter no matter what clock frequency you run the PICAXE at.
 

Robin Lovelock

Senior Member
Thanks Hippy - and particularly on this occasion Erco. Amazing - especially that second link - HAL from the Kubrick film 2001 was always very influential on me (www.gpss.co.uk/history.htm) - and text-to-speech is definitely of interest here. If you play the "Snoopy Sails!" video on www.gpss.co.uk/autop.htm you will see we started with speech on the Pocket PC based autopilot, before switching over to the picaxe.

As I mentioned, this is very much a little "parallel project" and has to play second fiddle to the priority work of getting a reliable boat system 24/7 tested, if we are to consider an attempt from UK to USA this year.

However, a second picaxe dedicated to sound is definitely the way to go for me. There are a lot of possabilities, including passing things like destination lat/lon across to allow better spoken outpiut of things like remaining range to destination.

In an ideal world I'd like to put together a picaxe text-to-speech solution that uses the same servo driver boards with which I am already familiar. Even a few hours going up a learning curve are expensive on my time - hence the value of this forum. Any suggestions for a shopping list of bits, so I can put together a prototype speaking sound picaxe ?
Even if I don't add it this year, my plan is to work on the second boat as soon as the first is launched :)

But right now, I'd like to give it a try, if not too time-consuming.

Robin
www.gpss.co.uk/autop.htm

p.s. at 1030am Saturday: Googling on "picaxe text to speech" finds http://www.picaxe.com/docs/spe030.pdf and the SPE030 product. Sadly this product seems to have been withdrawn, because I cannot find it or anything similar advertised on the main pages of www.picaxe.co.uk Hence my request for a "shopping list" seems more important than before. Meanwhile Snoopy continues his 24/7 tests on Bray Lake :)
 
Last edited:

Robin Lovelock

Senior Member
Thanks Erco. I have an "off topic" question:
what doides/resistors needed to limit the RS232 voltage swings from my PC COM port ? SOLUTION FOUND - SEE BELOW.

Reason is that I've found my GPS Simulator, running on the PC, which outputs on the old COM1 RS232 serial port,
plugged into my PICAXE Autopilot, instead of the BR355 GPS, was not working reliably. It also seemed to depend
on the picaxe battery voltage. It works 100% reliably when the GPS is plugged into the picaxe.

I've just dusted off my old oscilloscope to check the signals - and sure enough, the GPS swings between it's +5v and ov
shared with the picaxe, but the PC signal (from pins 3 and 5 of the 9 pin D COM1 port) swing much more (maybe 15v).

I can see my picaxe has a diode on the GPS input pin - I think Hippy advised me on this years ago,
and since then, I've not had any problem with real GPS data going into my picaxe reliably.

However, I'm now having to use my GPS simulator to test the UK-USA routing logic.
I thought it was working OK - but now I see it is unreliable, and now I think I know why.

Thought I'd post this, since I'm sure it has a standard solution.
Meanwhile I'll see if my local Maplins has a standard solution
to clamp RS232 output to 0->5v.

Snoopy continues his 24/7 tests: just survived a third night after most recent change :)

Robin
www.gpss.co.uk/autop.htm

p.s. I found solution - Hippy told me, 3 years ago, when I first started playing with my PC RS232 into the picaxe, to use a 22k serial resistor.
I just checked, and there is the 22k series resistor as it should be, but then I found that I'd wired the GPS plug strangely - when I corrected this, my GPS simulation from the PC started to work again ! :)

p.p.s. back to the main topic: Erco - what bits did you use for that picaxe TTS ? Stuff no longer available ?
Meanwhile I'm starting to get bugs out of the long range target heading calculation using the GPS simulator :)
 
Last edited:

DDJ2011

Member
Hi Robin,

I'm following your progress with great interest but I'm struggling to find the latest videos etc on your site - is there any chance you can upload them to you tube to make it easier?

Cheers,

DDJ
 

Robin Lovelock

Senior Member
Hi DDJ. My videos hosted on my site are linked from www.gpss.co.uk/autop.htm
and are in WMV (Windows Meta Video) format - so that might be a problem on a MAC
and the "Snoopy Sails!" one is quite big - so might take minutes to download.
If you are using a MAC try borrowing use of a friend's PC.
There are some old versions on u-tube but I won't be uploading any just yet.
e.g. the latest has more minutes than utube allows.
You can find my utobe videos on www.youtube.com/user/RobinLovelock
Robin

Waiting for reply on main subject of this thread - best hardware for picaxe sound including TTS :)
 

erco

Senior Member

Robin Lovelock

Senior Member
Thanks Erco. I followed your links. I don't begrudge spending their 25 USD, but this looks like a chip, and not a complete kit with embedded software, ready to go. Every hour I spend on this is an hour I don't spend on other parts of the robot boat project, so what I'm looking for is something where I can give it my 5v standard supply, some rs232 text from my autopilot picaxe, and hear some speech coming out. Any ideas ?
Robin
www.gpss.co.uk/autop.htm
 

Robin Lovelock

Senior Member
Thanks Erco - looks like what I want - have just ordered one to try at about 110 USD inc. postage to UK.
Meanwhile Snoopy is sailing on Bray Lake and I'm testing the trans-Atlantic route :)
Thanks also Jim. That also could be useful, but I'll try the TTS first.
Robin
 

JimPerry

Senior Member
Hi Robin - sent a PM a while back -
Magnetic coupling question
Hi

looked at some of your videos etc, great stuff - what puzzles me is how to you reset the servo if knocked out of whack when using a magnetic coupling?

Cheers

Jim Perry
 

Robin Lovelock

Senior Member
Hi Jim. I never did use magnetic coupling for the servos - an original idea from the University of Wales team.
Guess you were looking at some very old thoughts from further down my robot boat page.
There would not have been the problem you describe, if I had, because the magnetic discs are polarised across
their face, and so will return to the same position. For a rudder I assume you use the usual 90 degree servo.
I use a very simple linkage, between rudder servo and rudder post.
I see Snoopy is still sailing this morning - despite the rain :)

Robin
www.gpss.co.uk/autop.htm

p.s. I've updated the page above with more recent info.
e.g. we may launch this year if Snoopy has a "fighting chance" based on our 24/7 tests.
Yes, he's still out there, sailing in "Snoopy Corner" on Bray Lake :)
I expect delivery of the TTS module tomorrow, from USA, after payment of £25.90 import duty.
But that will be a project for next year I think.

p.p.s. the 30016 Emic Text-to-Speech module arrived today, and I had a nice distraction:
It was soon connected to my picaxe, and I JUST managed to squeeze in changes to my AUTOP1.BAS
autopilot program to make it speak instead of play beeps.
e.g. it now says "one hundred and thirty metres" instead of dah-dah-dit-dit-dit. Much nicer! :)
Code:
SEROUT 2, T9600_16, ( "S ",#b12, " metres",10 )
Maybe this WILL get tested this year on the boat currently on Bray Lake ! :)
There is now a video link from my page above, showing the three types of sounds used on the robot boats:
1) PAST - Pocket PC recorded speech 2) PRESENT - beeps from the picaxe 3) FUTURE? Picaxe-30016 TTS
or go direct to the video at www.gpss.co.uk/video/rbsound.wmv - Enjoy :)
Robin
 
Last edited:
Top