08M2 Tunes query

ZOR

Senior Member
Can someone tell me when this code is run port C.4 gets affected. I have a relay on C.4 via transistor and the relay chatters.
Been looking for a wiring fault but tried on 08m2 project board with same result.

uu:
tune c.2, 4,($30,$40,$50,$40,$50,$60,$70)
pause 1000
goto uu

Picaxe 08M2

Thanks
 

ZOR

Senior Member
Many thanks for the reply. I will try another 08M2 and see if same or not, just wanted confirmation either way first.
 

ZOR

Senior Member
Somethings not right somewhere. I tried this on C.2, but nothing happens on C.4, but with the tune command if affects C.4

uu:
low c.2
pause 100
high c.2
pause 100
goto uu

'tune c.2, 4,($30,$40,$50,$40,$50,$60,$70)
'pause 1000
'goto uu
 

hippy

Technical Support
Staff member
tune c.2, 4,($30,$40,$50,$40,$50,$60,$70)

You are using the command as if -

TUNE pin, speed, ( notes )

Whereas on the 08M2 the command format is -

TUNE led_option, speed, ( notes )

It just so happens that C.2 has numeric value 2 which causes output 4 to flash.

The 08M2 output always goes to pin 2. You probably want -

tune 0, 4,($30,$40,$50,$40,$50,$60,$70)
 

ZOR

Senior Member
Many thanks hippy, I was in the middle of tearing my board apart following texasclodhopper comment.

I tried your code and C.4 stops chattering thanks, but does it mean tune output comming from C.0 or still C.2 as wanted?

The code I am following is TOF Burglar alarm.
He updated his code, which shows the line you have corrected, but then there are other tune line of code

tune c.2, 4,($30,$40,$50,$40,$50,$60,$70) and
tune c.2,3,($50,$40,$30,$20)

Do these need changing to produce tune output on C.2. Not working with tunes before being confused. I thought on 08M2 there was only 1 tunes output pin (C.2)

Thanks again


Code:
#picaxe 08m2
;on original circuit output to c.2 did not work,
; output to c.1 did output to c.2 
;strange but that how it worked.

;c.0 standby ind
;c.1 program PB
;c.2 output tunes to phone
;c.3 Test PB / from alarm 
;c.4 relay coil
;c.5 not used, tied low

start:
;standby indication led.
high c.0

if pinc.3=1 then gosub dialout1

;=== outputs VOICE to program phone =======
if pinc.1=1 then 
tune c.1, 4,($30,$40,$50,$40,$50,$60,$70)
endif

goto start



;========== output ALARM VOICE dialling ================
dialout1:
; == short out microphone to put phone into VOICE mode ===
low c.0	;ind off
high c.4	;relay on
pause 3000
low c.4	;relay off

pause 1000
;=== output VOICE tones ===
tune c.2, 4,($30,$40,$50,$40,$50,$60,$70)

pause 4000 ; pause to allow phone to go into voice dialling mode
;=== output ALARM tune =====
for b2=1 to 70
tune c.2,3,($50,$40,$30,$20)
next b2
pause 2000

return
 

hippy

Technical Support
Staff member
I thought on 08M2 there was only 1 tunes output pin (C.2)
That is correct. I would guess that this is a previously unnoticed error in TOF's code. It explains the "on original circuit output to c.2 did not work, output to c.1 did output to c.2" comment.
 

ZOR

Senior Member
So just to confirm, these lines of code are ok?
tune c.2, 4,($30,$40,$50,$40,$50,$60,$70) and
tune c.2,3,($50,$40,$30,$20) - sending to output C.2.

Your code:
tune 0, 4,($30,$40,$50,$40,$50,$60,$70) - output to C.2 or C.0?

Thanks hippy
 

hippy

Technical Support
Staff member
So just to confirm, these lines of code are ok?
tune c.2, 4,($30,$40,$50,$40,$50,$60,$70) and
tune c.2,3,($50,$40,$30,$20) - sending to output C.2.
No, not for an 08M/08M2; see post #6

Your code:
tune 0, 4,($30,$40,$50,$40,$50,$60,$70) - output to C.2 or C.0?
See post #6; The 08M2 output always goes to pin 2
 

ZOR

Senior Member
Thanks hippy, changed all to tune 0,etc
Have a good day. If I remember, I will make reference to this on completed projects article.
 

ZOR

Senior Member
All works. TOF did a remarked version of the code, changing C.1 to C.2 on the code line for tunes. I was unaware of this change until first tests where my C.4 was chattering. So just updated the thread in completed projects, all fine, thanks all.
 

ZOR

Senior Member
Many thanks, I will study the referenced section on tunes.
I am not shortcutting, but is the code I am using that works incorrect?

Code:
         #picaxe 08m2
;on original circuit output to c.2 did not work,
; output to c.1 did output to c.2 
;strange but that how it worked.

;c.0 standby ind
;c.1 program PB
;c.2 output tunes to phone
;c.3 Test PB / from alarm 
;c.4 relay coil
;c.5 not used, tied low

start:
;standby indication led.
'high c.0

if pinc.3=1 then gosub dialout1

;=== outputs VOICE to program phone =======
if pinc.1=1 then 
tune c.1, 4,($30,$40,$50,$40,$50,$60,$70)
endif

goto start

;========== output ALARM VOICE dialling ================
dialout1:
; == short out microphone to put phone into VOICE mode ===
low c.0	;ind off
high c.4	;relay on
pause 3000
low c.4	;relay off

pause 1000
;=== output VOICE tones ===
tune c.1, 4,($30,$40,$50,$40,$50,$60,$70)
pause 4000 ; pause to allow phone to go into voice dialling mode

;=== output ALARM tune =====
for b2=1 to 5'70
tune c.1, 3,($50,$40,$30,$20)
next b2

pause 2000

return
Thanks again
 

hippy

Technical Support
Staff member
is the code I am using that works incorrect?

tune c.1, 4,($30,$40,$50,$40,$50,$60,$70)
tune c.1, 4,($30,$40,$50,$40,$50,$60,$70)
tune c.1, 3,($50,$40,$30,$20)
Yes, it is incorrect if C.1 is being used as a pin reference or you don't know why you have C.1 there.
 

ZOR

Senior Member
Oh dear hippy, now I am up the spout. I wanted something quick to use and thought copying a finished project would be okay. The strange thing is it all works, why should it if it's wrong.
I know the code starts with the comments:

;on original circuit output to c.2 did not work,
; output to c.1 did output to c.2
;strange but that how it worked.
I am trying to do something quickly to put in a house that will shortly be empty when a relative passes away. Not a permanent system, just something quickly to offer some security. House 25 miles away. Now I'm going backwards.
 

JimPerry

Senior Member
ZOR - use the KISS principle - alarm is straight-forward and fail-safe -phoning you and making dinner can get complicated :confused:
 

ZOR

Senior Member
Thanks Jim,however it works perfectly, the Picaxe is cold, it works every time. It would be good if someone told me not to use it like this and why. All the other bits of the alarm are working well, I was just working on this bit and a simple as possible 433mhz switch and thats it.
 

hippy

Technical Support
Staff member
The strange thing is it all works, why should it if it's wrong.
There are degrees of wrong. The code you have is incorrect but it works because the incorrectness isn't causing a problem.

The basic flaw as described earlier is putting a pin identifier where the options to flash a LED should be. I am guessing for TOF that C.2 affecting output 4 caused the circuit problem and changing it to C.1 stopped it affecting output 4 and he did not care that using C.1 was affecting output 0. And I guess your circuit doesn't care either if it's the same layout.
 

ZOR

Senior Member
Thanks hippy. Yes I am doing the same layout, however I am not using C.0 (TOF has an LED on it)
As long as I am not being nasty to the 08M2 then I will leave it as is. Thanks for all your help.
 

erco

Senior Member
You are using the command as if -

TUNE pin, speed, ( notes )

Whereas on the 08M2 the command format is -

TUNE led_option, speed, ( notes )

It just so happens that C.2 has numeric value 2 which causes output 4 to flash.

The 08M2 output always goes to pin 2. You probably want -

tune 0, 4,($30,$40,$50,$40,$50,$60,$70)
Ha, I made this same exact mistake last week. Ten minutes of head scratching until I went back to RTFM. :)
 

westaust55

Moderator
Thanks hippy. Yes I am doing the same layout, however I am not using C.0 (TOF has an LED on it)
As long as I am not being nasty to the 08M2 then I will leave it as is. Thanks for all your help.
@ZOR,
Why are you insistent on using an IO pin designation for the LED_Option parameter?

As hippy states it will work of a sort since there are degrees of wrong.

You should have a simple value (0,1,2 or3) and from what you indicate that should be zero (0) in your case since no LED's are being used.
Just try it and it should work plus there would be no confusion for those including you when reading the program in future.


The code I am following is TOF Burglar alarm.
TOF was likely using a much bigger PICAXE chip (ie not an 08M2) where it is necessary to define the IO pin upon which the TUNE command will function.
As hippy has mentioned, and indicated in the manuls, for 8 pin PICAXE chips, the pin used for TUNE is fixed and the parameter at the same position in the TUNE command is now used for a different function.
 
Last edited:

ZOR

Senior Member
Thanks again. I changed all the tune lines to start :
tune 0,

All works okay.
TOF thread shows all pictures and text with 08M2 used. Article needs links to give other followers some guidance.

Now I can move forward again. Regards, also to hippy.
 

ZOR

Senior Member
One last crack on the subject of tunes.

If I had used a 14M2 instead of 08M2, would I use:

TUNE pin, speed, (note, note, note...) where the pin is reference Tune B.5 etc, where the tune would come out from B.5 and no other pins would flash (LED)

Thanks
 

ZOR

Senior Member
Thanks again.

As a newbie still, what is this shown for? TUNE pin, speed, (note, note, note...)

So would TUNE B.5, 4, %00000000, (note, note, note...) work, obviosly with notes filled in. Regards
 

hippy

Technical Support
Staff member
As a newbie still, what is this shown for? TUNE pin, speed, (note, note, note...)
It depends on which PICAXE you are using and what values are used as parameters. That is not a supported command format on the 08M2. You can specify a pin but it will not be treated as a pin by the 08M2 compiler.

So would TUNE B.5, 4, %00000000, (note, note, note...) work, obviosly with notes filled in. Regards
Again it depends on the PICAXE being used. You could try it with the PE6 simulator.
 

westaust55

Moderator
Hello ZOR,

If you look at the PICAXE manual 2 or the link I gave:

TUNE pin, speed, (note, note, note...) (see below)

TUNE pin, speed, LED_mask, (note, note, note...) (M2 parts only)

TUNE LED_option, speed, (note, note, note...) (8 pin only - including 08M2)

So in terms of the currently available PICAXE chips to purchase, the first option is for the 20X2, 28X2 and 40X2.
 

ZOR

Senior Member
Thanks hippy, I did mention if using a 14M2. I am using a PE5 editor, which gave me no clue which pin noise was coming out, just made tune from my PC speaker.

Never mind I will try it and put a speaker on B.5 or whatever to see what happens. Thanks again

EDIT Thanks westaust55, just seen your reply which came as I was answering hippy

LAST EDIT: I put this in my PE5 simulator and it played a tune and no other activity was seen on other pins, so I am done, thanks

TUNE B.5, 4, %00000000, ($30,$40,$50,$40,$50,$60,$70)
 
Last edited:

erco

Senior Member
@Hippy: To clarify, LED option 3 on an 08M2 always alternately flashes pins 1 and 4?
 

ZOR

Senior Member
Thanks hippy, thats made it clearer.

erco, do you mean 0 and 4 flashing on option 3? or have I got it wrong. Maybe hippy might come back one last time to answer it
 

ZOR

Senior Member
Thanks hippy,that's it all sorted. I think erco was saying the word flashing was omitted on the line for option 3 which has now been corrected.
Best regards
 

AllyCat

Senior Member
Hi,

"3 - Outputs 0 and 4 flash alternatively "

To be pedantic, should it say alternately ?

Also, I see it says:

"The LEDs 'toggle' on/off at the end of every note. On 14/18/20 pin chips to have two (or more) LEDs flash alternately set one LED high, and the other low, before the tune command is used."

Does that mean that if you initialise one 08M2 output high and the other low in Mode 3, then they will flash in unison?

Cheers, Alan.
 

hippy

Technical Support
Staff member
Does that mean that if you initialise one 08M2 output high and the other low in Mode 3, then they will flash in unison?
Off-hand I have no recollection of the exact behaviour and would have to test that. Once I have done so we can word the case for when 'LED_option' is 3 appropriately.
 
Top